You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent handling of exclude='bads' in .pick() methods #13946
A user, Arthur Nguyen, raised an important usability issue in the MNE forum regarding the behavior of .pick() when bad channels are present.
Currently, the behavior of exclude='bads' depends on the type of input passed to .pick():
evoked.pick('eeg', exclude='bads')
excludes channels marked as bad and returns only clean EEG channels.
However,
evoked.pick(['F1', 'F2'], exclude='bads')
returns all requested channels, including those marked as bad, effectively ignoring the exclude parameter when channels are specified explicitly by name.
The current behavior is documented but it may still be surprising to users, since the same exclude argument behaves differently depending on the type of .pick() input. Users might expect exclude='bads' to be applied consistently regardless of how channels are selected.
After discussing this with @drammock, adding a warning might not be the ideal solution here. Instead, this may point to a broader API consistency issue: channel selection and exclusion should behave the same way independent of the input type provided to .pick().
A potential refactoring would involve reviewing all .pick()-related methods and standardise their behaviour:
Ensure all .pick() methods have an exclude parameter
Make exclude behave consistently for all supported .pick() input types
Align the default behavior across all .pick()-related methods
What should the default for exclude be? Right now, it is exclude="bads". This makes sense for picking channels by type but not for picking channels by name. (This is probably why it is ignored when picking by name.) Should the default be exclude="auto" which means excluding bads when picking by type but not when picking by name? And then exclude="bads" would always exclude bads, alse when picking by name.
yeah, for the first step (adding exclude to all the relevant signatures without changing default behavior) I think you're right we'll need exclude="auto" as the default
PR #14225 adds the exclude param to .get_data() for Raw, Epochs and Evokeds. Next up is to decide for a common default behaviour.
Currently, Epochs is the outlier. All TFR classes use as default exclude = 'bads'.
Update: use ast package to parse the objects that use exclude and picks to create an overview of the current state of the art before deciding further action (second PR).
Activity
wmvanvliet commentedon Jul 13, 2026
What should the default for
excludebe? Right now, it isexclude="bads". This makes sense for picking channels by type but not for picking channels by name. (This is probably why it is ignored when picking by name.) Should the default beexclude="auto"which means excluding bads when picking by type but not when picking by name? And thenexclude="bads"would always exclude bads, alse when picking by name.drammock commentedon Jul 13, 2026
yeah, for the first step (adding exclude to all the relevant signatures without changing default behavior) I think you're right we'll need
exclude="auto"as the defaultCarinaFo commentedon Aug 26, 2026
PR #14225 adds the exclude param to .get_data() for Raw, Epochs and Evokeds. Next up is to decide for a common default behaviour.
Currently, Epochs is the outlier. All TFR classes use as default exclude = 'bads'.
Notes on observed inconsistencies:
https://docs.google.com/document/d/19qBcebqgrdUIsVtUa8eaeVImHGdLtCkoSQbyEmRhDKE/edit?usp=sharing
CarinaFo commentedon Aug 27, 2026
Update: use ast package to parse the objects that use exclude and picks to create an overview of the current state of the art before deciding further action (second PR).