neu_vol.detect¶
Which format a location holds, and whether a precomputed scale actually stores data.
Detection reads marker objects (info, zarr.json, .zarray) and URL schemes,
never volume data. The exceptions are O(1) chunk-existence probes: CloudVolume writes
.gz-suffixed chunk keys, which read as zeros unless detected, and an info may
declare scales that were never written.
Attributes¶
Functions¶
|
Detect a source's format from its marker file (no data read). |
|
|
|
Index into |
|
Markers of volume formats other than |
|
True if these precomputed scales' chunk objects are |
|
|
|
Raise if |
|
Whether a precomputed scale stores any chunk: conclusive, like |
|
True if this precomputed scale's prefix holds no chunk object at all. |
|
True if this precomputed scale's origin chunk object is stored, under either suffix. |
Module Contents¶
- neu_vol.detect.detect_backend(location: str | Mapping[str, Any]) str | None¶
Detect a source’s format from its marker file (no data read).
info-> neuroglancer-precomputed;zarr.json-> zarr v3;.zarray/.zgroup-> zarr v2; advid://URL ->dvid;wk://->webknossos; a mapped-view descriptor ->mapped. ReturnsNoneif none match.Precomputed whose chunks are
.gz-suffixed reportsPRECOMPUTED_GZinstead, so callers fail loudly rather than reading zeros.A marker always wins:
hdf5andimage_stackhave no marker and are recognised bydetect_file_backend()only after every marker probe has missed.
- neu_vol.detect.detect_file_backend(location: str | Mapping[str, Any]) str | None¶
hdf5orimage_stackfor a local file, glob or directory of slices.Neither has a marker object, so detection uses the name plus one
stat, and runs only after every marker probe has missed:a glob is an image stack;
a file is judged by extension; an unknown one returns
None;a directory must actually contain a slice, so a typo is not mistaken for an empty stack.
Local paths only: neither reader has an object-store driver.
- neu_vol.detect.finest_populated_scale(location: str | Mapping[str, Any], scales: Sequence[Mapping[str, Any]]) int | None¶
Index into
scalesof the finest one that actually holds data, orNone.An
infomay declare scales that were never written; such a scale opens, reports its declared extent, and reads as the fill value everywhere. Three tiers, cheapest first:Probe origin chunks finest-first. An ordinary volume answers on the first check.
If a coarser scale has an origin chunk and finer ones do not, the finer ones are either unwritten or sparse at the origin;
scale_holds_data()decides.If no scale has an origin chunk, apply
scale_holds_data()to every scale, finest-first: a volume can be sparse at the origin of all its scales.
- neu_vol.detect.other_format_markers(location: str | Mapping[str, Any], fmt: str) list[str]¶
Markers of volume formats other than
fmtalready present atlocation.Creating a volume writes only its own marker, so a precomputed volume made where a zarr one lives leaves
infoandzarr.jsonside by side, and detection then never reaches the zarr.
- neu_vol.detect.precomputed_chunks_are_gzipped(location: str | Mapping[str, Any], scales: Mapping[str, Any] | Sequence[Mapping[str, Any]]) bool¶
True if these precomputed scales’ chunk objects are
.gz-suffixed.CloudVolume gzips chunks and appends
.gzto the key; tensorstore asks for the unsuffixed key and reads the fill value, so every block comes back as zeros.scalesis one entry ofinfo["scales"]or several in preference order. Each scale’s origin chunk is probed by name first (two existence checks), and only if no scale answers is a prefix listed, scale by scale in the order given. A listing is never bounded by itslimit— it enumerates the whole prefix — sodetect_backend()passes the scales coarsest-first, keeping any listing on the smallest prefix.
- neu_vol.detect.require_chunked_volume(fmt: str, location: str, op: str) str¶
fmtif it is a chunked multiscale volume; a useful error if it is not.Called by the ops that rewrite a volume in place. Without it an HDF5 file or image stack fails deep inside an occupancy listing that finds no chunk keys, which reads as “no data” rather than “not that kind of volume”.
- neu_vol.detect.require_populated_scale(spec: Mapping[str, Any], *, op: str = 'convert') None¶
Raise if
specnames a precomputed scale this volume never wrote.Reading an unwritten scale fails silently: every block is the fill value and the output is a correct-looking volume of zeros. This raises only on conclusive evidence — the scale’s prefix holds no chunk while another scale’s does — because a sparse volume may legitimately store nothing at the origin.
- neu_vol.detect.scale_holds_data(location: str | Mapping[str, Any], scale: Mapping[str, Any]) bool¶
Whether a precomputed scale stores any chunk: conclusive, like
scale_is_empty().Probes the origin chunk, then up to eight more predictable chunk keys (either suffix), and lists the prefix only if all of them miss, since a listing enumerates every object of a dense scale.
- neu_vol.detect.scale_is_empty(location: str | Mapping[str, Any], scale: Mapping[str, Any]) bool¶
True if this precomputed scale’s prefix holds no chunk object at all.
The conclusive form of
scale_stores_chunks(), at the cost of a listing. Cheap when the scale was never written (its prefix is empty); expensive on a sparse volume whose origin is background, where the whole prefix is enumerated.
- neu_vol.detect.scale_stores_chunks(location: str | Mapping[str, Any], scale: Mapping[str, Any]) bool¶
True if this precomputed scale’s origin chunk object is stored, under either suffix.
A True is evidence of a written scale; a False is not proof of an empty one, since a sparse volume may store nothing at its origin.
- neu_vol.detect.FORMAT_MARKERS¶
- neu_vol.detect.PRECOMPUTED_GZ = 'neuroglancer_precomputed_gz'¶
- neu_vol.detect.SINGLE_LEVEL_FORMATS¶
- neu_vol.detect.logger¶