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

Annotations/Labels invisible from certain angles #299

Open
jshanna100 opened this issue Feb 6, 2021 · 5 comments
Open

Annotations/Labels invisible from certain angles #299

jshanna100 opened this issue Feb 6, 2021 · 5 comments

Comments

@jshanna100
Copy link

I recently upgraded from Ubuntu 18 to 20, and updated my NVIDIA drivers to 460.39, and now pysurfer is not displaying parcellations and labels correctly anymore. From certain angles, the parcellation borders are somehow not visible, though if one rotates the brain they are visible. It is as though there is an inverse spotlight shining on the brain from above (see picture).

Changing the cortex alpha to 0.99 fixes the problem, though it is not a long term solution for me. 0.99 is still somehow quite transparent, and for my purposes I need the cortex to be opaque.

image

@mwaskom
Copy link
Member

mwaskom commented Feb 6, 2021

I think this is the same issue described in this thread: #258

Unfortunately as I understand it this is fundamentally a bug in some of the lower-level graphics libraries and there's no one-size-fits-all solution that can be implemented in pysurfer. But that thread has some workarounds that people have reported as effective on their specific systems.

@jshanna100
Copy link
Author

jshanna100 commented Feb 6, 2021

Thanks. Unfortunately none of the workarounds solved the problem for me, but I did run across some odd properties of the Brain surface opacity.

If I set the alpha to 1 as a parameter during the initialisation of the Brain object, and then manually set it 0.99 in the Mayavi pipeline, the cortex is almost completely opaque, as it should be. If, however, I set it to 0.99 as a Brain initialisation parameter, it is fairly transparent, and even more strangely, if I attempt to further change it manually in the Mayavi pipeline, it cannot reach the needed level of opacity; i.e. at 0.99 the cortex is too transparent, but the parcellation is drawn correctly, and then at 1.0 the cortex is completely opaque, but the parcellations are buggy again.

@larsoner
Copy link
Contributor

larsoner commented Feb 7, 2021

You could try enabling depth peeling with something like:

for ff in brain._figures:
    for f in ff:
        f.scene.renderer.use_depth_peeling = True

It's designed to help with depth-buffer resolution problems.

Alternatively, you might be able to use MNE-Python's implementation of a simialar Brain class. We basically started by trying to replicate the parts of PySurfer's viz using PyVista instead of Mayavi then moved toward volume viz, interactive viz, etc. according to what we needed in a new design along the lines of what has been discussed before. We recently refactored things so that all alpha blending of the overlays is done in the CPU so just a single mesh ends up being rendered per hemisphere.

@jshanna100
Copy link
Author

Enabling depth peeling had no effect except to significantly slow down redraw speed.

The MNE Brain class draws it perfectly well, but the problem is that I'm using this with some custom functionality I've made for visualising connectivity that makes heavy use of mlab's points3d and plot3d functions. It's not clear to me if/how these can be utilised within the mne.viz.Brain class...

@mmagnuski
Copy link

I had the same problem on one of my computers. A solution suggested in this issue by @solleo works well for me. For one hemisphere you can do:

n_children = len(brain.brain_matrix[0][0]._f.children)

for idx in range(1, n_children):
    (brain.brain_matrix[0][0]._f.children[idx].children[0].children[0]
     .children[0].actor.actor.force_opaque) = True

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

No branches or pull requests

4 participants