Mne-python: Set all types to False in pick_types

Created on 1 May 2020  Â·  15Comments  Â·  Source: mne-tools/mne-python

Would it make sense to set all arguments in pick_types to False by default? In other words, currently everything is False except for meg. I know where this is coming from, but for people working with EEG, NIRS, or other non-MEG signals, we always have to include meg=False in addition to e.g. eeg=True.

All 15 comments

deprecation cycle will be a huge pain. I feel fully guilty for this but
it's trade off.
If you have only EEG data it's not a pb though no?

>

+1 for doing it. I wish we had done it 5 (10?) years ago but it still seems worth it in the long run. I don't think actually it will be too terrible for users (many probably will have set it explicitly anyway), but even forcing them to add True/False (when MEG channels are present) will be more explicit in their uses anyway. A potential benefit (aside from consistency) is that it could actually help them uncover some silent bugs in their code.

So then raw.pick_types() with all default arguments would be an error? Or a raw object with zero channels? :)

Yeah, I suppose so. Kind of a weird side effect. But if you don't ask to pick anything it's probably better that it throws an error than it silently pick one channel type...

if you don't ask to pick anything it's probably better that it throws an error than it silently pick one channel type...

Agreed. +1 for embarking on the painful deprecation effort.

+1 from my end for doing this, the current behavior always felt weird to me (an EEG user).

@agramfort

If you have only EEG data it's not a pb though no?

Valid comment though. But since simultaneous recordings with different methods are gaining in popularity, I believe addressing this issue will become more and more important in the future.

Alright, so it looks like we agree that this must be done. I'll submit a PR.

I think this is a good idea. +1 from my side.

before fully diving into this let's have a clear plan as it's a lot of work.

In Master:

If you have EEG/MEG:
raw.pick_types(meg=False, eeg=True) -> EEG only
raw.pick_types() -> MEG only

If you have EEG:
raw.pick_types() -> Error?

If you have MEG:
raw.pick_types() -> MEG only

what behavior do you expect in the next release and the next next one?

The next release (0.21) should behave identically to 0.20, but a DeprecationWarning should be raised (something like "The defaults of pick_types will change in the next release. All signal types will be set to False by default (currently, meg=True by default).").

Release 0.22 should implement the new behavior. Your examples will be:

If you have EEG/MEG:

raw.pick_types(meg=False, eeg=True)  # EEG only, will work as before
raw.pick_types()  # error (no signals picked)
raw.pick_types(eeg=True)  # new option to pick EEG only

If you have EEG:

raw.pick_types()  # error (no signals picked)
raw.pick_types(eeg=True)  # need to select EEG

If you have MEG:

raw.pick_types()  # error (no signals picked)
raw.pick_types(meg=True)  # need to select MEG

I've converted @agramfort's list to a table, which we can potentially amend as the discussion progresses.

| Type | pick_types() call | master behavior | proposed new behavior |
|-----------|---------------------------------|-----------------|-----------------------|
| EEG & MEG | pick_types(meg=False, eeg=True) | EEG only | |
| EEG & MEG | pick_types() | MEG only | |
| EEG | pick_types() | Error? | |
| MEG | pick_types() | MEG only | |

What is the current behavior when I pick types that don't exist? Does it raise an error? Or pick nothing (i.e. return a zero-channel object)? Or is this a no-op?

Updated table based on @cbrnr's and @agramfort's comments – hope I copied everything correctly.

| Type | pick_types() call | master behavior | proposed new behavior |
|-----------|-----------------------------------|-------------------|-----------------------|
| EEG & MEG | pick_types(meg=False, eeg=True) | EEG only | EEG only |
| EEG & MEG | pick_types() | MEG only | error |
| EEG & MEG | pick_types(eeg=True) | EEG & MEG | EEG only |
| EEG | pick_types() | Error? | error |
| EEG | pick_types(eeg=True) | EEG & MEG | EEG only |
| MEG | pick_types() | MEG only | error |
| MEG | pick_types(meg=True) | MEG only | MEG only |

to be tested. I would really start by writing tests here.

>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nbara picture nbara  Â·  4Comments

jasmainak picture jasmainak  Â·  3Comments

SophieHerbst picture SophieHerbst  Â·  4Comments

DanielvdC picture DanielvdC  Â·  6Comments

mirgee picture mirgee  Â·  3Comments