neu_vol.readback¶
Read a body’s mesh and skeleton out of a published precomputed volume, local or remote.
The writers are in neu-morpho (neu_morpho.precomputed); reading needs no meshing
stack, so it is here, where every package that views or measures a volume can use it.
Formats: neuroglancer_multilod_draco and neuroglancer_legacy_mesh meshes,
neuroglancer_skeletons, each sharded or not.
Coordinates come back in physical nm: each subresource’s info transform is
applied. DracoPy (meshes) and osteoid (skeletons) are imported on first use.
Exceptions¶
A mesh or skeleton subresource is in a form this module cannot decode. |
Functions¶
|
Sorted ids of the bodies with a mesh under |
|
The mesh |
|
|
|
|
|
The skeleton |
Module Contents¶
- exception neu_vol.readback.UnsupportedSubresource¶
Bases:
ValueErrorA mesh or skeleton subresource is in a form this module cannot decode.
Distinct from a body with no mesh, which is an ordinary
None: anything batching reads should let this propagate rather than count it as a missing body.Initialize self. See help(type(self)) for accurate signature.
- neu_vol.readback.mesh_body_ids(volume: str, mesh_dir: str | None = None) list[int]¶
Sorted ids of the bodies with a mesh under
volume/mesh_dir;[]for none.mesh_dirdefaults to the directory the volume’sinfonames undermesh, elsemesh.A multi-resolution mesh counts once its
<id>.indexmanifest exists (neu-morpho writes it after the fragment data); a legacy mesh, once its<id>:0manifest does. One listing of the directory. A sharded mesh raisesUnsupportedSubresource: enumerating one means reading every minishard index (about a billion ids and 3.7 GB of index reads for one published fly CNS), so name the bodies explicitly instead.
- neu_vol.readback.mesh_transform(volume: str, mesh_dir: str = 'mesh')¶
The mesh
info’s stored-model to nmtransform, as a(3, 4)matrix.Identity included.
read_body_mesh()has already applied it; this is for reporting it and recovering stored-model coordinates. Raises when there is noinfoat the location, since an identity answer to a mistyped path would be believed.
- neu_vol.readback.read_body_mesh(volume: str, body_id: int, lod: int | None = None, mesh_dir: str = 'mesh')¶
(vertices_xyz_nm, faces, lod)for one LOD, orNoneif absent.loddefaults to the coarsest present, the cheapest to draw; pass 0 for full detail. The LOD’s octree fragments are concatenated with face indices rebased. Sharded and unsharded meshes are both read, by theshardingkey of the meshinfo; a sharded read fetches only the requested LOD.Vertices are always physical nm: stored coordinates go through the mesh
info’stransform, with no opt-out. neu-morpho writes identity; a foreign source may not (one published source declaresdiag(16)).mesh_transform()reports it.
- neu_vol.readback.read_body_skeleton(volume: str, body_id: int, skeleton_dir: str = 'skeleton', *, require_radii: bool = True)¶
(vertices_xyz_nm, edges, radii_nm)for one body, orNoneif absent.Vertices come back xyz, the order the format stores, matching
read_body_mesh()so the two overlay without a flip; the rest of the suite holds zyx in memory. They are physical nm, mapped through the skeletoninfo’stransformas the mesh reader maps its own. Sharded and unsharded skeletons are both read.Raises if the skeleton has no usable
radiusattribute. With none declared, osteoid returns one-1per vertex, which passes a length check and renders as an inverted tube, so negative radii are refused.require_radii=Falsereturnsradii_nm=Noneinstead, for a source that publishes centrelines only.
- neu_vol.readback.skeleton_transform(volume: str, skeleton_dir: str = 'skeleton')¶
The skeleton
info’stransform, as a(3, 4)matrix.Separate from
mesh_transform()because a source declares the two independently.