Skip to content

Commit f85e6ef

Browse files
committed
Merge remote-tracking branch 'upstream/main' into wip-mne-tools-fix-dyld
2 parents 70db2b8 + 3acfa3f commit f85e6ef

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add ``exclude`` parameter to :meth:`mne.io.Raw.get_data`, :meth:`mne.Epochs.get_data`, and :meth:`mne.Evoked.get_data` by `Carina Forster`_.

mne/epochs.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,7 @@ def _get_data(
17231723
picks=None,
17241724
item=None,
17251725
*,
1726+
exclude=(),
17261727
units=None,
17271728
tmin=None,
17281729
tmax=None,
@@ -1740,6 +1741,14 @@ def _get_data(
17401741
%(picks_all)s
17411742
item : slice | array-like | str | list | None
17421743
See docstring of get_data method.
1744+
exclude : list[str] | Literal["bads"]
1745+
Channels to exclude. If ``'bads'``, channels in ``info['bads']`` are
1746+
excluded; pass an empty list or tuple (the default) to include all
1747+
channels. Note: ``exclude`` is currently only applied when ``picks``
1748+
is ``None``; it is ignored when ``picks!=None`` (to be fixed in a
1749+
future release).
1750+
1751+
.. versionadded:: 1.13
17431752
%(units)s
17441753
tmin : int | float | None
17451754
Start time of data to get in seconds.
@@ -1806,7 +1815,7 @@ def _get_data(
18061815

18071816
orig_picks = picks
18081817
if orig_picks is None:
1809-
picks = _picks_to_idx(self.info, picks, "all", exclude=())
1818+
picks = _picks_to_idx(self.info, picks, "all", exclude=exclude)
18101819
else:
18111820
picks = _picks_to_idx(self.info, picks)
18121821

@@ -1992,6 +2001,7 @@ def get_data(
19922001
tmin: int | float | None = None,
19932002
tmax: int | float | None = None,
19942003
*,
2004+
exclude: list[str] | Literal["bads"] | tuple = (),
19952005
copy: bool = True,
19962006
verbose: bool | str | int | None = None,
19972007
) -> np.ndarray:
@@ -2019,6 +2029,14 @@ def get_data(
20192029
End time of data to get in seconds.
20202030
20212031
.. versionadded:: 0.24.0
2032+
exclude : list[str] | Literal["bads"]
2033+
Channels to exclude. If ``'bads'``, channels in ``info['bads']`` are
2034+
excluded; pass an empty list or tuple (the default) to include all
2035+
channels. Note: ``exclude`` is currently only applied when ``picks``
2036+
is ``None``; it is ignored when ``picks!=None`` (to be fixed in a
2037+
future release).
2038+
2039+
.. versionadded:: 1.13
20222040
copy : bool
20232041
Whether to return a copy of the object's data, or (if possible) a view.
20242042
See :ref:`the NumPy docs <numpy:basics.copies-and-views>` for an
@@ -2044,7 +2062,13 @@ def get_data(
20442062
when possible when ``copy=False``.
20452063
"""
20462064
return self._get_data(
2047-
picks=picks, item=item, units=units, tmin=tmin, tmax=tmax, copy=copy
2065+
picks=picks,
2066+
exclude=exclude,
2067+
item=item,
2068+
units=units,
2069+
tmin=tmin,
2070+
tmax=tmax,
2071+
copy=copy,
20482072
)
20492073

20502074
@verbose

mne/evoked.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def get_data(
242242
units: str | dict | None = None,
243243
tmin: float | None = None,
244244
tmax: float | None = None,
245+
exclude: list[str] | Literal["bads"] | tuple = (),
245246
) -> np.ndarray:
246247
"""Get evoked data as 2D array.
247248
@@ -253,6 +254,12 @@ def get_data(
253254
Start time of data to get in seconds.
254255
tmax : float | None
255256
End time of data to get in seconds.
257+
exclude : list[str] | Literal["bads"]
258+
Channels to exclude. If ``'bads'``, channels in ``info['bads']`` are
259+
excluded; pass an empty list or tuple (the default) to include all
260+
channels.
261+
262+
.. versionadded:: 1.13
256263
257264
Returns
258265
-------
@@ -266,7 +273,7 @@ def get_data(
266273
# Avoid circular import
267274
from .io.base import _get_ch_factors
268275

269-
picks = _picks_to_idx(self.info, picks, "all", exclude=())
276+
picks = _picks_to_idx(self.info, picks, "all", exclude=exclude)
270277

271278
start, stop = self._handle_tmin_tmax(tmin, tmax)
272279

mne/io/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ def get_data(
940940
return_times: bool = False,
941941
units: str | dict | None = None,
942942
*,
943+
exclude: list[str] | Literal["bads"] | tuple = (),
943944
tmin: int | float | None = None,
944945
tmax: int | float | None = None,
945946
verbose: bool | str | int | None = None,
@@ -961,6 +962,14 @@ def get_data(
961962
return_times : bool
962963
Whether to return times as well. Defaults to False.
963964
%(units)s
965+
exclude : list[str] | Literal["bads"]
966+
Channels to exclude. If ``'bads'``, channels in ``info['bads']`` are
967+
excluded; pass an empty list or tuple (the default) to include all
968+
channels. Note: ``exclude`` is currently only applied when ``picks``
969+
is not ``None``; it is ignored when ``picks=None`` (to be fixed in a
970+
future release).
971+
972+
.. versionadded:: 1.13
964973
tmin : int | float | None
965974
Start time of data to get in seconds. The ``tmin`` parameter is
966975
ignored if the ``start`` parameter is bigger than 0.
@@ -997,7 +1006,7 @@ def get_data(
9971006
# allocation and ~40 us of name resolution on every call.
9981007
picks = np.arange(self.info["nchan"])
9991008
else:
1000-
picks = _picks_to_idx(self.info, picks, "all", exclude=())
1009+
picks = _picks_to_idx(self.info, picks, "all", exclude=exclude)
10011010

10021011
# Get channel factors for conversion into specified unit
10031012
# (vector of ones if no conversion needed)

0 commit comments

Comments
 (0)