Skip to content

feat(plotting): add plot_surface for displaying meshes in napari#263

Draft
FelipeCybis wants to merge 3 commits into
mainfrom
worktree-plot-surface
Draft

feat(plotting): add plot_surface for displaying meshes in napari#263
FelipeCybis wants to merge 3 commits into
mainfrom
worktree-plot-surface

Conversation

@FelipeCybis

@FelipeCybis FelipeCybis commented Jul 7, 2026

Copy link
Copy Markdown
Member

!Waiting on #274 to continue here!

Closes #262.

What

Adds confusius.plotting.plot_surface, which displays a triangular mesh as a
napari Surface layer —
the mesh counterpart to plot_napari.

import confusius as cf
from confusius.atlas import Atlas

atlas = Atlas.from_brainglobe("allen_mouse_25um")
viewer, _ = cf.plotting.plot_napari(atlas.reference)
cf.plotting.plot_surface(atlas.get_mesh("VISp"), viewer=viewer, colormap="magenta")
  • Takes a (vertices, faces) mesh tuple, matching Atlas.get_mesh's return.
  • Optional per-vertex values for colormapped shading (flat surface otherwise).
  • Optional viewer to overlay on an existing viewer, and returns (viewer, layer),
    consistent with the other napari helpers.
  • Sets the scale bar unit (default "mm", the atlas mesh unit).

Because get_mesh returns vertices already in the atlas physical space and image
layers sit at their physical origin/spacing, the surface aligns with the image
layers without extra scaling — no scale/translate juggling needed.

Tests

Added TestPlotSurface in tests/unit/test_plotting/test_napari.py covering
mesh/values round-trip into the layer, the flat-surface default, and
overlay-on-existing-viewer + scale-bar-unit behavior.

Docs

  • Changelog entry under Enhancements.
  • New row in the visualization user-guide tool table. The API reference page
    auto-documents it via __all__.

Add plot_surface to display a triangular mesh (vertices, faces) as a
napari Surface layer, with an optional per-vertex values array for
colormapped shading. Pairs with Atlas.get_mesh to overlay BrainGlobe
atlas region surfaces on the reference template or a registered fUSI
volume; because both live in the same physical space, the surface
aligns without extra scaling.

Closes #262
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/confusius/plotting/napari.py 92.85% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

napari opens in 2D, where a Surface layer is drawn only as its
cross-section with the current slice plane, so a 3D mesh is all but
invisible. plot_surface now switches the viewer to 3D rendering and
resets the view to frame the mesh.
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

📖 Doc preview: https://confusius.tools/pr-preview/pr-263/

@FelipeCybis FelipeCybis self-assigned this Jul 9, 2026
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

Successfully merging this pull request may close these issues.

Add plot_surface for displaying meshes in napari

1 participant