You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in a recent conversation, @jstout211 mentioned a missing feature: setting the opacity of distributed solutions per-vertex (something that e.g. AFNI can do for MRIs).
Describe your proposed implementation
IDK how easy/hard this would be given that vertices are the corners of triangles; simple approach is set whole triangle as mean opacity of each vertex.
Describe possible alternatives
If using mean of corners looks like garbage, we could consider Pineda's triangle-filling algorithm [1] to interpolate values within each tri (though how we would actually render that I don't know).
use case is to highlight areas of the distributed source solution that meet some criterion / threshold (could be an anatomical label, some statistical criterion, etc) while still showing the rest of the solution on the brain.
Currently our 3D meshes have color (R,G,B,A) set on a per-vertex basis. I wouldn't get too much into the weeds about how we interpolate over the triangle and just let VTK do its thing.
I think to add support for this sort of thing we "just" need to add another *= statement, or (equvialently) allow self._opacity to be more than just a float but ndarray of shape (n_vertices,). To be tested, though...
Pineda (1988) focus on manually interpolating vertex values across triangles, but since VTK already handles this internally, implementing it ourselves would be redundant.
Based on this, I think we can proceed with @larsoner’s suggestion of supporting per vertex opacity via the existing RGBA . If I’m misunderstanding anything here, please feel free to correct me, I’d also be happy to test this locally and verify the behavior.
Following @larsoner's suggestion, I have implemented support for per-vertex opacity by refactoring _3d_overlay.py. The self.opacity attribute now accepts an ndarray of shapes n{vertices}, alongside the existing float support. I have verified the broadcasting and 3D rendering behavior locally and have opened PR #13706 for formal review and CI checks. I look forward to your feedback on the implementation!
Activity
larsoner commentedon Feb 24, 2026
Currently our 3D meshes have color
(R,G,B,A)set on a per-vertex basis. I wouldn't get too much into the weeds about how we interpolate over the triangle and just let VTK do its thing.And we currently have this:
mne-python/mne/viz/_3d_overlay.py
Lines 46 to 47 in c089d85
I think to add support for this sort of thing we "just" need to add another
*=statement, or (equvialently) allowself._opacityto be more than just afloatbut ndarray of shape(n_vertices,). To be tested, though...Aniketsy commentedon Feb 25, 2026
Pineda (1988)focus on manually interpolating vertex values across triangles, but since VTK already handles this internally, implementing it ourselves would be redundant.Based on this, I think we can proceed with @larsoner’s suggestion of supporting per vertex opacity via the existing RGBA . If I’m misunderstanding anything here, please feel free to correct me, I’d also be happy to test this locally and verify the behavior.
PragnyaKhandelwal commentedon Feb 28, 2026
Following @larsoner's suggestion, I have implemented support for per-vertex opacity by refactoring _3d_overlay.py. The self.opacity attribute now accepts an ndarray of shapes n{vertices}, alongside the existing float support. I have verified the broadcasting and 3D rendering behavior locally and have opened PR #13706 for formal review and CI checks. I look forward to your feedback on the implementation!