smriprep.utils.misc module
Self-contained utilities to be used within Function nodes.
- smriprep.utils.misc.apply_lut(in_dseg, lut, newpath=None)[source]
Map the input discrete segmentation to a new label set (lookup table, LUT).
- smriprep.utils.misc.fs_isRunning(subjects_dir, subject_id, mtime_tol=86400, logger=None)[source]
Checks FreeSurfer subjects dir for presence of recon-all blocking
IsRunning
files, and optionally removes any based on the modification time.- Parameters:
subjects_dir (os.PathLike or None) – Existing FreeSurfer subjects directory
subject_id (str) – Subject label
mtime_tol (int) – Tolerance time (in seconds) between current time and last modification of
recon-all.log
- Returns:
subjects_dir
- Return type:
os.PathLike or None
- smriprep.utils.misc.stringify_sessions(lst: list[str], max_length: int = 10, digest_size: int = 2) str [source]
Convert a list of session into a string identifier.
If the list has only one element, it returns that element. If the list has more than one element, it concatenates them with ‘+’. If the concatenated string exceeds max_length, it returns a string starting with ‘multi+’ followed by a BLAKE2b hash of the concatenated string.
Example
>>> stringify_sessions(['a']) 'a' >>> stringify_sessions(['a', 'b', 'c']) 'a-b-c' >>> stringify_sessions(['a', 'b', 'toolong']) 'multi-32b3' >>> stringify_sessions(['a', 'b', 'toolong'], max_length=12) 'a-b-toolong' >>> stringify_sessions(['a', 'b', 'toolong'], digest_size=4) 'multi-f1edd4fd'