Skip to content

API: picks as list of string #4502

@kingjr

Description

@kingjr

Picking a particular channel is currently relatively complex for new users.

It either involves pythonic tricks:

picks = [ii for ii, ch in enumerate(epochs.ch_names) if ch == 'mychan']
epochs.plot(picks=picks)

Or master of MNE's functions:

picks = mne.pick_channels(evoked.info. [`my_chan`])
epochs.plot(picks=picks)

Proposal 1

👍 0
Since picks is always referring to a list of int and ch_names is always a list of str, I propose that we accept picks ot be a list of str:

evoked.plot(picks=list(range(10)))
epochs.plot(picks=['my_chan'])

Proposal 2

👍 0

Accepting the parameter picks to be a list of int (for indexing), a list of str (to find channel names) or a dict (to quickly select channel types).

evoked.plot(picks=list(range(10)))
evoked.plot(picks=['MEG 1132', 'MEG 1022'])
evoked.plot(picks=dict(grad=True, eeg=False))
  • advantage: no deprecation, simplification of channel picking
  • disadvantage: keep clunky pick_type API

Proposal 3

👍 0

Same as proposal 2, but change pick_types to accept a types key that would accept list of str. This would allow

evoked.plot(picks=list(range(10)))
evoked.plot(picks=['MEG 1132', 'MEG 1022'])
evoked.plot(picks=dict(grad=True, eeg=False))
evoked.plot(picks=dict(types=('eeg', 'mag')))
mne.pick_types(info, types=('eeg', 'mag'))
  • advantage: easier to loop across channel types, no deprecation
  • disadvantage: more than one way to do pick_types

Proposal 4:

👍 4 (@larsoner, @kingjr, @nbara, @choldgraf)

Same as proposal 1, but automatically detect if str refer to ch_names of ch_types.

evoked.plot(picks=list(range(10)))
evoked.plot(picks=['MEG 1132', 'MEG 1022'])
evoked.plot(picks=('eeg', 'meg'))
  • inconvenient: risk of conflict between channel names and channel types
  • advantage: easier to loop across channel types

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions