source
tit.source ¶
EEG source-forward preparation and fsaverage field mapping.
Two pipelines that put EEG source reconstruction and TI stimulation fields on a common cortical grid:
- :func:
prepare_forward-- build an MNE-compatible EEG forward solution (leadfield + source space + fsaverage morph) from a SimNIBS head model. - :func:
project_fields_to_fsaverage-- project existing simulation field outputs (TI_max, TI_normal, |E|) onto an fsaverage template.
Both run under the SimNIBS interpreter::
simnibs_python -m tit.source config.json
See Also¶
tit.source.config : ForwardConfig and FsavgMapConfig dataclasses.
ForwardConfig
dataclass
¶
ForwardConfig(eeg_net: str = 'GSN-HydroCel-185', fsaverage_spacing: int = 5, cpus: int = 1, overwrite: bool = False)
Parameters for rebuilding a SimNIBS/MNE EEG forward solution.
Attributes¶
eeg_net : str
EEG cap name without the .csv suffix, as found in the subject's
m2m_<id>/eeg_positions/ directory (e.g. "GSN-HydroCel-185").
fsaverage_spacing : int
fsaverage subdivision factor (5, 6, or 7) for the morph target.
cpus : int
SimNIBS FEM workers used while computing the leadfield.
overwrite : bool
Recompute even when valid outputs already exist. The expensive FEM
leadfield is still reused when present unless this is True.
FsavgMapConfig
dataclass
¶
FsavgMapConfig(fields: tuple[str, ...] = (lambda: VALID_FSAVG_FIELDS)(), fsaverage_spacing: int = 5, workers: int = 1, overwrite: bool = False)
Parameters for projecting simulation field outputs onto fsaverage.
Attributes¶
fields : tuple of str
Which field quantities to project. Any of
:data:VALID_FSAVG_FIELDS ("TI_max", "TI_normal",
"magnitude").
fsaverage_spacing : int
fsaverage subdivision factor (5, 6, or 7) to morph onto.
workers : int
Number of subjects projected in parallel (1 = serial).
overwrite : bool
Re-project even when a cached .npz already exists.
project_fields_to_fsaverage ¶
project_fields_to_fsaverage(subjects: list[tuple[str, str]], cfg: FsavgMapConfig) -> list[tuple[str, str, str]]
Project field outputs to fsaverage for many (subject, simulation) pairs.
Parameters¶
subjects : list of (str, str)
(subject_id, simulation_name) pairs to project.
cfg : FsavgMapConfig
Field selection, fsaverage spacing, worker count, overwrite flag.
Returns¶
list of (str, str, str)
Per-pair (subject_id, status, message) results.
Source code in tit/source/fsaverage.py
project_subject ¶
Project one (subject, simulation) and cache the result as .npz.
Returns (subject_id, status, message) where status is one of
{"ok", "cached", "failed"} so batch runs can record and continue.
Source code in tit/source/fsaverage.py
prepare_forward ¶
prepare_forward(subject_id: str, cfg: ForwardConfig, *, output_dir: str | Path | None = None) -> tuple[Path, Path, Path]
Rebuild one subject's forward, source-space, and fsaverage morph files.
Parameters¶
subject_id : str
Subject identifier without the sub- prefix (e.g. "101").
cfg : ForwardConfig
EEG net, fsaverage spacing, FEM worker count, and overwrite flag.
output_dir : str or pathlib.Path or None
Destination directory. Defaults to pm.forward(subject_id)
(derivatives/SimNIBS/sub-<id>/forward/).
Returns¶
tuple of pathlib.Path
(fwd_path, src_path, morph_path).
Source code in tit/source/forward.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | |