Stain-aware Domain Alignment for Imbalance Blood Cell Classification

Yongcheng Li, Lingcong Cai, Ying Lu, Xianghua Fu, Xiao Han, Li Ma, Wenxing Lai, Xiangzhong Zhang, Xiaomao Fan

Abstract

Blood cell identification is critical for hematological analysis as it aids physicians in diagnosing various blood-related diseases. In real-world scenarios, blood cell image datasets often present the issues of domain shift and data imbalance, posing challenges for accurate identification. To address these issues, we propose a novel classification method termed SADA (Stain-aware Domain Alignment). The primary objective is to mine domain-invariant features in the presence of domain shifts and data imbalances. We propose a stain-based augmentation approach and a local alignment constraint to learn domain-invariant features, alongside a domain-invariant supervised contrastive learning strategy to capture discriminative features. We decouple the training process into two stages: domain-invariant feature learning and classification training, alleviating the problem of data imbalance. Experimental results on four public datasets and a private real-world dataset demonstrate that SADA achieves a new state-of-the-art baseline, significantly outperforming existing methods. Source code: https://github.com/AnoK3111/SADA.

Introduction: The Challenges of Domain Shift and Data Imbalance

In clinical practice, automated blood cell identification is a vital tool for diagnosing hematological disorders. However, real-world deployment faces two significant hurdles: domain shift and data imbalance. Domain shift occurs because blood smears from different laboratories vary in color, lighting, and texture due to differing staining protocols and equipment. Simultaneously, blood cell populations are naturally imbalanced; common cells like neutrophils vastly outnumber rare types like basophils, leading models to potentially ignore minority classes.

Visualizing the challenges of domain shift across datasets and the inherent class imbalance in blood cell counts.

Current deep learning models often overfit to the specific "style" of a training dataset or fail to recognize rare classes because they are overwhelmed by majority classes. The SADA framework addresses these challenges by mining domain-invariant features—biological markers that remain consistent regardless of the imaging environment.

Methodology: The SADA Framework

SADA decouples the training process into two distinct stages: domain-invariant feature learning and classification training. This separation is specifically designed to mitigate biases introduced by imbalanced data by first establishing a robust feature space.

The SADA framework architecture, illustrating the two-stage training process including Stain-Based Augmentation (SBA), Local Alignment (LA), and Domain-Invariant Supervised Contrastive Learning (DISC).

Stain-Based Augmentation (SBA)

Using the Beer-Lambert law and Sparse Non-negative Matrix Factorization (SNMF), images are decomposed into a structural "density map" and a color-based "stain matrix." By performing "stain-swapping," SADA generates synthetic images that preserve biological structure while mimicking the appearance of different domains. This allows the model to see the same cell in multiple "styles."

Local Alignment (LA) Constraint

To ensure the model prioritizes morphology over color, a pixel-wise alignment loss is applied. This forces the neural network to produce nearly identical feature maps for an original image and its color-shifted synthetic counterparts, ensuring the learned features are robust to stain variation.

Domain-Invariant Supervised Contrastive Learning (DISC)

Standard contrastive learning can capture domain-specific noise. SADA introduces DISC, which calculates a "pure" anchor by averaging features of a cell across multiple synthetic stains. This anchor helps the model learn discriminative features truly representative of the cell type rather than the specific imaging conditions.

Experimental Evaluation and Results

The researchers evaluated SADA on four public benchmarks (Acevedo-20, Raabin-WBC, LDWBC, and Zheng-18) and a private clinical dataset (SYSU3H). These datasets encompass a wide variety of staining methods (e.g., Giemsa, Wright-Giemsa) and imaging hardware.

SADA demonstrated a "big margin" improvement over existing state-of-the-art methods like BoDA and Mixup:

  • Superior Accuracy: Across four public datasets, SADA achieved an average F1-micro score of 84.4% and an F1-macro score of 68.6%, outperforming the next best method by roughly 4%.
  • Robustness to New Domains: In "leave-one-out" cross-dataset evaluations, SADA showed significantly less performance degradation than its competitors, proving its generalizability to unseen clinical environments.
  • Visual Interpretability: Grad-CAM visualizations reveal that SADA focuses precisely on internal cell structures, such as nuclear lobes and granules, whereas other models are often distracted by background tint.

Conclusion

SADA addresses the critical challenges of domain shift and class imbalance in medical imaging by mathematically decoupling cell structure from staining style. By treating stain variation as a variable to be normalized rather than noise, the model learns features more akin to a human pathologist. While the computational overhead of SNMF and multi-stain augmentation is a consideration, the significant gains in accuracy for rare cell types make SADA a powerful tool for clinical hematology. Future research may extend this stain-aware approach to other histopathology tasks, such as cancer biopsy analysis, where staining inconsistency remains a major barrier to AI adoption.

Summary updated

Abstract

Blood cell identification is critical for hematological analysis as it aids physicians in diagnosing various blood-related diseases. In real-world scenarios, blood cell image datasets often present the issues of domain shift and data imbalance, posing challenges for accurate blood cell identification. To address these issues, we propose a novel blood cell classification method termed SADA via stain-aware domain alignment. The primary objective of this work is to mine domain-invariant features in the presence of domain shifts and data imbalances. To accomplish this objective, we propose a stain-based augmentation approach and a local alignment constraint to learn domain-invariant features. Furthermore, we propose a domain-invariant supervised contrastive learning strategy to capture discriminative features. We decouple the training process into two stages of domain-invariant feature learning and classification training, alleviating the problem of data imbalance. Experiment results on four public blood cell datasets and a private real dataset collected from the Third Affiliated Hospital of Sun Yat-sen University demonstrate that SADA can achieve a new state-of-the-art baseline, which is superior to the existing cutting-edge methods with a big margin. The source code can be available at the URL (\url{https://github.com/AnoK3111/SADA}).
BibTeX
@misc{li2024stain,
  author = {Yongcheng Li and Lingcong Cai and Ying Lu and Xianghua Fu and Xiao Han and Li Ma and Wenxing Lai and Xiangzhong Zhang and Xiaomao Fan},
  title = {{Stain-aware Domain Alignment for Imbalance Blood Cell Classification}},
  year = {2024},
  eprint = {2412.02976},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.02976},
}
Figure