Patch-Wise Hypergraph Contrastive Learning with Dual Normal Distribution Weighting for Multi-Domain Stain Transfer

Haiyan Wei, He Xu, Bin Zhu, Yulian Geng, Aolei Liu, Wenfei Yin, Jian Liu

TL;DR

This paper introduces STNHCL, a novel method for virtual stain transfer in histopathology that uses hypergraphs to capture complex relationships between image patches, preserving crucial pathological details. It also proposes a more nuanced negative sample weighting strategy that adapts to tissue and background regions, leading to state-of-the-art performance in stain transfer and downstream tasks.

What Problem Does This Paper Address?

Histopathology relies on staining to visualize tissue structures for diagnosis. While Hematoxylin and Eosin (H&E) is common, other stains highlight specific features but are more labor-intensive and costly. Virtual stain transfer aims to generate these specialized stains from H&E images, reducing costs and effort. However, existing methods often struggle with "cycle consistency" assumptions, leading to a loss of detailed pathological information and limited style variation. This paper tackles the challenge of preserving higher-order semantic relationships between image patches during stain transfer, which is crucial for accurate pathological interpretation, and improving the effectiveness of contrastive learning techniques in this domain.

Methods

The core of STNHCL is a patch-wise hypergraph contrastive learning framework.

  • Hypergraph Modeling: Instead of traditional graph structures that only capture pairwise relationships between patches, STNHCL uses hypergraphs. Hypergraphs allow for hyperedges to connect multiple nodes (patches), enabling the model to capture more complex, higher-order semantic correlations within and between input and output images. This helps maintain a consistent higher-order topology.
  • Soft k-means Clustering: Soft k-means is used to group patches for hypergraph construction, offering computational advantages and easier parameter tuning compared to fuzzy c-means.
  • Hypergraph Neural Networks (HGNNs): HGNNs are employed to perform convolution on the patch node features within the hypergraph structure, effectively extracting these higher-order relationships.
  • Dual Normal Distribution Weighting: To improve upon existing contrastive learning strategies, STNHCL introduces a novel negative sample weighting mechanism. It leverages discriminator heatmaps to distinguish between tissue and background regions. For tissue regions, a "hard-weighting" strategy is applied, emphasizing informative negative samples. For background regions, a more "easy-weighting" strategy is used, acknowledging their simpler structure. This weighting is further refined using a Gaussian distribution, providing a more balanced and less extreme approach than previous methods.

Datasets

The paper uses three publicly available datasets:

  • Human kidney dataset (from ANHIR)
  • Human lung lesion dataset (from ANHIR)
  • Glomeruli Segmentation Dataset (for downstream tasks)

No new benchmarks were introduced; the focus was on applying the proposed method to existing datasets and tasks.

Key Insights and Ideas

  • Hypergraphs for Richer Relationships: The key insight is that image patches have complex, higher-order relationships that simple graphs fail to capture. Hypergraphs provide a more expressive way to model these intricate connections, leading to better preservation of pathological information during stain transfer.
  • Adaptive Negative Sample Weighting: Recognizing that tissue and background regions have different characteristics, the paper proposes a dual weighting strategy. This adaptive approach, using Gaussian distributions and discriminator heatmaps, allows for more effective utilization of negative samples, improving the contrastive learning objective.
  • Bridging the Gap in Stain Transfer: The method directly addresses the limitations of cycle-consistency losses, which often over-restrict style variation and lose critical details. By focusing on patch-wise contrastive learning with hypergraphs, STNHCL achieves a better balance between content preservation and stylistic transformation.

Key Results

  • State-of-the-Art Performance: STNHCL achieves state-of-the-art results on both human kidney and human lung lesion datasets for H&E to special stain transfer tasks, outperforming existing methods in terms of Contrast Structure Similarity (CSS), Fréchet Inception Distance (FID), and Kernel Inception Distance (KID). For example, on the human lung lesion dataset, it achieved the best CSS (0.943) and lowest FID (35.66) and KID (2.67).
  • Superior Visual Quality: Qualitative results show that STNHCL generates clearer, more contrast-rich images with better structural and semantic alignment compared to other methods.
  • Excellent Downstream Performance: The model also performs excellently on downstream tasks like glomeruli segmentation, with generated stains achieving comparable or even superior accuracy to original H&E stains.
  • Ablation Studies: Experiments confirm the effectiveness of each component of STNHCL, with the full model significantly outperforming its individual parts.

Limitations and Future Work

  • Hyperparameter Sensitivity: While soft k-means offers easier tuning, the paper notes that the dual normal distribution weighting strategy uses controllable hyperparameters (μ and σ). Table III shows that performance is sensitive to the choice of these means, suggesting that optimal parameter selection might require further investigation.
  • Computational Cost: While soft k-means is more efficient than fuzzy c-means, hypergraph construction and HGNNs can still be computationally intensive.
  • Future Work: The paper implicitly suggests that further exploration of hypergraph structures and advanced HGNN architectures could lead to even more robust stain transfer. Additionally, investigating more sophisticated methods for region segmentation or adaptive weighting could further enhance performance.

Summary updated

Abstract

Virtual stain transfer leverages computer-assisted technology to transform the histochemical staining patterns of tissue samples into other staining types. However, existing methods often lose detailed pathological information due to the limitations of the cycle consistency assumption. To address this challenge, we propose STNHCL, a hypergraph-based patch-wise contrastive learning method. STNHCL captures higher- order relationships among patches through hypergraph modeling, ensuring consistent higher-order topology between input and output images. Additionally, we introduce a novel negative sample weighting strategy that leverages discriminator heatmaps to apply different weights based on the Gaussian distribution for tissue and background, thereby enhancing traditional weighting methods. Experiments demonstrate that STNHCL achieves state- of-the-art performance in the two main categories of stain transfer tasks. Furthermore, our model also performs excellently in downstream tasks. Code is available at https://github.com/Whywwwzzzg/STNHCL.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
Human Lung Lesion DatasetSTNHCLCSS0.943H&E-to-IHC stain transfer evaluation on the human lung lesion dataset; reported in the …
Source quote
L161: Ours │ 0.943 │ 35.66 │ 2.67
Human Lung Lesion DatasetSTNHCLFID35.66Image Generation
Source quote
L161: Ours │ 0.943 │ 35.66 │ 2.67
Human Lung Lesion DatasetSTNHCLKID×1002.67H&E-to-IHC stain transfer evaluation on the human lung lesion dataset; KID is reported …
Source quote
L161: Ours │ 0.943 │ 35.66 │ 2.67
Human Kidney DatasetSTNHCLCSS0.776H&E-to-special-stain transfer evaluation on the human kidney dataset; reported in the q…
Source quote
L171: Ours │ 0.776 │ 56.53 │ 5.75
Human Kidney DatasetSTNHCLFID56.53Image Generation
Source quote
L171: Ours │ 0.776 │ 56.53 │ 5.75
Human Kidney DatasetSTNHCLKID×1005.75H&E-to-special-stain transfer evaluation on the human kidney dataset; KID is reported m…
Source quote
L171: Ours │ 0.776 │ 56.53 │ 5.75
BibTeX
@misc{wei2025patch,
  author = {Haiyan Wei and He Xu and Bin Zhu and Yulian Geng and Aolei Liu and Wenfei Yin and Jian Liu},
  title = {{Patch-Wise Hypergraph Contrastive Learning with Dual Normal Distribution Weighting for Multi-Domain Stain Transfer}},
  year = {2025},
  eprint = {2503.09523},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.09523},
  howpublished = {arXiv},
}
Figure