nifti_average_config
tit.stats.nifti_average_config ¶
Configuration dataclass for group NIfTI averaging (owner: B4).
Mirrors the fields the "NIfTI Group Averaging" panel collects, so
:mod:tit.config_io can generate a JSON Schema for it and a future
POST /api/jobs (kind "nifti_average") can validate a request body
before submitting the job. Pure Python -- no numpy/nibabel dependency.
Public API¶
NiftiAverageSpace Which per-subject NIfTI space the group average is computed in. NiftiAverageSubject One subject/simulation/group assignment row. NiftiAverageConfig Configuration for one group NIfTI averaging run.
See Also¶
tit.stats.nifti_average : Runner entry point that consumes this config
(simnibs_python -m tit.stats.nifti_average config.json).
tit.stats.nifti.load_grouped_subjects_ti_toolbox : Loads the per-group data.
NiftiAverageSubject
dataclass
¶
One subject/simulation/group assignment row.
Attributes¶
subject_id : str
Subject identifier (without the sub- prefix).
simulation_name : str
Simulation folder name whose NIfTI is averaged.
group : str, optional
Group label this subject belongs to. Default is "Group1".
NiftiAverageConfig
dataclass
¶
NiftiAverageConfig(output_name: str, subjects: list[NiftiAverageSubject], space: NiftiAverageSpace = MNI, nifti_file_pattern: str | None = None, diff_pairs: list[str] = list())
Configuration for one group NIfTI averaging run.
Attributes¶
output_name : str
Name of the output subdirectory under
derivatives/ti-toolbox/nifti_average/ (the GUI's "Analysis Name").
subjects : list of NiftiAverageSubject
Subject/simulation/group rows -- at least 2, spanning at least 1 group.
space : NiftiAverageSpace, optional
Which per-subject NIfTI space to average in. Selects the default
nifti_file_pattern when one is not given explicitly. Default is
:attr:NiftiAverageSpace.MNI.
nifti_file_pattern : str or None, optional
Filename pattern with {subject_id}/{simulation_name}
placeholders. Defaults to :data:_DEFAULT_PATTERNS [space] when
left None.
diff_pairs : list of str, optional
"GroupA-GroupB" pairs to difference. Empty (the default) means
every pairwise combination of the groups present in subjects.
Labels may contain hyphens ("post-op-pre-op"): an entry is split
at the one hyphen that leaves a group label on both sides.
Raises¶
ValueError
If output_name is blank or not a valid folder name
(:func:tit.paths.validate_name), fewer than 2 subjects are given,
a group label is not a valid file-name part (it names
average_<group>.nii.gz), or a diff_pairs entry does not name
two different groups exactly one way or repeats an earlier pair.
Notes¶
Group labels are stripped of edge whitespace, so "Group1 " and
"Group1" are one group.
See Also¶
tit.stats.nifti_average.main : Consumes this config.
difference_pairs ¶
The (A, B) group pairs whose A - B difference maps the run writes.
Returns¶
list of tuple of str Every pair of the groups in alphabetical order when diff_pairs is empty, else one pair per diff_pairs entry, in the order given.
Raises¶
ValueError If an entry does not split into two different known group labels, splits into them at more than one hyphen, or repeats an earlier pair.