diff --git a/doc/changes/dev/13688.other.rst b/doc/changes/dev/13688.other.rst new file mode 100644 index 00000000000..c061900d78a --- /dev/null +++ b/doc/changes/dev/13688.other.rst @@ -0,0 +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`. \ No newline at end of file diff --git a/doc/changes/names.inc b/doc/changes/names.inc index 09c5818b6af..c6b4b00c499 100644 --- a/doc/changes/names.inc +++ b/doc/changes/names.inc @@ -96,6 +96,7 @@ .. _Ezequiel Mikulan: https://github.com/ezemikulan .. _Ezequiel Mikulan: https://github.com/ezemikulan .. _Fahimeh Mamashli: https://github.com/fmamashli +.. _Famous Raj Bhat: https://github.com/Famous077 .. _Farzin Negahbani: https://github.com/Farzin-Negahbani .. _Federico Raimondo: https://github.com/fraimondo .. _Federico Zamberlan: https://github.com/fzamberlan diff --git a/mne/epochs.py b/mne/epochs.py index 405dbc09a67..c9600a0650f 100644 --- a/mne/epochs.py +++ b/mne/epochs.py @@ -1556,6 +1556,20 @@ def drop(self, indices, reason="USER", verbose=None): ------- epochs : instance of Epochs The epochs with indices dropped. Operates in-place. + + Notes + ----- + This method expects zero-based indices into the currently remaining + epochs, not the original event indices (as found in + the ``selection`` attribute). If some epochs were previously dropped (possibly + automatically, e.g., due to rejection thresholds or being too close to recording + start or end), you may need to convert indices before calling this method:: + + # epochs.selection contains the original indices (which are also shown by + # epochs.plot()) of the remaining epochs + plot_idx = 1 # index shown in epochs.plot() + drop_idx = np.where(epochs.selection == plot_idx)[0] + epochs.drop(drop_idx) """ indices = np.atleast_1d(indices)