NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Masked Pre-Training of Transformers for Histology Image Analysis

Shuai Jiang, Liesbeth Hondelink, Arief A. Suriawinata, Saeed HassanpourarXiv 2023

Abstract

In digital pathology, whole slide images (WSIs) are widely used for applications such as cancer diagnosis and prognosis prediction. Visual transformer models have recently emerged as a promising method for encoding large regions of WSIs while preserving spatial relationships among patches. However, due to the large number of model parameters and limited labeled data, applying transformer models to WSIs remains challenging. Inspired by masked language models, we propose a pretext task for training the transformer model without labeled data to address this problem. Our model, MaskHIT, uses the transformer output to reconstruct masked patches and learn representative histological features based on their positions and visual features. The experimental results demonstrate that MaskHIT surpasses various multiple instance learning approaches by 3% and 2% on survival prediction and cancer subtype classification tasks, respectively. Furthermore, MaskHIT also outperforms two of the most recent state-of-the-art transformer-based methods. Finally, a comparison between the attention maps generated by the MaskHIT model with pathologist's annotations indicates that the model can accurately identify clinically relevant histological structures in each task.

Introduction

Digital pathology relies on Whole Slide Images (WSIs) for critical tasks like cancer diagnosis and prognosis. While Vision Transformers (ViTs) can capture spatial relationships across large regions, they are data-hungry and prone to overfitting on limited labeled medical datasets. Traditional Multiple Instance Learning (MIL) methods treat patches as unordered "bags," effectively ignoring the spatial context and geographical relationships between different tissue structures.

To bridge this gap, we introduce MaskHIT (Masked Pre-training for Histology Images using Transformer). This approach teaches the model to understand complex tissue architecture through self-supervised learning before any medical labels are introduced, allowing it to capture vital spatial dependencies that MIL methods miss.

Methodology

MaskHIT utilizes a hybrid architecture designed to process massive histological regions efficiently. The pipeline consists of several key stages:

  1. Feature Extraction: A pre-trained ResNet backbone acts as a fixed feature extractor, converting $224 \times 224$ pixel patches into compact feature vectors.
  2. Transformer Backbone: These vectors are processed by a transformer that handles large regions (e.g., $4480 \times 4480$ pixels). Positional encodings are integrated to preserve the spatial arrangement of patches within the region.
  3. Masked Pre-training: Inspired by BERT, the model randomly masks 40% of the patches. The transformer is then tasked with reconstructing the features of these missing patches based on the surrounding context.
  4. Dual Loss Function: Training is guided by a combination of Restoration Loss ($L_2$), which minimizes the distance between reconstructed and original features, and Contrastive Loss (InfoNCE), which ensures the model learns unique, representative features.
Overview of the MaskHIT architecture, illustrating (a) the masked pre-training phase with dual loss functions and (b) the fine-tuning process for clinical tasks like survival prediction.

Experimental Setup

The model was pre-trained on a massive dataset from The Cancer Genome Atlas (TCGA), encompassing 14 cancer types, over 7,000 slides, and 60 million tissue patches. Evaluation was conducted on survival prediction and cancer subtyping tasks across five major cancer types (BRCA, COAD, LGG, LUAD, OV). Additionally, an external benchmark using a dataset from Dartmouth-Hitchcock Medical Center (DHMC) was used to validate the model's performance on Renal Cell Carcinoma (RCC) subtype classification.

Results and Discussion

MaskHIT demonstrated significant performance gains over traditional MIL methods and recent state-of-the-art transformer architectures.

Quantitative Performance

In survival prediction tasks, MaskHIT achieved an average c-index of 0.612, representing a 3% improvement over the best MIL baseline (MHAttn). In cancer subtyping, the model reached an AUC of 0.958–0.964, outperforming MIL approaches by approximately 2%. Notably, MaskHIT-20x outperformed the Hierarchical Image Pyramid Transformer (HIPT) across multiple survival tasks, showing an average c-index increase of 0.071.

Comparison of survival prediction performance (c-index) across five TCGA datasets. MaskHIT consistently outperforms various Multiple Instance Learning (MIL) baselines.

Key Insights

  • The Necessity of Pre-training: Ablation studies revealed that without the masked pre-training phase, the transformer performed worse than simple MIL. The model's strength lies in its ability to learn the "grammar" of tissue architecture during the self-supervised phase.
  • Scale and Efficiency: Performance improved as the region size increased, suggesting that a wider "neighborhood" of tissue provides better predictive context. Furthermore, MaskHIT showed remarkable data efficiency, outperforming other models even when trained on only 25% of the available data.
  • Interpretability: Visualization of attention maps confirmed that the model naturally focuses on clinically relevant areas, such as tumor regions and necrosis, aligning with human pathologist annotations.

Conclusion

MaskHIT addresses the challenges of applying transformers to digital pathology by leveraging masked self-supervised pre-training. By capturing spatial dependencies within large tissue regions, the model significantly improves performance in cancer diagnosis and prognosis. Future work will focus on capturing global relationships across entire slides and reducing the quadratic computational cost associated with increasing region sizes.

Summary updated

BibTeX
@misc{jiang2023masked,
  author = {Shuai Jiang and Liesbeth Hondelink and Arief A. Suriawinata and Saeed Hassanpour},
  title = {{Masked Pre-Training of Transformers for Histology Image Analysis}},
  year = {2023},
  eprint = {2304.07434},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.07434},
}
Figure