Skip to content

GUI

What both toolkits share: helpers for building controls and the models they read. The widgets themselves are on the Qt and anywidget pages.

Image control values

cellier.gui.image_control_values

image_control_values(visual: Any, *, fields: list[str] | tuple[str, ...], colormap_names: list[str] | None = None, clim_range: tuple[float, float] | None = None, channel_labels: dict[int, str] | None = None, decimals: int = 2, axis_names: Iterable[str] | None = None, threshold_range: tuple[float, float] | None = None, thickness_range: tuple[float, float] | None = None) -> dict[str, Any]

Everything either front end needs to build the image control.

The result is the values argument of QtImageControls and of the anywidget image control. The convenience viewers call this for every ImageControl in a controls= list; call it yourself only when building the widget directly. The dict's layout is internal: pass it through unchanged.

Parameters:

Name Type Description Default
visual BaseImageVisual

The representative visual.

required
fields sequence of str

The appearance fields the config asked for. The shared section's blending and interpolation rows and the mode switch are always shown.

required
colormap_names list[str] or None

Colormap choices. A curated default when None.

None
clim_range tuple[float, float] or None

Contrast slider bounds. Inferred from the current limits when None.

None
channel_labels dict[int, str] or None

Per-channel names; "Channel {i}" when absent.

None
decimals int

Decimal places for values in data units (the contrast limits and the iso threshold). Fractions such as opacity always show 2.

2
axis_names iterable of str or None

The axis names the projection-axis row offers (the store's, which name the world's), when fields asks for it.

None
threshold_range tuple[float, float] or None

Iso-threshold slider bounds. None: the contrast slider's on an image, whose threshold is in the same units; on a MaskedImage, whose threshold is in the mask's units, a window of max(1, |t|) either side of the threshold t.

None
thickness_range tuple[float, float] or None

A MaskedImage's thickness slider bounds, world units. None: (0, max(10, 4 * thickness)). Ignored for other images.

None

Returns:

Type Description
dict

Plain data, JSON-compatible apart from integer channel keys and "colormaps", which holds the models' own color_map values. A colormap built inline (Colormap([...], name="white_green")) is not in cmap's catalogue, so its name cannot be resolved back into a colormap; a toolkit that needs the real thing reads it from there, while the page dicts keep the JSON-safe name.

Axis values

The values a dims slider can take on one world axis: any position in a range, or only the listed positions (a channel axis, say). axis_values_from_viewer derives them from a viewer's data.

cellier.gui.ContinuousAxisValues pydantic-model

Bases: CellierModel

An axis that can be sliced at any world position in [min, max].

Parameters:

Name Type Description Default
min float

Lowest world position the slider reaches. Must be finite.

required
max float

Highest world position the slider reaches. Must be finite and >= min.

required
decimals int

Decimal places the slider's position readout shows. Default 2. Display only: the slider stays continuous and the model receives the full-precision position.

required
step_size float

World distance one keyboard step (an arrow key) or one mouse-wheel notch moves the slider. Default 1.0. Must be finite and > 0. Set it to the axis's voxel spacing to step one plane at a time. Dragging is unaffected: the slider still reaches every position.

required

Config:

  • frozen: True

Fields:

Validators:

  • _check_bounds

cellier.gui.DiscreteAxisValues pydantic-model

Bases: CellierModel

An axis that can only be sliced at the listed world positions.

The slider steps through values by position, so irregular spacing is fine. A position set from elsewhere that falls between two values is shown as the nearest one (a position exactly halfway between two values goes to the higher one); it is not written back, because the renderer resolves it with the same rule.

Parameters:

Name Type Description Default
values tuple[float, ...]

World positions: at least one, all finite, strictly increasing. A tuple rather than an array so that equality stays total -- an ndarray field makes __eq__ return an array, which breaks every containing model's comparison.

required
labels tuple[str, ...] or None

Readout text for each value, e.g. channel names; one entry per value. None shows the value itself.

required
draw_ticks bool

Whether the slider marks each value with a tick. Default False: one mark per value is only affordable on a short axis, and nothing turns it on by itself. Set it on an axis that has few enough values to be worth marking, such as a channel axis. Warns (UserWarning) above 50 marks, where dragging the slider becomes unresponsive.

required

Raises:

Type Description
ValueError

When values is empty, not finite or not strictly increasing, or labels does not have one entry per value.

Config:

  • frozen: True

Fields:

Validators:

  • _check_values
  • _warn_dense_ticks

min property

min: float

The first value.

max property

max: float

The last value.

Clipping planes helpers

What a clipping planes control of either toolkit is built from. See Clip a visual with planes.

cellier.gui.get_clipping_planes_data_from_visual

get_clipping_planes_data_from_visual(visual: Any, store: Any) -> dict[str, Any]

What a clipping planes control is built with, read off the models.

Parameters:

Name Type Description Default
visual BaseVisual

The visual. For a group of visuals edited together, the first: they read one store, and the visuals of a link group carry the same planes.

required
store BaseDataStore

The store the visual reads.

required

Returns:

Type Description
dict[str, Any]

coordinate_system (the store's level-0 system id, as a string), data_store_id (as a string), axis_names, bounds ([low, high] per data axis) and planes (the rows).

cellier.gui.get_axis_bounds_from_store

get_axis_bounds_from_store(controller: Any, data: Mapping[str, Any]) -> Callable[[], list[list[float]]] | None

A reader of a store's current bounds; not the bounds themselves.

The returned function takes no arguments, looks the store up by id and returns its current [low, high] per axis. A clipping planes control calls it when the store's extent changes (DataStoreMetadataChangedEvent) to move its slider ranges. It exists because a control does not hold the controller.

Parameters:

Name Type Description Default
controller CellierController or None

Looks the store up by id each time, so the reader holds no store.

required
data Mapping[str, Any]

From get_clipping_planes_data_from_visual: its data_store_id and axis_names are used.

required

Returns:

Type Description
Callable or None

The bounds_source of a clipping planes control; None without a controller.

cellier.gui.ClippingPlaneGizmoTarget

Bases: NamedTuple

Where the gizmo of a clipping planes control is drawn.

Parameters:

Name Type Description Default
visual_id UUID

The visual whose plane the gizmo edits.

required
canvas_id UUID

The 3D canvas the gizmo is drawn in.

required
scene_id UUID

That canvas's scene, whose DimsChangedEvent the control follows.

required

cellier.gui.get_clipping_plane_gizmo_data

get_clipping_plane_gizmo_data(controller: Any, visual_id: UUID, canvas_id: UUID) -> dict[str, Any]

The gizmo arguments of a clipping planes control, for one visual and canvas.

Selects nothing: the caller names the visual whose plane the gizmo edits and the canvas it is drawn in, as for CellierController.add_clipping_plane_gizmo. The canvas must exist: build the canvas before the control.

Parameters:

Name Type Description Default
controller CellierController

The controller the control is wired to.

required
visual_id UUID

The visual whose plane the gizmo edits. One of the control's visuals.

required
canvas_id UUID

A canvas of that visual's scene.

required

Returns:

Type Description
dict[str, Any]

gizmo_target (a ClippingPlaneGizmoTarget), gizmo_plane (the id of the plane that has the canvas's gizmo now, as a string, if it is one of this visual's; otherwise None) and gizmo_blocked (a reader of why a plane cannot have one, over controller.clipping_plane_gizmo_blocked).

Raises:

Type Description
KeyError

If the visual or the canvas is not registered.

ValueError

If the canvas does not show the visual's scene.

Render planes helpers

The planes a visual in the "plane" render mode draws its data on: the clipping planes rows with the extents added, in world units.

cellier.gui.get_render_planes_data_from_visual

get_render_planes_data_from_visual(controller: Any, visual_id: UUID, *, blocked: Callable[[], str] | None = None) -> dict[str, Any]

What a render planes control is built with, read through the controller.

Unlike a clipping planes control, a render planes control reads the scene as well as the visual: its planes are in world coordinates, a new one is put on the axes the 3D view displays, and the control is disabled while the planes are not drawn.

Parameters:

Name Type Description Default
controller CellierController

The controller the control is wired to.

required
visual_id UUID

The visual. For a group of visuals edited together, the first.

required
blocked Callable[[], str] or None

Why the control is disabled now, or "". None uses controller.render_planes_blocked(visual_id): the visual is not in the "plane" render mode, or the view is 2D.

None

Returns:

Type Description
dict[str, Any]

Keyword arguments of the control: coordinate_system (the world system's id, as a string), axis_ids and axis_names (the world axes, in order), planes (the visual's render_planes), scene_id, data_store_id and state_source, a reader of {"blocked", "displayed_axes", "bounds"} as they are now.

Raises:

Type Description
KeyError

If the visual is not registered.

cellier.gui.RenderPlaneGizmoTarget

Bases: NamedTuple

Where the gizmo of a render planes control is drawn.

Parameters:

Name Type Description Default
visual_id UUID

The visual whose plane the gizmo edits.

required
canvas_id UUID

The 3D canvas the gizmo is drawn in.

required
scene_id UUID

That canvas's scene.

required

cellier.gui.get_render_plane_gizmo_data

get_render_plane_gizmo_data(controller: Any, visual_id: UUID, canvas_id: UUID) -> dict[str, Any]

The gizmo arguments of a render planes control, for one visual and canvas.

Selects nothing: the caller names the visual whose plane the gizmo edits and the canvas it is drawn in, as for CellierController.add_render_plane_gizmo. The canvas must exist: build the canvas before the control.

Returns:

Type Description
dict[str, Any]

gizmo_target (a RenderPlaneGizmoTarget), gizmo_plane (the id of the render plane that has the canvas's gizmo now, as a string, if it is one of this visual's; otherwise None) and gizmo_blocked (a reader of why a plane cannot have one, over controller.render_plane_gizmo_blocked).

Raises:

Type Description
KeyError

If the visual or the canvas is not registered.

ValueError

If the canvas does not show the visual's scene.

Dataset info

cellier.gui.dataset_info_from_path

dataset_info_from_path(zarr_path: str, *, multiscale_index: int = 0, series_index: int = 0) -> DatasetInfo

Extract display metadata from an OME-Zarr store by URI.

Uses yaozarrs to validate and read OME metadata, and direct JSON reads for the per-level array shapes.

Prefer store.dataset_info() when you have a store: this opens the group, which for a remote URI is a network round trip.

Parameters:

Name Type Description Default
zarr_path str

Root URI of the OME-Zarr group (file://, s3://, etc.).

required
multiscale_index int

Which multiscales[] entry to read. Defaults to 0.

0
series_index int

For Bf2Raw containers, which child image series to inspect.

0

Returns:

Type Description
DatasetInfo

The same sectioned description a store's dataset_info returns.