neu_vol.mapped

A supervoxel volume read through a lookup table, addressed by a small descriptor file.

A segmentation delivered as supervoxels plus agglomeration views (webknossos’ agglomerate_view_NN) is one volume and N tables; each view is table[supervoxels], read on the fly. A view is addressed by a descriptor, a JSON file any location-taking entry point accepts (neu-vol info, read_piece, neu-vol convert --src):

{"neu_vol": "mapped-volume", "version": 1,
 "source": "/path/to/supervoxels.precomputed",
 "table": "agglomerate_view_80.npy", "mapping": "agglomerate_view_80"}

Relative paths resolve against the descriptor’s directory, so a directory of views moves whole. Level 0 is exact; coarse levels are approximate, since table[mode(sv)] is not mode(table[sv]), so measure at level 0 (convert rebuilds the pyramid from it). Descriptors and tables may be local or on an object store; a table is loaded whole, once per process.

Attributes

Functions

absolute(location) → str

A local path made absolute; a URL unchanged. Descriptors record locations this way,

clear_cache() → None

is_descriptor(location) → bool

True if location is a JSON object (local or remote) carrying this marker.

load_table(path) → numpy.ndarray

location_spec(path) → dict

The mapped spec for a descriptor: the source's own spec, wrapped.

read_descriptor(path) → dict

The descriptor at path, with source and table resolved.

table_bytes(table) → bytes

A table as .npy bytes, for writing through location.

write_descriptor(path, *, source, table, mapping[, origin]) → None

Write a descriptor at path (local or remote).

Module Contents

neu_vol.mapped.absolute(location: str) → str

A local path made absolute; a URL unchanged. Descriptors record locations this way, so they mean the same thing from whatever directory they are read.

neu_vol.mapped.clear_cache() → None
neu_vol.mapped.is_descriptor(location: Any) → bool

True if location is a JSON object (local or remote) carrying this marker.

Only .json names are read, so detection costs nothing for any other location.

neu_vol.mapped.load_table(path: str) → numpy.ndarray
neu_vol.mapped.location_spec(path: str) → dict

The mapped spec for a descriptor: the source’s own spec, wrapped.

neu_vol.mapped.read_descriptor(path: str) → dict

The descriptor at path, with source and table resolved.

neu_vol.mapped.table_bytes(table: numpy.ndarray) → bytes

A table as .npy bytes, for writing through location.

neu_vol.mapped.write_descriptor(path: str, *, source: str, table: str, mapping: str, origin: Mapping[str, Any] | None = None) → None

Write a descriptor at path (local or remote).

table is stored as given, so pass a bare file name for a table beside the descriptor — that keeps a directory of views movable as a whole. source is made absolute if it is a relative local path.

neu_vol.mapped.MARKER = 'mapped-volume'
neu_vol.mapped.TAG = 'mapped'