Skip to content

Add plot_surface for displaying meshes in napari #262

Description

@FelipeCybis

Summary

Add a plot_surface function to confusius.plotting that displays a triangular
mesh as a napari Surface
layer.

Motivation

[Atlas.get_mesh][confusius.atlas.Atlas.get_mesh] already returns a region's mesh
as (vertices, faces) in the atlas physical space (millimetres), but there is
currently no way to display it in the napari viewer. This is particularly useful
for overlaying the surface meshes bundled with BrainGlobe atlases on top of the
reference template or a registered fUSI volume — e.g. to visually check a
registration or to show a region of interest in 3D.

Proposed API

import confusius as cf
from confusius.atlas import Atlas

atlas = Atlas.from_brainglobe("allen_mouse_25um")

# Reference template as an image layer, region mesh overlaid as a surface.
viewer, _ = cf.plotting.plot_napari(atlas.reference)
cf.plotting.plot_surface(atlas.get_mesh("VISp"), viewer=viewer)
  • Accepts a (vertices, faces) mesh tuple (matching Atlas.get_mesh's return).
  • Optional per-vertex values for colormapped shading (defaults to a flat surface).
  • Optional viewer to overlay on an existing viewer, consistent with
    [plot_napari][confusius.plotting.plot_napari].
  • Returns (viewer, layer) like the other napari helpers.

Because get_mesh returns vertices already in the atlas physical space and image
layers are placed at their physical origin/spacing, the surface aligns with the
image layers without extra scaling.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions