PytorchTileDataset, a torch.utils.data.Dataset adapter that wraps WSIDataset for use with torch.utils.data.DataLoader. Two sampling modes are supported:
"sequential"— patches in slide-load order (deterministic)."random"— same patches, but indices are shuffled each epoch.
- A ready-made
WSIDataset. - A directory path (
strorPath) — all supported WSI files inside it are discovered and loaded. - A list of file paths — each path is opened as a slide.
SamplingMode
SEQUENTIAL- Iterate over every patch in slide-load order.RANDOM- Shuffle the global patch indices each epoch.
PytorchTileDataset
WSIDataset, a directory path, or a list of file paths. When a path or list is given, extractor is required so the slides can be opened and tiled automatically.
"sequential" (default) Patches are returned in the order slides were loaded — slide 0 patch 0, slide 0 patch 1, …, slide N patch M.
"random" The same set of patches, but the global indices are shuffled. Call shuffle between epochs (or at init) to re-randomise.
In both modes len() equals the total patch count, and every patch is visited exactly once per full iteration.
One of:
- A
WSIDatasetinstance (used directly). - A
strorPathpointing to a directory — all supported WSI files are discovered and loaded. - A
listof file paths — each is opened as a slide.
extractor- Required when data is a path or list of paths. A configuredTileExtractorused to tile each slide.sampling-"sequential"or"random"(default"sequential").transform- Optional callable applied to thenp.ndarray(H, W, C)patch.seed- Optional RNG seed for reproducible shuffling.
ValueError- If data is a path/list but extractor is not provided.FileNotFoundError- If a directory path contains no supported WSIs.
shuffle
sampling is "sequential".
Optional RNG seed for reproducibility.
__len__
int- Total patch count across all slides.
__getitem__
(patch, metadata) tuple for a global patch index.
Global patch index (0-based).

