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_rms) 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_rms").
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 the fsaverage .msh 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 write it as an fsaverage .msh.
Returns (subject_id, status, message) where status is one of
{"ok", "partial", "cached", "failed"} so batch runs can record and
continue; "partial" means some requested fields could not be projected.
Source code in tit/source/fsaverage.py
prepare_forward ¶
prepare_forward(subject_id: str, cfg: ForwardConfig, *, output_dir: str | Path | None = None, info: Info | None = None, trans: Transform | 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/).
info : mne.Info or None
A recording's Info whose dig carries the LPA, Nasion and RPA
cardinal points. The head<->MRI transform is coregistered from them,
so the forward is in the recording's head frame. Default: the net's
own template fiducials.
trans : mne.transforms.Transform or None
An explicit head->MRI transform (MNE head -> MRI frames); used as is,
never re-estimated. Pass info or trans, not both.
Returns¶
tuple of pathlib.Path
(fwd_path, src_path, morph_path).
Source code in tit/source/forward.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |