feat(plotting): add plot_surface for displaying meshes in napari - #263
Draft
FelipeCybis wants to merge 1 commit into
Draft
FelipeCybis wants to merge 1 commit into
FelipeCybis wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
|
📖 Doc preview: https://confusius.tools/pr-preview/pr-263/ |
FelipeCybis
force-pushed
the
worktree-plot-surface
branch
2 times, most recently
from
September 1, 2026 16:11
e63ff16 to
487a289
Compare
FelipeCybis
force-pushed
the
worktree-plot-surface
branch
from
September 1, 2026 16:33
487a289 to
aa7f881
Compare
Add `plot_surface`, a thin wrapper over `napari.Viewer.add_surface` for a bare `(vertices, faces)` mesh with optional per-vertex values, and `plot_atlas_mesh` (also `ds.atlas.plot.mesh` via the new `AtlasPlotAccessor`), which pulls meshes, per-vertex atlas colors, layer name, world axis labels, and units from an atlas Dataset and merges every requested region into one Surface layer. Both switch the viewer to 3D. Builds on the multi-region `get_mesh` dict API. Mesh vertices are world `(z, y, x)` coordinates, so surfaces coincide with image layers placed by `plot_napari` under the VoxelData model; a unit test checks a mesh vertex against the image layer's own voxel-to-world mapping on a shifted grid. Closes #262. Closes #335.
FelipeCybis
force-pushed
the
worktree-plot-surface
branch
from
September 2, 2026 13:17
aa7f881 to
c66db00
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #262. Closes #335.
Stacked on #448 (multi-region
get_meshand batched mesh prefetch), which is stacked on #446.What
Adds two napari helpers for meshes, the mesh counterpart to
plot_napari:confusius.plotting.plot_surface(mesh, ...): a thin wrapper overnapari.Viewer.add_surfacetaking a bare(vertices, faces)tuple, with optional per-vertexvaluesfor colormapped shading.confusius.plotting.plot_atlas_mesh(atlas, regions, sides, ...): the atlas-aware version, which pulls the meshes, per-vertex colors, layer name, axis labels, and units from the atlas Dataset before handing off toplot_surface. Also reachable asds.atlas.plot.mesh(...), through a newAtlasPlotAccessorhanging off the.atlasnamespace.Both switch the viewer to 3D (
ndisplay = 3): in 2D a Surface layer is drawn only as its cross-section with the current slice plane, which leaves a 3D mesh all but invisible.Because
get_meshreturns vertices already in the atlas physical space, and image layers sit at their physical origin and spacing, surfaces line up with the image layers without anyscale/translatejuggling.Multiple regions per call (#335)
plot_atlas_meshtakes the sameregions/sidesarguments as the multi-regionget_meshfrom #448 and merges every requested region into a single Surface layer, giving each region its own atlas color through the layer'svertex_colors. An explicitcolormap, or per-vertexvalues, still overrides that. The layer is named after the region (full name plus acronym) when a single region is requested, and after the requested acronyms otherwise.Tests
TestPlotSurfaceandTestPlotAtlasMeshintests/unit/test_plotting/test_napari.py: mesh and values round-tripping into the layer, the flat-surface default, overlay on an existing viewer with units, name and per-vertex colors read from the atlas, hemisphere clipping, the multi-region merge (face re-indexing and per-region colors), and accessor delegation.Docs
plot.meshfor display.__all__.