feat(plotting): add plot_surface for displaying meshes in napari#263
Draft
FelipeCybis wants to merge 7 commits into
Draft
feat(plotting): add plot_surface for displaying meshes in napari#263FelipeCybis wants to merge 7 commits into
FelipeCybis wants to merge 7 commits into
Conversation
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 Report❌ Patch coverage is
📢 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.
Contributor
|
📖 Doc preview: https://confusius.tools/pr-preview/pr-263/ |
…gion plot_surface now mirrors plot_napari: pass an atlas Dataset and a region, and the layer's mesh, name, default color, and scale-bar unit are all pulled from the atlas (via the .atlas accessor's get_mesh and lookup) instead of a raw (vertices, faces) tuple. Adds side/clip forwarding to get_mesh and draws the surface in the region's Allen color by default. Promotes the atlas test fixtures to tests/unit/conftest.py so the plotting tests reuse the same mock atlas as the atlas tests.
plot_surface goes back to a thin wrapper over napari.add_surface, taking a (vertices, faces) tuple. The atlas-aware behavior moves to a new plot_atlas_mesh(atlas, region, ...) that pulls the mesh, name, Allen color, and units from the atlas and delegates to plot_surface. Also adds an AtlasPlotAccessor exposing ds.atlas.plot.mesh(region, ...). Routes the surface unit through the layer's units param instead of the deprecated ScaleBar.unit setter.
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.
!Waiting on #274 to continue here!
Closes #262.
What
Adds
confusius.plotting.plot_surface, which displays a triangular mesh as anapari
Surfacelayer —the mesh counterpart to
plot_napari.(vertices, faces)mesh tuple, matchingAtlas.get_mesh's return.valuesfor colormapped shading (flat surface otherwise).viewerto overlay on an existing viewer, and returns(viewer, layer),consistent with the other napari helpers.
"mm", the atlas mesh unit).Because
get_meshreturns vertices already in the atlas physical space and imagelayers sit at their physical origin/spacing, the surface aligns with the image
layers without extra scaling — no
scale/translatejuggling needed.Tests
Added
TestPlotSurfaceintests/unit/test_plotting/test_napari.pycoveringmesh/values round-trip into the layer, the flat-surface default, and
overlay-on-existing-viewer + scale-bar-unit behavior.
Docs
auto-documents it via
__all__.