mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

[MRG] Add copy and channel selection for a Layout object

Open mscheltienne opened this issue 2 years ago • 3 comments

I had a report that plot_evoked_topo(..., layout=layout, exclude=["M1", "M2"]) was partially ignoring the exclusion. The plot still had the 2 empty M1/M2 channels because they were present in the layout.

I added 2 methods to the Layout object: copy and pick. Nothing fancy, beside that the pick method is not based on a function in mne._fiff.pick. I did not find one that was fitting all the needs for a Layout instance. The pick method is now used in the plotting function.

mscheltienne avatar Jan 05 '24 15:01 mscheltienne

Renders:

  • copy: https://output.circle-artifacts.com/output/job/223aa771-8bc2-462e-a63d-fe95e0194ef8/artifacts/0/html/generated/mne.channels.Layout.html#mne.channels.Layout.copy
  • pick: https://output.circle-artifacts.com/output/job/223aa771-8bc2-462e-a63d-fe95e0194ef8/artifacts/0/html/generated/mne.channels.Layout.html#mne.channels.Layout.pick

mscheltienne avatar Jan 06 '24 16:01 mscheltienne

Yes, the only oneI found that would work is picks = _picks_to_idx(len(layout.names), picks) which picks on a number of channels. It's more limited and restrictive on the inputs than the logic above. I do plan to propose a new channel selection API, to try to 1. clean-up all the redundant code and multiple pick functions in mne._fiff.pick https://github.com/mne-tools/mne-python/blob/main/mne/_fiff/pick.py and 2. open a public API for channel selection (#11913 https://github.com/mne-tools/mne-python/issues/11913). Hopefully next week 😉

yes I think #11913 should be done first here. I would not have this complex and common code here.

Message ID: @.***>

agramfort avatar Jan 08 '24 10:01 agramfort

Agree, but I think #11913 will take time, thus I would first merge this PR with a TODO comment left in the codebase and a x-ref to replace the logic with whatever is defined in #11913. Especially as I do have someone at our site that could use this channel selection on a layout to improve his topographic plots.

mscheltienne avatar Jan 08 '24 15:01 mscheltienne

It would be nice, yes :)

mscheltienne avatar May 29 '24 19:05 mscheltienne

Thanks @mscheltienne !

larsoner avatar May 30 '24 14:05 larsoner