cellmap_flow.image_data_interface
A dataset to read in world coordinates, through the input chain.
ImageDataInterface(path, voxel_size) picks the level of a multiscale
group or precomputed volume for voxel_size (io.multiscale), reads
its metadata (io.metadata) and keeps its voxel grid (io.geometry)
and the array (io.source). A read of a world ROI is the grid’s box of voxels, read
with padding where it runs past the array. With
on_voxel_size_mismatch="resample", a dataset with no level at
voxel_size is resampled to it (io.resample); the deprecated
output_voxel_size resamples what is read, crudely. What is read goes through the input
chain on the way: the normalizers and ChannelSelector given as
input_norms, else the process’s chain (process_chain().input_norms)
as it is at read time, which user process_chunk scripts rely on.
Attributes
Classes
A tensorstore seen through the input chain, for neuroglancer to index. |
Functions
|
|
|
Read |
|
The input channel a chain asks for: its first ChannelSelector, else 0. |
|
Index one channel out of a multichannel tensorstore. |
Module Contents
- cellmap_flow.image_data_interface.logger
- cellmap_flow.image_data_interface.ON_VOXEL_SIZE_MISMATCH = ('relabel', 'resample', 'error')
- cellmap_flow.image_data_interface.RESAMPLE_HINT = 'on_voxel_size_mismatch="resample" (`resample: true` in a YAML, `--resample` on the command...
- cellmap_flow.image_data_interface.legacy_meta(meta: cellmap_flow.io.metadata.ArrayMeta)
(voxel_size, offset, chunk_shape, shape, axes_names, filetype), the tuple the old readers returned, from an ArrayMeta: spatial axes only, voxel size and offset as lists of nanometer floats.The zarr v2/N5 reader always took the last n axes (n spatial ones) and called them z, y, x, whatever the metadata said, on disk; a URL now reads the same. The others take the spatial axes by name. Both are kept.
- class cellmap_flow.image_data_interface.ImageDataInterface(dataset_path, voxel_size=None, mode='r', output_voxel_size=None, custom_fill_value=None, concurrency_limit=1, normalize=True, input_norms=None, on_voxel_size_mismatch='relabel', cache_bytes=0)
- path
- input_norms = None
- actual_voxel_size = None
- requested_voxel_size = None
- shape
- voxel_size = None
- offset = None
- roi
- custom_fill_value = None
- concurrency_limit = 1
- cache_bytes = 0
- source
- normalize = True
- property resampled: bool
Whether reads are resampled from
actual_voxel_sizetovoxel_size: the data then really is atvoxel_size. When the two differ and this is False, the level was relabelled, and the data really lies atactual_voxel_size.
- property ts
The dataset seen through the input chain (one channel, normalized).
With
normalize=Falsethis is the plain tensorstore of the selected channel, as it always was.A resampled dataset has none: its voxels exist only as
to_ndarray_tscomputes them.source.tsis the level as stored.
- read_box(box: cellmap_flow.io.geometry.Box, fill=0) numpy.ndarray
The voxels of
box(aBoxof voxel indices atvoxel_size) through the input chain, as a numpy array padded withfillwhere it runs past the array:to_ndarray_tsby voxels instead of nm. Unlikets, works on a resampled dataset too.
- with_input_norms(input_norms)
This dataset, read through
input_normsinstead of the process’s chain.Shares the opened tensorstore, so it is cheap to make one per request.
- property info
- to_ndarray_ts(roi=None)
roi(world nm; all of the array when None) read through the input chain, as a numpy array.Where the ROI runs past the array it is padded with
custom_fill_value(0 when unset; “edge” repeats the border voxels), after the chain: padding is never normalized.A resampled dataset (
resampled) is read atvoxel_sizebyio.resample: the stored voxels are resampled, then go through the chain, as a stored level atvoxel_sizewould. A ROI is read at the deprecatedoutput_voxel_sizewhen that differs from the voxel size (see_read_resampled); the whole array never is.
- cellmap_flow.image_data_interface.apply_norms(data, input_norms=None)
Read
dataif it is a tensorstore view and run it through the chain.input_norms=Nonemeans the process’s chain,process_chain().input_norms.
- cellmap_flow.image_data_interface.selected_channel(input_norms) int
The input channel a chain asks for: its first ChannelSelector, else 0.
- cellmap_flow.image_data_interface.select_channel(ts_dataset, channel=0, spatial_ndim=3)
Index one channel out of a multichannel tensorstore.
The channel axis is the one labelled c/c^/channel when the store labels its dimensions, and otherwise the first one (the OME-Zarr convention). Arrays with no more than
spatial_ndimdimensions are returned as is.
- class cellmap_flow.image_data_interface.LazyNormalization(ts_dataset, input_norms=None, normalize=True, spatial_ndim=3)
A tensorstore seen through the input chain, for neuroglancer to index.
The channel and the normalizers are looked up on every access rather than fixed when the store was opened: a server that has already read one chunk must still follow a ChannelSelector that changes afterwards.
input_norms=Nonefollows the process’s chain,process_chain().input_norms, as it is at each access: a worker that unpickles one reads its own chain, not the sender’s.normalize=Falseselects the channel but applies no normalizers.- ts_dataset
- input_norms = None
- normalize = True
- spatial_ndim = 3
- chain()
- norms_to_apply()
- selected()
The raw (unnormalized) tensorstore for the channel the chain selects.