diff --git a/caiman/mmapping.py b/caiman/mmapping.py index 65dd10cf4..ce4b040e8 100644 --- a/caiman/mmapping.py +++ b/caiman/mmapping.py @@ -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: @@ -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) diff --git a/caiman/motion_correction.py b/caiman/motion_correction.py index a819fff95..d2e9b6bef 100644 --- a/caiman/motion_correction.py +++ b/caiman/motion_correction.py @@ -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]