neu_morpho.precomputed¶
Write neuroglancer precomputed meshes and skeletons (stage-2 output).
Meshes: write_mesh_info() (the info, once) and write_body_multires()
(per-LOD octree fragments), encoded by vol2mesh.multires. Skeletons: the
neuroglancer_skeletons format via osteoid’s Skeleton.to_precomputed —
write_skeleton_info() and write_body_skeleton().
Axis order. Model space is physical nm, held zyx in memory; both formats store
xyz. vol2mesh flips meshes internally and encode_skeleton() flips skeletons;
getting it wrong mirrors skeletons through the z=x diagonal relative to their meshes.
Every write goes through neu-vol’s kvstore helpers, never open(), so
output_dir may be a local path or an s3:// URL. Hence multires.build_info /
encode_multilod_object (a dict and bytes), never write_info /
write_object_mesh, which write to the local filesystem.
Attributes¶
Functions¶
|
Fail fast if Draco quantization would collapse triangles at a coarse LOD. |
|
Encode a global-nm zyx skeleton as precomputed xyz bytes. |
|
Position resolution (nm) at the COARSEST LOD — the one that bites. |
|
True if a precomputed |
|
Write one body's multi-resolution mesh; returns fragments written (0 if empty). |
|
Write one body's skeleton blob; returns the vertex count (0 if empty). |
|
Write the multi-resolution mesh |
|
Write the |
Module Contents¶
- neu_morpho.precomputed.check_quantization(cfg: neu_morpho.config.MeshConfig, chunk_shape_xyz: Sequence[float], voxel_size_zyx: Sequence[float], *, min_ratio: float = 4.0) None¶
Fail fast if Draco quantization would collapse triangles at a coarse LOD.
When the coarsest LOD’s step approaches the voxel size, decimated triangles quantize to zero area and Draco rejects the whole body (“All triangles are degenerate”); at 10 bits and scale 2 that was 29% of bodies.
- neu_morpho.precomputed.encode_skeleton(skeleton) bytes¶
Encode a global-nm zyx skeleton as precomputed xyz bytes.
The vertex attributes are normalized to
SKELETON_VERTEX_ATTRIBUTES, so the blob matches theinfo. Unknown radii stay-1.
- neu_morpho.precomputed.quantization_step_nm(cfg: neu_morpho.config.MeshConfig, chunk_shape_xyz: Sequence[float]) float¶
Position resolution (nm) at the COARSEST LOD — the one that bites.
Draco spreads
2**bitssteps across each octree cell, and a LOD-l cell ischunk * 2**lwide, so the step doubles per LOD.
- neu_morpho.precomputed.volume_exists(volume_dir: str) bool¶
True if a precomputed
infois present atvolume_dir(one request; works on object stores, where there is no directory to stat).
- neu_morpho.precomputed.write_body_multires(output_dir: str, body_id: int, mesh, cfg: neu_morpho.config.MeshConfig, *, chunk_shape_xyz: Sequence[float], grid_origin_xyz: Sequence[float]) int¶
Write one body’s multi-resolution mesh; returns fragments written (0 if empty).
LOD 0 is the assembled mesh; each coarser LOD decimates by
cfg.lod_decimation_factorand is octree-partitioned. Writes<body>and<body>.index(unsharded multires). Vertices are nm; theinfotransform is identity. Cells count fromgrid_origin_xyz, which must lie below every vertex.
- neu_morpho.precomputed.write_body_skeleton(output_dir: str, body_id: int, skeleton) int¶
Write one body’s skeleton blob; returns the vertex count (0 if empty).
- neu_morpho.precomputed.write_mesh_info(output_dir: str, cfg: neu_morpho.config.MeshConfig, *, transform=None, lod_scale_multiplier: float = 1.0) None¶
Write the multi-resolution mesh
info(once per output volume).
- neu_morpho.precomputed.write_skeleton_info(output_dir: str, *, transform: Sequence[float] | None = None, vertex_attributes: Sequence[dict] | None = None) None¶
Write the
neuroglancer_skeletonsinfo(once per output volume).The transform is identity: vertices are already physical nm in the same model space as the meshes, so neuroglancer must not re-scale them.
- neu_morpho.precomputed.IDENTITY_TRANSFORM = [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0]¶
- neu_morpho.precomputed.SKELETON_VERTEX_ATTRIBUTES¶
- neu_morpho.precomputed.VALID_QUANTIZATION_BITS = (10, 16)¶
- neu_morpho.precomputed.WEBGL_SKELETON_ATTRIBUTE_DTYPES¶
- neu_morpho.precomputed.logger¶