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): a re-run reuses the cached HDF5 and only re-assembles the MNE files.
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) -> 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 | |