Cell Graph Transformer for Nuclei Classification

Wei Lou, Guanbin Li, Xiang Wan, Haofeng Li

TL;DR

The Cell Graph Transformer (CGT) advances nuclei classification in histopathology by treating both cells and their connections as learnable tokens, allowing for flexible, long-range context modeling. To overcome the training instability of graph-based transformers, the authors introduce a Topology-Aware Pretraining (TAP) strategy that uses a robust Graph Convolutional Network (GCN) to "warm up" the feature extractor, leading to state-of-the-art performance across multiple benchmarks.

What Problem Does This Paper Address?

In computational pathology, identifying the types of cell nuclei (e.g., inflammatory, epithelial, neoplastic) is vital for disease diagnosis and prognosis. Traditional methods often use Convolutional Neural Networks (CNNs), which excel at local pixel features but struggle to capture the broader "macrostructure"—how cells are organized and interact across a tissue sample.

To capture these relationships, researchers turned to Graph Neural Networks (GNNs). By representing nuclei as nodes and their spatial relationships as edges, GNNs can model cellular microenvironments. However, standard GNNs are limited: they typically pass messages only between immediate neighbors over fixed, non-learnable edges. While Transformers offer the flexibility to capture long-range dependencies, they are notoriously difficult to train on graphs from scratch. Poorly initialized features lead to "noisy" self-attention, where the model struggles to distinguish meaningful biological connections from random correlations.

Methods

The authors propose a two-stage framework to get the best of both worlds: the structural robustness of GCNs and the expressive power of Transformers.

1. The Cell Graph Transformer (CGT)

The CGT architecture consists of three main components:

  • Cell Graph Construction: Nuclei centroids are detected, and a $k$-nearest neighbor graph is built to define spatial relationships.
  • Cell Graph Tokenization (CGToken): This is the "secret sauce." Unlike standard Transformers that only look at nodes, CGT treats both nodes (nuclei) and edges (connections) as input tokens. To preserve the graph's structure, they use Link Markers (derived from Laplacian eigenvectors) and Token Markers to tell the Transformer which tokens are nodes, which are edges, and how they are connected.
  • Transformer Encoder: A standard stack of transformer layers processes these tokens, allowing every node to potentially attend to every other node and edge, enabling a highly flexible "learnable adjacency."
Figure 2: Overview of the Cell Graph Transformer (CGT) framework. The framework includes the construction and tokenization of cell graphs as well as a transformer encoder. Tokens are the input feature vectors of the transformer encoder. Adjacency is embedded into the tokens via link and token markers.

2. Topology-Aware Pretraining (TAP)

To solve the convergence issue, the authors introduce TAP. Before training the Transformer, they use a GCN to pretrain the CNN-based feature extractor. Because GCNs are constrained by the fixed graph topology, they are more robust to initial noise. This "structure-guided" pretraining ensures that by the time the Transformer starts learning, the visual features already reflect the underlying biological organization.

Figure 3: The proposed Topology-Aware Pretraining Strategy. It trains the feature extractor with an instance-level nuclei clas- sification loss and two pixel-level auxiliary losses. The model weights of the trained feature extractor are then used to initialize the feature extractor in training the proposed cell graph transformer.

Datasets

The model was evaluated on four major nuclei classification benchmarks:

  • PanNuke: 7,901 images across 19 organs.
  • Lizard: A large-scale dataset for colonic nuclear instance segmentation.
  • NuCLS: 1,744 image patches from breast cancer images.
  • BRCA-M2C: 120 image patches focused on inflammatory, epithelial, and stromal cells.

Key Insights and Ideas

  • Edges are Tokens Too: By explicitly tokenizing edges, the model can learn specific representations for the interactions between cells, not just the cells themselves.
  • GCNs as a "Training Wheels" for Transformers: The most significant "aha" moment is using the local, rigid message-passing of a GCN to stabilize the early feature learning of a global, flexible Transformer.
  • Link Markers for Topology: Using Laplacian eigendecomposition to create link markers is a clever way to inject graph connectivity into a sequence-based Transformer without losing the benefits of global attention.

Key Results

The CGT achieved state-of-the-art (SOTA) results across all tested datasets.

  • Performance Boost: On PanNuke, NuCLS, and Lizard, the CGT outperformed the previous best models by 1.9%, 3.4%, and 3.2% in average F-score ($F_{avg}$), respectively.
  • Ablation Success: The ablation studies proved that the TAP strategy is critical. Using GCN-based pretraining improved the final Transformer's performance by 7.4% compared to standard ImageNet pretraining.
  • Visual Accuracy: Qualitative results show that CGT is much better at distinguishing between similar-looking cell types (like tumor vs. stromal cells) by looking at how they are clustered and connected.
Visual comparison of results

Limitations and Future Work

  • Computational Complexity: While the inference time is manageable, the model size and memory requirements are higher than standard GNNs. The authors noted they couldn't test more than four transformer layers due to GPU memory limitations.
  • Dependency on Detection: The CGT is a classification framework that relies on an external tool for initial nuclei segmentation or detection. Its performance is naturally capped by the quality of these initial detections.
  • Future Directions: The authors suggest exploring even sparser graph representations or more efficient attention mechanisms to handle even larger whole-slide images (WSIs) more effectively.

Summary updated

BibTeX
@inproceedings{lou2024cell,
  author = {Wei Lou and Guanbin Li and Xiang Wan and Haofeng Li},
  title = {{Cell Graph Transformer for Nuclei Classification}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i4.28179},
}
Figure