STAMP
An open-source, end-to-end software pipeline and standardized methodological protocol for Solid Tumor Associative Modeling in Pathology, developed by the Kather Lab (Else Kröner Fresenius Center for Digital Health, TU Dresden; RWTH Aachen; University Medical Center Mainz). Published in Nature Protocols (El Nahhas et al., 2024/2025; DOI: 10.1038/s41596-024-01047-2; PMID: 39285224).
GitHub Repository: KatherLab/STAMP
Web Interface: KatherLab/STAMP-Workbench
Published Protocol: El Nahhas OSM, van Treeck M, Wölflein G, Unger M, Ligero M, Lenz T, Wagner SJ, Hewitt KJ, Khader F, Foersch S, Truhn D, Kather JN. From whole-slide image to biomarker prediction: end-to-end weakly supervised deep learning in computational pathology. Nature Protocols 20, 293–316 (2025). DOI: 10.1038/s41596-024-01047-2
Companion Literature Review: [[From whole-slide image to biomarker prediction: end-to-end weakly supervised deep learning in computational pathology]]
Why STAMP Matters
Computational pathology has rapidly advanced with the introduction of self-supervised foundation models (such as UNI, Virchow, and CONCH). However, translating whole-slide images (WSIs) into clinically actionable diagnostic predictions requires a cohesive, standardized protocol that links gigapixel histology images, patient metadata, and downstream modeling while preventing fatal methodological traps (such as patient-level data leakage).
STAMP provides a complete, unified workflow covering the entire trajectory from raw slide scanning to validated clinical biomarker predictions:
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ STAMP SYSTEM ARCHITECTURE │
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
1. RAW TISSUE SLIDES (.svs, .ndpi, .mrxs, .tiff)
│
▼
┌──────────────────────────────────────────────────────────────────────┐
│ PREPROCESSING & FEATURE EXTRACTION (`stamp preprocess`) │
│ • Fast luminance-based tissue thresholding (brightness_cutoff: 240) │
│ • Micron-per-pixel standardization (default_slide_mpp: 1.0) │
│ • Reusable tile caching (lossless PNG or 100x compressed JPG) │
│ • Unified Factory: 18+ foundation encoders (UNI2, Virchow2, CONCH1.5)│
└──────────────────┬───────────────────────────────────────────────────┘
│ Standardized Patch Features (.h5)
▼
┌──────────────────────────────────────────────────────────────────────┐
│ CONTEXT ENCODING & MULTI-SLIDE FUSION │
│ • Slide Context: TITAN, PRISM, GigaPath, COBRA2, EAGLE, MADELEINE │
│ • Patient Virtual Slide Fusion: Concatenates multi-slide resections │
└──────────────────┬───────────────────────────────────────────────────┘
│ Patient-Level or Bag-Level Embeddings
▼
┌──────────────────────────────────────────────────────────────────────┐
│ WEAKLY SUPERVISED MODELING & MULTI-TARGET LEARNING │
│ • Vision Transformer (ViT) with ALiBi positional encoding │
│ • TransMIL linear self-attention across large tile bags │
│ • Barspoon Encoder-Decoder multi-target classification │
│ • Survival analysis (Cox loss) and continuous regression │
│ • Tabular clinicopathologic covariate fusion │
└──────────────────┬───────────────────────────────────────────────────┘
│ Trained Weights & Checkpoints (.ckpt)
▼
┌──────────────────────────────────────────────────────────────────────┐
│ EVALUATION, EXPLAINABILITY & AGENT INTEGRATION │
│ • Patient-stratified k-fold cross-validation (`stamp crossval`) │
│ • Automated AUROC, AUPRC, and 95% CI generation (`stamp statistics`) │
│ • Attention heatmaps, class maps, top/bottom predictive tiles │
│ • FastMCP Model Context Protocol server (`mcp/server.py`) │
└──────────────────────────────────────────────────────────────────────┘Key Features & Capabilities
1. Unified Feature Extractor Ecosystem (18+ Models)
STAMP includes pre-configured loaders with strict normalization and resolution enforcement across all major computational pathology foundation models:
ctranspath
256 px @ 10×
Swin Transformer
Pan-cancer H&E
chief-ctranspath
256 px @ 10×
Swin Transformer
Multi-tissue cancer & biomarkers
uni / uni2
256 px @ 20×
ViT-L/16, ViT-H/14
Multi-organ clinical pathology
conch / conch1_5
512 px @ 20×
CoCa ViT-B/16
Vision-language histopathology
virchow / virchow2 / virchow-full
224 px @ 20×
ViT-H/14 (1.5M/3.1M WSIs)
Clinical-grade oncology
gigapath
224 px @ 20×
LongNet / ViT
1.3B slide-level foundation model
h-optimus-0 / h-optimus-1
224 px @ 20×
ViT-g/14 (Bioptimus)
Multimodal biology & oncology
musk
224 px @ 20×
Multi-scale Vision Transformer
Single-cell & tissue patches
mstar
224 px @ 20×
Vision Transformer
Multi-stain histopathology
plip
224 px @ 20×
CLIP ViT-B/32
Medical visual-language alignment
dinobloom
224 px @ 40×
DINOv2 ViT
Generalizable cell hematology
red-dino
224 px @ 40×
DINOv2 ViT
Red blood cell morphology
keep
224 px @ 20×
Vision-Language ViT
Knowledge-enhanced diagnosis
ticon
224 px @ 20×
ViT
Tile contextualizer
2. Slide- and Patient-Level Context Encoders
Beyond instance-level feature extraction, STAMP supports direct whole-slide contextual embedding extraction using leading slide encoders:
TITAN (requires
conch1_5)PRISM (requires
virchow-full)GigaPath (requires
gigapath)COBRA2 (accepts
conch,uni,virchow2, orh-optimus-0)EAGLE (accepts
ctranspathorchief-ctranspath)MADELEINE (accepts
conch)CHIEF (accepts
chief-ctranspath)
3. Patient-Level "Virtual Slide" Concatenation
When a patient case involves multiple surgical blocks, naive pooling either loses spatial identity or biases sample counts. STAMP's encode_patients command concatenates multiple slides belonging to the same patient along the spatial coordinate axis, synthesizing a single "virtual slide" representing the complete surgical encounter. The resulting patient embeddings allow fast, lightweight MultiLayer Perceptron (MLP) classification that drastically reduces training times and prevents overfitting in low-sample cohorts.
4. Multi-Target Joint Classification (Barspoon)
Predicting related biomarkers independently (e.g., separate models for KRAS, BRAF, and NRAS in colorectal cancer) ignores biological correlations and co-occurrence patterns. STAMP integrates Barspoon, an Encoder-Decoder Transformer architecture that takes an arbitrary list of target columns in clini_table and predicts the entire molecular panel simultaneously, improving label efficiency on co-occurring driver mutations.
5. Survival Analysis and Continuous Regression
STAMP natively switches its loss functions, network heads, and metrics based on task:
task: "classification": Cross-entropy loss, AUROC, AUPRC, sensitivity, specificity, F1.task: "regression": Mean Squared Error (MSE), Pearson and Spearman rank correlation coefficients.task: "survival": Cox proportional hazards partial likelihood loss evaluating right-censored time-to-event outcomes (time_labelandstatus_label) assessed via Concordance Index (C-index).
6. Explainability: Heatmaps, Class Maps & Top/Bottom Tiles
Spatial Attention Heatmaps: Overlays normalized attention scores over slide overviews to visualize focal hotspots.
Class Maps: Categorical segmentation showing which disease phenotype or grade each tile votes for.
Top / Bottom Tile Extraction: Automatically crops and outputs the top-$k$ most predictive patches and bottom-$k$ least predictive patches (
topk: 5,bottomk: 5), enabling pathologists to audit model reasoning and identify potential confounders.
Installation & Architecture
STAMP utilizes uv to manage strict, reproducible environments with pinned dependencies. Notably, complex compiled GPU extensions (flash-attn, mamba-ssm, and causal-conv1d) are distributed via the Astral pre-built wheel index compiled against CUDA 13.0 and PyTorch 2.11, eliminating brittle local C++/CUDA compilation failures.
CLI Commands & Configuration
STAMP exposes a unified command-line interface driven by a single YAML configuration file (config.yaml):
Complete End-to-End Workflow
Step 1: Initialize Configuration File
Step 2: Preprocess WSIs into Feature Embeddings
Step 3: Run Patient-Stratified Cross-Validation
Step 4: Compute Aggregated Statistics & ROC/PR Curves
Step 5: Generate Attention Heatmaps and Top Tiles
Native FastMCP Server & Agentic Orchestration
STAMP v2.5 introduces a native FastMCP server (mcp/server.py), allowing autonomous LLM coding agents (such as Antigravity, Claude, or OpenAI Agents) to run computational pathology experiments directly via Model Context Protocol:
Available MCP Tools:
preprocess_stamp(): Tile and extract features from whole-slide images.train_stamp(): Train weakly supervised MIL models on extracted embeddings.crossval_stamp(): Run $k$-fold cross-validation with patient-level splitting.deploy_stamp(): Deploy trained models to held-out test sets.encode_slides_stamp(): Compute whole-slide representations via slide encoders (TITAN, PRISM, etc.).encode_patients_stamp(): Synthesize patient-level virtual slides across multi-block cases.heatmaps_stamp(): Generate spatial attention overlays, class maps, and audit tiles.statistics_stamp(): Aggregate AUROCs, AUPRCs, and 95% confidence intervals.check_available_devices(): Query available CUDA, MPS, or CPU acceleration.analyze_csv()&list_column_values: Validate clinical metadata and slide mapping tables.
Launching the FastMCP Server:
Vault Context & Literature Connections
[[From whole-slide image to biomarker prediction: end-to-end weakly supervised deep learning in computational pathology]] — Comprehensive clipping note reviewing the Nature Protocols publication.
[[TRIDENT]] — High-throughput WSI processing toolkit from the Mahmood Lab supporting 33+ patch encoders and 8+ slide encoders with SSD caching.
[[PathoActivationAtlas]] — Visual interpretability framework from the Kather Lab generating class visualizations and activation atlases for foundation models.
[[HERO: Histology Encoder for Robust Representation in Oncology]] — Caris Life Sciences foundation model evaluated on slide-level tasks using weakly supervised attention pooling.
[[Navigating foundation model selection in digital pathology through performance evaluation and tradeoff analysis]] — Systematic trade-off analysis of pathology foundation models.
[[Digital Pathology Software]] — Catalog of software, libraries, and frameworks across digital and computational pathology.
Last updated