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
FIX NaN values in Volume/Vertex rendering as black instead of transparent (#612)
* Initial plan
* Initial plan for fixing NaN transparency issue
Agent-Logs-Url: https://github.com/gallantlab/pycortex/sessions/a5d0ee68-41d6-4451-8ed5-a84b060a457f
Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
* Fix NaN values rendering as black instead of transparent in Volume/Vertex raw
When using Volume.raw or Vertex.raw, NaN values in data were rendered as
opaque black because: (1) colormap conversion maps NaN to black RGB, and
(2) after uint8 conversion, the NaN info is lost so the alpha getter's
NaN detection fails.
Fix:
- In Dataview.raw: explicitly set alpha=0 for NaN positions before
returning the RGBA channels
- In Volume.raw/Vertex.raw: store a _nan_mask on the RGB object
- In VolumeRGB/VertexRGB alpha getters: apply stored _nan_mask to
enforce alpha=0 for NaN positions, even after user alpha override
Agent-Logs-Url: https://github.com/gallantlab/pycortex/sessions/a5d0ee68-41d6-4451-8ed5-a84b060a457f
Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
* Revert unintended change to overlays.svg
Agent-Logs-Url: https://github.com/gallantlab/pycortex/sessions/a5d0ee68-41d6-4451-8ed5-a84b060a457f
Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
* Address code review comments with improved documentation
Agent-Logs-Url: https://github.com/gallantlab/pycortex/sessions/a5d0ee68-41d6-4451-8ed5-a84b060a457f
Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
* Restore overlays.svg to match origin/main
Agent-Logs-Url: https://github.com/gallantlab/pycortex/sessions/a5d0ee68-41d6-4451-8ed5-a84b060a457f
Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
* Fix NaN handling in WebGL surface_vertex shader for Vertex objects (issue #455)
Add NaN detection in the surface_vertex shader's colormap lookup.
When vertex data contains NaN, the normalized colormap coordinates
(cuv.x/cuv.y) become NaN. Use the GLSL idiom (x != x) to detect
NaN and set vColor to vec4(0.) (fully transparent) so NaN vertices
are discarded instead of rendered as colored.
Agent-Logs-Url: https://github.com/gallantlab/pycortex/sessions/4091acc2-7dc4-4b78-bd80-52e45c73d1ea
Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
* FIX NaN transparency in WebGL surface_vertex shader via JS-side nanmask
WebGL drivers sanitize NaN values in vertex attributes to 0, so the
shader-only NaN detection (cuv.x != cuv.x) never fires. Instead, detect
NaN in JavaScript when vertex data is loaded, build a nanmask attribute
(1=valid, 0=NaN), replace NaN with 0 in the data, and check the mask in
the vertex shader.
Also refactors the Python side:
- Dataview.raw returns (rgba, nan_mask) to avoid redundant np.isnan
- Volume.raw / Vertex.raw reuse the mask from the parent
- DataviewRGB._apply_nan_mask() consolidates duplicated logic
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
Co-authored-by: Matteo Visconti di Oleggio Castello <mvdoc@berkeley.edu>
0 commit comments