Class Scene

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.