Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 15 commits into from
May 30, 2024

Conversation

mscheltienne
Copy link
Member

@mscheltienne mscheltienne commented Jan 5, 2024

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 mscheltienne changed the title Add copy and channel selection of a Layout Add copy and channel selection for a Layout object Jan 5, 2024
@mscheltienne mscheltienne marked this pull request as ready for review January 6, 2024 16:42
@mscheltienne mscheltienne changed the title Add copy and channel selection for a Layout object [MRG] Add copy and channel selection for a Layout object Jan 6, 2024
self.pos = self.pos[picks]
self.ids = self.ids[picks]
self.names = [self.names[k] for k in picks]
return self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you check if this logic is not present elsewhere? I would be surprised if it's not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 and 2. open a public API for channel selection (#11913). Hopefully next week 😉

@agramfort
Copy link
Member

agramfort commented Jan 8, 2024 via email

@mscheltienne
Copy link
Member Author

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.

@larsoner larsoner added this to the 1.8 milestone May 29, 2024
Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mscheltienne still want this one? Sorry it fell off the radar a bit. Seems good enough to go for me

@mscheltienne
Copy link
Member Author

It would be nice, yes :)

@larsoner larsoner merged commit d6a58cb into mne-tools:main May 30, 2024
30 checks passed
@larsoner
Copy link
Member

Thanks @mscheltienne !

@mscheltienne mscheltienne deleted the layout branch May 30, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants