WSIMeta¶
tiatoolbox
.wsicore
.wsimeta
.WSIMeta
- class WSIMeta(slide_dimensions, axes, level_dimensions=None, objective_power=None, level_count=None, level_downsamples=(1,), vendor=None, mpp=None, file_path=None, raw=None)[source]¶
Whole slide image metadata class.
- Parameters:
slide_dimensions (int, int) – Tuple containing the width and height of the WSI. These are for the baseline (full resolution) image if the WSI is a pyramid or multi-resolution.
level_dimensions (list) – A list of dimensions for each level of the pyramid or for each resolution in the WSI.
objective_power (float, optional) – The power of the objective lens used to create the image.
level_count (int | None) – (int, optional): The number of levels or resolutions in the WSI. If not given this is assigned len(level_dimensions). Defaults to None.
level_downsamples (
list
offloat
) – List of scale values which describe how many times smaller the current level is compared with the baseline.vendor (str, optional) – Scanner vendor/manufacturer description.
file_path (Path, optional) – Path to the corresponding WSI file.
raw (dict, optional) – Dictionary of unprocessed metadata extracted from the WSI format. For JPEG-2000 images this contains an xml object under the key “xml”.
axes (str)
- slide_dimensions¶
Tuple containing the width and height of the WSI. These are for the baseline (full resolution) image if the WSI is a pyramid or multi-resolution. Required.
- axes¶
Axes ordering of the image. This is most relevant for OME-TIFF images where the axes ordering can vary. For most images this with be “YXS” i.e. the image is store in the axis order of Y coordinates first, then X coordinates, and colour channels last.
- Type:
- level_dimensions¶
A list of dimensions for each level of the pyramid or for each resolution in the WSI. Defaults to [slide_dimension].
- Type:
- objective_power¶
The magnification power of the objective lens used to scan the image. Not always present or accurate. Defaults to None.
- Type:
- level_count¶
(int): The number of levels or resolutions in the WSI. If not given this is assigned len(level_dimensions). Defaults to len(level_dimensions).
- level_downsamples¶
List of scale values which describe how many times smaller the current level is compared with the baseline. Defaults to (1,).
- mpp¶
Microns per pixel. Derived from objective power and sensor size. Not always present or accurate. Defaults to None.
- file_path¶
Path to the corresponding WSI file. Defaults to None.
- Type:
Path
- raw¶
Dictionary of unprocessed metadata extracted from the WSI format. For JP2 images this contains an xml object under the key “xml”. Defaults to empty dictionary.
- Type:
Initialize WSIMeta.
Methods
Convert WSIMeta to dictionary of Python types.
Get the downsample factor for a level.
Calculate scale of each level in the WSI relative to given resolution.
Validate passed values and cast to Python types.
- level_downsample(level)[source]¶
Get the downsample factor for a level.
For non-integer values of level, the downsample factor is linearly interpolated between from the downsample factors of the level below and the level above.
- relative_level_scales(resolution, units)[source]¶
Calculate scale of each level in the WSI relative to given resolution.
Find the relative scale of each image pyramid / resolution level of the WSI relative to the given resolution and units.
Values > 1 indicate that the level has a larger scale than the target and < 1 indicates that it is smaller.
- Parameters:
resolution (Resolution) – Scale to calculate relative to units.
units (Units) – Units of the scale. Allowed values are: “mpp”, “power”, “level”, “baseline”. Baseline refers to the largest resolution in the WSI (level 0).
self (WSIMeta)
- Raises:
ValueError – Missing MPP metadata.
ValueError – Missing objective power metadata.
ValueError – Invalid units.
- Returns:
Scale for each level relative to the given scale and units.
- Return type:
Examples
>>> from tiatoolbox.wsicore.wsireader import WSIReader >>> wsi = WSIReader.open(input_img="./CMU-1.ndpi") >>> print(wsi.info.relative_level_scales(0.5, "mpp")) [array([0.91282519, 0.91012514]), array([1.82565039, 1.82025028]) ...
>>> from tiatoolbox.wsicore.wsireader import WSIReader >>> wsi = WSIReader.open(input_img="./CMU-1.ndpi") >>> print(wsi.info.relative_level_scales(0.5, "baseline")) [0.125, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0]