cellmap_flow.io.raw
The raw data as a model reads it: a worldarray array through the input chain.
open_raw(path, voxel_size) opens, with worldarray, the level a model at
voxel_size reads: the level of a multiscale group or precomputed volume
for that size (the finest no coarser than it), the path of one level as it
is. When no level is at that size the level found is read as if it were
(“relabel”: voxel for voxel, its corner rescaled, with a warning) or
resampled to it (resample=True). What comes back is a plain
worldarray.WorldArray: voxel_size and corner (nm, spatial axes),
shape (every axis), read and read_index; spatial_shape and
spatial_axes pick out its spatial part.
RawInput is what a model reads its input from, and what a config’s
process_chunk(idi, roi) or predict script is given: to_ndarray_ts(roi)
is the world box roi through the input chain, the normalizers (and
ChannelSelector) given as input_norms, else the process’s chain
(process_chain().input_norms) as it is at read time, which scripts rely
on. The inference server reads with serving.chunkmirage_ops.BlockInput,
the same protocol over the block chunkmirage read for a chunk.
Attributes
Classes
What a model reads its input from: |
Functions
|
Whether data of |
|
The level of |
|
|
|
The names of |
|
|
|
The input channel a chain asks for: its first ChannelSelector's, else 0. |
|
The index of |
|
worldarray's |
|
|
Module Contents
- cellmap_flow.io.raw.logger
- cellmap_flow.io.raw.RESAMPLE_HINT = 'resample=True (`resample: true` in a YAML, `--resample` on the command line) resamples it to...
- cellmap_flow.io.raw.is_label_dtype(dtype) bool
Whether data of
dtypeis resampled as labels (nearest voxel) rather than as intensities (mean and linear): bool, or an integer type of 32 bits or more.
- cellmap_flow.io.raw.open_raw(path, voxel_size=None, resample=False, padding='edge', context=None) worldarray.WorldArray
The level of
patha model atvoxel_sizereads, open.voxel_size(nm, z, y, x) picks the level of a multiscale group or precomputed volume: the finest not coarser than it (worldarray’s “floor”), or withresamplethe coarsest not coarser than it on any axis, else the finest. The path of one level, or of an array, is read as it is. Without a voxel size a group’s first level is opened.When the level is not at
voxel_size, reads are relabelled (the default, with a warning: the level is read voxel for voxel as if it were atvoxel_size, so the data really lies where itssource_voxel_sizeandsource_translationsay andcorneris its own corner rescaled) or, withresample, resampled to it by worldarray (labels by the nearest voxel, intensities linearly), from the level’s own corner.resampledtells the two apart;voxel_sizeis the size reads are at either way.paddingis what a read past the array is padded with, after the chain: “edge” (the default), the array’s outermost voxels repeated, is what a model’s input is read with, since a flat fill is a wall the model never saw in training;0for anything else. The reads go through one tensorstore reader thread and no cache (worldarray’scapped_context(network=False)) unlesscontextsays otherwise.
- cellmap_flow.io.raw.spatial_shape(array: worldarray.WorldArray) tuple
array’s shape on its spatial axes (its resampled shape when it resamples): what cellmap-flow calls the dataset’s shape, z, y, x.
- cellmap_flow.io.raw.spatial_axes(array: worldarray.WorldArray) tuple
The names of
array’s spatial axes (z, y, x when the store names none).
- cellmap_flow.io.raw.apply_norms(data, input_norms=None)
data(a tensorstore view is read first) through the chaininput_norms;Nonemeans the process’s,process_chain().input_norms.
- cellmap_flow.io.raw.selected_channel(input_norms) int
The input channel a chain asks for: its first ChannelSelector’s, else 0.
- cellmap_flow.io.raw.channel_axis(array: worldarray.WorldArray)
The index of
array’s channel axis: the one named c, c^ or channel, else its first non-spatial axis; None for an array with spatial axes only.
- cellmap_flow.io.raw.channel_select(array: worldarray.WorldArray, input_norms)
worldarray’s
selectfor reading one channel ofarray: its channel axis pinned to the channel the chain asks for; None for an array with spatial axes only.
- cellmap_flow.io.raw.raw_channels(path) tuple
(count, labels)for the raw atpath: how many channels a model can be given to read (1 for an array with spatial axes only), and their names, an OME-Zarr’somero.channels[].labelwhen it names every channel, else None.
- class cellmap_flow.io.raw.RawInput(array: worldarray.WorldArray, input_norms=None, normalize=True)
What a model reads its input from:
array(the level a model reads,open_raw’s) through the input chain.input_normsis the chain reads go through, the normalizers and the ChannelSelector;Nonefollows the process’s chain (process_chain().input_norms) as it is at each read, so a worker that unpickles one reads its own chain, not the sender’s.normalize=Falsereads the channel the chain selects as it is stored, through no normalizer: the finetune trainer and the AI-annotate reader normalize for themselves.- array
- input_norms = None
- normalize = True
- chain() list
The chain reads go through now.
- with_input_norms(input_norms) RawInput
This input read through
input_normsinstead; the open array is shared.
- to_ndarray_ts(roi) numpy.ndarray
The world box
roi(nm, half-open; a funlibRoi, a worldarrayBoxor a(begin, end)pair) through the chain: the channel the chain selects of a multichannel array, the normalizers applied unlessnormalizeis off, and past the array whatopen_raw’spaddingsays, added after the chain, so padding is never normalized. A voxel is read when its centre lies in the box (worldarray’s rule). An array that resamples is resampled first, then goes through the chain, as a stored level at that voxel size would.
- read_index(begin, end) numpy.ndarray
Voxels
[begin, end)on the array’s spatial grid (its resampled grid when it resamples), read asto_ndarray_tsreads them.