nifti
tit.stats.nifti ¶
TI-Toolbox NIfTI loading helpers for statistical analysis.
Convenience wrappers around nibabel that resolve paths through
:func:tit.paths.get_path_manager and return arrays ready for
voxelwise group comparison or correlation pipelines.
Public API¶
load_subject_nifti_ti_toolbox Load a single subject's NIfTI from the BIDS simulation tree. load_group_data_ti_toolbox Stack multiple subjects into a 4-D array. load_grouped_subjects_ti_toolbox Load multiple subjects organized by named groups.
See Also¶
tit.stats.comparison : Voxelwise group comparison pipeline. tit.stats.correlation : Voxelwise correlation pipeline.
load_subject_nifti_ti_toolbox ¶
load_subject_nifti_ti_toolbox(subject_id: str, simulation_name: str, nifti_file_pattern: str = 'grey_{simulation_name}_TI_MNI_MNI_TI_max.nii.gz', dtype=float32) -> tuple[ndarray, Nifti1Image, str]
Load a single subject's NIfTI file from TI-Toolbox BIDS structure.
Parameters¶
subject_id : str
Subject identifier (e.g. '070').
simulation_name : str
Simulation folder name (e.g. 'ICP_RHIPPO').
nifti_file_pattern : str, optional
Filename pattern with {subject_id} / {simulation_name}
placeholders.
dtype : numpy dtype, optional
Data type for the returned array. Default is np.float32.
Returns¶
data : numpy.ndarray 3-D array of voxel values. img : nibabel.Nifti1Image The loaded NIfTI image (useful for affine / header). filepath : str Absolute path of the loaded file.
Raises¶
FileNotFoundError If the resolved NIfTI path does not exist.
Source code in tit/stats/nifti.py
load_group_data_ti_toolbox ¶
load_group_data_ti_toolbox(subject_configs: list[dict], nifti_file_pattern: str = 'grey_{simulation_name}_TI_MNI_MNI_TI_max.nii.gz', dtype=float32) -> tuple[ndarray, Nifti1Image, list[str]]
Load and stack multiple subjects into a 4-D array.
Parameters¶
subject_configs : list of dict
Each dict must contain 'subject_id' and 'simulation_name'
keys (e.g. {'subject_id': '070', 'simulation_name': 'ICP_RHIPPO'}).
nifti_file_pattern : str, optional
Filename pattern forwarded to :func:load_subject_nifti_ti_toolbox.
dtype : numpy dtype, optional
Data type for the returned arrays. Default is np.float32.
Returns¶
data_4d : numpy.ndarray
Shape (X, Y, Z, n_subjects).
template_img : nibabel.Nifti1Image
Image from the first subject (affine / header reference).
subject_ids : list of str
Subject identifiers in the same order as the last axis of
data_4d.
Raises¶
ValueError If no subjects could be loaded.
Source code in tit/stats/nifti.py
load_grouped_subjects_ti_toolbox ¶
load_grouped_subjects_ti_toolbox(subject_configs: list[dict], nifti_file_pattern: str = 'grey_{simulation_name}_TI_MNI_MNI_TI_max.nii.gz', dtype=float32) -> tuple[dict[str, ndarray], Nifti1Image, dict[str, list[str]]]
Load subjects organized by named groups.
Each config dict must include a 'group' key in addition to the
fields required by :func:load_group_data_ti_toolbox. Configs
without a 'group' key are assigned to the 'default' group.
Parameters¶
subject_configs : list of dict
Each dict must contain 'subject_id', 'simulation_name',
and 'group' (e.g. 'Responders').
nifti_file_pattern : str, optional
Filename pattern forwarded to :func:load_subject_nifti_ti_toolbox.
dtype : numpy dtype, optional
Data type for the returned arrays. Default is np.float32.
Returns¶
groups_data : dict of str to numpy.ndarray
Mapping from group name to a 4-D array (X, Y, Z, n_subjects).
template_img : nibabel.Nifti1Image
Image from the first loaded subject.
groups_ids : dict of str to list of str
Mapping from group name to ordered list of subject identifiers.