cmb.segment_cerebellum#

cmb.segment_cerebellum(subject, subjects_dir=None, cmb_dir=None, segmentation_fname=None, save_segmentation=True, recompute=False, intermediate_caching=False)[source]#

Compute or load the cerebellar segmentation for a subject.

Existing saved segmentations are reused by default; save_segmentation only controls whether newly computed results are written to disk.

Parameters:
subjectstr

The FreeSurfer subject name.

subjects_dirpath-like | None

The path to the directory containing the FreeSurfer subjects reconstructions. If None, defaults to the SUBJECTS_DIR environment variable.

cmb_dirpath-like | None

Path to the CMB data directory. If None (default), uses the default CMB data directory.

segmentation_fnamepath-like | None

The path to load/save the segmentation. If None (default), uses the path <subjects_dir>/<subject>/mri/cerebellum_segmentation.nii.gz.

save_segmentationbool

If True (default), saves a newly computed segmentation to disk. If False, newly computed segmentations are returned without saving. This flag does not prevent loading an existing segmentation from segmentation_fname when recompute=False.

recomputebool

If True, always computes a new segmentation. If save_segmentation=True, the result is written to segmentation_fname and overwrites any existing file there. If False (default), an existing segmentation at segmentation_fname is loaded and returned if present.

intermediate_cachingbool

If True, reuses existing intermediate registration and nnU-Net predictions from <cmb_dir>/data/segm_folder/tmp and keeps newly generated intermediates there. If False (default), uses a temporary work directory for this run without touching any existing intermediate cache.

Returns:
nibabel.Nifti1Image

The cerebellar segmentation as a NIfTI image object.