-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[ENH, MRG] Add mne.viz.Brain.plot_sensors
and refactor mne.viz.plot_alignment
#9585
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My major comment is that I think even without plotting any data values I think this is / should be a larger undertaking involving deduplication (and shared functionality) with plot_alignment. I'd rather not add new code that does 20-50% of what plot_alignment
allows for plotting sensors using totally different code (and somewhat different API) to accomplish it...
... one long-term view / option would be to make |
So I agree and ideally this would be refactored but, after looking at the |
In general I don't like this approach. To me it's much cleaner to take the existing code and refactor it first. Then everything is modularized and understandable, and no functionality has changed. Then the next PR can be to reuse code from the private function(s) now called by |
Ok, I'll take a shot at refactoring in this PR. |
Sure but let's get the GUI and everything working first. It's a higher priority, and even though combining |
For sure, I didn't mean right now :) |
f73a42d
to
c1d78df
Compare
Ok, I think this does some really nice refactorization and makes I think the coordinate frame handling is a big improvement and clearer to me at least now. |
@alexrockhill MY APPOLOGIES!! I meant to open a PR to your PR, but instead I have just pushed directly to your branch. |
Mistake aside, I think the new API significantly simplified the example I just pushed. However, the colours of the optodes have changed (brain too, but I dont mind that). Is this intentional? If so, we should update the tutorial text. But I think the colours for the new version are too similar between sources and detectors (both look red to me). Old colorsNew colorsI also noticed that distance is now in mm? But was previously in m? Was this change also intentional? |
That's okay, you're welcome to push commits. |
Brain has a keyword argument units that can be set to either mm or m so that can go either way. The colors were just my rough matplotlib "gray"/"red"/"brown" but should really be copied directly, I can update that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexrockhill your comment on this PR says it "does some nice refactorization" but as far as I can tell this is still a completely separate implementation from what is done in plot_alignment
(with no refactored-out shared helper functions). Am I missing something?
Ok I refactored quite a bit to clean everything up and make nice
Hmmm, yes I haven't gotten to the refactoring |
OK... can you remove |
mne.viz.Brain.plot_sensors
mne.viz.Brain.plot_sensors
I'm giving it a shot modifying |
Fixes #9635 now and will fix #9627 in a minute. I gave it a real try to do larger refactoring but the lack of a requirement of the |
mne.viz.Brain.plot_sensors
mne.viz.Brain.plot_sensors
and refactor mne.viz.plot_alignment
Ok @drammock, it works now and all the tests should pass. Everything is refactored and actually the differences were reconcilable with a bit more effort. You're welcome to review or I'm happy to wait until @larsoner gets back. I just wanted to finish this so that I knew what the |
Ok so I tried both a |
I am still -1 on a divergent API. I'd rather stick to and expand the plot_alignment API somehow rather than introduce a new interface, as above: #9585 (comment) I'd rather have slightly less clean code in a shared private function than these divergent APIs with non-DRY code |
Okay, now the API is the same... there go my nice color plotting options though, guess it's we're just stuck with the defaults |
For this PR, sure. I think if we want to add color options (which I agree is a good idea and worth doing!) we should figure out how to do it in |
mne/viz/_3d.py
Outdated
|
||
|
||
def _plot_sensors(info, to_cf_t, renderer, picks, meg, eeg, fnirs, | ||
warn_meg, head_surf, units, verbose): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @GuillaumeFavelier this is doing what we discussed yesterday
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to take verbose
here
opacity=alpha, reset_camera=False, | ||
render=False) | ||
|
||
self._renderer._update() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
I just wanted to add |
Co-authored-by: Alexandre Gramfort <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very close!
mne/viz/_brain/_brain.py
Outdated
del trans | ||
# get transforms to "mri"window | ||
to_cf_t = _get_transforms_to_coord_frame( | ||
info, head_mri_t, coord_frame='mri', verbose=verbose) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to pass verbose
here
mne/viz/_3d.py
Outdated
|
||
|
||
def _plot_sensors(info, to_cf_t, renderer, picks, meg, eeg, fnirs, | ||
warn_meg, head_surf, units, verbose): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to take verbose
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully the last round...
Thanks @alexrockhill ! |
Awesome |
@alexrockhill this is wrong: See how it looks on stable: I did not check but I strongly suspect this PR broke the |
This adds simple sphere plotting to
mne.viz.Brain
for sensors. The color is controllable by channel name and type as is scale and alpha/opacity.Hopefully this is helpful to @GuillaumeFavelier to build off for a more advanced version in #8803, I didn't mean to supplant that PR only to provide a simple version to build from.
Here is a simple script to view the results on the sample data:
Closes #8803