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
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 | |