Prepare topo plot.
(inst, ch_type, sphere=None)
| 110 | |
| 111 | |
| 112 | def _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 |
no test coverage detected