cellmap_flow.io.source

Reading array data with tensorstore, whatever the format.

open_array(path) gives an ArraySource for zarr v2 and v3, N5 and neuroglancer precomputed, on local disk or at an http(s)://, s3:// or gs:// URL (io.store). Every format is seen the same way: C order, as the metadata in io.metadata describes it (channels first, then z, y, x), with voxel 0 at index 0. read_padded reads a Box of voxels from it, or from any view of it, padding what lies outside the array.

Where the voxels are in the world is io.geometry’s business, and what the input chain does to them is ImageDataInterface’s.

Attributes

logger

Classes

ArraySource

One array, read with tensorstore: every channel, not normalized.

Functions

open_array(→ ArraySource)

The array at path, to read with tensorstore; it is opened on the

read_padded(→ numpy.ndarray)

The voxels of box (one entry per dimension of store; all of

Module Contents

cellmap_flow.io.source.logger
class cellmap_flow.io.source.ArraySource(path: str, concurrency_limit: int | None = 1, cache_bytes: int = 0)

One array, read with tensorstore: every channel, not normalized.

Opened on first use and then kept, so everything sharing the source (ImageDataInterface’s with_input_norms views) shares one open store, and its cache.

path
concurrency_limit = 1
cache_bytes = 0
property ts

C order, voxel 0 at index 0.

Type:

The tensorstore

read(box: cellmap_flow.io.geometry.Box | None = None, fill=0) → numpy.ndarray

read_padded of this array: all of it when box is None.

cellmap_flow.io.source.open_array(path: str, concurrency_limit: int | None = 1, cache_bytes: int = 0) → ArraySource

The array at path, to read with tensorstore; it is opened on the first read (a missing or unreadable array raises then).

concurrency_limit: how many files tensorstore reads and chunks it decodes at once; None leaves its defaults (one decode per core). cache_bytes: how much decoded data it keeps for later reads of the same chunks (0: none). Cached chunks are still checked against the file on every read, so what is read never differs.

cellmap_flow.io.source.read_padded(store, box: cellmap_flow.io.geometry.Box | None = None, fill=0, transform=None) → numpy.ndarray

The voxels of box (one entry per dimension of store; all of it when None) as a numpy array, padded where the box runs past the store’s domain.

fill is the padding value, or “edge” to repeat the border voxels: each voxel outside the array takes the value of the nearest one inside. A box wholly outside the array is all padding. transform is applied to what was read before the padding is added: ImageDataInterface runs its input chain there, so padding is never normalized, and a box with nothing to read still has the chain’s dtype.