MCPcopy
hub / github.com/mne-tools/mne-python / read_forward_solution

Function read_forward_solution

mne/forward/forward.py:519–714  ·  view source on GitHub ↗

Read a forward solution a.k.a. lead field. Parameters ---------- fname : path-like The file name, which should end with ``-fwd.fif``, ``-fwd.fif.gz``, ``_fwd.fif``, ``_fwd.fif.gz``, ``-fwd.h5``, or ``_fwd.h5``. include : list, optional List of names of channe

(fname, include=(), exclude=(), *, ordered=True, verbose=None)

Source from the content-addressed store, hash-verified

517
518@verbose
519def read_forward_solution(fname, include=(), exclude=(), *, ordered=True, verbose=None):
520 """Read a forward solution a.k.a. lead field.
521
522 Parameters
523 ----------
524 fname : path-like
525 The file name, which should end with ``-fwd.fif``, ``-fwd.fif.gz``,
526 ``_fwd.fif``, ``_fwd.fif.gz``, ``-fwd.h5``, or ``_fwd.h5``.
527 include : list, optional
528 List of names of channels to include. If empty all channels
529 are included.
530 exclude : list, optional
531 List of names of channels to exclude. If empty include all channels.
532 %(ordered)s
533 %(verbose)s
534
535 Returns
536 -------
537 fwd : instance of Forward
538 The forward solution.
539
540 See Also
541 --------
542 write_forward_solution, make_forward_solution
543
544 Notes
545 -----
546 Forward solutions, which are derived from an original forward solution with
547 free orientation, are always stored on disk as forward solution with free
548 orientation in X/Y/Z RAS coordinates. To apply any transformation to the
549 forward operator (surface orientation, fixed orientation) please apply
550 :func:`convert_forward_solution` after reading the forward solution with
551 :func:`read_forward_solution`.
552
553 Forward solutions, which are derived from an original forward solution with
554 fixed orientation, are stored on disk as forward solution with fixed
555 surface-based orientations. Please note that the transformation to
556 surface-based, fixed orientation cannot be reverted after loading the
557 forward solution with :func:`read_forward_solution`.
558 """
559 check_fname(
560 fname,
561 "forward",
562 ("-fwd.fif", "-fwd.fif.gz", "_fwd.fif", "_fwd.fif.gz", "-fwd.h5", "_fwd.h5"),
563 )
564 fname = _check_fname(fname=fname, must_exist=True, overwrite="read")
565 # Open the file, create directory
566 logger.info(f"Reading forward solution from {fname}...")
567 if fname.suffix == ".h5":
568 return _read_forward_hdf5(fname)
569 f, tree, _ = fiff_open(fname)
570 with f as fid:
571 # Find all forward solutions
572 fwds = dir_tree_find(tree, FIFF.FIFFB_MNE_FORWARD_SOLUTION)
573 if len(fwds) == 0:
574 raise ValueError(f"No forward solutions in {fname}")
575
576 # Parent MRI data

Calls 15

check_fnameFunction · 0.85
_check_fnameFunction · 0.85
_read_forward_hdf5Function · 0.85
fiff_openFunction · 0.85
dir_tree_findFunction · 0.85
find_source_space_hemiFunction · 0.85
find_tagFunction · 0.85
_read_oneFunction · 0.85
is_fixed_orientFunction · 0.85
_merge_fwdsFunction · 0.85
invert_transformFunction · 0.85