neu_vol.source_metadata¶
Read coordinate metadata and the level-0 data location from a source volume.
convert uses this so voxel_size / offset need not be re-specified when the
source carries them (OME-NGFF zarr groups, precomputed info, DVID, webknossos, an
HDF5 file that records its own frame). Explicit arguments override what is read here;
sources that record nothing return None.
Returned dict keys: data_spec (the array/scale spec to read), voxel_size /
offset (z, y, x), units, spatial_axes, has_channels, kind.
Two tiers, differing in cost: the readers read one small metadata document each;
describe() and existing_levels() additionally open every level, which on an
object store costs about ten times as much (15.8 s against 1.4 s on an 8-level zarr).
Attributes¶
Functions¶
|
Detected format, coordinate metadata and the levels actually present. |
|
|
|
|
|
The backend spec for one level of a multiscale volume. |
|
The backend spec addressing |
|
Each level's own voxel size, from the volume's metadata. |
|
Coordinate metadata and the level-0 |
|
|
Module Contents¶
- neu_vol.source_metadata.describe(volume: str, *, dataset: str | None = None, level: int | None = None) neu_vol.report.Description¶
Detected format, coordinate metadata and the levels actually present.
Returns a
Description: a dict that also renders as the tableneu-vol infoprints, with.frame()giving the per-level rows as a DataFrame.leveldescribes that source scale instead of level 0.An HDF5 file or image stack has one level and may record no metadata, so
metacan beNone. An HDF5 file may hold several arrays:datasetsis{name: {"shape", "dtype", "chunks", <recorded frame>}}for every HDF5 file, andNonefor other formats;datasetis the array the rest of the dict describes, orNone;with several arrays and none named,
shape/dtype/meta/level_voxel_sizesareNoneandlevelsis empty; callers needing one array userequire_one_array().
Raises
FileNotFoundErrorif nothing atvolumelooks like a volume.
- neu_vol.source_metadata.existing_levels(volume: str, fmt: str, probe: int = 12, *, dataset: str | None = None) dict[int, dict]¶
{level: {"shape", "chunks", "read_chunks"}}for the levels that open.Probes upward until a level fails to open, so it works on a conversion still in progress, whose group metadata is written last. A single-container format has only level 0. Chunking is read per level, since levels may be chunked differently;
chunksis the write chunk (the shard, when sharded) andread_chunksthe unit actually fetched.
- neu_vol.source_metadata.level0_chunking(described: Mapping[str, Any], location: str)¶
(read chunk, write chunk)of a described source’s level 0, either possiblyNone.describe()reports chunking only for levels it finds; a bare array has none, so its chunking is read from the array itself. The two differ when the level is sharded: the write chunk is the shard.
- neu_vol.source_metadata.level_spec(volume: str, fmt: str, level: int, *, dataset: str | None = None) dict[str, Any]¶
The backend spec for one level of a multiscale volume.
zarr v3 puts each level in its own subdirectory; precomputed, DVID and webknossos select one with
scale_index. A single-container format has only level 0, and any other raises, since its backend would ignorescale_indexand open level 0 anyway.
- neu_vol.source_metadata.location_spec(location: str, fmt: str, *, dataset: str | None = None) dict[str, Any]¶
The backend spec addressing
location, in the formfmtexpects.Most formats take
path; an image stack takessource(a directory or glob), HDF5 takespathplus thedatasetinside the container, and DVID and webknossos take the fields of their URLs. Everything that turns a user-supplied location into a spec goes through here.datasetnames the array inside an HDF5 file. When omitted it is resolved bysole_dataset(), which raises, listing the candidates, unless the file holds exactly one. Ignored for every other format.
- neu_vol.source_metadata.read_level_voxel_sizes(spec: Mapping[str, Any]) list[tuple[float, ...]] | None¶
Each level’s own voxel size, from the volume’s metadata.
Noneif absent.Read per level, never derived from shape ratios (shapes are ceil-divided, so the ratio is inexact) or from
2**level(pyramids may be anisotropic). Finest-first,(z, y, x), spatial axes only.
- neu_vol.source_metadata.read_source_metadata(spec: Mapping[str, Any]) dict | None¶
Coordinate metadata and the level-0
data_specforspec;Noneif absent.See the module docstring for the keys. An image stack records no physical scale, so it always returns
None.
- neu_vol.source_metadata.require_one_array(described: Mapping[str, Any], location: str, op: str) dict¶
describedif it resolved a single array; otherwise an error naming the datasets.For callers that go on to read the array, which would otherwise fail on a
Noneshapefrom a multi-array HDF5 container.
- neu_vol.source_metadata.logger¶