-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG: Pyvista background plotter #6551
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: Pyvista background plotter #6551
Conversation
|
This pull request introduces 2 alerts when merging e8d2d8e into 26231ff - view on LGTM.com new alerts:
|
Codecov Report
@@ Coverage Diff @@
## master #6551 +/- ##
=========================================
+ Coverage 89.4% 89.4% +<.01%
=========================================
Files 415 416 +1
Lines 74985 75140 +155
Branches 12330 12347 +17
=========================================
+ Hits 67039 67182 +143
- Misses 5118 5123 +5
- Partials 2828 2835 +7 |
|
Starting by 1), these are examples using Basic VisualizationActivation Data VisualizationDisplay ROI ValuesI have to report 2 bugs for now: |
This reverts commit e4f2b74.
|
That's great! Bugs like the no refresh are probably not "our problem" (they are an upstream library bug) but there are often workarounds. We can work around them later. In the meantime if you can file a bug report with some minimal example to pyvista that's great. |
|
After discussing IRC with @larsoner and @agramfort, it seems that building the doc with the experimental version of the offscreen |
tutorials/simulation/plot_dics.py
Outdated
| fig = brain._figures[0][0] | ||
| mne.viz.set_3d_view(fig, azimuth=0, elevation=0, distance=550, | ||
| focalpoint=[0, 0, 0]) | ||
| mne.viz.set_3d_title(fig, 'MNE-dSPM inverse (RMS)') |
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.
Instead just do brain.show_view https://pysurfer.github.io/generated/surfer.Brain.html#surfer.Brain.show_view
And maybe in stc.plot you could use time_label='MNE-dSPM inverse (RMS)' to set the title instead?
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.
I had some trouble to make it work with time_label locally. The window's title wasn't updated for some reason and I obtained the "Mayavi Scene" instead. Maybe I did something wrong, I'll push my changes.
tutorials/simulation/plot_dics.py
Outdated
| fig = brain._figures[0][0] | ||
| mne.viz.set_3d_view(fig, azimuth=0, elevation=0, distance=550, | ||
| focalpoint=[0, 0, 0]) | ||
| mne.viz.set_3d_title(fig, 'DICS power map, approach %d' % approach) |
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.
same, hopefully can remove the use_3d_backend
| time_label = "MEG %d" | ||
| brain_meg = stc_psf_meg.plot(hemi='rh', subjects_dir=subjects_dir, | ||
| time_label=time_label, | ||
| figure=create_3d_figure(size=(500, 500))) |
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.
I don't understand why you need to use use_3d_backend in these examples. stc.plot should use PySurfer which will use mayavi anyway
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.
It's for the create_3d_figure() function which relies on the _Renderer now. Before the port, it was mlab.figure().
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.
You don't need create_3d_figure, use stc.plot(..., size=(500, 500)) instead
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.
Oh wait, that could lead to a problem with it plotting into the same Mayavi figure because it's the same subject name.
In that case, perhaps do figure=1 in the first plot and figure=2 in the second one, and it should spawn separate plots for you.
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.
(one of these two solutions should hopefully work and allow you to avoid the MNE context manager business)
|
All CIs are happy with this version. The results are available here. |
mne/viz/_3d.py
Outdated
| hemis = [hemi] | ||
|
|
||
| if title is None: | ||
| if title is None and isinstance(time_label, str): |
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.
Actually instead of using time_label you could just pass title. Sorry I forgot it was an argument at all. Then you don't need to add this conditional.
So for the code in the example you can do title = 'MNE...'; stc.plot(time_label=title, title=title, ...) and it will show up in the title bar and in the image itself. Is that what you want?
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.
Yes, that's perfect!
| time_label = "MNE %d" | ||
| brain_mne = stc_ctf_mne.plot(hemi='rh', subjects_dir=subjects_dir, | ||
| time_label=time_label, | ||
| figure=create_3d_figure(size=(500, 500))) |
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.
You can't use figure=1 here and figure=2 below?
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.
I just missed this example, thank you
|
@GuillaumeFavelier can you look through the rendered examples and set this to MRG if it's good to go? +1 for merge from me if so |
environment.yml
Outdated
| - mne | ||
| - vtk | ||
| - pyvista>=0.20.3 | ||
| - https://github.com/GuillaumeFavelier/pyvista/zipball/memory_footprint |
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.
I would wait for pyvista to merge the PRs so we use master here. Maybe some API we'll change still. wdyt @GuillaumeFavelier ?
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.
Yes, the discussion about memory optimization is still open. I would recommend waiting until it's merged then I can probably do one last pass to check that everything works as expected.
|
I'vee check the examples and apart the fact that the montage look like a "salami brain" everything looks fine. Maybe the lighting of this https://14519-1301584-gh.circle-artifacts.com/0/dev/auto_tutorials/source-modeling/plot_dipole_orientations.html#sphx-glr-auto-tutorials-source-modeling-plot-dipole-orientations-py could be made lighter but I'm +1 to merge like this. maybe just add the lighting of the example above to the todo list next to reducing the diameter of the location markers. |
|
let's fix the montage plots before merging then.
… |
|
@GuillaumeFavelier the travis error is not related. only network. |
|
NICE!! great job @GuillaumeFavelier, we are almost free of mayavi |
|
Great!!
…On Fri, Aug 2, 2019, 16:59 Alexandre Gramfort ***@***.***> wrote:
Merged #6551 <#6551> into
master.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6551?email_source=notifications&email_token=ABVX5YZ3BUVL6MT7DOZXTGDQCRDWBA5CNFSM4H7PKB7KYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOS3F5YSA#event-2529942600>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABVX5Y3QF33OWGQ5NE5VFULQCRDWBANCNFSM4H7PKB7A>
.
|
* Switch to BackgroundPlotter * Add _set_3d_view() * Add _set_3d_title() * Fix unused variables * Fix offscreen support * Update pyvista package * Catch DeprecationWarning coming from ipywidget * Fix import ordering * TST: try with test_plot_alignment as slowtest * Enable snapshot_brain_montage * TST: Try to build the doc with pyvista [circle full] * Revert "TST: Try to build the doc with pyvista" This reverts commit e4f2b74. * Refactor _Figure management * Fix _set_3d_view and _set_3d_title * Fix set_camera * TST: Try to build doc [circle full] * TST: Fix the test [circle full] * TST: Fix the test again [circle full] * TST: Try to build doc [circle full] * TST: Try build doc again [circle full] * TST: build doc with pyvista [circle full] * Revert doc testing * Improve mayavi/pyvista backend switching * Update backend switching in examples/tutorials * Catch some deprecation warnings * Catch some more warnings * TST: Build doc with pyvista [circle full] * Revert "TST: Build doc with pyvista" This reverts commit cbeef23. * Update backend switching for plot_dics.py * Fix duplicate figure bug and drastically improve camera settings * TST: Build doc with pyvista [circle full] * Revert "TST: Build doc with pyvista" This reverts commit cac3487. * TST: Upgrade PyVista to master version * TST: Upgrade PyVista to version 0.21.2 * TST: Use conda version 4.5.10 * TST: Use conda version 4.7.5 * TST: Build doc with pyvista [circle full] * TST: Build doc normally [circle full] This reverts commit 66c6f3d. * revert last commit [circle full] * Revert "Disable building of doc for now" This reverts commit be7cd48. * Go back to the doc building configuration with pyvista This reverts commit 20570f8. * TST: Ignore doc/tutorials/report.rst in doctest [circle front] * TST: Render all the figures [circle full] * Revert "TST: Ignore doc/tutorials/report.rst in doctest" This reverts commit d968917. * TST: Build doc with pyvista [circle full] * Fix plot_ecog.py [circle full] * Clean doc scraper conf * Avoid use_3d_backend in examples/tutorials * Fix minor bugs * Fix figure title * Avoid use_3d_backend in plot_mne_crosstalk_function.py * TST: Update PyVista to 0.21.3 [circle full] * Switch back to mayavi to build the doc by default (compatibility with Pysurfer) * Fix tube radius















Fixes the last part of #6518.
This PR adds the missing
_set_3d_view()and_set_3d_title()functions to the pyvista 3d backend and switches toBackgroundPlotter.In order to avoid regression, I need to investigate:
_Brainobject features (my results are here)State of testing:
DeprecationWarningcoming fromipywidgets(see also FIX,VIZ: Fix DeprecationWarning in pyvista backend #6578)test_plot_alignment()becomes aslow_test(see also VIZ, BUG: test_plot_alignment timeout #6566)snapshot_brain_montage(my results are here)set_3d_backendto facilitate 3d backend transition0.21.3CONDA_VERSIONupgraded (see also TST: Testing CIs for LinkError on Azure #6590)tutorials/misc/plot_ecog.pyBuild examples/tutorials with pyvista:
make test-doc(fixed by BUG: Restore conftest to doctests #6599)To do next:
BackgroundPlotterfor testing now that offscreen rendering is available.mne/report.pyto use the 3d backend abstraction layerKnown issues:
make html_dev(fixed by #293)