Skip to content

Commit

Permalink
Fix paths for more temporary files over a run to land in caiman_data/…
Browse files Browse the repository at this point in the history
…temp/
  • Loading branch information
pgunn committed Apr 18, 2024
1 parent 126ca4a commit b607769
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions caiman/mmapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def save_memmap(filenames:list[str],
recompute_each_memmap = True


if recompute_each_memmap or (remove_init>0) or (idx_xy is not None)\
if recompute_each_memmap or (remove_init > 0) or (idx_xy is not None)\
or (xy_shifts is not None) or (add_to_movie != 0) or (border_to_0>0)\
or slices is not None:

Expand Down Expand Up @@ -527,7 +527,7 @@ def save_memmap(filenames:list[str],
sys.stdout.flush()
Ttot = Ttot + T

fname_new = caiman.paths.fn_relocated(fname_tot + f'_frames_{Ttot}.mmap')
fname_new = os.path.join(caiman.paths.get_tempdir(), caiman.paths.fn_relocated(f'{fname_tot}_frames_{Ttot}.mmap'))
try:
# need to explicitly remove destination on windows
os.unlink(fname_new)
Expand Down
9 changes: 6 additions & 3 deletions caiman/motion_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,12 @@ def __init__(self, fname, min_mov=None, dview=None, max_shifts=(6, 6), niter_rig
"""
if 'ndarray' in str(type(fname)) or isinstance(fname, caiman.base.movies.movie):
logging.info('Creating file for motion correction "tmp_mov_mot_corr.hdf5"')
caiman.movie(fname).save('tmp_mov_mot_corr.hdf5')
fname = ['tmp_mov_mot_corr.hdf5']
mc_tempfile = os.path.join(caiman.paths.get_tempdir(), 'tmp_mov_mot_corr.hdf5')
if os.path.isfile(mc_tempfile):
os.remove(mc_tempfile) # Eventually get_tempdir() will keep jobs separate and make this safer
logging.info(f"Creating file for motion correction: {mc_tempfile}")
caiman.movie(fname).save(mc_tempfile)
fname = [mc_tempfile]

if not isinstance(fname, list):
fname = [fname]
Expand Down

0 comments on commit b607769

Please sign in to comment.