wsidata.reader.PylibCZIReader#

class PylibCZIReader(file, **kwargs)#

Bases: ReaderBase

Use pylibCZIrw to interface with Zeiss CZI whole-slide images.

Depends on pylibCZIrw, the official Python binding to libCZI maintained by Zeiss. Unlike BioFormats, pylibCZIrw decodes JPEG-XR natively via libCZI on every platform it ships wheels for, including arm64 macOS - so this reader is the recommended backend for .czi files on Apple Silicon, where BioFormats cannot load the ome:jxrlib native library.

Parameters:
filestr or Path

Path to the CZI file on disk.

Notes

pylibCZIrw does not expose pre-baked pyramid levels. This reader therefore presents a synthetic pyramid built by requesting downsampled reads via pylibCZIrw’s zoom parameter, which is the sanctioned way to obtain lower-resolution views.

The CZI format stores coordinates in an absolute reference frame whose origin can be far from (0, 0). This reader translates between the wsidata zero-origin convention and the CZI absolute coordinate space so that read_region(0, 0, ...) returns the top-left of the scene, matching every other wsidata reader.

pylibCZIrw zero-pads out-of-bounds reads (at any origin, including negative), so this reader does not add an extra bounds guard.

The initial implementation targets Bgr24 (24-bit BGR) CZI files, which is the pixel format used by brightfield H&E scans on Zeiss microscopes. Other pixel types raise NotImplementedError.

create_reader()#

Create the reader

This function should be implemented in the subclass

  1. create the reader

  2. use set_reader to set the reader

detach_reader()#

Detach the reader

This function will be called when the object is deleted or sent to other process

Please implement this function in the subclass

  1. Close the reader

  2. use set_reader to set the reader to None

  3. Clean up any resources that are not python-managed

get_region(x, y, width, height, level=0, **kwargs)#

Read a region at the given pyramid level.

Follows the wsidata convention: (x, y) is in level-0, zero-origin coordinates; (width, height) is in pixel units at the requested level.

get_thumbnail(size, **kwargs)#

Get a thumbnail whose longest edge is size pixels.