group
tit.analyzer.group ¶
Multi-subject group analysis.
Runs per-subject ROI analyses in-process via :class:Analyzer, aggregates the
results into a summary CSV with an AVERAGE row, and produces a 2x2 comparison
bar-chart saved as PDF.
Public API¶
GroupResult Container for multi-subject group analysis outcomes. run_group_analysis Run the same ROI analysis across multiple subjects and summarise.
See Also¶
tit.analyzer.analyzer : Single-subject analyzer used per-subject.
GroupResult
dataclass
¶
GroupResult(subject_results: dict[str, AnalysisResult], summary_csv_path: Path, comparison_plot_path: Path | None)
Outcome of a multi-subject group analysis.
Attributes¶
subject_results : dict of str to AnalysisResult
Mapping of subject ID to its
:class:~tit.analyzer.analyzer.AnalysisResult.
summary_csv_path : pathlib.Path
Path to the summary CSV (one row per subject plus an AVERAGE row).
comparison_plot_path : pathlib.Path or None
Path to the 2x2 comparison bar-chart PDF, or None if plotting
failed.
See Also¶
run_group_analysis : Factory function that produces this result. AnalysisResult : Per-subject analysis container.
run_group_analysis ¶
run_group_analysis(subject_ids: list[str], simulation: str, space: str = 'mesh', tissue_type: str = 'GM', analysis_type: str = 'spherical', center: tuple[float, float, float] | None = None, radius: float | None = None, coordinate_space: str = 'subject', spheres: Sequence[tuple[float, float, float, float]] | None = None, atlas: str | None = None, region: str | list[str] | None = None, visualize: bool = False, output_dir: str | Path | None = None, field: str | None = None, mask_path: str | None = None) -> GroupResult
Run the same ROI analysis across multiple subjects and summarise.
Dispatches to analyze_sphere or analyze_cortex on each subject,
builds a summary CSV (with an AVERAGE row), and generates a 2x2
comparison bar-chart PDF.
Parameters¶
subject_ids : list of str
Subject identifiers (without sub- prefix).
simulation : str
Simulation (montage) folder name, shared by all subjects.
space : str, optional
"mesh" or "voxel". Default "mesh".
tissue_type : str, optional
"GM", "WM", or "both" (voxel only). Default "GM".
analysis_type : str, optional
"spherical", "cortical" or "mask". Default
"spherical".
center : tuple of float or None, optional
(x, y, z) sphere centre; required when analysis_type is
"spherical".
radius : float or None, optional
Sphere radius in mm; required when analysis_type is
"spherical".
coordinate_space : str, optional
"subject" or "MNI" (spherical and mask). Default
"subject"; a group mask analysis requires "MNI".
spheres : sequence of tuple of float or None, optional
One (x, y, z, r) per sphere, unioned into a single ROI
(spherical only). Takes precedence over center/radius.
atlas : str or None, optional
Atlas name (cortical only).
region : str, list of str, or None, optional
Region name or list of region names (cortical only).
visualize : bool, optional
Generate per-subject visualization artifacts. Default False.
output_dir : str, pathlib.Path, or None, optional
Override output directory. If None, derived from PathManager.
field : str or None, optional
Field to analyze (constants.FIELD_REGISTRY name, e.g.
"TI_max", "TI_normal", "hf_peak"). Default None
resolves the TI_max/mTI_max envelope per subject.
mask_path : str or None, optional
MNI-space NIfTI mask (analysis_type="mask" only).
Returns¶
GroupResult
Per-subject results, the summary CSV path
(group_summary.csv), and the comparison plot path.
Raises¶
KeyError
If analysis_type is not "spherical", "cortical" or
"mask".
ValueError
If analysis_type="mask" with a non-MNI coordinate_space or an
unreadable mask_path.
FileNotFoundError
If a subject has no field file for simulation in space.
Examples¶
from tit.analyzer import run_group_analysis res = run_group_analysis( ... subject_ids=["ernie", "101"], simulation="L_Insula", space="voxel", ... analysis_type="spherical", center=(-35.0, 5.0, 5.0), radius=10.0, ... coordinate_space="MNI", ... ) # doctest: +SKIP res.summary_csv_path.name, sorted(res.subject_results) # doctest: +SKIP ('group_summary.csv', ['101', 'ernie']) run_group_analysis(["ernie", "101"], "L_Insula", space="mesh", ... analysis_type="cortical", atlas="DK40", ... region="lh.insula") # doctest: +SKIP
See Also¶
Analyzer : Single-subject analyzer used internally per subject. GroupResult : Container for the returned outcomes.
Source code in tit/analyzer/group.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |