Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/devel/12763.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix check for dropping all channels in :meth:`mne.io.Raw.drop_channels` and related methods, by :newcontrib:`Farzin Negahbani`.
10 changes: 6 additions & 4 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@

.. _Fahimeh Mamashli: https://github.com/fmamashli

.. _Farzin Negahbani: https://github.com/Farzin-Negahbani

.. _Federico Raimondo: https://github.com/fraimondo

.. _Federico Zamberlan: https://github.com/fzamberlan
Expand Down Expand Up @@ -508,6 +510,8 @@

.. _Rotem Falach: https://github.com/Falach

.. _Sammi Chekroud: https://github.com/schekroud

.. _Samu Taulu: https://phys.washington.edu/people/samu-taulu

.. _Samuel Deslauriers-Gauthier: https://github.com/sdeslauriers
Expand Down Expand Up @@ -536,6 +540,8 @@

.. _Senwen Deng: https://snwn.de

.. _Seyed Yahya Shirazi: https://neuromechanist.github.io

.. _Sheraz Khan: https://github.com/SherazKhan

.. _Silvia Cotroneo: https://github.com/sfc-neuro
Expand Down Expand Up @@ -625,7 +631,3 @@
.. _Zhi Zhang: https://github.com/tczhangzhi/

.. _Zvi Baratz: https://github.com/ZviBaratz

.. _Seyed Yahya Shirazi: https://neuromechanist.github.io

.. _Sammi Chekroud: https://github.com/schekroud
2 changes: 2 additions & 0 deletions mne/channels/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ def drop_channels(self, ch_names, on_missing="raise"):

bad_idx = [self.ch_names.index(ch) for ch in ch_names if ch in self.ch_names]
idx = np.setdiff1d(np.arange(len(self.ch_names)), bad_idx)
if len(idx) == 0:
raise ValueError("All channels would be dropped.")
return self._pick_drop_channels(idx)

@verbose
Expand Down
2 changes: 2 additions & 0 deletions mne/channels/tests/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ def test_drop_channels():
raw.drop_channels(m_chs, on_missing="warn")
# ...or ignored altogether
raw.drop_channels(m_chs, on_missing="ignore")
with pytest.raises(ValueError, match="All channels"):
raw.drop_channels(raw.ch_names)


def test_pick_channels():
Expand Down