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

Spatial Context-Driven Positive Pair Sampling for Enhanced Histopathology Image Classification

Willmer Rafell Quiñones Robles, Sakonporn Noree, Young Sin Ko, Bryan Wong, Jongwoo Kim, Mun Yong Yi · OpenReview

Abstract

Deep learning has demonstrated great promise in cancer classification from whole-slide images (WSIs) but remains constrained by the need for extensive annotations. Annotation-free methods, such as multiple instance learning (MIL) and self-supervised learning (SSL), have emerged to address this challenge; however, current SSL techniques often depend on synthetic augmentations or temporal context, which may not adequately capture the intricate spatial relationships inherent to histopathology. In this work, we introduce a novel spatial context-driven positive pair sampling strategy for SSL that leverages the natural coherence of adjacent patches in WSIs. By constructing biologically relevant positive pairs from spatially proximate patches, our approach harnesses inherent spatial coherence to enhance patch-level representations, ultimately boosting slide-level classification performance. Experiments on multiple datasets reveal that our strategy improves classification accuracy by 5% to 10% over the standard method, paving the way for more clinically relevant AI models in cancer diagnosis.

Introduction

In computational pathology, Whole-Slide Images (WSIs) are gigapixel-scale digital files that present significant processing challenges for standard deep learning models. The prevailing approach involves partitioning these slides into smaller "patches." To train models on these patches without the prohibitive cost of expert labeling, researchers increasingly rely on Self-Supervised Learning (SSL).

However, conventional SSL typically utilizes "instance discrimination," where a single patch is transformed into two different "views" via synthetic augmentations like flipping or color jittering. While effective for natural images, this approach often fails to capture the complex spatial structures of human tissue. It ignores a fundamental biological truth: spatially adjacent patches are highly likely to share identical biological properties. By treating these neighbors as unrelated, standard SSL overlooks a rich, inherent source of supervisory signal.

Methodology

We propose a Spatial Context-Driven Positive Pair Sampling strategy that incorporates immediate spatial neighbors into the SSL training objective. This method moves beyond simple transformation invariance to leverage the natural morphological coherence of tissue.

Overview of the Dual Positive Pair sampling strategy, illustrating the combination of standard augmentation-based pairs and contextual neighbor-based pairs.

Key Components:

  1. Contextual Pairing: For any given "pivot" patch, the algorithm identifies its immediate neighbors within a Chebyshev distance of 1 (the eight surrounding patches).
  2. Dual Loss Function: The training objective is modified to balance two goals: transformation invariance (learning that a patch is the same despite synthetic changes) and spatial coherence (learning that a patch should have a similar representation to its immediate neighbor).
  3. Modular Integration: The method is framework-agnostic and has been successfully integrated into major SSL architectures, including Barlow Twins (BT), BYOL, VICReg, and DINOv2.

Experimental Setup

The study utilized four distinct datasets to ensure robustness across different organs and cancer types:

  • Camelyon16 (Public): Breast cancer metastasis in lymph node sections.
  • TCGA NSCLC (Public): Lung cancer subtypes (Adenocarcinoma vs. Squamous Cell Carcinoma).
  • Stomach Tissue (Private): 600 WSIs categorized into normal, dysplastic, and malignant.
  • Colorectal Tissue (Private): 600 WSIs with similar diagnostic categories.

Results and Discussion

Our experiments demonstrate that the contextual approach consistently outperforms standard SSL across all tested datasets and frameworks.

Performance comparison of standard vs. contextual SSL across multiple datasets, showing consistent improvements in Accuracy and AUROC.

Key Insights:

  • The "Goldilocks" Zone of Distance: Performance consistently peaks at a Chebyshev distance of 1. As the distance between patches increases, the likelihood of a "mismatch" (sampling two different tissue types) rises, leading to a decline in representation quality.
  • Biological Grounding: While color jittering helps models ignore staining variations, spatial context helps models understand morphology. This mimics the workflow of human pathologists who analyze surrounding architecture rather than isolated cells.
  • Closing the Supervision Gap: In several experiments, particularly on the Colon dataset, the contextual SSL approach nearly closed the performance gap between self-supervised and fully supervised models.
  • Architecture Resilience: Improvements were observed for both traditional Convolutional Neural Networks (ResNet-18) and modern Vision Transformers (ViT-Tiny), though Transformers showed higher sensitivity to the quality of the spatial context.

Conclusion

By leveraging the inherent spatial coherence of histopathology images, our spatial context-driven sampling strategy provides a modular, "plug-and-play" enhancement for SSL. While the current study used a fixed magnification (20x) and patch size (256x256), future work will explore adaptive sampling radii based on local tissue complexity and hierarchical spatial context across multiple resolutions. This approach represents a significant step toward more biologically grounded and clinically relevant AI models for cancer diagnosis.

Summary updated

BibTeX
@misc{robles2025spatial,
  author = {Willmer Rafell Quiñones Robles and Sakonporn Noree and Young Sin Ko and Bryan Wong and Jongwoo Kim and Mun Yong Yi},
  title = {{Spatial Context-Driven Positive Pair Sampling for Enhanced Histopathology Image Classification}},
  year = {2025},
  eprint = {2503.05170},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.05170},
}
Figure