DOC: clarify index mismatch in Epochs.drop when epochs are auto-dropped#13688
Open
Famous077 wants to merge 4 commits intomne-tools:mainfrom
Open
DOC: clarify index mismatch in Epochs.drop when epochs are auto-dropped#13688Famous077 wants to merge 4 commits intomne-tools:mainfrom
Famous077 wants to merge 4 commits intomne-tools:mainfrom
Conversation
Author
drammock
requested changes
Feb 25, 2026
mne/epochs.py
Outdated
Comment on lines
1543
to
1557
| If some epochs were automatically dropped (e.g., due to | ||
| insufficient data or rejection), the indices shown in | ||
| :meth:`mne.Epochs.plot` may not match the indices expected | ||
| by this method. The plot shows indices from | ||
| :attr:`mne.Epochs.selection` (original event indices), | ||
| while this method uses 0-based indices into the current | ||
| set of remaining epochs. To convert plot indices to drop | ||
| indices, use:: | ||
|
|
||
| # epochs.selection contains the original indices | ||
| # 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) | ||
|
|
Member
There was a problem hiding this comment.
This is pretty good. I think:
- it should be in a separate
Notessection of the docstring - it should emphasize less "automatic dropping" and "what is shown in epochs.plot" and instead focus on the fact that this method expects zero-based indices into the currently remaining epochs (not the epochs' original indices, as found in
epochs.selection).
drammock
reviewed
Feb 25, 2026
Member
There was a problem hiding this comment.
please also revert the (whitespace-only) changes to this file.
Author
|
Hi @drammock , Thanks for the feedback. I've moved the content into a separate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference issue (if any)
Fixed issue #11373
-->
What does this implement/fix?
--> The indices shown in epochs.plot() reflect epochs.selection
(original event indices), while epochs.drop() uses 0-based
indices into the remaining epochs. This PR clarifies this
behavior in the docstring and adds an example showing how to
correctly convert plot indices using epochs.selection.
Additional information
--> only documentation, No additional changes to code logic.