Repository navigation
Closed
Description
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
Reacted by Nicolas Barascud
Metadata
Metadata
Assignees
Labels
No labels
Activity
dengemann commentedon Aug 18, 2017
kingjr commentedon Aug 18, 2017
@dengemann For pick_types we could accept
picksto be adictdengemann commentedon Aug 18, 2017
kingjr commentedon Aug 18, 2017
Proposal 2
Sorry, I meant accepting the parameter
picksto be a list ofint(for indexing), a list ofstr(to find channel names) or adict(to quickly select channel types).EDIT: Copied to top
dengemann commentedon Aug 18, 2017
kingjr commentedon Aug 18, 2017
I see. However, the issue is that a list of types would conflict with a list of names.
I'm thus in favor of Proposal 2, i.e. accepting list of string and dict.
I'll update the above description.
larsoner commentedon Aug 18, 2017
@kingjr I updated your proposal to to be Py3k-friendly, and to reorder with
list(range(...))first (since it's what we have now)larsoner commentedon Aug 18, 2017
It does seem like proposal 2 would just require a ~6-line private function anytime we use
picks, so it's not so bad from an implementation standpoint. And from a user standpoint it's pretty simple.It does have overlap, e.g.
inst.pick_types(['EEG 001', 'EEG 002'])will be the same asinst.pick_channels(['EEG 001', 'EEG 002']), but I can live with that.@kingjr if your sense is that this will reduce pain substantially for new users, +1 from me
dengemann commentedon Aug 18, 2017
kingjr commentedon Aug 18, 2017
Can you describe in what way Proposal 2 wouldn't?
This would still require a "smart" guess; not safe IMO.
Why? We wouldn't need to update
pick_typesin any of these proposallarsoner commentedon Aug 18, 2017
Agreed, we would just update any function that has
picksargument. Instead of taking only list of int, take the other things, too.pick_typesandpick_channelswould remain the same.dengemann commentedon Aug 18, 2017
kingjr commentedon Aug 18, 2017
I agree; although for this we can propose an orthogonal PR where mne.pick_types accepts a list of str
dengemann commentedon Aug 18, 2017
choldgraf commentedon Aug 18, 2017
I'm +1 with
mne.pick_types(info, types=('mag', 'grad', 'eog'))I think this is much more descriptive than having a gigantic list of true/false.
I'm also +1 for allowing lists of strings. I'm a little hesitant to allow for
dict(eeg=True)since I agree that is a clunky API already.What if instead of
dict(grad=True.., we alloweddict(types=['eeg', 'meg', ...])?37 remaining items
agramfort commentedon Aug 21, 2017
jasmainak commentedon Aug 21, 2017
I honestly find the existing
picksAPI quite intuitive and well designed, but what I find missing is a clear documentation or tutorial.For me,
picksis nothing but a list of indices and all thepick_xxxfunctions are helpers to compute these indices. If you are using a scripting language like Matlab or Python, indexing is one of the first thing you learn.If you change the semantics of what
picksis (e.g., in Proposal 4), this will require a change in the code not just in code but also in other repos (like autoreject). [@dengemann up for another PR? :P ]Please consider carefully the implications of this change
dengemann commentedon Aug 21, 2017
nbara commentedon Aug 21, 2017
@jasmainak Not sure I agree with you.
Like many others I'm guessing, I spend most of my analysis time doing exploratory work, i.e. quickly looking at my data to get a "feel" of how they look, or check that e.g. an basic ERP is here or not.
And to do this the current system is particularly unintuitive. For instance I'll want to look at channel Oz, or Cz, and I don't care what index they correspond to (esp. given that these indices might change depending on the layout), ideally I'd just want to do
evoked.plot('Cz'), and then quickly see I I get something similar in another channelevoked.plot('Cz'). Then I might wan to try new filter settings on all my channels before plotting again. This takes quite a lot of keystrokes currently. Not to mention that the process of copy-picking before plotting is just... weird.agramfort commentedon Aug 21, 2017
choldgraf commentedon Aug 21, 2017
*and ECoG people have 0 ability to predict their channel names ahead of time
larsoner commentedon Aug 21, 2017
jasmainak commentedon Aug 21, 2017
@nbara have you used
evoked.plot_topo? It seems to be exactly for your requirement.jasmainak commentedon Aug 21, 2017
I think we would have to handle non-int lists as you correctly anticipate. When it is
int, it's really easy to index matrices without thinking twice. You're probably proposing thatpicksis internally handled still as anintlist but I guess that would need additional code ...nbara commentedon Aug 21, 2017
@jasmainak No I wasn't aware of plot_topo, thanks ! Does it work for TF data?
@agramfort #4221 looks very neat indeed!
O_O I used to work with MEG and I knew exactly where my channels were (on a CTF system, I used to plot a bunch of channels together using wildcards such as MRT* to get all right temporal sensors etc.).
As for ECoG, well yes... But wouldn't you just have some kind of map/image showing electrode implantation and use that to look at your activations for each patient ? I mean, it's not about knowing the location in advance, in some cases it's just more convenient to plot stuff by some kind of label instead of by number. Or maybe that's just me :)
Anyway, I don't mean to pollute this thread too much. Still in favour of Proposal 4.
jasmainak commentedon Aug 21, 2017
yep, take a look here :)
agramfort commentedon Aug 22, 2017
larsoner commentedon Aug 22, 2017
kingjr commentedon Aug 22, 2017