Skip to content

Commit 219e8a1

Browse files
Famous077pre-commit-ci[bot]tsbinnsdrammock
authored
DOC: clarify index mismatch in Epochs.drop when epochs are auto-dropped (#13688)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Thomas S. Binns <t.s.binns@outlook.com> Co-authored-by: Daniel McCloy <dan@mccloy.info>
1 parent 03436eb commit 219e8a1

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

doc/changes/dev/13688.other.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a note to :meth:`mne.Epochs.drop` describing a potential mismatch between the indices expected by :meth:`~mne.Epochs.drop` and those found in the ``selection`` attribute when epochs have been automatically dropped, by :newcontrib:`Famous Raj Bhat`.

doc/changes/names.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
.. _Ezequiel Mikulan: https://github.com/ezemikulan
9797
.. _Ezequiel Mikulan: https://github.com/ezemikulan
9898
.. _Fahimeh Mamashli: https://github.com/fmamashli
99+
.. _Famous Raj Bhat: https://github.com/Famous077
99100
.. _Farzin Negahbani: https://github.com/Farzin-Negahbani
100101
.. _Federico Raimondo: https://github.com/fraimondo
101102
.. _Federico Zamberlan: https://github.com/fzamberlan

mne/epochs.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,20 @@ def drop(self, indices, reason="USER", verbose=None):
15561556
-------
15571557
epochs : instance of Epochs
15581558
The epochs with indices dropped. Operates in-place.
1559+
1560+
Notes
1561+
-----
1562+
This method expects zero-based indices into the currently remaining
1563+
epochs, not the original event indices (as found in
1564+
the ``selection`` attribute). If some epochs were previously dropped (possibly
1565+
automatically, e.g., due to rejection thresholds or being too close to recording
1566+
start or end), you may need to convert indices before calling this method::
1567+
1568+
# epochs.selection contains the original indices (which are also shown by
1569+
# epochs.plot()) of the remaining epochs
1570+
plot_idx = 1 # index shown in epochs.plot()
1571+
drop_idx = np.where(epochs.selection == plot_idx)[0]
1572+
epochs.drop(drop_idx)
15591573
"""
15601574
indices = np.atleast_1d(indices)
15611575

0 commit comments

Comments
 (0)