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, hf_peak, hf_sar) 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",
"hf_peak", "hf_sar").
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
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |