Skip to main content
Tile specification dataclass. Defines TileSpec, a pure data structure describing tile geometry (size, stride, resolution, measurement unit). This module lives in the data layer so it can be imported by both bioptimus.extraction and bioptimus.models without creating circular dependencies. For backward compatibility, TileSpec is re-exported from types.

TileSpec

Defines the specifications of a tile within a WSI for extraction.
The size of the tile as (width, height) or a single integer for both dimensions.
The stride of the tile as (stride_width, stride_height) or a single integer for both dimensions.
The resolution at which the tile is defined.
The unit of measurement for the tile dimensions.
Example:

size

(width, height)

stride

(stride_width, stride_height)

width

Returns the tile width.

height

Returns the tile height.

stride_width

Returns the horizontal stride.

stride_height

Returns the vertical stride.

scale_to_reference

Returns a new TileSpec scaled to reference-level pixels.
float
required
Ratio of the reference-level downsample to the target-resolution downsample.
MPP
required
Microns-per-pixel at the target resolution.
TileSpec
A new TileSpec in reference-level pixels.
Raises:
  • ValueError — If unit is not PIXELS or UM.