-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MRG: Multiple fixes in PyVista 3d backend #8041
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: Multiple fixes in PyVista 3d backend #8041
Conversation
|
TL;DR: The issue is that the
|
|
Looks like the normals are still not fixed, so the abstraction layer is still missing something |
|
It appears that the normals are most of the time computed by VTK for the mayavi backend too. mne-python/mne/viz/backends/_pysurfer_mayavi.py Lines 362 to 367 in 3d3bb9a
Even though the abstraction layer supports receiving precomputed normals, they would need to be computed on-the-fly in most cases. |
|
Ahh I see. So the question is, why can't we use |
I think this is related to an issue on macos during migration to pyvista 0.25/vtk 9 if i'm not mistaken |
That's a good idea :) |
Yes but the question is why do we hit it on PyVista but not Mayavi? Maybe we won't anymore now that we supply the normals in |
|
Okay, i'll take care of that in here 👍 |
|
In terms of visual quality, it's certainly better to have smooth shading 🤩 |
|
We now get on Linux the same sort of segfault we've been seeing on macOS: https://travis-ci.org/github/mne-tools/mne-python/jobs/710809861 |
Good news that it's consistent then 😅 ? I'll try the custom VTK filter now. |
|
I try first with a homemade private function and if it works I'll use PyVista |
|
Sounds good. Although if it does turn out to be a parameters issue, we should definitely open a PyVista issue about it as segfaulting with default parameters is not good. Maybe they need to be triaged by VTK version or something -- and maybe there is an underlying VTK bug, again worth whittling down to a minimal example, as the VTK folks have generally been very responsive when I've brought them issues that are easily reproducible. |
|
For reference, here are the parameters used for normal computation (for smooth shading) by the 3d backends ('x' for True, ' ' for False):
When using those values with PyVista ( When forcing PyVista to use the same parameters as Mayavi, the CIs are happy (version 30af751) therefore I suppose that either I can't reproduce those failures locally so I will push some test commits to clarify the situtation. Note: default values for PyVista are available in the documentation |
|
Great! Worth opening an issue about the defaults being unsafe in PyVista? |
|
I did my best playing with my 2e6f434, 90c42fb and 7868c18 show that it's not because of the parameters of I did 52655ec to start from scratch because I was too focused on Now I tend to think that the segfault happens when the normals are actually recomputed (normals are always computed as long as |
Feel free to add one. And also during long debugging sessions like this you can speed up iterations by changing |
mne/viz/backends/_pyvista.py
Outdated
| cmap=cmap, | ||
| backface_culling=backface_culling, | ||
| smooth_shading=self.figure.smooth_shading | ||
| smooth_shading=self.figure.smooth_shading, |
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.
Shouldn't this just be False since they're either added or computed above?
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 remove it in the commit just after
| # to the same location in the destination (fsaverage) mesh, and vice-versa. | ||
|
|
||
| renderer_kwargs = dict(bgcolor='w', smooth_shading=False) | ||
| renderer_kwargs = dict(bgcolor='w') |
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.
This is the one place we actually don't want smooth shading. Is there any way to disable it on this example? It makes it clear that the mesh is decimated quite a bit. Or maybe we should just use wireframes to make the point? WDYT?
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.
Yeah I think wireframes could look good for the last plots:
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.
Using wireframe could be a bit messy. I will let this option then 👍
|
I modified |
|
Thanks @GuillaumeFavelier ! |
This PR fixes multiple things with the PyVista 3d backend.
ToDo:
representationin the PyVista 3d backend.renderer.mesh()function when possiblenninfos from the surface parameter and use them as normals data inrenderer.surface()UseOR use same parameters as mayavismooth_shading=Truewhen the normals are not givenmeshfunctions to avoid code duplication