Data¶
Data stores hold the arrays backing each visual, along with the request and slice-result types used to fetch data for the current view.
Common¶
cellier.data.BaseDataStore ¶
Bases: CellierEventedModel
The base class for all DataStores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
UUID4
|
The unique identifier for the data store. When not given it is
taken from the first entry of |
required |
name
|
str
|
The name of the data store. |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
The store's intrinsic (voxel) coordinate systems, one per resolution
level, index Constructed by the caller. There is no shorthand: pass built
Stored, not derived. Transforms serialize their endpoints as UUIDs, so a system rebuilt on load would mint fresh ids and every transform naming it would point at nothing. The default is an empty list: a store with no axis metadata does
not invent one, because |
required |
level_scales
|
list[tuple[float, ...]]
|
Per-level, per-axis scale of level This is where a pyramid's geometry is stated. The readers derive it from OME-NGFF metadata; it is raw numbers, which is all a store can know on its own. |
required |
level_translations
|
list[tuple[float, ...]]
|
The offset half of the same, in level-0 voxels.
|
required |
level_transforms
|
list[AffineTransform]
|
Level Derived, not authored. Built from |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
The unique identifier for the data store. |
data_changed |
Signal
|
Emits a |
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The one number the world-extent of a visual is built from. Every consumer -- the axis ranges a slider is sized from, and the out-of-domain check that decides a visual has no data at a given slice position -- reads it through the visual's own transform:
Stating it here, once, is what lets that rule have no special case: a gridded store and a point cloud answer the same question by different rules, and a transform maps either without knowing which it was given.
Level 0 always. Other resolution levels derive from it through
level_transforms, and a per-level extent would be several ways
to say one thing.
Gridded stores use the edge convention, (-0.5, size - 0.5),
because a voxel is centred on its index. Geometry stores use the
bounding box of their vertices, with no padding, because a vertex is
a point.
Cached by geometry stores. Their extent is a pass over every
vertex, so they compute it once and keep it until an "extent"
change (notify_changed, or reassigning positions). An
in-place write to positions without notify_changed("extent")
leaves the cached extent stale, by contract.
Returns:
| Type | Description |
|---|---|
tuple[tuple[float, float], ...] or None
|
One |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If a concrete store has not implemented it. There is no default: a store that cannot say what it spans must say so, rather than inventing an extent that consumers would size a slider from. |
DATASET_INFO_LABEL
class-attribute
¶
DATASET_INFO_LABEL: str = 'data store'
What this kind of store calls itself in the Store type row.
A human-readable name rather than the store_type discriminator: the
row is read by a person, and "in-memory points" says more than
"points_memory".
__setattr__ ¶
Assign a field, announcing the change when it is a data field.
A class-level hook rather than a connection to self.events made
in model_post_init: model_copy(deep=True) -- which
to_model and from_model use -- runs no model_post_init, so
a connection would silently go missing on every copy. Construction
assigns through __dict__ and announces nothing.
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
model_post_init ¶
model_post_init(__context: Any) -> None
Check the systems passed at construction and install their transforms.
Stores that open array handles in their own model_post_init call
this after opening them: the level count and rank it checks against
are read off the handles.
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
dataset_info ¶
dataset_info() -> DatasetInfo
Describe what this store holds, for display in a dataset-info widget.
Returns the store's identity only. Each concrete store overrides this to append what is specific to it -- shapes and scale levels for an image, node and edge counts for a graph -- so a new store type gains a populated widget by implementing one method, with nothing to register in the GUI layer.
Every implementation is cheap: it reads metadata the store already holds and never triggers a read of the underlying array. Statistics that would require one (an image's value range, a label image's unique labels) are reported only where the data is already resident in memory.
Returns:
| Type | Description |
|---|---|
DatasetInfo
|
The sections to draw, in display order. |
cellier.data.DataStoreType
module-attribute
¶
DataStoreType = Annotated[Union[MultiscaleZarrDataStore, ImageMemoryStore, OMEZarrImageDataStore, LabelMemoryStore, OMEZarrLabelDataStore, PointsMemoryStore, LinesMemoryStore, MeshMemoryStore, MultiscaleMeshStore, GraphMemoryStore], Field(discriminator='store_type')]
Any data store model, told apart by its store_type field.
The type of the DataManager.stores values; a saved viewer file uses it to
rebuild each store as the right class.
cellier.data.DatasetInfo
dataclass
¶
Everything a dataset-info widget draws for one data store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sections
|
list[RowSection | MatrixSection]
|
The blocks, in display order. Conventionally the first is an
unlabelled |
required |
cellier.data.RowSection
dataclass
¶
(label, value) rows, optionally under their own heading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str or None
|
Heading for the block. |
required |
rows
|
list[tuple[str, str]]
|
The rows, in display order. Both halves are coerced to |
required |
collapsed
|
bool
|
Whether a labelled block starts closed. Ignored when |
False
|
cellier.data.MatrixSection
dataclass
¶
A labelled 2-D array, drawn as a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
Heading for the table, e.g. |
required |
matrix
|
ndarray
|
The values. Formatted by the widget, not here, so a front end can choose its own precision. |
required |
row_labels
|
list[str]
|
Header text. For a homogeneous affine these are the axis names plus a trailing entry for the homogeneous coordinate. |
required |
col_labels
|
list[str]
|
Header text. For a homogeneous affine these are the axis names plus a trailing entry for the homogeneous coordinate. |
required |
Images¶
cellier.data.image.ImageMemoryStore ¶
Bases: BaseDataStore
In-memory image data store backed by a numpy array.
Serves axis-aligned slices or full sub-volumes to the chunk scheduler.
The read itself is synchronous (read_padded); get_data runs
it in the event loop's default executor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The image data. Any dtype; coerced to float32 on construction. Shape convention follows numpy axis order — e.g. (D, H, W) for 3-D, (H, W) for 2-D, (T, C, D, H, W) for 5-D. |
required |
name
|
str
|
Human-readable label. Default |
required |
id
|
UUID4
|
Unique identifier. Taken from the |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
The store's coordinate system, as a one-entry list built by the
caller, with one axis per array dimension. A voxel grid is
sample-indexed, so build its axes with |
required |
level_scales
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_translations
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_transforms
|
list[AffineTransform]
|
The level-0 identity, installed from |
required |
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
level_shapes
property
¶
List with one entry (level 0 = the full array).
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The edge convention: an axis of size voxels spans
[-0.5, size - 0.5]. See
axis_extents.
__setattr__ ¶
Assign a field, announcing the change when it is a data field.
A class-level hook rather than a connection to self.events made
in model_post_init: model_copy(deep=True) -- which
to_model and from_model use -- runs no model_post_init, so
a connection would silently go missing on every copy. Construction
assigns through __dict__ and announces nothing.
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
model_post_init ¶
model_post_init(__context: Any) -> None
Check the systems passed at construction and install their transforms.
Stores that open array handles in their own model_post_init call
this after opening them: the level count and rank it checks against
are read off the handles.
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the array: shape, dtype, value range and footprint.
The value range is a full pass over the array, affordable only
because the data is already resident in RAM. The zarr-backed stores
deliberately omit it (see their dataset_info).
get_data
async
¶
get_data(request: ChunkRequest) -> ndarray
Return the requested sub-region as a float32 array.
Runs read_padded in the event loop's default executor, so a
large slice never blocks the loop.
read_padded ¶
read_padded(request: ChunkRequest) -> ndarray
Return the requested sub-region as a float32 array, synchronously.
Interprets request.axis_selections generically:
intentry → sliced axis; the integer index is applied and the axis is dropped from the output.(start, stop)tuple → displayed axis; a slice is applied and the axis is kept in the output.
Out-of-bounds coordinates are clamped to array extents and zero-padded on the output side so the returned shape always matches what the caller requested.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ChunkRequest
|
Built by the render layer from the current view.
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
float32 array with one dimension per displayed (tuple) axis. |
cellier.data.image.MultiscaleZarrDataStore
pydantic-model
¶
Bases: TensorStoreCacheMixin, BaseDataStore
Data store for a multiscale zarr volume read via tensorstore.
Public fields are validated and serialisable (pydantic).
Tensorstore handles are opened synchronously in model_post_init
and stored as private attributes so they are not serialised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_type
|
Literal['multiscale_zarr']
|
Discriminator field. Always |
required |
zarr_path
|
Path to the root directory of the multiscale zarr store.
Pass as a string; |
required | |
scale_names
|
Ordered list of subdirectory names, finest → coarsest,
e.g. |
required | |
level_scales
|
Per-level, per-axis scale of level-k voxels in level-0 voxels.
|
required | |
level_translations
|
The offset half of the same, in level-0 voxels. |
required | |
id
|
Unique identifier. Taken from the |
required | |
data_coordinate_systems
|
One system per resolution level, finest first. The store reads no
axis metadata, so these come from the caller --
|
required | |
level_transforms
|
Level |
required | |
name
|
Human-readable name for the store (inherited from
|
required |
Attributes:
| Name | Type | Description |
|---|---|---|
n_levels |
int
|
Number of scale levels (length of |
level_shapes |
list[tuple[int, ...]]
|
List of shape tuples, one per level. |
Config:
arbitrary_types_allowed:True
Fields:
-
id(UUID4 | Annotated[str, AfterValidator(lambda x: UUID(x, version=4))]) -
data_coordinate_systems(list[DataCoordinateSystem]) -
level_scales(list[tuple[float, ...]]) -
level_translations(list[tuple[float, ...]]) -
level_transforms(list[AffineTransform]) -
cache_pool_bytes(int) -
request_concurrency(int) -
file_io_concurrency(int | None) -
recheck_cached_data(bool) -
store_type(Literal['multiscale_zarr']) -
zarr_path(str) -
scale_names(list[str]) -
name(str)
Validators:
-
_check_cache_pool_bytes→cache_pool_bytes -
_check_request_concurrency→request_concurrency -
_check_file_io_concurrency→file_io_concurrency -
_validate_level_geometry
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
ndim
property
¶
ndim: int
Number of data dimensions, read off the level-0 handle.
This store reads no axis metadata -- unlike the OME-Zarr readers it
is constructed from bare scale and translation vectors. Its axes
come from a caller's data_coordinate_system or from the scene it
is added to, and this rank is what either must match.
level_shapes
property
¶
Shape for each scale level, finest first.
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The edge convention: an axis of size voxels spans
[-0.5, size - 0.5]. See
axis_extents.
dtype
property
¶
Data type of the underlying arrays.
Read off the level-0 tensorstore handle, which is already open, so
this costs nothing. get_data converts to float32 on the way
out; this reports what is actually on disk.
__setattr__ ¶
Set a field, reopening the handles when the cache settings change.
cache_pool_bytes, request_concurrency and
file_io_concurrency rebuild the pool on a new context.
recheck_cached_data reopens on the same context. Every other
field is set as usual. Assigning the value a field already has is
a no-op, so a redundant write does not throw away a warm cache.
Raises:
| Type | Description |
|---|---|
ValueError
|
If value is out of range for the field. |
RuntimeError
|
If a paint transaction is open on this store. Reopening would leave the paint write buffer holding a handle bound to the discarded pool, so the change is refused until the stroke is committed or aborted. |
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
register_paint_writer ¶
register_paint_writer(writer: Any) -> None
Record the paint write buffer currently open on this store.
Held weakly: a controller that is dropped without tearing down does not leave the store permanently locked.
The first registration reopens the handles with rechecks on, on the same context, so a write from outside this store is not masked by the cache while painting. Registering again while registered (a fresh buffer after an autosave) only swaps the reference. A transaction already open on the old handle is unaffected: it shares the context, so its staged and committed writes are visible through the new handles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
writer
|
Any
|
An object with a |
required |
unregister_paint_writer ¶
Forget the paint write buffer, undoing register_paint_writer.
Reopens the handles with rechecks off again, unless
recheck_cached_data keeps them on.
revalidate_cache ¶
Revalidate every cached chunk once, on its next read.
Reopens the handles on the same context with
recheck_cached_data="open": chunks cached before now are checked
against the kvstore when next read (unchanged ones cost a 304,
changed ones are refetched), then trusted again. Called for every
announced change, so a store another process writes to shows the
new data after notify_changed.
A no-op while rechecks are on, since every read revalidates then, and before the handles are opened.
model_post_init ¶
model_post_init(__context: Any) -> None
Open all tensorstore handles.
Called automatically by pydantic after __init__. The handles
open synchronously, on the constructing thread, so construction
blocks until every level is open; build the store before the event
loop has work to keep responsive.
from_scale_and_translation
classmethod
¶
from_scale_and_translation(*, zarr_path: str, scale_names: list[str], level_scales: list[tuple[float, ...]], level_translations: list[tuple[float, ...]], data_coordinate_system: DataCoordinateSystem | None = None, name: str = 'multiscale zarr data store') -> MultiscaleZarrDataStore
Construct from per-level scale and translation vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zarr_path
|
str
|
Path to the root directory of the multiscale zarr store. |
required |
scale_names
|
list[str]
|
Ordered list of subdirectory names, finest → coarsest. |
required |
level_scales
|
list[tuple[float, ...]]
|
Per-level scale vectors. |
required |
level_translations
|
list[tuple[float, ...]]
|
Per-level translation vectors. |
required |
data_coordinate_system
|
DataCoordinateSystem | None
|
The level-0 coordinate system, one axis per data dimension. The
coarser levels copy its axes (names, types, units and sampling)
with fresh ids, and the store adopts its |
None
|
name
|
str
|
Human-readable name for the store. |
'multiscale zarr data store'
|
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the pyramid: path, dtype, and the per-level geometry.
No value range: unlike the in-memory stores, computing one here would mean reading every level-0 chunk off disk or over the network.
The per-level scale rows are derived from level_scales
rather than asserted -- the examples used to hardcode strings like
"2x isotropic" that no longer matched an anisotropic pyramid.
get_data
async
¶
get_data(request: ChunkRequest) -> ndarray
Read a single padded brick, returning a zero-padded float32 array.
Interprets request.axis_selections generically: displayed axes
(tuple ranges) become slice dimensions in the output; sliced axes
(int values) become point selections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ChunkRequest
|
Padded brick specification. Coordinates may be negative or exceed store bounds; clamping is handled internally. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
out |
ndarray
|
|
cellier.data.image.OMEZarrImageDataStore
pydantic-model
¶
Bases: TensorStoreCacheMixin, BaseDataStore
Data store for an OME-Zarr v0.5 image read via tensorstore.
Use the from_path class method to construct from an OME-Zarr URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_type
|
Literal['ome_zarr_image']
|
Discriminator field. Always |
required |
zarr_path
|
str
|
URI to the root OME-Zarr group. Must start with |
required |
multiscale_index
|
int
|
Index into |
required |
scale_names
|
list[str]
|
Per-level relative array paths, finest to coarsest. |
required |
level_scales
|
list[tuple[float, ...]]
|
Full-rank (all axes) per-level scale: level-k voxels in level-0 voxels. Level 0 is all ones by construction. |
required |
level_translations
|
list[tuple[float, ...]]
|
The offset half of the same, in level-0 voxels. |
required |
physical_scale
|
list[float]
|
Level-0 data-to-world scale per axis, i.e. the OME global scale
composed with the level-0 dataset scale. |
required |
physical_translation
|
list[float]
|
Level-0 data-to-world translation per axis, the companion to
|
required |
channel_labels
|
list[str] or None
|
One name per channel, in channel-index order, from the image's
|
required |
name
|
str
|
Human-readable name for the store. |
required |
id
|
UUID4
|
Unique identifier. Taken from the |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
One system per resolution level, finest first, and the store's only
record of its axis names, types and units. |
required |
level_transforms
|
list[AffineTransform]
|
Level |
required |
anonymous
|
bool
|
When True, read an |
required |
cache_pool_bytes
|
int
|
Chunk cache cap for this store, in bytes, shared by all of its
resolution levels. |
required |
request_concurrency
|
int
|
Requests outstanding at once against a remote kvstore. No effect on a local store. |
required |
file_io_concurrency
|
int or None
|
Reads outstanding at once against the local filesystem. |
required |
recheck_cached_data
|
bool
|
Revalidate cached chunks on every read. Default False. |
required |
Config:
arbitrary_types_allowed:True
Fields:
-
id(UUID4 | Annotated[str, AfterValidator(lambda x: UUID(x, version=4))]) -
data_coordinate_systems(list[DataCoordinateSystem]) -
level_scales(list[tuple[float, ...]]) -
level_translations(list[tuple[float, ...]]) -
level_transforms(list[AffineTransform]) -
cache_pool_bytes(int) -
request_concurrency(int) -
file_io_concurrency(int | None) -
recheck_cached_data(bool) -
store_type(Literal['ome_zarr_image']) -
zarr_path(str) -
multiscale_index(int) -
scale_names(list[str]) -
physical_scale(list[float]) -
physical_translation(list[float]) -
channel_labels(list[str] | None) -
anonymous(bool) -
name(str)
Validators:
-
_check_cache_pool_bytes→cache_pool_bytes -
_check_request_concurrency→request_concurrency -
_check_file_io_concurrency→file_io_concurrency
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
level_shapes
property
¶
Full-rank shape per level (all axes), finest first.
Returns shapes over all axes, including non-spatial ones.
The controller projects to the displayed subshape using
dims.displayed_axes before constructing the render visual.
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The edge convention: an axis of size voxels spans
[-0.5, size - 0.5]. See
axis_extents.
__setattr__ ¶
Set a field, reopening the handles when the cache settings change.
cache_pool_bytes, request_concurrency and
file_io_concurrency rebuild the pool on a new context.
recheck_cached_data reopens on the same context. Every other
field is set as usual. Assigning the value a field already has is
a no-op, so a redundant write does not throw away a warm cache.
Raises:
| Type | Description |
|---|---|
ValueError
|
If value is out of range for the field. |
RuntimeError
|
If a paint transaction is open on this store. Reopening would leave the paint write buffer holding a handle bound to the discarded pool, so the change is refused until the stroke is committed or aborted. |
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
register_paint_writer ¶
register_paint_writer(writer: Any) -> None
Record the paint write buffer currently open on this store.
Held weakly: a controller that is dropped without tearing down does not leave the store permanently locked.
The first registration reopens the handles with rechecks on, on the same context, so a write from outside this store is not masked by the cache while painting. Registering again while registered (a fresh buffer after an autosave) only swaps the reference. A transaction already open on the old handle is unaffected: it shares the context, so its staged and committed writes are visible through the new handles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
writer
|
Any
|
An object with a |
required |
unregister_paint_writer ¶
Forget the paint write buffer, undoing register_paint_writer.
Reopens the handles with rechecks off again, unless
recheck_cached_data keeps them on.
revalidate_cache ¶
Revalidate every cached chunk once, on its next read.
Reopens the handles on the same context with
recheck_cached_data="open": chunks cached before now are checked
against the kvstore when next read (unchanged ones cost a 304,
changed ones are refetched), then trusted again. Called for every
announced change, so a store another process writes to shows the
new data after notify_changed.
A no-op while rechecks are on, since every read revalidates then, and before the handles are opened.
model_post_init ¶
model_post_init(__context: Any) -> None
Open all TensorStore handles (synchronous, before QtAsyncio).
from_path
classmethod
¶
from_path(zarr_path: str, *, multiscale_index: int = 0, series_index: int = 0, anonymous: bool = False, cache_pool_bytes: int = DEFAULT_CACHE_POOL_BYTES, request_concurrency: int = DEFAULT_REQUEST_CONCURRENCY, file_io_concurrency: int | None = None, recheck_cached_data: bool = False, data_coordinate_system: DataCoordinateSystem | None = None, name: str = 'ome zarr image data store') -> OMEZarrImageDataStore
Construct from an OME-Zarr v0.5 URI.
Supports both standard Image stores and Bf2Raw (bioformats2raw) multi-series containers. For Bf2Raw stores the series_index selects which child image to open.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zarr_path
|
str
|
URI with a scheme prefix: |
required |
multiscale_index
|
int
|
Which |
0
|
series_index
|
int
|
For Bf2Raw containers, which image series to open. Ignored for standard Image stores. Defaults to 0. |
0
|
anonymous
|
bool
|
When True, read an |
False
|
cache_pool_bytes
|
int
|
Chunk cache cap for this store, in bytes, shared by all of its
resolution levels. |
DEFAULT_CACHE_POOL_BYTES
|
request_concurrency
|
int
|
Requests outstanding at once against a remote kvstore. Raise it
together with |
DEFAULT_REQUEST_CONCURRENCY
|
file_io_concurrency
|
int or None
|
Reads outstanding at once against the local filesystem. |
None
|
recheck_cached_data
|
bool
|
Revalidate cached chunks on every read. Set it when another process writes this data while it is open. Default False. |
False
|
data_coordinate_system
|
DataCoordinateSystem or None
|
The level-0 coordinate system, one axis per array dimension.
|
None
|
name
|
str
|
Human-readable name for the store. |
'ome zarr image data store'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the URI scheme is not supported, the series index is out of range, an NGFF axis has an empty type and no data_coordinate_system is passed, or the passed system does not have one axis per array dimension. |
TypeError
|
If the OME metadata is neither Image nor Bf2Raw (e.g. a Plate). |
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the store from metadata it already holds.
Reads only fields parsed at construction plus the open tensorstore
handles' shapes and dtype -- it never re-opens the group, which for
an s3:// store would mean a network round trip every time an
appearance panel is built.
No value range, for the same reason: it would be a full read of level 0.
get_data
async
¶
get_data(request: ChunkRequest) -> ndarray
Read a single padded brick, returning a zero-padded float32 array.
Interprets request.axis_selections generically: displayed axes
(tuple ranges) become slice dimensions in the output; sliced axes
(int values) become point selections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ChunkRequest
|
Padded brick specification. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
|
cellier.data.image.ChunkRequest ¶
Bases: NamedTuple
A request for one padded brick / chunk of data.
All coordinates encode the padded region including overlap. They
may be negative or exceed the store bounds; get_data() on the
MultiscaleZarrDataStore is responsible for clamping and
zero-padding so the returned array always has the full requested
shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk_request_id
|
Unique ID for this individual chunk. |
required | |
slice_request_id
|
Shared ID for all chunks that belong to the same planning event. |
required | |
scale_index
|
0-based index into |
required | |
axis_selections
|
Per-axis selection in data axis order. Each element is either:
- |
required |
Labels¶
cellier.data.label.LabelMemoryStore ¶
Bases: BaseDataStore
In-memory label data store backed by a numpy integer array.
Serves axis-aligned slices or full sub-volumes as int32 arrays. Source dtype may be int8, int16, or int32; int64/uint* are rejected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
Integer label array (int8, int16, or int32). Shape follows numpy axis order — e.g. (D, H, W) for 3-D, (H, W) for 2-D. Deserialisation also accepts the |
required |
name
|
str
|
Human-readable label. Default |
required |
id
|
UUID4
|
Unique identifier. Taken from the |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
The store's coordinate system, as a one-entry list built by the
caller, with one axis per array dimension. A voxel grid is
sample-indexed, so build its axes with |
required |
level_scales
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_translations
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_transforms
|
list[AffineTransform]
|
The level-0 identity, installed from |
required |
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The edge convention: an axis of size voxels spans
[-0.5, size - 0.5]. See
axis_extents.
__setattr__ ¶
Assign a field, announcing the change when it is a data field.
A class-level hook rather than a connection to self.events made
in model_post_init: model_copy(deep=True) -- which
to_model and from_model use -- runs no model_post_init, so
a connection would silently go missing on every copy. Construction
assigns through __dict__ and announces nothing.
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
model_post_init ¶
model_post_init(__context: Any) -> None
Check the systems passed at construction and install their transforms.
Stores that open array handles in their own model_post_init call
this after opening them: the level count and rank it checks against
are read off the handles.
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the array, including how many distinct labels it holds.
The label count is a full pass over the array (np.unique), which
is affordable only because the data is already resident in RAM.
OMEZarrLabelDataStore deliberately omits it: there the same row
would mean reading every chunk off disk.
get_data
async
¶
get_data(request: ChunkRequest) -> ndarray
Return the requested sub-region as an int32 array.
Runs read_padded in the event loop's default executor.
read_padded ¶
read_padded(request: ChunkRequest) -> ndarray
Return the requested sub-region as an int32 array, synchronously.
Interprets request.axis_selections generically:
- int entry → sliced axis (dropped from output)
- (start, stop) tuple → displayed axis (kept in output)
Out-of-bounds coordinates are clamped and zero-padded. Always returns int32 regardless of source dtype.
cellier.data.label.OMEZarrLabelDataStore
pydantic-model
¶
Bases: TensorStoreCacheMixin, BaseDataStore
Multiscale OME-Zarr label store returning int32 bricks.
Use the from_path class method to construct from a URI that
points to an OME-NGFF label group (containing ome → multiscales
metadata).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_type
|
Literal['ome_zarr_label']
|
Discriminator field. Always |
required |
zarr_path
|
str
|
URI to the label group. Must point to the label sub-group
(e.g. |
required |
multiscale_index
|
int
|
Which multiscale entry to use (default 0). |
required |
scale_names
|
list[str]
|
Per-level relative array paths, finest to coarsest. |
required |
level_scales
|
list[tuple[float, ...]]
|
Full-rank per-level scale: level-k voxels in level-0 voxels. |
required |
level_translations
|
list[tuple[float, ...]]
|
The offset half of the same, in level-0 voxels. |
required |
physical_scale
|
list[float]
|
Level-0 data-to-world scale per axis, i.e. the OME global scale
composed with the level-0 dataset scale. |
required |
physical_translation
|
list[float]
|
Level-0 data-to-world translation per axis, the companion to
|
required |
name
|
str
|
Human-readable name for the store. |
required |
id
|
UUID4
|
Unique identifier. Taken from the |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
One system per resolution level, finest first, and the store's only
record of its axis names, types and units. |
required |
level_transforms
|
list[AffineTransform]
|
Level |
required |
anonymous
|
bool
|
When True, read an |
required |
cache_pool_bytes
|
int
|
Chunk cache cap for this store, in bytes, shared by all of its
resolution levels. |
required |
request_concurrency
|
int
|
Requests outstanding at once against a remote kvstore. No effect on a local store. |
required |
file_io_concurrency
|
int or None
|
Reads outstanding at once against the local filesystem. |
required |
recheck_cached_data
|
bool
|
Revalidate cached chunks on every read. Default False. |
required |
Config:
arbitrary_types_allowed:True
Fields:
-
id(UUID4 | Annotated[str, AfterValidator(lambda x: UUID(x, version=4))]) -
data_coordinate_systems(list[DataCoordinateSystem]) -
level_scales(list[tuple[float, ...]]) -
level_translations(list[tuple[float, ...]]) -
level_transforms(list[AffineTransform]) -
cache_pool_bytes(int) -
request_concurrency(int) -
file_io_concurrency(int | None) -
recheck_cached_data(bool) -
store_type(Literal['ome_zarr_label']) -
zarr_path(str) -
multiscale_index(int) -
scale_names(list[str]) -
physical_scale(list[float]) -
physical_translation(list[float]) -
anonymous(bool) -
name(str)
Validators:
-
_check_cache_pool_bytes→cache_pool_bytes -
_check_request_concurrency→request_concurrency -
_check_file_io_concurrency→file_io_concurrency
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
level_shapes
property
¶
Full-rank shape per level (all axes), finest first.
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The edge convention: an axis of size voxels spans
[-0.5, size - 0.5]. See
axis_extents.
__setattr__ ¶
Set a field, reopening the handles when the cache settings change.
cache_pool_bytes, request_concurrency and
file_io_concurrency rebuild the pool on a new context.
recheck_cached_data reopens on the same context. Every other
field is set as usual. Assigning the value a field already has is
a no-op, so a redundant write does not throw away a warm cache.
Raises:
| Type | Description |
|---|---|
ValueError
|
If value is out of range for the field. |
RuntimeError
|
If a paint transaction is open on this store. Reopening would leave the paint write buffer holding a handle bound to the discarded pool, so the change is refused until the stroke is committed or aborted. |
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
register_paint_writer ¶
register_paint_writer(writer: Any) -> None
Record the paint write buffer currently open on this store.
Held weakly: a controller that is dropped without tearing down does not leave the store permanently locked.
The first registration reopens the handles with rechecks on, on the same context, so a write from outside this store is not masked by the cache while painting. Registering again while registered (a fresh buffer after an autosave) only swaps the reference. A transaction already open on the old handle is unaffected: it shares the context, so its staged and committed writes are visible through the new handles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
writer
|
Any
|
An object with a |
required |
unregister_paint_writer ¶
Forget the paint write buffer, undoing register_paint_writer.
Reopens the handles with rechecks off again, unless
recheck_cached_data keeps them on.
revalidate_cache ¶
Revalidate every cached chunk once, on its next read.
Reopens the handles on the same context with
recheck_cached_data="open": chunks cached before now are checked
against the kvstore when next read (unchanged ones cost a 304,
changed ones are refetched), then trusted again. Called for every
announced change, so a store another process writes to shows the
new data after notify_changed.
A no-op while rechecks are on, since every read revalidates then, and before the handles are opened.
model_post_init ¶
model_post_init(__context: Any) -> None
Open all TensorStore handles (synchronous, before QtAsyncio).
from_path
classmethod
¶
from_path(zarr_path: str, *, multiscale_index: int = 0, anonymous: bool = False, cache_pool_bytes: int = DEFAULT_CACHE_POOL_BYTES, request_concurrency: int = DEFAULT_REQUEST_CONCURRENCY, file_io_concurrency: int | None = None, recheck_cached_data: bool = False, data_coordinate_system: DataCoordinateSystem | None = None, name: str = 'ome zarr label data store') -> OMEZarrLabelDataStore
Construct from a URI pointing directly at an OME-NGFF label group.
The URI must point at a zarr group that carries ome.multiscales
metadata (i.e. the label sub-group itself, not the root OME-Zarr).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zarr_path
|
str
|
URI with a scheme prefix: |
required |
multiscale_index
|
int
|
Which |
0
|
anonymous
|
bool
|
When True, read an |
False
|
cache_pool_bytes
|
int
|
Chunk cache cap for this store, in bytes, shared by all of its
resolution levels. |
DEFAULT_CACHE_POOL_BYTES
|
request_concurrency
|
int
|
Requests outstanding at once against a remote kvstore. Raise it
together with |
DEFAULT_REQUEST_CONCURRENCY
|
file_io_concurrency
|
int or None
|
Reads outstanding at once against the local filesystem. |
None
|
recheck_cached_data
|
bool
|
Revalidate cached chunks on every read. Set it when another process writes this data while it is open. Default False. |
False
|
data_coordinate_system
|
DataCoordinateSystem or None
|
The level-0 coordinate system, one axis per array dimension.
|
None
|
name
|
str
|
Human-readable name for the store. |
'ome zarr label data store'
|
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the store from metadata it already holds.
Like the image store, this never re-opens the group and never reads
array data -- so no label count, which would require a full pass
over level 0. LabelMemoryStore reports one because its data is
already in RAM.
The Data type row names the on-disk dtype and the int32 the
store hands out, which differ whenever the source is int8 or int16.
get_data
async
¶
Read a padded brick, returning int32 (zero-padded for out-of-bounds).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ChunkRequest
|
Padded brick specification with |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
int32 array. |
Points¶
cellier.data.points.PointsMemoryStore ¶
Bases: BaseDataStore
In-memory point-cloud data store backed by numpy arrays.
get_data runs the filter in the event loop's default executor, so
a large cloud does not stall the loop; read is the same
filter, synchronous.
Positions are stored in data-axis order: column 0 is axis 0 (z),
column 1 is axis 1 (y), column 2 is axis 2 (x). The render layer
applies the [:, [2, 1, 0]] reversal before uploading to pygfx.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
(n_points, ndim) float32 array. |
required |
colors
|
ndarray | None
|
(n_points, 4) float32 RGBA, index-matched to positions. Pass None for uniform-color rendering. |
required |
sizes
|
ndarray | None
|
(n_points,) float32 per-point sizes. Pass None for uniform-size rendering. |
required |
name
|
str
|
Human-readable label. |
required |
id
|
UUID4
|
Unique identifier. Taken from the |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
The store's coordinate system, as a one-entry list built by the
caller, with one axis per |
required |
level_scales
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_translations
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_transforms
|
list[AffineTransform]
|
The level-0 identity, installed from |
required |
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The bounding box of the points, with no padding -- a vertex is a point,
not a cell, so there is no half-voxel to add. None when the
store is empty. See
axis_extents.
color_mode
property
¶
color_mode: str
"vertex" when per-point colors are present, else "uniform".
Descriptive only. It reports what this store carries; it does not decide what the material does. Where RGB comes from is declared on the appearance and honoured verbatim -- the render layer never infers it from the data and never writes it back at commit time.
__setattr__ ¶
Assign a field, announcing the change when it is a data field.
A class-level hook rather than a connection to self.events made
in model_post_init: model_copy(deep=True) -- which
to_model and from_model use -- runs no model_post_init, so
a connection would silently go missing on every copy. Construction
assigns through __dict__ and announces nothing.
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
model_post_init ¶
model_post_init(__context: Any) -> None
Check the systems passed at construction and install their transforms.
Stores that open array handles in their own model_post_init call
this after opening them: the level count and rank it checks against
are read off the handles.
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the point cloud: count, dimensionality, extent, footprint.
color_mode and size_mode are deliberately absent: they
describe how the points are drawn, not what the store holds, and
the appearance model is where a reader should look for that.
get_data
async
¶
get_data(request: PointsSliceRequest) -> PointsData
Return proximity-filtered point data for request.
The filter (read) runs in the loop's default executor. A
filter that raises because the store changed under it fails this
read; the change's invalidation reads again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
PointsSliceRequest
|
Planned by the render layer from the current view. |
required |
Returns:
| Type | Description |
|---|---|
PointsData
|
Proximity-filtered, projected points ready for GPU upload.
|
read ¶
read(request: PointsSliceRequest) -> PointsData
The filter of get_data, run on the calling thread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
PointsSliceRequest
|
Planned by the render layer from the current view. |
required |
Returns:
| Type | Description |
|---|---|
PointsData
|
Proximity-filtered, projected points ready for GPU upload.
|
cellier.data.points.PointsSliceRequest ¶
Bases: NamedTuple
Request for one proximity-filtered slice of points data.
The first three fields are the request fields every store request carries: ids that are fresh per plan (never in a cache key) and the level, always 0 here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slice_request_id
|
UUID
|
Shared ID for all requests in one planning event. |
required |
chunk_request_id
|
UUID
|
Per-request ID. For points (never tiled) this equals
|
required |
scale_index
|
int
|
Always 0 — no LOD levels. Present for parity with the image requests. |
required |
displayed_axes
|
tuple[int, ...]
|
Axis indices rendered in the canvas (2 for 2D, 3 for 3D). |
required |
retained_axes
|
tuple[int, ...]
|
The data axes this visual's geometry keeps, ascending. Not the same list as |
required |
region
|
ConvexRegion
|
The selected region, already pulled back into data
coordinates. It is the whole filter -- one Required: comparing a world position against data coordinates instead could, on a 2 um z spacing, show a point 24 um off the slice plane and hide the three that are on it. |
required |
fold_axes
|
tuple[int, ...]
|
Collapsed data axes whose columns the store also returns, for the render layer's per-element fold. Empty in every view where no collapsed axis reaches a displayed one. |
required |
cellier.data.points.PointsData
dataclass
¶
Proximity-filtered points data returned by PointsMemoryStore.get_data().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_id
|
UUID
|
Echo of PointsSliceRequest.slice_request_id. |
required |
positions
|
ndarray
|
(n_points, n_displayed_dims) float32. Projected onto displayed axes; padded to 3D in the render layer. |
required |
colors
|
ndarray | None
|
(n_points, 4) float32 RGBA, index-matched to positions. None when the store carries no per-point colors. |
required |
sizes
|
ndarray | None
|
(n_points,) float32 per-point sizes. None when the store carries no per-point sizes. |
required |
color_mode
|
str
|
|
'uniform'
|
size_mode
|
str
|
|
'uniform'
|
is_empty
|
bool
|
True when the proximity filter produced zero surviving points and a placeholder geometry was returned. |
False
|
original_indices
|
ndarray | None
|
(n_points,) int array mapping each row of |
None
|
fold_positions
|
ndarray | None
|
|
None
|
Lines¶
cellier.data.lines.LinesMemoryStore ¶
Bases: BaseDataStore
In-memory line-segment data store backed by numpy arrays.
Stores a collection of line segments as vertex pairs. For segment n,
positions[n * 2] is the start point and positions[n * 2 + 1]
is the end point.
Positions are stored in data-axis order: column 0 is axis 0 (z),
column 1 is axis 1 (y), column 2 is axis 2 (x). The render layer
applies the [:, [2, 1, 0]] reversal before uploading to pygfx.
get_data runs the filter in the event loop's default executor, so
a large set of segments does not stall the loop; read is the
same filter, synchronous.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
(n_vertices, ndim) float32 array. Must have an even number of rows. |
required |
colors
|
ndarray | None
|
(n_vertices, 4) float32 RGBA, index-matched to positions. Pass None for uniform-color rendering. |
required |
name
|
str
|
Human-readable label. |
required |
id
|
UUID4
|
Unique identifier. Taken from the |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
The store's coordinate system, as a one-entry list built by the
caller, with one axis per |
required |
level_scales
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_translations
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_transforms
|
list[AffineTransform]
|
The level-0 identity, installed from |
required |
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The bounding box of the vertices, with no padding -- a vertex is a point,
not a cell, so there is no half-voxel to add. None when the
store is empty. See
axis_extents.
color_mode
property
¶
color_mode: str
"vertex" when per-vertex colors are present, else "uniform".
Descriptive only. It reports what this store carries; it does not decide what the material does. Where RGB comes from is declared on the appearance and honoured verbatim -- the render layer never infers it from the data and never writes it back at commit time.
__setattr__ ¶
Assign a field, announcing the change when it is a data field.
A class-level hook rather than a connection to self.events made
in model_post_init: model_copy(deep=True) -- which
to_model and from_model use -- runs no model_post_init, so
a connection would silently go missing on every copy. Construction
assigns through __dict__ and announces nothing.
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
model_post_init ¶
model_post_init(__context: Any) -> None
Check the systems passed at construction and install their transforms.
Stores that open array handles in their own model_post_init call
this after opening them: the level count and rank it checks against
are read off the handles.
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the segments: count, dimensionality, extent, footprint.
The vertex count is spelled out beside the segment count to make the
two-vertices-per-segment layout visible; a reader comparing this
block against the raw array would otherwise see twice what they
expect. color_mode is absent -- it is a display property.
get_data
async
¶
get_data(request: LinesSliceRequest) -> LinesData
Return slab-filtered segment data for request.
The filter (read) runs in the loop's default executor. A
filter that raises because the store changed under it fails this
read; the change's invalidation reads again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
LinesSliceRequest
|
Planned by the render layer from the current view. |
required |
Returns:
| Type | Description |
|---|---|
LinesData
|
Filtered, projected segment data ready for GPU upload. |
read ¶
read(request: LinesSliceRequest) -> LinesData
The filter of get_data, run on the calling thread.
A segment survives when both of its endpoints lie inside the request's region: the slab around the current slice, which is tilted in a rotated view. When the request carries clipping planes, each surviving segment is then cut at the planes; a segment entirely on the clipped side is dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
LinesSliceRequest
|
Planned by the render layer from the current view. |
required |
Returns:
| Type | Description |
|---|---|
LinesData
|
Filtered, projected segment data ready for GPU upload.
|
cellier.data.lines.LinesSliceRequest ¶
Bases: NamedTuple
Request for one slab-filtered slice of line-segment data.
The first three fields are the request fields every store request carries: ids that are fresh per plan (never in a cache key) and the level, always 0 here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slice_request_id
|
UUID
|
Shared ID for all requests in one planning event. |
required |
chunk_request_id
|
UUID
|
Per-request ID. For lines (never tiled) this equals
|
required |
scale_index
|
int
|
Always 0 — no LOD levels. Present for parity with the image requests. |
required |
displayed_axes
|
tuple[int, ...]
|
Axis indices rendered in the canvas (2 for 2D, 3 for 3D). |
required |
retained_axes
|
tuple[int, ...]
|
The data axes this visual's geometry keeps, ascending. Not the same list as |
required |
region
|
ConvexRegion
|
The selected region, already pulled back into data
coordinates. It is the whole filter -- one Required: comparing a world position against data coordinates instead could, on a 2 um z spacing, show a vertex 24 um off the slice plane and hide the ones that are on it. |
required |
clip_planes
|
tuple[tuple[tuple[float, ...], float], ...]
|
Clipping planes the read applies on the CPU, as |
required |
fold_axes
|
tuple[int, ...]
|
Collapsed data axes whose columns the store also returns, for the render layer's per-element fold. |
required |
cellier.data.lines.LinesData
dataclass
¶
Slab-filtered line-segment data returned by LinesMemoryStore.get_data().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_id
|
UUID
|
Echo of LinesSliceRequest.slice_request_id. |
required |
positions
|
ndarray
|
(n_vertices, n_displayed_dims) float32. n_vertices is always even;
pair |
required |
colors
|
ndarray | None
|
(n_vertices, 4) float32 RGBA, index-matched to positions. None when the store carries no per-vertex colors. |
required |
color_mode
|
str
|
|
'uniform'
|
is_empty
|
bool
|
True when the slab filter produced zero surviving segments and a placeholder geometry was returned. |
False
|
original_edge_indices
|
ndarray | None
|
(n_segments,) int array mapping each rendered segment to its edge
index in the store's full segment array. This is the slab filter's
surviving-segment list; in a full 3-D view it is the identity
|
None
|
fold_positions
|
ndarray | None
|
|
None
|
Meshes¶
cellier.data.mesh.MeshMemoryStore ¶
Bases: BaseDataStore
In-memory triangle mesh data store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
(n_vertices, N) float32 vertex positions for any world dimensionality N ≥ 2. For a 3-D scene use shape (n_vertices, 3); for a 4-D scene (t, z, y, x) use shape (n_vertices, 4). |
required |
indices
|
ndarray
|
(n_faces, 3) int32 triangle face indices. Must be int32 — pygfx rejects int64 at upload time. int64 input is coerced silently by the validator. |
required |
colors
|
ndarray | None
|
Per-vertex (n_vertices, 4) or per-face (n_faces, 4) float32 RGBA.
Which of the two is declared by |
required |
colors_layout
|
str | None
|
This used to be inferred by comparing |
required |
name
|
str
|
Human-readable label. |
required |
id
|
UUID4
|
Unique identifier. Taken from the |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
The store's coordinate system, as a one-entry list built by the
caller, with one axis per |
required |
level_scales
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_translations
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_transforms
|
list[AffineTransform]
|
The level-0 identity, installed from |
required |
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
ndim
property
¶
ndim: int
Number of spatial dimensions per vertex.
Present for parity with the points and lines stores, which the mesh
store previously lacked -- every caller had to reach into
positions.shape[1] itself.
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The bounding box of the vertices, with no padding -- a vertex is a point,
not a cell, so there is no half-voxel to add. None when the
store is empty. See
axis_extents.
colors_mode
property
¶
colors_mode: str
'vertex', 'face', or 'none' -- the declared layout.
Reads colors_layout rather than comparing array lengths. The
old inference reported per-vertex colours as per-face on any mesh
with as many vertices as faces.
__setattr__ ¶
Assign a field, announcing the change when it is a data field.
A class-level hook rather than a connection to self.events made
in model_post_init: model_copy(deep=True) -- which
to_model and from_model use -- runs no model_post_init, so
a connection would silently go missing on every copy. Construction
assigns through __dict__ and announces nothing.
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
model_post_init ¶
model_post_init(__context: Any) -> None
Check the systems passed at construction and install their transforms.
Stores that open array handles in their own model_post_init call
this after opening them: the level count and rank it checks against
are read off the handles.
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the mesh: vertex and face counts, extent, footprint.
colors_mode is deliberately absent: it describes how the mesh is
drawn, not what the store holds.
Closed says whether the surface is watertight, which decides
whether a 2D section of it can be filled: an open surface draws its
outline only. It is worked out by the first 2D section read, so it
reads "not computed" before one.
level_arrays ¶
level_arrays(level: int = 0) -> MeshLevelArrays
The arrays of level; this store has level 0 only.
level_cache ¶
level_cache(level: int = 0) -> LevelCache
What the reads of level share (normals, bounds indexes).
get_data
async
¶
get_data(request: MeshSliceRequest) -> MeshData | MeshSectionData
Return the mesh sliced for request, upload-ready.
The work runs in an executor thread, so the event loop stays free. There are no cancellation checkpoints: the chunk scheduler, which issues these reads, never cancels one.
What comes back depends on request.section:
None(a 3D view, or a 2D view of a mesh with no extent across the slice): whole faces. A face survives only when all of its vertices are inside the request's region, the mesh analogue of the lines store's "both endpoints must pass" rule. The result is aMeshData.- set (a 2D view that cuts the mesh): the mesh cut by the slice
plane or slab, as a
MeshSectionData-- the outline and fill of the cross-section -- not a face-by-face filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
MeshSliceRequest
|
Built by the render layer from the current view. |
required |
Returns:
| Type | Description |
|---|---|
MeshData or MeshSectionData
|
Reindexed, projected geometry ready for GPU upload.
|
cellier.data.mesh.MultiscaleMeshStore ¶
Bases: BaseDataStore
In-memory triangle mesh with levels of detail.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
levels
|
list[MeshLevel]
|
The mesh at each level, finest first, at least one. Every level
is the same surface in the same data coordinates: there is one data
coordinate system and no per-level transform. Every level has the
same number of position columns. Either every level has colours,
all with the same |
required |
name
|
str
|
Human-readable label. |
required |
id
|
UUID4
|
Unique identifier. Taken from the |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
The store's coordinate system, as a one-entry list, with one axis per position column. Empty by default, in which case the store takes the scene's world axes when it is added to a scene. |
required |
Notes
Level numbers here and on a request (scale_index) are 0-based, 0 the
finest. A visual's GeometryLodConfig.coarse_level is 1-based, like
the image settings.
The store's extent is level 0's. Build levels with quadric decimation rather than quadric clustering: a decimated level stays watertight, so its 2D section still closes and is filled.
Reassigning levels announces a change. A level is frozen; to change
one, assign a new list.
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
axis_extents
property
¶
Per-axis (low, high) of the finest level's vertices.
None when that level is empty. See
axis_extents.
__setattr__ ¶
Assign a field, announcing the change when it is a data field.
A class-level hook rather than a connection to self.events made
in model_post_init: model_copy(deep=True) -- which
to_model and from_model use -- runs no model_post_init, so
a connection would silently go missing on every copy. Construction
assigns through __dict__ and announces nothing.
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
model_post_init ¶
model_post_init(__context: Any) -> None
Check the systems passed at construction and install their transforms.
Stores that open array handles in their own model_post_init call
this after opening them: the level count and rank it checks against
are read off the handles.
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the mesh: its levels, extent and footprint.
Closed says, per level, whether the surface is watertight, which
decides whether a 2D section of that level can be filled. It is
worked out by the level's first 2D section read.
level_arrays ¶
level_arrays(level: int = 0) -> MeshLevelArrays
The arrays of level (0 is the finest).
level_cache ¶
level_cache(level: int = 0) -> LevelCache
What the reads of level share (normals, bounds indexes).
get_data
async
¶
get_data(request: MeshSliceRequest) -> MeshData | MeshSectionData
Return one level, sliced and upload-ready.
The same read as MeshMemoryStore.get_data, on the level the
request names (scale_index, 0 the finest). It runs in an
executor thread, with no cancellation checkpoints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
MeshSliceRequest
|
Built by the render layer from the current view. |
required |
Returns:
| Type | Description |
|---|---|
MeshData or MeshSectionData
|
The level's faces inside the request's region, or its section.
|
cellier.data.mesh.MeshLevel
pydantic-model
¶
Bases: CellierModel
One level of detail of a mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
|
required |
indices
|
ndarray
|
|
required |
colors
|
ndarray or None
|
Per-vertex |
required |
colors_layout
|
('vertex', 'face')
|
Required whenever |
"vertex"
|
A
|
|
required | |
the
|
|
required |
Config:
arbitrary_types_allowed:Truefrozen:True
Fields:
-
positions(ndarray) -
indices(ndarray) -
colors(ndarray | None) -
colors_layout(Literal['vertex', 'face'] | None)
Validators:
-
_coerce_positions→positions -
_coerce_indices→indices -
_coerce_colors→colors -
_check_shapes
cellier.data.mesh.MeshSliceRequest ¶
Bases: NamedTuple
Request for one slab-filtered slice of one level of a mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slice_request_id
|
UUID
|
Shared ID for all requests in one planning event. |
required |
chunk_request_id
|
UUID
|
Per-request ID. For mesh (never tiled) this equals
|
required |
scale_index
|
int
|
The level to read, 0 the finest. A single-level store has level 0 only. |
required |
displayed_axes
|
tuple[int, ...]
|
Axis indices rendered in the canvas. |
required |
retained_axes
|
tuple[int, ...]
|
The data axes this visual's geometry keeps, ascending. Not the same list as |
required |
region
|
ConvexRegion
|
The selected region, already pulled back into data coordinates. It is the whole filter: a face survives when all three of its vertices are inside. |
required |
output_axes
|
tuple[int, ...]
|
The data axes to emit, in the column order of the result. The
render visual passes |
required |
section
|
MeshSectionRequest or None
|
|
required |
cellier.data.mesh.MeshData
dataclass
¶
One level of a mesh at one request, ready to upload.
Returned by a mesh store's get_data. Every array is contiguous and
in the dtype and column order the GPU takes, so the render visual builds
a gfx.Geometry from it without a copy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_id
|
UUID
|
Echo of MeshSliceRequest.slice_request_id. |
required |
positions
|
ndarray
|
|
required |
indices
|
ndarray
|
(n_faces, 3) int32. Reindexed to reference only the vertices
in |
required |
normals
|
ndarray | None
|
|
required |
colors
|
ndarray | None
|
Per-vertex (n_vertices, 4) or per-face (n_faces, 4) float32 RGBA. None when the store carries no color data. |
required |
color_mode
|
str
|
|
'vertex'
|
is_empty
|
bool
|
True when the slab contained no surviving faces and a placeholder geometry was returned. |
False
|
original_face_indices
|
ndarray | None
|
(n_faces,) int array mapping each row of |
None
|
level
|
int
|
The level the data is of, 0 the finest. |
0
|
bounds
|
ndarray | None
|
|
None
|
cellier.data.mesh.MeshSectionData
dataclass
¶
One level of a mesh cut by a plane or slab, ready to upload.
Returned by a mesh store's get_data for a request with a
section. Positions are (n, 3) float32 in the request's
output_axes order with zeros in the third column.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_id
|
UUID
|
Echo of |
required |
level
|
int
|
The level the data is of, 0 the finest. |
required |
fill_positions
|
ndarray
|
|
required |
fill_indices
|
ndarray
|
|
required |
fill_colors
|
ndarray or None
|
|
required |
fill_face_ids
|
ndarray
|
|
required |
outline_positions
|
ndarray
|
|
required |
outline_colors
|
ndarray or None
|
|
required |
outline_face_ids
|
ndarray
|
|
required |
color_mode
|
str
|
The store's colour layout, |
'vertex'
|
is_empty
|
bool
|
Neither part has anything to draw. |
False
|
fill_bounds
|
ndarray or None
|
|
None
|
outline_bounds
|
ndarray or None
|
|
None
|
n_closed_loops
|
int
|
Closed loops of the cut, and segments of components that did not close (outline only). |
0
|
n_open_segments
|
int
|
Closed loops of the cut, and segments of components that did not close (outline only). |
0
|
Graphs¶
cellier.data.graph.GraphMemoryStore ¶
Bases: BaseDataStore
In-memory spatial-graph data store backed by numpy arrays.
One store backs one graph visual and returns nodes and edges together in
a single GraphData per slice, so the two can never be committed to
the GPU out of sync.
The flat numpy arrays are the source of truth and are what
serializes; the spatial_graph index is a derived, lazily built
private attribute reachable through graph. A store used only
with slice_strategy="mask" never builds an index at all, which is
what makes spatial-graph optional at runtime and not merely at
import time.
Positions are stored in data-axis order: column 0 is axis 0 (t or z),
the last column is x. The render layer applies the [:, [2, 1, 0]]
reversal before uploading to pygfx.
edges holds endpoint row indices, not original node ids; the
conversion happens once, at construction. node_ids is read only
when building a pick payload, never on the per-frame path.
get_data runs the filter in the event loop's default executor, so a
large graph or a wide trail does not stall the loop; read is
the same filter, synchronous.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
(n_nodes, ndim) float32 array in data-axis order. |
required |
edges
|
ndarray
|
(n_edges, 2) int32 array of endpoint row indices into positions. |
required |
node_ids
|
ndarray | None
|
Original node ids (arbitrary dtype -- geff files may carry uint64 or
strings). Defaults to |
required |
node_colors
|
ndarray | None
|
(n_nodes, 4) float32 RGBA, row-matched to positions. |
required |
node_sizes
|
ndarray | None
|
(n_nodes,) float32 per-node sizes. |
required |
edge_colors
|
ndarray | None
|
(n_edges, 4) float32 RGBA, row-matched to edges. Expanded to two vertices per edge at slice time. |
required |
axis_scales
|
tuple[float, ...] | None
|
A geff file's per-axis |
required |
axis_offsets
|
tuple[float, ...] | None
|
The per-axis |
required |
directed
|
bool
|
Whether the graph is directed. Decides which |
required |
slice_strategy
|
str
|
|
required |
name
|
str
|
Human-readable label. |
required |
id
|
UUID4
|
Unique identifier. Taken from the |
required |
data_coordinate_systems
|
list[DataCoordinateSystem]
|
The store's coordinate system, as a one-entry list built by the
caller, with one axis per |
required |
level_scales
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_translations
|
list[tuple[float, ...]]
|
Unused by this single-resolution store; left empty. |
required |
level_transforms
|
list[AffineTransform]
|
The level-0 identity, installed from |
required |
data_coordinate_system
property
¶
data_coordinate_system: DataCoordinateSystem
The level-0 (intrinsic) coordinate system.
Returns:
| Type | Description |
|---|---|
DataCoordinateSystem
|
The finest-resolution system. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the store has no coordinate systems. The message names the two ways to supply them, because this is the error a caller who built a bare in-memory store outside a viewer will hit. |
axis_extents
property
¶
Per-axis (low, high) extents in level-0 data coordinates.
The bounding box of the nodes, with no padding -- a vertex is a point,
not a cell, so there is no half-voxel to add. None when the
store is empty. See
axis_extents.
node_color_mode
property
¶
node_color_mode: str
"vertex" when per-node colours are present, else "uniform".
Descriptive only: it says what the store carries, and never decides what the material does.
node_size_mode
property
¶
node_size_mode: str
"vertex" when per-node sizes are present, else "uniform".
edge_color_mode
property
¶
edge_color_mode: str
"vertex" when per-edge colours are present, else "uniform".
graph
property
¶
graph: Any
The spatial index, built on first use over ROW indices.
Node ids in the returned SpatialGraph / SpatialDiGraph are
arange(n_nodes), not the caller's node_ids, so queries
return buffer rows directly and nothing on the per-frame path pays
an id-to-row translation. Reaching past the public query wrappers
therefore sees row indices.
Raises:
| Type | Description |
|---|---|
ImportError
|
When |
edge_span
property
¶
Per-axis 99th percentile of abs(pos[u, ax] - pos[v, ax]).
Compare against the data extent on the axis being sliced: well
under ~15% of the extent means slice_strategy="roi" will pay
off. Purely informational -- nothing reads this to choose a
strategy.
Computed on first access and cached, so a store that never asks never pays the O(E) pass. 99th percentile rather than max so a handful of outlier edges (a track skipping frames through an occlusion) does not misrepresent an otherwise local graph.
__setattr__ ¶
Assign a field, announcing the change when it is a data field.
A class-level hook rather than a connection to self.events made
in model_post_init: model_copy(deep=True) -- which
to_model and from_model use -- runs no model_post_init, so
a connection would silently go missing on every copy. Construction
assigns through __dict__ and announces nothing.
notify_changed ¶
notify_changed(kind: StoreChangeKind = 'contents', regions: Sequence[DataRegion] | None = None) -> None
Announce that the store's data changed.
Reassigning a data field announces itself; call this after an
in-place write, which nothing can see -- store.data[...] = v
or store.positions[:] = p.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
'extent' or 'contents'
|
|
'contents'
|
regions
|
Sequence[DataRegion] or None
|
Where the data changed, as per-axis |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If kind is not one of the two kinds. |
model_post_init ¶
model_post_init(__context: Any) -> None
Check the systems passed at construction and install their transforms.
Stores that open array handles in their own model_post_init call
this after opening them: the level count and rank it checks against
are read off the handles.
set_data_coordinate_systems ¶
set_data_coordinate_systems(systems: list[DataCoordinateSystem], level_transforms: list[AffineTransform] | None = None) -> None
Install the store's coordinate systems and level transforms.
Assignment rather than construction because the systems are sometimes derived from the scene the store is added to, which the store cannot see at construction time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
systems
|
list[DataCoordinateSystem]
|
One per resolution level, finest first. |
required |
level_transforms
|
list[AffineTransform] or None
|
Level |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If systems is empty, if level_transforms has a different length, or if a multi-level store is given no level transforms -- there is no downsampling factor to infer them from here. Also if the systems are not one per resolution level with one axis per data dimension. |
from_arrays
classmethod
¶
from_arrays(positions: ndarray, edges: ndarray, *, node_ids: ndarray | None = None, node_colors: ndarray | None = None, node_sizes: ndarray | None = None, edge_colors: ndarray | None = None, axis_scales: tuple[float, ...] | None = None, axis_offsets: tuple[float, ...] | None = None, directed: bool = False, slice_strategy: Literal['mask', 'roi'] = 'mask', data_coordinate_system: DataCoordinateSystem | None = None, name: str = 'graph_memory_store') -> GraphMemoryStore
Build a store from raw arrays -- the dependency-free path.
No spatial index is constructed here, and none is constructed at all
unless graph is touched or slice_strategy="roi".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
(n_nodes, ndim) node positions in data-axis order. |
required |
edges
|
ndarray
|
(n_edges, 2) endpoint row indices. |
required |
node_ids
|
ndarray | None
|
Original node ids; defaults to |
None
|
node_colors
|
ndarray | None
|
Optional per-element appearance arrays. |
None
|
node_sizes
|
ndarray | None
|
Optional per-element appearance arrays. |
None
|
edge_colors
|
ndarray | None
|
Optional per-element appearance arrays. |
None
|
axis_scales
|
tuple[float, ...] | None
|
Per-axis data-to-world scale and offset, normally left None for raw arrays. |
None
|
axis_offsets
|
tuple[float, ...] | None
|
Per-axis data-to-world scale and offset, normally left None for raw arrays. |
None
|
directed
|
bool
|
Whether the graph is directed. |
False
|
slice_strategy
|
str
|
|
'mask'
|
data_coordinate_system
|
DataCoordinateSystem | None
|
The store's coordinate system, one axis per |
None
|
name
|
str
|
Human-readable label. |
'graph_memory_store'
|
Returns:
| Type | Description |
|---|---|
GraphMemoryStore
|
|
from_geff
classmethod
¶
from_geff(path: Any, *, axis_names: list[str] | None = None, node_color_prop: str | None = None, node_size_prop: str | None = None, directed: bool | None = None, slice_strategy: Literal['mask', 'roi'] = 'mask', data_coordinate_system: DataCoordinateSystem | None = None, name: str = 'graph_memory_store') -> GraphMemoryStore
Build a store from a geff file.
There is deliberately no transform parameter: the file's
axes are the sole source of the store's scale and offset at
construction. CellierController.add_graph(transform=...) still wins
when passed explicitly, as it does for every other visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the geff store. |
required |
axis_names
|
list[str] | None
|
Which of the file's axes to load as position columns, and in what
order. |
None
|
node_color_prop
|
str | None
|
Node properties to use as |
None
|
node_size_prop
|
str | None
|
Node properties to use as |
None
|
directed
|
bool | None
|
Overrides the file's |
None
|
slice_strategy
|
str
|
|
'mask'
|
data_coordinate_system
|
DataCoordinateSystem | None
|
The store's coordinate system. |
None
|
name
|
str
|
Human-readable label, and the name of a generated system. |
'graph_memory_store'
|
Returns:
| Type | Description |
|---|---|
GraphMemoryStore
|
|
dataset_info ¶
dataset_info() -> DatasetInfo
Describe the graph: structure, world placement, geff provenance.
Never touches self.graph: reading it would build the spatial
index, and opening an appearance panel is not a reason to pay for
one. Only the arrays already held are measured.
The geff section is the first consumer of axes / node_props
/ edge_props, which until now were, in the words of their own
comment, "retained for downstream display" with nothing reading
them. It is absent for a store built from raw arrays.
The three *_color_mode / *_size_mode properties are
deliberately absent: they describe how the graph is drawn, not what
the store holds.
ids_for_rows ¶
ids_for_rows(rows: Any) -> ndarray
Translate node row indices to the store's original node ids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
array-like of int
|
Row indices into |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Original node ids, in the store's own id dtype. |
rows_for_ids ¶
rows_for_ids(ids: Any) -> ndarray
Translate original node ids to row indices into positions.
Requires node_ids to be sorted, which it is for every geff file
and for the arange default. Called on an explicit user request,
never per frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids
|
array - like
|
Original node ids. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Row indices, |
edge_row_for_endpoints ¶
Return the store edge row joining two node rows, or -1.
Used only to give an ROI-sliced edge pick the same edge_index
a mask-sliced one carries. The ROI index returns endpoint pairs
rather than edge rows, and translating a whole candidate set every
reslice is exactly the per-frame searchsorted that indexing
nodes by row removes -- so the translation happens here, for one
edge, on a pick.
Backed by a sorted key array built on first call and cached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_row
|
int
|
Endpoint row indices. |
required |
target_row
|
int
|
Endpoint row indices. |
required |
Returns:
| Type | Description |
|---|---|
int
|
Row into |
query_nodes_in_roi ¶
Return the original ids of nodes inside an axis-aligned box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roi_min
|
array-like of float
|
Per-axis lower and upper bounds, in data-axis order. |
required |
roi_max
|
array-like of float
|
Per-axis lower and upper bounds, in data-axis order. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Original node ids (see |
query_nearest_nodes ¶
Return the original ids of the k nodes nearest each point.
query_nearest_edges ¶
Return endpoint id pairs for the k edges nearest each point.
get_data
async
¶
get_data(request: GraphSliceRequest) -> GraphData
Return slab-filtered graph data for request.
The filter (read) runs in the loop's default executor. A
filter that raises because the store changed under it fails this
read; the change's invalidation reads again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
GraphSliceRequest
|
Planned by the render layer from the current view. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
Filtered, projected node and edge data ready for GPU upload. |
read ¶
read(request: GraphSliceRequest) -> GraphData
The filter of get_data, run on the calling thread.
Inclusion rule
A node survives when it is inside the slab on every non-displayed axis. An edge survives when either endpoint does, and it draws in full to the out-of-slab endpoint's projected position. That far endpoint contributes a line vertex but no node marker -- which is the only rule that renders anything for tracking data, where every edge spans two timepoints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
GraphSliceRequest
|
Planned by the render layer from the current view. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
Filtered, projected node and edge data ready for GPU upload. |
cellier.data.graph.GraphSliceRequest ¶
Bases: NamedTuple
Request for one slab-filtered slice of spatial-graph data.
Mirrors PointsSliceRequest with one change: the scalar thickness
becomes a per-axis asymmetric extent, so a trail window on any sliced
axis is expressible without a second request type.
The first three fields are the request fields every store request carries: ids that are fresh per plan (never in a cache key) and the level, always 0 here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slice_request_id
|
UUID
|
Shared ID for all requests in one planning event. |
required |
chunk_request_id
|
UUID
|
Per-request ID. For graphs (never tiled) this equals
|
required |
scale_index
|
int
|
Always 0 -- no LOD levels. Present for parity with the image requests. |
required |
displayed_axes
|
tuple[int, ...]
|
Axis indices rendered in the canvas (2 for 2D, 3 for 3D). |
required |
slice_positions
|
dict[int, float]
|
Collapsed axis -> the slab's centre, in data coordinates. Graphs keep a per-axis slab rather than filtering by the region
alone: a trail window is asymmetric and its fade is a signed
distance from the slice, neither of which region containment can
express. The centre is the region pulled back through the visual's
transform, and |
required |
retained_axes
|
tuple[int, ...]
|
The data axes this visual's geometry keeps, ascending. Not the same list as |
required |
extents
|
dict[int, tuple[float, float]]
|
Axis -> |
required |
fades
|
dict[int, tuple[float, float, float]]
|
Axis -> |
required |
clip_planes
|
tuple[tuple[tuple[float, ...], float], ...]
|
Clipping planes the read applies on the CPU, as |
required |
fold_axes
|
tuple[int, ...]
|
Collapsed data axes whose columns the store also returns, for the render layer's per-element fold. |
required |
region
|
ConvexRegion or None
|
An exact filter in data coordinates on top of the windows: a node
is selected only inside it. Set for a slab tilted through the data
(an |
required |
cellier.data.graph.GraphData
dataclass
¶
Slab-filtered graph data returned by GraphMemoryStore.get_data().
Nodes and edges travel together in one object so they can never be committed to the GPU out of sync.
node_alpha / edge_alpha are deliberately separate from the
colour arrays. The store computes the trail fade because it is a
function of the data and the slice position; the render layer composes
it with the base colour because that is where the appearance lives.
Keeping them apart avoids handing an appearance colour down into the
store, and lets the fade ride its own 1-float buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_id
|
UUID
|
Echo of |
required |
node_positions
|
ndarray
|
(n, n_displayed) float32. Projected onto displayed axes; padded to 3D in the render layer. |
required |
node_colors
|
ndarray | None
|
(n, 4) float32 RGBA, row-matched to |
None
|
node_sizes
|
ndarray | None
|
(n,) float32 per-node sizes, or None. |
None
|
node_alpha
|
ndarray | None
|
(n,) float32 trail-fade multiplier in [0, 1], or None when no trail axis has fading enabled. |
None
|
node_color_mode
|
str
|
|
'uniform'
|
node_size_mode
|
str
|
|
'uniform'
|
original_node_rows
|
ndarray | None
|
(n,) int array mapping each rendered node back to its row in the store's full position array. None on the empty-placeholder path. |
None
|
edge_positions
|
ndarray
|
(2 * e, n_displayed) float32 in |
required |
edge_colors
|
ndarray | None
|
(2 * e, 4) float32 RGBA, row-matched to |
None
|
edge_alpha
|
ndarray | None
|
(2 * e,) float32 per-vertex fade, or None. Row-aligned with
|
None
|
edge_color_mode
|
str
|
|
'uniform'
|
edge_endpoint_rows
|
ndarray | None
|
(e, 2) int array of the endpoint node rows of each rendered edge. Present on both slice strategies and used to build an edge pick payload's endpoint ids. None on the empty-placeholder path. |
None
|
original_edge_rows
|
ndarray | None
|
(e,) int array mapping each rendered edge to its row in the store's
full edge array. Populated by the |
None
|
nodes_empty
|
bool
|
True when the node filter produced zero rows and placeholder geometry was returned. |
False
|
edges_empty
|
bool
|
True when the edge filter produced zero rows. Independent of
|
False
|
node_fold_positions
|
ndarray | None
|
The nodes' and the edge vertices' positions on the request's
|
None
|
edge_fold_positions
|
ndarray | None
|
The nodes' and the edge vertices' positions on the request's
|
None
|