Abstract
Accurate classification of Whole Slide Images (WSIs) and Regions of Interest (ROIs) is a fundamental challenge in computational pathology. While mainstream approaches often adopt Multiple Instance Learning (MIL), they struggle to capture the spatial dependencies among tissue structures. Graph Neural Networks (GNNs) have emerged as a solution to model inter-instance relationships, yet most rely on static graph topologies and overlook the physical spatial positions of tissue patches. Moreover, conventional attention mechanisms lack specificity, limiting their ability to focus on structurally relevant regions. In this work, we propose a novel GNN framework with deformable attention for pathology image analysis. We construct a dynamic weighted directed graph based on patch features, where each node aggregates contextual information from its neighbors via attention-weighted edges. Specifically, we incorporate learnable spatial offsets informed by the real coordinates of each patch, enabling the model to adaptively attend to morphologically relevant regions across the slide. This design significantly enhances the contextual field while preserving spatial specificity. Our framework achieves state-of-the-art performance on four benchmark datasets (TCGA-COAD, BRACS, gastric intestinal metaplasia grading, and intestinal ROI classification), demonstrating the power of deformable attention in capturing complex spatial structures in WSIs and ROIs.
Introduction
In computational pathology, the analysis of gigapixel-scale Whole Slide Images (WSIs) presents a significant computational challenge. Due to the massive resolution, standard practice involves Multiple Instance Learning (MIL), where images are decomposed into thousands of small patches. However, conventional MIL frameworks often treat these patches as an unordered "bag of words," neglecting the critical spatial relationships and tissue architecture that are essential for accurate diagnosis.
While Graph Neural Networks (GNNs) and Transformers have been introduced to model these dependencies, they face three primary hurdles: static topologies that fail to adapt to irregular tumor shapes, the neglect of absolute physical coordinates, and the quadratic computational cost of global self-attention. This paper introduces the Deformable Attention Graph (DAG), a framework designed to overcome these limitations by adaptively "stretching" its attention toward morphologically relevant regions using learnable spatial offsets.
The Deformable Attention Graph Framework
The core of the DAG framework is the treatment of patches as nodes in a dynamic, weighted directed graph. Unlike standard attention mechanisms that operate on fixed grids or global sets, DAG employs several novel components:
- Learnable Spatial Offsets: A lightweight "OffsetNet" predicts $K$ spatial offsets for each patch. This allows the model to dynamically reach beyond immediate neighbors to attend to distant but morphologically related regions.
- Physical Coordinate Integration: By utilizing the actual $(x, y)$ coordinates of each patch, the model calculates query points as the sum of the original coordinate and the learned offset.
- Dynamic Edge Construction: For every query point, the model identifies the nearest actual patch in the WSI, creating a flexible graph structure that adapts to the underlying tissue architecture.
This approach effectively adapts deformable attention—originally designed for rigid grids in natural images—to the sparse and irregular distribution of patches in histopathology slides.
Experimental Evaluation
The DAG framework was evaluated across four diverse datasets, utilizing the UNI pathology foundation model as the backbone feature encoder for all experiments:
- TCGA-COAD: 465 slides for colon adenocarcinoma classification.
- Gastric Intestinal Metaplasia: 984 slides for grading gastric lesions.
- BRACS: 4,492 images for breast cancer subtyping.
- Intestinal Cancer Classification: 9,381 images for multi-class tissue classification.
Performance Results
DAG consistently outperformed state-of-the-art baselines, including TransMIL, WiKG, and CLAM-SB. On the TCGA-COAD dataset, it achieved an accuracy of 87.31%, representing a 0.64% improvement over the next best method (DyHG). Similarly, it reached 80.39% accuracy on the Gastric-IM dataset, outperforming competitors by 0.8%.
Interpretability and Qualitative Analysis
A key advantage of the DAG framework is its interpretability. Visualization of the attention maps reveals that the model is significantly better at "hugging" the actual boundaries of lesions compared to standard models, which often produce blurry or over-extended regions of interest.
Ablation studies further confirmed that the inclusion of absolute spatial coordinates is vital; where a tissue structure is located often provides as much diagnostic value as its morphological appearance. The model demonstrated robustness, performing optimally with approximately 8 neighbors, balancing computational efficiency with sufficient contextual capture.
Conclusion
The Deformable Attention Graph framework represents a significant step forward in WSI analysis by successfully integrating spatial specificity with dynamic graph learning. By moving beyond static grids and incorporating physical coordinates, DAG captures complex tissue architectures more effectively than previous MIL or GNN approaches. Future work will focus on extending this framework to granular tasks such as automated segmentation and more specific clinical entity recognition.
Summary updated