neu_morpho.fragments

Intermediate per-(body, block) fragments (stage 1 -> stage 2 handoff).

Stage 1 writes one fragment per body per block under <chunked_dir>/h<bucket>/<body_id>/<iz>_<iy>_<ix>.<fmt>, bucket being body_id % FANOUT in three hex digits. Stage 2 finds bodies by listing the buckets. Filesystem-backed.

Buckets keep directories narrow: one directory per body directly under chunked_dir made listing a large run hang. They do not reduce the file count. The h prefix keeps a bucket from parsing as a body id, which is how the old flat layout is recognized and refused.

Meshes (.drc) and skeletons (.skel) share the layout, each in its own store. Skeleton fragments use the precomputed encoding but hold zyx global-nm vertices, the space stage 2 fuses in; the zyx->xyz flip happens once, at output.

Attributes

Exceptions

OldFragmentLayout

The store holds body directories at its top level, from before bucketing.

Functions

body_dir(chunked_dir, body_id) → str

bucket_name(body_id) → str

count_bodies(chunked_dir) → int | None

How many bodies have fragments. None if the store does not exist.

fragment_path(chunked_dir, body_id, block_index[, fmt]) → str

list_bodies(chunked_dir) → list[int]

read_body_fragments(chunked_dir, body_id[, fmt]) → list

Load all of a body's fragment meshes (vol2mesh.Mesh).

read_body_skel_fragments(chunked_dir, body_id[, fmt]) → list

Load all of a body's skeleton fragments (osteoid.Skeleton, zyx nm).

write_fragment(chunked_dir, body_id, block_index, mesh) → None

write_skel_fragment(chunked_dir, body_id, block_index, ...) → None

Module Contents

exception neu_morpho.fragments.OldFragmentLayout

Bases: RuntimeError

The store holds body directories at its top level, from before bucketing.

Initialize self. See help(type(self)) for accurate signature.

neu_morpho.fragments.body_dir(chunked_dir: str, body_id: int) → str
neu_morpho.fragments.bucket_name(body_id: int) → str
neu_morpho.fragments.count_bodies(chunked_dir: str) → int | None

How many bodies have fragments. None if the store does not exist.

On CephFS, from the store’s recursive directory counts, which are instant (and may lag the filesystem by seconds); elsewhere one listing per bucket, which on ceph takes tens of seconds for a 4096-bucket store. Never a walk into the body directories.

neu_morpho.fragments.fragment_path(chunked_dir: str, body_id: int, block_index: Sequence[int], fmt: str = 'drc') → str
neu_morpho.fragments.list_bodies(chunked_dir: str) → list[int]
neu_morpho.fragments.read_body_fragments(chunked_dir: str, body_id: int, fmt: str = 'drc') → list

Load all of a body’s fragment meshes (vol2mesh.Mesh).

neu_morpho.fragments.read_body_skel_fragments(chunked_dir: str, body_id: int, fmt: str = 'skel') → list

Load all of a body’s skeleton fragments (osteoid.Skeleton, zyx nm).

neu_morpho.fragments.write_fragment(chunked_dir: str, body_id: int, block_index: Sequence[int], mesh, fmt: str = 'drc') → None
neu_morpho.fragments.write_skel_fragment(chunked_dir: str, body_id: int, block_index: Sequence[int], skeleton, fmt: str = 'skel') → None
neu_morpho.fragments.FANOUT = 4096