neu_vol.scales

Pyramid levels from a volume’s own metadata: the one parser per format.

  • precomputed: each entry of info["scales"] has its own resolution (xyz nm), size (xyz voxels) and optional voxel_offset (in that level’s voxels).

  • zarr / OME-NGFF: each multiscale dataset has its own scale transform and an optional translation, which is already in physical units.

Voxel sizes come from the metadata, never from 2 ** level: real pyramids are anisotropic. Levels are ordered finest first, so index 0 is full resolution. Every module that reads info or an OME zarr.json goes through the functions here.

Functions

describe_scales(spec) → str

Human-readable pyramid listing, from one info or zarr.json.

finest_first(scales) → list[int]

Indices into info["scales"], finest resolution first.

level_factor(voxel_sizes, level) → tuple[int, ...]

How many level-0 voxels one voxel of level spans, per axis.

ome_levels(multiscale) → list[tuple[str, neu_lib.Frame]]

(path, frame) per dataset, in listed order, over the spatial axes only.

ome_multiscale(meta) → dict | None

The first OME multiscale of a group zarr.json; None for anything else.

precomputed_info(location) → dict | None

The volume's info document, or None if it has none.

precomputed_level(scale) → tuple[tuple[int, ...], neu_lib.Frame]

(shape_zyx, frame) for one entry of info["scales"].

read_scales(spec) → list[neu_lib.ScaleInfo]

All pyramid levels of a source, finest first. Raises if metadata is absent.

read_zarr_json(location, *parts) → dict | None

A zarr.json document, or None if absent.

scale_spec(spec, scale_index) → dict

A read spec pinned to one pyramid level.

spatial_axes(multiscale) → list[int]

Positions of the space axes in a multiscale's axis list.

Module Contents

neu_vol.scales.describe_scales(spec: str | Mapping[str, Any]) → str

Human-readable pyramid listing, from one info or zarr.json.

Much cheaper than neu_vol.describe(), which opens every level.

neu_vol.scales.finest_first(scales: Sequence[Mapping[str, Any]]) → list[int]

Indices into info["scales"], finest resolution first.

neu_vol.scales.level_factor(voxel_sizes: Sequence[Sequence[float]], level: int) → tuple[int, ...]

How many level-0 voxels one voxel of level spans, per axis.

voxel_sizes is each level’s own voxel size, finest first (as neu_vol.source_metadata.read_level_voxel_sizes() returns them). Raises ValueError if level is absent or not an integer multiple of level 0; the message reads after the volume’s name.

neu_vol.scales.ome_levels(multiscale: Mapping[str, Any]) → list[tuple[str, neu_lib.Frame]]

(path, frame) per dataset, in listed order, over the spatial axes only.

neu_vol.scales.ome_multiscale(meta: Mapping[str, Any] | None) → dict | None

The first OME multiscale of a group zarr.json; None for anything else.

neu_vol.scales.precomputed_info(location: str | Mapping[str, Any]) → dict | None

The volume’s info document, or None if it has none.

neu_vol.scales.precomputed_level(scale: Mapping[str, Any]) → tuple[tuple[int, ...], neu_lib.Frame]

(shape_zyx, frame) for one entry of info["scales"].

neu_vol.scales.read_scales(spec: str | Mapping[str, Any]) → list[neu_lib.ScaleInfo]

All pyramid levels of a source, finest first. Raises if metadata is absent.

neu_vol.scales.read_zarr_json(location: str | Mapping[str, Any], *parts: str) → dict | None

A zarr.json document, or None if absent.

neu_vol.scales.scale_spec(spec: str | Mapping[str, Any], scale_index: int) → dict

A read spec pinned to one pyramid level.

precomputed selects the level with scale_index; zarr addresses the level’s subgroup by path. Use this rather than writing a spec by hand: an unrecognised key is silently ignored, so {"scale": 2} opens full resolution and reads the wrong place, failing as empty data rather than an error.

neu_vol.scales.spatial_axes(multiscale: Mapping[str, Any]) → list[int]

Positions of the space axes in a multiscale’s axis list.