Module functions

slideio.get_driver_ids()

Returns a list of ids of available image drivers

slideio.open_slide(path: str, driver: str = 'AUTO')

Returns an instance of a slide object

Parameters
  • path – a path to the image file

  • driver – name of the driver or “AUTO” for automatic driver selection

class slideio.Compression

Members:

Unknown

Uncompressed

Jpeg

JpegXR

Png

Jpeg2000

LZW

HuffmanRL

CCITT_T4

CCITT_T6

JpegOld

Zlib

JBIG85

JBIG43

NextRLE

PackBits

ThunderScanRLE

RasterPadding

RLE_LW

RLE_HC

RLE_BL

PKZIP

KodakDCS

JBIG

NikonNEF

JBIG2

GIF

BIGGIF

property name
class slideio.Slide(path: str, driver: str)

Slide class represents slides, normally a single image file or a folder. Slide contains a collection of scenes - separate images.

property file_path

Returns path to the slide file/folder

get_aux_image(image_name)

Get auxiliary image as objecty.

Parameters

image_name – name of the auxiliary image

get_aux_image_names()

Get list of auxiliary image names

get_aux_image_raster(image_name, size=(0, 0), channel_indices=[])

Get auxiliary image as numpy array.

Parameters
  • image_name – name of the auxiliary image

  • channel_indices – array of channel indices to be retrieved. [] - all channels.

  • size – size of the block after rescaling. (0,0) - no scaling.

get_scene(index)

Return slide scene by index

property num_aux_images

Number of auxiliary images of the slide.

property num_scenes

Number of scenes in the slide

property raw_metadata

Raw metadata extracted from the slide

class slideio.Scene(scene)

slideio Scene class.

Scene class represents a single 2D-4D image from a Slide object. The class implements methods for accessing the image raster and metadata. All raster channels of the scene have the same resolution and the same size. Raster channels may have different data types depending on the image format. A scene can represent a separate region of interest of the slide. A Scene object can be created by a “get_scene” method of a Slide object or by using the constructor:

scene = Scene(slide, scene_index)

apply_transformation(transormation)

Transform scene raster

Parameters

transformation – transformation parameters

property compression

Compression method for the scene raster data.

property file_path

File path to the scene. In the most cases the same as file path of the slide.

get_aux_image(image_name, size=(0, 0), channel_indices=[])

Get auxiliary image as a numpy array.

Parameters
  • image_name – name of the auxiliary image

  • channel_indices – array of channel indices to be retrieved. [] - all channels.

  • size – size of the block after rescaling. (0,0) - no scaling.

get_aux_image_names()

Get list of auxiliary image names

get_channel_data_type(channel)

Returns data type for a scene channel by index :param channel: channel index.

get_channel_name(channel)

Returns name of a scene channel by index :param channel: channel index.

get_raw_metadata()

Get raw metadata of the scene

get_zoom_level_info(index)

Get information about a level in the internal image pyramid.

property magnification

Scanning magnification extracted from the slide metadata.

property name

Scene name extracted from slide metadata.”

property num_aux_images

Number of auxiliary images of the scene.

property num_channels

Number of raster channels in the scene raster data.

property num_t_frames

Number of time frames in the scene raster data.

property num_z_slices

Number slices along Z axis in the scene raster data.

property num_zoom_levels

Number of zoom levels in internal image pyramid.

property origin

Coordinates of the top left corner of the scene. A tuple (x, y).

read_block(rect=(0, 0, 0, 0), size=(0, 0), channel_indices=[], slices=(0, 1), frames=(0, 1))

Reads rectangular block of the scene with optional rescaling.

Parameters
  • rect – block rectangle, defined as a tuple (x, y, widht, height), where x,y - pixel coordinates of the top left corner of the block relatively to the scene top left corner, width, height - block width and height

  • size – size of the block after rescaling. (0,0) - no scaling.

  • channel_indices – array of channel indices to be retrieved. [] - all channels.

  • slices – range of z slices (first, last+1) to be retrieved. (0,3) for 0,1,2 slices. (0,0) for the first slice only.

  • frames – range of time frames (first, last+1) to be retrieved.

Returns

numpy array with pixel values

property rect

Scene rectangle in pixels. A tuple (x-origin, y-origin, width, height).

property resolution

Scene resolution in meters per pixel (pixel size in meters). A tuple (x-res, y-res)

save_image(params, output_path, callback=None)

Save scene image to a file :param params: image format of the output file :param output_path: path to the output file :param callback: callback progress function

property size

Scene size in pixels. A tuple (width, height).

property t_resolution

Time distance between two time-frames in seconds.

property z_resolution

Distance between two Z-slices in meters.

slideio.compare_images(left, right)

Compares two images represented by numpy arrays

slideio.set_log_level(log_level: str)

Sets log level

slideio.convert_scene(scene, params, output_path, callback=None)

Save scene to a file with conversion

Parameters
  • scene – origin scene

  • params – image format of the output file

  • output_path – path to the output file

  • callback – callback progress function

slideio.transform_scene(scene, params)

Transform scene raster

Parameters
  • scene – origin scene

  • params – transformation parameters

class slideio.ColorSpace

Members:

GRAY

HSV

HLS

YCbCr

XYZ

Lab

Luv

YUV

property name
class slideio.DataType

Members:

Byte

Int8

Int16

Float16

Int32

Float32

Float64

UInt16

Unknown

None

property name

Examples:

import slideio
slideio.get_driver_ids()
> ['CZI', 'GDAL', 'SVS']
slide = slideio.open_slide(file_path="/data/a.czi",driver_id="CZI")
slide.get_num_scenes()
> 1