Skip to content

Image Loading

Functions

get_image_metadata

get_image_metadata(image) -> dict[str, Any]

Extract useful metadata from an OMERO ImageWrapper.

Returns a dict with keys: size_x, size_y, size_z, size_c, size_t, pixel_type (numpy dtype string), pixel_size_x, pixel_size_y, pixel_size_z (µm, float | None), channels (list of dicts with 'name', 'color', 'emission_wavelength', 'window_start', 'window_end', 'active'), name, id


is_large_image

is_large_image(image) -> bool

Return True if image should be loaded via tile-based access.


load_image_data

load_image_data(image) -> dict[str, Any]

Load a regular (non-pyramidal) OMERO image into numpy arrays.

Returns:

Type Description
dict with:

images — list of numpy arrays, one per channel, shape (Z, Y, X) metadata — result of :func:get_image_metadata


load_image_lazy

load_image_lazy(image) -> dict[str, Any]

Load image data lazily as dask arrays.

For pyramidal images with multiple resolution levels this returns a list-of-lists (one sub-list per channel, each containing one dask array per resolution level, coarsest last). For plain large images it returns a single-resolution lazy array per channel.

Returns:

Type Description
dict with keys ``images`` (list of dask arrays or list-of-lists)
and ``metadata``.

Classes

RegularImagePlaneProvider

RegularImagePlaneProvider(image, max_cache_mb: int = 256)

On-demand plane/stack loader for regular OMERO images.

Slice viewing can fetch only the currently needed (c, z, t) plane, while projection modes can request a full (Z, Y, X) stack for the selected channel/timepoint.

prefetch_planes

prefetch_planes(requests: list[tuple[int, int, int]]) -> None

Asynchronously prefetch (c, z, t) planes into the cache.

prefetch_neighbors

prefetch_neighbors(channels: list[int], z: int, t: int) -> None

Prefetch nearby Z/T planes for active channels.


PyramidTileProvider

PyramidTileProvider(image, max_cache_mb: int = 512)

Thread-safe multi-resolution tile provider for OMERO pyramid images.

Fetches single-channel 2-D tiles via ICE RawPixelsStore.getTile() and caches them in an LRU dictionary. Safe to call get_tile from a background thread while the main thread calls get_cached_tile.

Parameters:

Name Type Description Default
image ImageWrapper

Connected OMERO image.

required
max_cache_mb int

Maximum tile cache size in megabytes.

512

full_size

full_size() -> tuple[int, int]

(width, height) at the highest resolution level.

best_level_for_scale

best_level_for_scale(scale: float) -> int

Return pyramid level where one level-pixel ~= one screen-pixel.

scale = screen_pixels / full_res_image_pixels.

get_cached_tile

get_cached_tile(level, c, z, t, tx, ty)

Return tile from cache (no server fetch). Returns None if not cached.

get_tile

get_tile(level, c, z, t, tx, ty)

Return tile, fetching from server if not in cache.

load_overview

load_overview(z: int = 0, t: int = 0) -> list[np.ndarray]

Load all channels at level 0 (smallest) as numpy arrays.

Returns a list of arrays, one per channel, each shape (1, Y, X). Useful for quick overview display and contrast percentile computation.