acia.segm.czi_source#
Lazy, memory-bounded image source for Zeiss CZI files.
A CZI file may contain several scenes (stage positions); the ROI workflow
processes a single scene, which itself is a time series. CZISequenceSource
selects one scene and exposes that scene’s (T, H, W, C) time series through
the standard ImageSequenceSource contract.
The CZI file is opened lazily on first access and read one plane at a time
via aicspylibczi’s read_image (which reads only the addressed subblocks),
so peak memory stays at a single frame regardless of file size (CZI files may be
hundreds of gigabytes). aicspylibczi is an optional dependency, imported
lazily inside CZISequenceSource._ensure_reader().
This mirrors acia.segm.nd2_source: a “position” is the CZI scene (S)
axis, the exact analogue of ND2’s P.
- class acia.segm.czi_source.CZISequenceSource[source]#
Bases:
ImageSequenceSource,JupyterVisualizationMixinA single CZI scene exposed as a lazy
(T, H, W, C)time series.Axis mapping is done by name (using the reader’s
dimsstring), never by a fixed axis order. For each frame the source selectsS == positionandT == frame, moves the channel axis last, and adds a trailing channel axis for grayscale planes so every frame is shaped(H, W, C).The reader is opened lazily and only a single plane is materialized at a time via
read_image; the whole scene/file is never loaded.- Parameters:
path – Path to the
.czifile.position – Index of the scene to expose. A file with no
Saxis is treated as a single scene (only0is valid).pixel_size – Optional pint length per pixel that overrides the file’s scaling metadata. Strings like
"0.5 um"are accepted.frame_interval – Optional scalar time between frames (pint or string) that overrides metadata-derived timing.
timepoints – Optional explicit per-frame pint
Quantityarray that overrides metadata-derived timing.
- property scene_names: dict[int, str | None]#
Mapping of scene index -> name (e.g.
{0: 'P1', 1: 'P2', ...}).
- property pixel_size#
Pint length per pixel, resolved from the file (or override).
- property timepoints#
Per-frame pint timepoints, or
Noneif uncalibrated.
- property channel_names: list[str]#
Channel names from CZI metadata (best-effort; empty if unavailable).
- get_frame(frame)[source]#
Read a single
(H, W, C)plane for(scene=position, frame).Only the requested plane is materialized (via
read_image); the whole scene/file is never loaded.- Parameters:
frame (int) – Time index of the frame to read.
- Returns:
BaseImage – A
LocalImagewrapping the(H, W, C)plane.- Return type: