Module functions

class slideio.Compression

Members:

Unknown

Uncompressed

Jpeg

JpegXR

Png

Jpeg2000

LZW

HuffmanRL

CCITT_T4

CCITT_T6

LempelZivWelch

JpegOld

Zlib

JBIG85

JBIG43

NextRLE

PackBits

ThunderScanRLE

RasterPadding

RLE_LW

RLE_HC

RLE_BL

PKZIP

KodakDCS

JBIG

NikonNEF

JBIG2

GIF

BIGGIF

property name

handle) -> str

Type

(self

class slideio.Scene(slide, index: int)

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)

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 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.

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 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)

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.

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

slideio.compare_images(left, right)

Compares two images represented by numpy arrays

slideio.get_driver_ids()

Returns a list of ids of available image drivers

slideio.open_slide(path: str, driver: str)

Returns an instance of a slide object

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