Skip to main content
Tile and mega-tile specification types for WSI extraction. Defines the TileSpec and MegaTileSpec dataclasses as well as the GridLayout enum and the MegaTileRegion container. TileSpec Encapsulates tile size, stride, target resolution, and measurement unit. Used by TileExtractor. GridLayout Enum for rectangular vs. hexagonal tiling grids. MegaTileSpec Describes a mega tile — a grid of smaller tiles — including grid dimensions, per-tile specification, layout, stride, and valid-tile-ratio bounds. Used by MegaTileExtractor. MegaTileRegion Immutable container returned by the mega-tile extractor. Holds the top-left location, grid shape, per-tile RegionSpec list, tile-availability mask, and aggregate tissue statistics. Example:

GridLayout

Layout strategy for arranging tiles within a mega tile.
Standard row-major rectangular grid.
Offset hex grid — odd rows are shifted right by half a tile width, producing a honeycomb pattern.
Example:

MegaTileSpec

Defines the specification of a mega tile — a grid of smaller tiles. A mega tile groups rows × cols individual tiles into a single logical region that can be extracted from a WSI. The per-tile geometry is delegated to TileSpec.
tuple[int, int]
Number of tiles as (rows, cols).
TileSpec
Size, stride, resolution, and unit for each individual tile.
GridLayout
Rectangular or hexagonal arrangement. Defaults to RECTANGULAR.
tuple[int, int] | None
Stride expressed in number of tiles as (stride_rows, stride_cols). None defaults to megatile_shape (no overlap).
float
Minimum fraction of tiles that must pass the tissue-mask threshold for the mega tile to be kept. Defaults to 0.5.
float | None
Optional upper bound on the valid-tile fraction. None means no upper limit.
Example:

megatile_shape

(rows, cols) in number of tiles

megatile_stride

(stride_rows, stride_cols)

rows

Number of tile rows in the mega tile.

cols

Number of tile columns in the mega tile.

num_tiles

Total number of tiles in the mega tile grid.

effective_stride

Returns the stride, defaulting to megatile_shape when not set.
tuple[int, int]
tuple[int, int]: (stride_rows, stride_cols) in tiles.

MegaTileRegion

A group of tiles forming one extracted mega tile. Returned by MegaTileExtractor.
RegionLocation
Absolute slide coordinates of the top-left corner of the mega tile.
MegaTileSpec
The specification that produced this mega tile (grid shape, tile spec, layout, stride, and valid-ratio bounds).
List[RegionSpec]
Per-tile region specifications, ordered row-major (tile_specs[row * cols + col]).
np.ndarray
Boolean array of shape (rows, cols) indicating which tiles passed the tissue threshold.
float
Fraction of tiles that are valid (tissue).
Example:

grid_shape

(rows, cols) — number of tiles in each direction.

grid_layout

Layout used during extraction.

rows

Number of tile rows.

cols

Number of tile columns.

num_valid_tiles

Count of tiles that passed the tissue threshold.

num_tiles

Total tile slots in the grid.