forward
tit.source.forward ¶
Rebuild MNE-compatible EEG forward solutions from SimNIBS head models.
For a subject with an existing m2m_<id> head model, :func:prepare_forward
produces the three files an MNE source-reconstruction needs:
sub-<id>_net-<net>-fwd.fif-- the forward solution (gain matrix)sub-<id>_net-<net>-src.fif-- the cortical source spacesub-<id>_net-<net>-morph.h5-- a SourceMorph onto fsaverage
plus the point-electrode leadfield (*_leadfield.hdf5) and the head<->MRI
transform (*-trans.fif) they are derived from. All outputs land under
derivatives/SimNIBS/sub-<id>/forward/ -- a namespace distinct from the
optimizer's leadfields/ (which uses modeled electrodes for stimulation
dose; the EEG forward uses point electrodes per the SimNIBS EEG convention).
The expensive FEM leadfield is computed at most once per (subject, net, net CSV,
head mesh): sub-<id>_net-<net>-provenance.json records the sha256 of the net
CSV and head mesh (and the fsaverage spacing of the assembled files), and a
re-run reuses the leadfield / MNE files only when they match exactly.
Runs under simnibs_python (imports both mne and simnibs)::
simnibs_python -m tit.source forward_config.json
See Also¶
tit.source.config.ForwardConfig : Parameter object. tit.source.fsaverage.project_fields_to_fsaverage : The companion field-mapping pipeline that puts simulation fields on the same fsaverage grid.
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 | |