Skip to content

Inconsistent handling of exclude='bads' in .pick() methods #13946

Description

@CarinaFo

Proposed documentation/API change

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

Related issues:
#12577
#12197

Fixes #14013

Activity

  1. wmvanvliet commented on Jul 13, 2026

    @wmvanvliet
    Contributor

    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.

  2. drammock commented on Jul 13, 2026

    @drammock
    Member

    Should the default be exclude="auto"

    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

  3. self-assigned this
    on Aug 25, 2026
  4. moved this from Claimed to In Progress in 2026 MNE-Python Maintainers Sprinton Aug 26, 2026
  5. CarinaFo commented on Aug 26, 2026

    @CarinaFo
    ContributorAuthor

    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

  6. CarinaFo commented on Aug 27, 2026

    @CarinaFo
    ContributorAuthor

    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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions