跳轉至

pyHisto.slide

pyHisto.slide

Slide adapter: uniform, lazy true-RGB access to OME-Zarr slides and arrays.

open_slide normalises the inputs accepted by the stain-calibration code:

  • tanoa NGFF 0.5 stores (zarr v3, ome group attribute, axes t,c,z,y,x, physical-µm scale transforms, omero channel labels such as Blue,Green,Red for Zeiss Bgr24);
  • legacy pyHisto 4D c,z,y,x stores (NGFF 0.4 style top-level attributes are accepted too);
  • in-memory NumPy / dask arrays shaped (Y, X, C) or (C, Y, X) with an explicit channel_order and mpp.

Channel order is resolved in exactly one place, :func:_resolve_channel_order, from the omero labels (or the explicit channel_order). Unlabelled or unrecognisably labelled 3-channel data without channel_order raises ValueError -- there is no silent RGB/BGR guess (see the BGR defect of the legacy CZI->zarr path).

All reads are lazy: :meth:Slide.read_region indexes only the requested window of one level, so only the chunks overlapping it are fetched.

Slide

Slide(levels, downsamples, mpp, channel_order, perm, slide_id)

Lazy, true-RGB multi-resolution slide.

channel_order instance-attribute

channel_order = channel_order

slide_id instance-attribute

slide_id = slide_id

n_levels property

n_levels: int

mpp property

mpp: Optional[float]

Level-0 pixel size in µm.

level_shape

level_shape(level: int) -> Tuple[int, int]

downsample

downsample(level: int) -> float

level_mpp

level_mpp(level: int) -> Optional[float]

read_region

read_region(level: int, x: int, y: int, w: int, h: int) -> np.ndarray

Return the (h, w, 3) uint8 true-RGB window at level coordinates.

nodata_mask

nodata_mask(level: int, region=None) -> np.ndarray

Boolean mask of no-data pixels (all channels == 0) at level.

region=(x, y, w, h) restricts it to a window; otherwise the level is processed in row strips (bounded memory, bool output only).

thumbnail

thumbnail(max_px: int = 1024) -> np.ndarray

RGB thumbnail with longest side <= max_px.

Read from the coarsest level whose longest side is still >= max_px (or level 0 if every level is smaller), then box-averaged down.

open_slide

open_slide(path_or_array, *, channel_order=None, mpp=None, slide_id=None) -> Slide

Open an OME-Zarr store (path / zarr group) or a NumPy/dask array as a :class:Slide.

channel_order: stored channel order ("RGB", "BGR" or label sequence); required when the input carries no recognisable omero channel labels. mpp: level-0 pixel size in µm; overrides the store's physical scale and is required for array input.