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

Method pick

mne/channels/layout.py:146–256  ·  view source on GitHub ↗

Pick a subset of channels. Parameters ---------- %(picks_layout)s exclude : str | int | array-like of str or int Set of channels to exclude, only used when ``picks`` is set to ``'all'`` or ``None``. Exclude will not drop channels explicitly pr

(self, picks=None, exclude=(), *, verbose=None)

Source from the content-addressed store, hash-verified

144
145 @verbose
146 def pick(self, picks=None, exclude=(), *, verbose=None):
147 """Pick a subset of channels.
148
149 Parameters
150 ----------
151 %(picks_layout)s
152 exclude : str | int | array-like of str or int
153 Set of channels to exclude, only used when ``picks`` is set to ``'all'`` or
154 ``None``. Exclude will not drop channels explicitly provided in ``picks``.
155 %(verbose)s
156
157 Returns
158 -------
159 layout : instance of Layout
160 The modified layout.
161
162 Notes
163 -----
164 .. versionadded:: 1.7
165 """
166 # TODO: all the picking functions operates on an 'info' object which is missing
167 # for a layout, thus we have to do the extra work here. The logic below can be
168 # replaced when https://github.com/mne-tools/mne-python/issues/11913 is solved.
169 if (isinstance(picks, str) and picks == "all") or (picks is None):
170 picks = deepcopy(self.names)
171 apply_exclude = True
172 elif isinstance(picks, str):
173 picks = [picks]
174 apply_exclude = False
175 elif isinstance(picks, slice):
176 try:
177 picks = np.arange(len(self.names))[picks]
178 except TypeError:
179 raise TypeError(
180 "If a slice is provided, it must be a slice of integers."
181 )
182 apply_exclude = False
183 else:
184 try:
185 picks = [_ensure_int(picks)]
186 except TypeError:
187 picks = (
188 list(picks) if isinstance(picks, tuple | set) else deepcopy(picks)
189 )
190 apply_exclude = False
191 if apply_exclude:
192 if isinstance(exclude, str):
193 exclude = [exclude]
194 else:
195 try:
196 exclude = [_ensure_int(exclude)]
197 except TypeError:
198 exclude = (
199 list(exclude)
200 if isinstance(exclude, tuple | set)
201 else deepcopy(exclude)
202 )
203 for var, var_name in ((picks, "picks"), (exclude, "exclude")):

Calls 3

_ensure_intFunction · 0.85
setFunction · 0.85
warnFunction · 0.85

Tested by 15

rawFunction · 0.36
_bias_paramsFunction · 0.36
_evoked_cov_sphereFunction · 0.36
test_make_forward_dipoleFunction · 0.36
test_field_map_ctfFunction · 0.36
test_make_field_map_eegFunction · 0.36
test_make_field_map_megFunction · 0.36
test_make_field_map_meegFunction · 0.36
test_as_meg_type_evokedFunction · 0.36