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

Function _prepare_topomap_plot

mne/viz/topomap.py:112–199  ·  view source on GitHub ↗

Prepare topo plot.

(inst, ch_type, sphere=None)

Source from the content-addressed store, hash-verified

110
111
112def _prepare_topomap_plot(inst, ch_type, sphere=None):
113 """Prepare topo plot."""
114 from ..channels.layout import _find_topomap_coords, _pair_grad_sensors, find_layout
115
116 info = copy.deepcopy(inst if isinstance(inst, Info) else inst.info)
117 sphere, clip_origin = _adjust_meg_sphere(sphere, info, ch_type)
118
119 clean_ch_names = _clean_names(info["ch_names"])
120 for ii, this_ch in enumerate(info["chs"]):
121 this_ch["ch_name"] = clean_ch_names[ii]
122 for comp in info["comps"]:
123 comp["data"]["col_names"] = _clean_names(comp["data"]["col_names"])
124 info._update_redundant()
125 info["bads"] = _clean_names(info["bads"])
126 info._check_consistency()
127
128 if any(ch["coil_type"] in _opm_coils for ch in info["chs"]):
129 modality = "opm"
130 elif ch_type in _fnirs_types:
131 modality = "fnirs"
132 else:
133 modality = "other"
134
135 # special case for merging grad channels
136 layout = find_layout(info)
137 if (
138 ch_type == "grad"
139 and layout is not None
140 and (
141 layout.kind.startswith("Vectorview")
142 or layout.kind.startswith("Neuromag_122")
143 )
144 ):
145 picks, _ = _pair_grad_sensors(info, layout)
146 pos = _find_topomap_coords(info, picks[::2], sphere=sphere)
147 merge_channels = True
148 elif modality != "other":
149 picks, pos, merge_channels, overlapping_channels = _find_overlaps(
150 info, ch_type, sphere, modality=modality
151 )
152 else:
153 merge_channels = False
154 if ch_type == "eeg":
155 picks = pick_types(info, meg=False, eeg=True, ref_meg=False, exclude="bads")
156 elif ch_type == "csd":
157 picks = pick_types(info, meg=False, csd=True, ref_meg=False, exclude="bads")
158 elif ch_type == "dbs":
159 picks = pick_types(info, meg=False, dbs=True, ref_meg=False, exclude="bads")
160 elif ch_type == "seeg":
161 picks = pick_types(
162 info, meg=False, seeg=True, ref_meg=False, exclude="bads"
163 )
164 else:
165 picks = pick_types(info, meg=ch_type, ref_meg=False, exclude="bads")
166
167 if len(picks) == 0:
168 raise ValueError(f"No channels of type {ch_type!r}")
169

Callers 11

_plot_projs_topomapFunction · 0.85
_plot_ica_topomapFunction · 0.85
plot_ica_componentsFunction · 0.85
plot_tfr_topomapFunction · 0.85
plot_evoked_topomapFunction · 0.85
_topomap_animationFunction · 0.85
_plot_corrmapFunction · 0.85
plot_arrowmapFunction · 0.85
plot_regression_weightsFunction · 0.85
_line_plot_onselectFunction · 0.85
plot_topomapMethod · 0.85

Calls 9

_adjust_meg_sphereFunction · 0.85
_clean_namesFunction · 0.85
find_layoutFunction · 0.85
_pair_grad_sensorsFunction · 0.85
_find_topomap_coordsFunction · 0.85
pick_typesFunction · 0.85
_update_redundantMethod · 0.80
_find_overlapsFunction · 0.70
_check_consistencyMethod · 0.45

Tested by

no test coverage detected