neu_morpho.mesh

Block-first meshing: stage 1 (mesh a block’s labels) + stage 2 (assemble a body).

Stage 1 (mesh_block): mesh every present (or allowlisted) label of one block with Mesh.from_label_volume, halo’d for stitching; peak memory is one block, never a whole-object mask. Stage 2 (assemble_body): concatenate a body’s fragments and stitch_adjacent_faces into one mesh, keeping all components.

Functions

assemble_body(fragment_meshes, cfg)

Concatenate + stitch a body's block fragments into one mesh (all components).

count_components(mesh) → int

Connected components of the mesh, over shared vertex indices.

mesh_block(seg_block_zyx, box_nm_zyx, cfg[, allowlist]) → dict[int, object]

Mesh every (allowlisted) label in one block. Returns {body_id: Mesh}.

mesh_metrics(mesh) → dict

Per-body mesh metrics for the metrics DB (columns match metrics_db._EXTRA).

surface_area_nm2(mesh) → float

Total triangle area. Vertices are nm (coords.py), so this is nm².

Module Contents

neu_morpho.mesh.assemble_body(fragment_meshes: Sequence[object], cfg: neu_morpho.config.MeshConfig)

Concatenate + stitch a body’s block fragments into one mesh (all components).

neu_morpho.mesh.count_components(mesh) → int

Connected components of the mesh, over shared vertex indices.

Also a QC signal: a spanning body that reports more than one may not have stitched, though a body genuinely split by the segmentation reports more than one too.

neu_morpho.mesh.mesh_block(seg_block_zyx: numpy.ndarray, box_nm_zyx: numpy.ndarray, cfg: neu_morpho.config.MeshConfig, allowlist: set[int] | None = None) → dict[int, object]

Mesh every (allowlisted) label in one block. Returns {body_id: Mesh}.

box_nm_zyx is the block’s physical (nm) box (see coords.physical_box), so vertices come out in nm world coords. Background (0) is excluded; meshes are per-block simplified so downstream assembly works on already-reduced geometry.

neu_morpho.mesh.mesh_metrics(mesh) → dict

Per-body mesh metrics for the metrics DB (columns match metrics_db._EXTRA).

neu_morpho.mesh.surface_area_nm2(mesh) → float

Total triangle area. Vertices are nm (coords.py), so this is nm².