Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caiman.paths.memmap_frames_filename() to build paths in $CAIMAN_TEMP by default #1469

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion caiman/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,23 @@ def fn_relocated(fn:str, force_temp:bool=False) -> str:
# In the future we may consistently store these somewhere under the caiman_datadir


def memmap_frames_filename(basename: str, dims: tuple, frames: int, order: str = 'F') -> str:
def memmap_frames_filename(basename: str, dims: tuple, frames: int, order: str = 'F', in_tempdir:bool=True) -> str:
# Some functions calling this have the first part of *their* dims Tuple be the number of frames.
# They *must* pass a slice to this so dims is only X, Y, and optionally Z. Frames is passed separately.
# This defaults to being in CAIMAN_TEMP (itself defaulting to $CAIMAN_DATA/temp) to avoid having files land randomly elsewhere
#
# It is strongly encouraged to use the return value from this function to find files rather than calculating where things
# *should* be.
dimfield_0 = dims[0]
dimfield_1 = dims[1]
if len(dims) == 3:
dimfield_2 = dims[2]
else:
dimfield_2 = 1

if in_tempdir:
basename = os.path.join(get_tempdir(), os.path.split(basename)[1]) # lop off old path if present, attach a new one in the temp dir

return f"{basename}_d1_{dimfield_0}_d2_{dimfield_1}_d3_{dimfield_2}_order_{order}_frames_{frames}.mmap"

def fname_derived_presuffix(basename:str, addition:str, swapsuffix:str = None) -> str:
Expand Down
Loading