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

Function read_morph_map

mne/morph_map.py:38–112  ·  view source on GitHub ↗

Read morph map. Morph maps can be generated with mne_make_morph_maps. If one isn't available, it will be generated automatically and saved to the ``subjects_dir/morph_maps`` directory. Parameters ---------- subject_from : str Name of the original subject as named in

(
    subject_from, subject_to, subjects_dir=None, xhemi=False, verbose=None
)

Source from the content-addressed store, hash-verified

36
37@verbose
38def read_morph_map(
39 subject_from, subject_to, subjects_dir=None, xhemi=False, verbose=None
40):
41 """Read morph map.
42
43 Morph maps can be generated with mne_make_morph_maps. If one isn't
44 available, it will be generated automatically and saved to the
45 ``subjects_dir/morph_maps`` directory.
46
47 Parameters
48 ----------
49 subject_from : str
50 Name of the original subject as named in the ``SUBJECTS_DIR``.
51 subject_to : str
52 Name of the subject on which to morph as named in the ``SUBJECTS_DIR``.
53 subjects_dir : path-like
54 Path to ``SUBJECTS_DIR`` is not set in the environment.
55 xhemi : bool
56 Morph across hemisphere. Currently only implemented for
57 ``subject_to == subject_from``. See notes of
58 :func:`mne.compute_source_morph`.
59 %(verbose)s
60
61 Returns
62 -------
63 left_map, right_map : ~scipy.sparse.csr_array
64 The morph maps for the 2 hemispheres.
65 """
66 subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
67
68 # First check for morph-map dir existence
69 mmap_dir = subjects_dir / "morph-maps"
70 if not mmap_dir.is_dir():
71 try:
72 os.mkdir(mmap_dir)
73 except Exception:
74 warn(f'Could not find or make morph map directory "{mmap_dir}"')
75
76 # filename components
77 if xhemi:
78 if subject_to != subject_from:
79 raise NotImplementedError(
80 "Morph-maps between hemispheres are currently only "
81 "implemented for subject_to == subject_from"
82 )
83 map_name_temp = "%s-%s-xhemi"
84 log_msg = "Creating morph map %s -> %s xhemi"
85 else:
86 map_name_temp = "%s-%s"
87 log_msg = "Creating morph map %s -> %s"
88
89 map_names = [
90 map_name_temp % (subject_from, subject_to),
91 map_name_temp % (subject_to, subject_from),
92 ]
93
94 # find existing file
95 fname = None

Callers 4

test_make_morph_mapsFunction · 0.90
morph_labelsFunction · 0.85
_compute_sparse_morphFunction · 0.85
_compute_morph_matrixFunction · 0.85

Calls 6

get_subjects_dirFunction · 0.85
warnFunction · 0.85
_read_morph_mapFunction · 0.85
_make_morph_mapFunction · 0.85
_write_morph_mapFunction · 0.85
infoMethod · 0.80

Tested by 1

test_make_morph_mapsFunction · 0.72