- Tissue masking — a whole-slide image is mostly background. Tissue segmentation produces a binary mask so background is discarded before the expensive feature step.
- Tiling — the slide is too large to process at once, so it is split into small, model-sized tiles. Only tiles that overlap tissue are kept.
Resolutions differ by stage: tissue segmentation runs at 8 µm/px (coarse, 512×512 tiles), while embeddings and gene predictions run at 0.5 µm/px (224×224 tiles). The mask is generated once and reused to filter the fine-resolution grid.
The quick path: the Inference pipeline
Inference masks tissue, caches the result, and reuses it automatically for later embed/predict calls.
<workspace>/tissue/<slide>.png and reused on the next tissue(), embed(), or predict() call. Visualize it against the slide thumbnail with the built-in helper:

Tissue mask (right) beside the slide thumbnail (left), TCGA-LUAD TCGA-75-7027. Background is discarded before feature extraction. Representative example.
The manual path: masks and tiles as artifacts
1. Generate a tissue mask
Build a mask provider from the tissue-seg endpoint. It is reusable across slides — it generates a fresh mask per slide..npy):
2. Tile the slide
ATileSpec defines the tile geometry; TileExtractor builds the grid, filters it against the mask, and exports the tiles. Passing mask_provider lets the extractor generate the per-slide mask during fit.
to_csv writes one row per retained tile:
save writes each tile image as {slide}_x{left}_y{top}_w{width}_h{height}_{res}_mask_r{ratio}.png.

