wsidata.open_wsi#

open_wsi(wsi, store='auto', reader=None, attach_images=False, image_key=None, save_images=False, attach_thumbnail=False, thumbnail_key='wsi_thumbnail', thumbnail_size=2000, save_thumbnail=False, **kwargs)#

Open a whole slide image.

You can attach images and thumbnails to the SpatialData object. By default, only the thumbnail is attached, the thumbnail is a downsampled version of the whole slide image, the original image is not attached as it will make unnecessary copies of the data on disk when saving the SpatialData object.

Parameters:
wsistr or Path or SpatialData

The path to whole slide image, or an existing SpatialData object. When passing a SpatialData object, image_key must be provided.

storestr, optional

The backed file path, by default will create a zarr file with the same name as the slide file. You can either supply a file path or a directory. If a directory is supplied, the zarr file will be created in that directory. This is useful when you want to store all zarr files in a specific location. Pass None to skip persistence (no zarr store will be set).

readerstr, optional

Reader to use, by default None. Passing None enables automatic reader selection. To check avaiable readers: print(wsidata.READERS)

attach_imagesbool, optional, default: False

Whether to attach whole slide image to image slot in the spatial data object.

image_keystr, optional

The key to store the whole slide image, by default “wsi”. If the wsi is a SpatialData object, the image from this key will be used as the whole slide image.

save_imagesbool, optional, default: False

Whether to save the whole slide image to on the disk. Only works for wsi.save() method.

attach_thumbnailbool, optional, default: False

Whether to attach thumbnail to image slot in the spatial data object.

thumbnail_keystr, optional

The key to store the thumbnail, by default “wsi_thumbnail”.

thumbnail_sizeint, optional, default: 2000

The size of the thumbnail.

save_thumbnailbool, optional, default: False

Whether to save the thumbnail to on the disk. Only works for wsi.write() method.

Returns:
WSIData

Whole slide image data.

Examples

>>> from wsidata import open_wsi
>>> wsi = open_wsi("slide.svs")