[MRG] Add copy and channel selection for a Layout object
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.
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
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: @.***>
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.
It would be nice, yes :)
Thanks @mscheltienne !