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

Function read_source_spaces

mne/source_space/_source_space.py:881–940  ·  view source on GitHub ↗

Read the source spaces from a FIF file. Parameters ---------- fname : path-like The name of the file, which should end with ``-src.fif`` or ``-src.fif.gz``. patch_stats : bool, optional (default False) Calculate and add cortical patch statistics to the surfac

(fname, patch_stats=False, verbose=None)

Source from the content-addressed store, hash-verified

879
880@verbose
881def read_source_spaces(fname, patch_stats=False, verbose=None):
882 """Read the source spaces from a FIF file.
883
884 Parameters
885 ----------
886 fname : path-like
887 The name of the file, which should end with ``-src.fif`` or
888 ``-src.fif.gz``.
889 patch_stats : bool, optional (default False)
890 Calculate and add cortical patch statistics to the surfaces.
891 %(verbose)s
892
893 Returns
894 -------
895 src : SourceSpaces
896 The source spaces.
897
898 See Also
899 --------
900 write_source_spaces, setup_source_space, setup_volume_source_space
901 """
902 # be more permissive on read than write (fwd/inv can contain src)
903 fname = _check_fname(fname, overwrite="read", must_exist=True)
904 check_fname(
905 fname,
906 "source space",
907 (
908 "-src.fif",
909 "-src.fif.gz",
910 "_src.fif",
911 "_src.fif.gz",
912 "-fwd.fif",
913 "-fwd.fif.gz",
914 "_fwd.fif",
915 "_fwd.fif.gz",
916 "-inv.fif",
917 "-inv.fif.gz",
918 "_inv.fif",
919 "_inv.fif.gz",
920 ),
921 )
922
923 ff, tree, _ = fiff_open(fname)
924 with ff as fid:
925 src = _read_source_spaces_from_tree(
926 fid, tree, patch_stats=patch_stats, verbose=verbose
927 )
928 src.info["fname"] = fname
929 node = dir_tree_find(tree, FIFF.FIFFB_MNE_ENV)
930 if node:
931 node = node[0]
932 for p in range(node["nent"]):
933 kind = node["directory"][p].kind
934 pos = node["directory"][p].pos
935 tag = read_tag(fid, pos)
936 if kind == FIFF.FIFF_MNE_ENV_WORKING_DIR:
937 src.info["working_dir"] = tag.data
938 elif kind == FIFF.FIFF_MNE_ENV_COMMAND_LINE:

Calls 6

_check_fnameFunction · 0.85
check_fnameFunction · 0.85
fiff_openFunction · 0.85
dir_tree_findFunction · 0.85
read_tagFunction · 0.85