-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
From fmriprep.utils.misc
:
def check_deps(workflow):
"""Make sure dependencies are present in this system."""
from nipype.utils.filemanip import which
return sorted(
(node.interface.__class__.__name__, node.interface._cmd)
for node in workflow._get_all_nodes()
if (hasattr(node.interface, '_cmd') and which(node.interface._cmd.split()[0]) is None)
)
def fmt_subjects_sessions(subses: list[tuple[str]], concat_limit: int = 1):
"""
Format a list of subjects and sessions to be printed.
Example
-------
>>> fmt_subjects_sessions([('01', 'A'), ('02', ['A', 'B']), ('03', None), ('04', ['A'])])
'sub-01 ses-A, sub-02 (2 sessions), sub-03, sub-04 ses-A'
"""
output = []
for subject, session in subses:
if isinstance(session, list):
if len(session) > concat_limit:
output.append(f'sub-{subject} ({len(session)} sessions)')
continue
session = session[0]
if session is None:
output.append(f'sub-{subject}')
else:
output.append(f'sub-{subject} ses-{session}')
return ', '.join(output)
and
@cache
def estimate_bold_mem_usage(bold_fname: str) -> tuple[int, dict]:
import nibabel as nb
import numpy as np
img = nb.load(bold_fname)
nvox = int(np.prod(img.shape, dtype='u8'))
# Assume tools will coerce to 8-byte floats to be safe
bold_size_gb = 8 * nvox / (1024**3)
bold_tlen = img.shape[-1]
mem_gb = {
'filesize': bold_size_gb,
'resampled': bold_size_gb * 4,
'largemem': bold_size_gb * (max(bold_tlen / 100, 1.0) + 4),
}
return bold_tlen, mem_gb
in the latter case, generalizing "bold" appearances to "image" or "file".
Metadata
Metadata
Assignees
Labels
No labels