neurocaps.analysis.CAP.caps2niftis#
- CAP.caps2niftis(output_dir, suffix_filename=None, fwhm=None, knn_dict=None, progress_bar=False)[source]#
Convert CAPs to NifTI Statistical Maps.
Projects CAPs onto the parcellation in defined in
parcel_approachto create compressed NifTI (.nii.gz) statistical maps. One image is generated per CAP and separate images are generated per group.- Parameters:
output_dir (
str) – Directory to save nii.gz files. The directory will be created if it does not exist.suffix_filename (
strorNone, default=None) – Appended to the name of the saved file.fwhm (
floatorNone, default=None) – Strength of spatial smoothing to apply (in millimeters) to the statistical map prior to interpolating from MNI152 space to fsLR surface space. Uses Nilearn’simage.smooth_img.knn_dict (
dict[str, int | bool], default=None) –Use KNN (k-nearest neighbors) interpolation with reference atlas masking to fill in non-background coordinates that are assigned zero. Useful when custom parcellation does not project well from volumetric to surface space. The following subkeys are recognized:
”k”: An integer (Default=1). Determines the number of nearest neighbors to consider.
”reference_atlas”: A string (Default=”Schaefer”). Specifies the atlas to use for reference masking (“AAL” or “Schaefer”).
”resolution_mm”: An integer (Default=1). Spatial resolution of the Schaefer parcellation (in millimeters) (1 or 2).
”remove_labels”: A list or array (Default=None). The label IDs as integers of the regions in the parcellation to not interpolate.
Note
KNN interpolation is applied before
fwhm.progress_bar (
bool, default=False) –If True, displays a progress bar.
Added in version 0.21.5.
- Returns:
self
Important
Parcellation Approach:
parcel_approachmust have the “maps” subkey containing the path to th NifTI file of the parcellation.Assumption: This function assumes that the background label for the parcellation is zero. During extraction of the numerical labels from the parcellation map, the first element (assumed to be zero/the background label after sorting) is skipped. Then the remaining sorted labels are iterated over to map each element of the CAP cluster centroid onto the corresponding non-zero label IDs in the parcellation.