Prepare for forward computation. The sensors dict contains keys for each sensor type, e.g. 'meg', 'eeg'. The vale for each of these is a dict that comes from _prep_meg_channels or _prep_eeg_channels. Each dict contains: - defs : a list of dicts (one per channel) with 'rmag', 'cosma
(
src,
mri_head_t,
info,
bem,
mindist,
n_jobs,
*,
bem_extra="",
trans="",
info_extra="",
meg=True,
eeg=True,
ignore_ref=False,
allow_bem_none=False,
on_inside="raise",
verbose=None,
)
| 439 | |
| 440 | @verbose |
| 441 | def _prepare_for_forward( |
| 442 | src, |
| 443 | mri_head_t, |
| 444 | info, |
| 445 | bem, |
| 446 | mindist, |
| 447 | n_jobs, |
| 448 | *, |
| 449 | bem_extra="", |
| 450 | trans="", |
| 451 | info_extra="", |
| 452 | meg=True, |
| 453 | eeg=True, |
| 454 | ignore_ref=False, |
| 455 | allow_bem_none=False, |
| 456 | on_inside="raise", |
| 457 | verbose=None, |
| 458 | ): |
| 459 | """Prepare for forward computation. |
| 460 | |
| 461 | The sensors dict contains keys for each sensor type, e.g. 'meg', 'eeg'. |
| 462 | The vale for each of these is a dict that comes from _prep_meg_channels or |
| 463 | _prep_eeg_channels. Each dict contains: |
| 464 | |
| 465 | - defs : a list of dicts (one per channel) with 'rmag', 'cosmag', etc. |
| 466 | - ch_names: a list of str channel names corresponding to the defs |
| 467 | - compensator (optional): the ndarray compensation matrix to apply |
| 468 | - post_picks (optional): the ndarray of indices to pick after applying the |
| 469 | compensator |
| 470 | """ |
| 471 | # Read the source locations |
| 472 | logger.info("") |
| 473 | # let's make a copy in case we modify something |
| 474 | src = _ensure_src(src).copy() |
| 475 | nsource = sum(s["nuse"] for s in src) |
| 476 | if len(src) and nsource == 0: |
| 477 | raise RuntimeError( |
| 478 | "No sources are active in these source spaces. " |
| 479 | '"do_all" option should be used.' |
| 480 | ) |
| 481 | logger.info( |
| 482 | "Read %d source spaces a total of %d active source locations", len(src), nsource |
| 483 | ) |
| 484 | # Delete some keys to clean up the source space: |
| 485 | for key in ["working_dir", "command_line"]: |
| 486 | if key in src.info: |
| 487 | del src.info[key] |
| 488 | |
| 489 | # Read the MRI -> head coordinate transformation |
| 490 | logger.info("") |
| 491 | _print_coord_trans(mri_head_t) |
| 492 | |
| 493 | # make a new dict with the relevant information |
| 494 | arg_list = [info_extra, trans, src, bem_extra, meg, eeg, mindist, n_jobs, verbose] |
| 495 | cmd = f"make_forward_solution({', '.join(str(a) for a in arg_list)})" |
| 496 | mri_id = dict(machid=np.zeros(2, np.int32), version=0, secs=0, usecs=0) |
| 497 | |
| 498 | info_trans = str(trans) if isinstance(trans, Path) else trans |
no test coverage detected