Skip to main content
IEEE Open Journal of Engineering in Medicine and Biology logoLink to IEEE Open Journal of Engineering in Medicine and Biology
. 2026 Apr 23;7:187–195. doi: 10.1109/OJEMB.2026.3687108

Stain Consistency Learning: Handling Stain Variation for Automatic Digital Pathology Segmentation

Michael Yeung 1, Todd Watts 2, Sean YW Tan 3, Peiyuan Jing 4, Pedro F Ferreira 5,6, Andrew D Scott 5,6, Sonia Nielles-Vallespin 5,6, Guang Yang 7,8,9,10,✉
PMCID: PMC13278751  PMID: 42328493

Abstract

Stain variation poses a major challenge for automated digital pathology. Numerous techniques address this issue, yet show limited success, especially outside H&E stains and classification tasks. We propose Stain Consistency Learning (SCL), combining stain-specific augmentation and a novel consistency loss to learn stain-invariant features. We conduct the first large-scale evaluation of ten methods on Massons trichrome and H&E datasets for segmentation. Our results demonstrate that traditional stain normalization offers little benefit, while stain augmentation and adversarial learning significantly improve performance. SCL consistently outperforms all other methods.

Keywords: Computational pathology, domain adaptation, instance segmentation, stain augmentation, stain normalization

I. Introduction

With rising biopsy demands and limited pathologists [1], computational pathology leveraging AI offers efficient interpretation, providing automatic, accurate and efficient interpretation of digital pathology, with performance comparable to expert pathologists [2], [3], [4].

Despite the significant progress made with AI-based computational pathology, there remains several legal, ethical and technical challenges that limit its translation into clinical practice [5]. Among the technical challenges, stain variation represents one of the most important barriers hindering the generalisation of machine learning models to external data. This is because machine learning models may overfit to stain appearances observed on training data, and fail to generalise to images from other centres or scanners which display different staining characteristics [6].

Stains are chemical dyes applied to histology slides to enhance tissue contrast and highlight certain structures. The most widely used stain is haematoxylin and eosin (H&E), which stains nuclei dark purple and the extracellular matrix and cytoplasm pink. For specific situations, other stains may be preferred, such as Massons trichrome stain for connective tissue, or immunohistochemical stains for proteins. Depending on the stain used, the same tissue section can differ considerably in appearance (Fig. 1).

Fig. 1.

Fig. 1.

Examples of stain variation in digital pathology. (a) Inter-stain variation of consecutive (i) H&E and (ii) HER2 receptor antibody stained data, and (iii) H&E and (iv) Periodic acidSchiff (PAS) stained data. b) Intra-stain variation of H&E stained data. Inter-stain variation images were selected from Breast Cancer Immunohistochemical (BCI) dataset (a iii) and Center for Applied Medical Research (CIMA) histology dataset (a iiiiv), and intra-stain variation images were selected from the MIDOG dataset (b iii) and Lizard dataset (b iiiiv).

Alongside inter-stain variation, there is also intra-stain variation, where tissue appearances may differ despite applying the same stain. Stain variation arises during the complex process of acquiring digital pathology, where differences in tissue preparation protocol, stain manufacturer and scanner type may contribute towards both inter-stain and intra-stain variation [7].

In recent years, there has been considerable progress in developing methods to improve the robustness of machine learning models to stain variation [7], [8]. These methods can be broadly categorised into stain normalisation, stain augmentation and stain adversarial learning approaches (Fig. 2).

Fig. 2.

Fig. 2.

Overview of methods to handle stain variation on digital pathology. (a) Stain normalisation methods standardise the staining prior to training and inference, removing the need for machine learning models to learn stain variation. (b) Stain augmentation methods apply stain-specific perturbations to the training data, increasing the diversity of staining observed by the model during training. (c) Stain adversarial learning involves joint optimisation of a specialised loss function (Inline graphic) to learn stain-invariant features in addition to the downstream task (Inline graphic).

Stain normalisation handles stain variation by standardising the staining prior to model training and inference, reducing the total variation in staining seen by the model. Broadly, stain normalisation approaches can be divided into statistical, stain separation and deep learning methods. Statistical methods involve matching the image characteristics of a reference image to a set of images and include histogram matching (HM) [9], [10], Fourier Domain Adaptation (FDA) [11], [12], [13], and Reinhards method [14]. These methods can be applied to a wide variety of imaging data but are prone to generating artefacts or require careful hyperparameter tuning. Stain separation methods were developed specifically for histology data, and involve matching the stain characteristics of a reference image to a set of images. Ruifrok and Johnston proposed the first stain separation method, known as the colour deconvolution (CD) algorithm [15], which decomposes an image into stain colour and stain concentration components. However, CD is not scalable because it requires obtaining the stain colour matrix empirically. Later approaches focused on automatically extracting the stain colour matrix through matrix decomposition, including the use of singular value decomposition (SVD) [16], non-negative matrix factorisation (NMF) [17], [18] and integrated optimisation [19]. In recent years, deep learning-based methods using generative adversarial networks (GANs) have become a popular choice for performing stain normalisation, reframing the problem as an unsupervised, style-transfer task [20], [21], [22], [23]. There has been progress in reducing the inference time [23], as well as adapting GANs to handle multiple domains [24], [25]. However, it is currently unclear whether GANs are suitable methods for clinical use because there are uncertainties as to whether the original image content could be altered during the transformation [26].

While stain normalisation must be applied during inference, stain augmentation and stain adversarial approaches are only necessary during training. Stain augmentations are colour augmentation methods that were developed for histology images [27], [28], [29]. Stain Jitter generates diversity by applying noise directly to the H&E colour channels extracted using CD [27], with two hyperparameters controlling the degree of pertubation. RandStainNA is a more recent approach that overcomes the need for hyperparameter tuning by using the training data to determine the degree of stain perturbation [29]. The use of GANs to generate stain diversity has also been explored [28], [30], [31], although existing GAN-based augmentation approaches are computationally expensive and require domain labels for training [32].

Stain adversarial methods encourage optimisation for learning stain-invariant features using specialised loss functions. Domain-adversarial neural network (DANN) training involves the use of a task-specific loss, such as classification or segmentation, together with a domain classification loss [33]. To avoid the need for domain labels, Marini et al. replaced the domain classification loss with a regression loss and trained models to maximise the regression loss when predicting H&E colour matrices [34]. However, stain adversarial methods rely on network modifications for generating auxiliary outputs, limiting their flexibility for integration into existing pipelines.

Despite numerous methods developed to handle stain variation, many of the methods have not been widely adopted due to problems associated with computational complexity, need for domain labels or hyperparameter tuning, and concern over image content alterations. Moreover, the majority of methods to handle stain variation were developed and evaluated on classification tasks using H&E-stained data and it is unclear whether these methods generalise to different stains or tasks. To address these issues, we propose a novel framework, named stain consistency learning (SCL), to handle variation of different stains for segmentation tasks. In this paper, we propose the following contributions:

  • 1)

    We propose stain consistency learning, a novel method that incorporates stain-specific augmentation with a specialised loss function to encourage the learning of stain colour invariant features.

  • 2)

    We perform the first large-scale comparison of methods to handle stain variation for segmentation tasks, evaluating ten methods on datasets of Massons trichrome stained cells and H&E stained nuclei, and show that stain consistency learning outperforms all other methods across datasets.

  • 3)

    We demonstrate the benefit of leveraging larger, unlabelled datasets to improve the performance of stain augmentation methods, alleviating the dependency on stain variation within the training data.

II. Materials and Methods

A. Stain Consistency Learning

SCL incorporates a new stain augmentation method to increase stain diversity observed by the model, and a complementary loss function to encourage the learning of stain colour invariant features.

1). Stain Consistency Augmentation

Unlike previous approaches relying on a single reference matrix, SCA (Fig. 3) independently extracts a stain color matrix from each image independently.

Fig. 3.

Fig. 3.

Overview of Stain Consistency Augmentation. (a) Pre-processing. (1) Each image is first converted into optical density space. (2) Images are decomposed into a stain colour and stain concentration matrix using Macenkos method. (3) The mean and standard deviation statistics are extracted per channel for the stain concentration matrix, and per element for the stain colour matrix. (4) Mean and standard deviation statistics are aggregated across the dataset. (5) A normal distribution is fit for each statistic. (b) Augmentation. During training, the selected image is decomposed into stain colour and stain concentration matrices. The stain colour matrix is replaced with one sampled from the fitted distributions, while the per-channel mean and standard deviation statistics of the stain concentration matrix are normalised using the sampled stain concentration values, generating an image with augmented stain colour and concentration properties.

To augment an image (I), the image is first converted to optical density (OD) space:

1).

In OD space, the image can be decomposed into a stain colour matrix (C) and stain concentration matrix (S):

1).

Macenkos method was used to obtain the stain colour matrix [16] due to its favorable trade-off between accuracy and efficiency, although the proposed framework is not restricted to this choice of stain separation method. The stain concentration matrix can then be obtained by inverting the stain colour matrix:

1).

For each image, we compute the stain colour matrix Inline graphic, as well as the mean Inline graphic and standard deviations Inline graphic for each stain Inline graphic in the stain concentration matrix.

Following this, we adopt RandStainNAs approach by fitting a distribution over the dataset for the extracted features [29]. Specifically, we fit three multivariate Gaussian distributions Inline graphic, Inline graphic, and Inline graphic, for the stain colour matrix, as well as the mean and standard deviation of the stain concentration matrix, respectively:

1).

To augment a given image Inline graphic, we first extract the stain colour matrix Inline graphic, as well as the per-channel mean Inline graphic and standard deviation Inline graphic of the stain concentration matrix. Next, we sample from the fitted distributions to obtain a stain colour matrix Inline graphic, and sample mean Inline graphic and standard deviations Inline graphic to normalise the stain concentration matrix. We replace the stain colour matrix Inline graphic with Inline graphic, and transform the stain concentration matrix Inline graphic:

1).

Finally, the modified stain colour and stain concentration matrices are combined and converted to RGB space, producing the augmented image, Inline graphic:

1).

2). Stain Consistency Loss

Stain augmentation methods encourage the learning of stain-invariant features by requiring model predictions to remain accurate in the presence of stain variation. To bridge the gap between stain augmentation and stain adversarial learning approaches, we instead propose SCL (Fig. 4).

Fig. 4.

Fig. 4.

Overview of Stain Consistency Learning. For each training image, we sample a single stain concentration matrix and two stain colour matrices from our fitted distributions. These are used to generate two augmented variants, by normalising the original image with the same stain concentration matrix and replacing the stain colour matrix with different stain colour matrices. Both augmented variants are then input into the model separately, and the stain consistency loss is computed based on the two segmentation outputs.

SCL optimizes models to learn features invariant to stain color while remaining sensitive to concentration differences. Two augmented versions of the same image, differing only in color matrices but sharing concentration information, are input during training. Their segmentation outputs are compared using a mean absolute error loss, excluding background pixels. By passing both images as inputs, we define the stain consistency loss (Inline graphic) as the mean absolute error between the two segmentation outputs, Inline graphic and Inline graphic, excluding background pixels and following transformation using a sigmoid activation function:

2).

where m iterates over the pixels corresponding to the ground truth objects.

B. Dataset Description

1). Lizard Dataset

The Lizard dataset is the largest open-source dataset with instance segmentation labels in digital pathology, comprised of 495,179 labeled nuclei from six sources [35]. We use the training image patches of the Lizard dataset prepared by the CoNIC challenge [36] (Table IV, available online).

The Lizard dataset consists of H&E-stained whole slide images of colonic tissue at 20 objective magnification. Nuclei instance segmentation masks were generated through a semi-automatic approach, using HoVer-Net to provide annotations that were subsequently manually refined for challenging cases [37]. The CoNIC challenge provides 4,981 256256 non-overlapping patches, from which we remove all patches without nuclei, leaving 4,841 patches for training and evaluation.

2). Cardiomyocyte Dataset

Our in-house dataset consists of four porcine hearts that were subsequently formalin fixed and paraffin embedded [38]. Transmural sections were obtained at 5 Inline graphicm thickness and stained with Massons trichrome. We obtained high-resolution microscopy data at 20 magnification with 456 nm/pixel resolution (C9600-12, Hamamatsu, Hamamatsu City, Japan). We randomly extracted 200 224 224 patches per heart, with two sets of cell instance segmentation labels separately provided by two individuals experienced with histology data.

C. Implementation Details

We used the VersaTile1 framework for instance segmentation, with the default settings. The data augmentation settings for VersaTile are shown in Table V (available online). For cell segmentation, we perform four-fold cross validation, involving successive training on images from one subject, and evaluation on images from the other three subjects. For the Lizard dataset, we use image patches from DigestPath for training, and image patches from CoNSeP, CRAG, GlaS and PanNuke for evaluation. We selected DigestPath for training because it is the only dataset within the Lizard dataset that does not have an overlapping dataset source with the other datasets. For each method, we train three models, initialised with different random seeds, and report the average performance. All experiments were conducted on NVIDIA RTX-6000 GPU. For evaluating, we use two popular instance segmentation metrics: F1 and PQ score.

III. Results

A. Qualitative Comparison of Stain Augmentation Methods

To provide a qualitative comparison of different stain augmentation methods, we provide a range of examples of augmented H&E images from the Lizard dataset and Massons trichrome images from our in-house dataset in Fig. 5. The appearance of stain normalised images are available in the supplementary materials (Fig. 6).

Fig. 5.

Fig. 5.

Example images after applying different stain augmentation methods. (a) Original image. (b) Stain Jitter [27]. (c) RandStainNA (Inline graphic space) [29]. (d) SCA (proposed). The images were selected from the Lizard dataset and our in-house dataset to represent a range of stain appearances. Each augmented image demonstrates four consecutive applications of the stain augmentation method on the original image. RandStainNA and SCA parameters were fit on the Lizard dataset. For Stain Jitter, we set Inline graphic = 0.25 and Inline graphic = 0.05 [27].

As shown in Fig. 5, stain augmentation methods are able to generate a diverse range of stain appearances. While Stain Jitter appears to produce the most diverse range of colour variation, it also generates the largest number of unrealistic augmented images. This is particularly evident with poorly stained images, where the addition of noise could result in stain colour values shifting to outside of the realistic range. In contrast, both RandStainNA and SCA do not display systematic errors and maintain generally realistic stain variation across the sample of images. However, applying RandStainNA occasionally results in the introduction of colour artefacts, which is not apparent with SCA, and overall SCA generates the most realistic stain variation.

B. Quantitative Comparison on Instance Segmentation

We evaluate the effects of using various stain normalisation, stain augmentation and stain adversarial learning methods on cell and nuclei segmentation performance.

The results for cell segmentation are shown in Table I.

TABLE I. Performance on Cell Segmentation Using Different Methods to Handle Stain Variation. The Best Performance is Denoted in Bold. The Bootstrapped 95 Confidence Intervals are Shown in Brackets. The Overall Performance is Computed as the Mean Performance Using Annotator 1 and 2 as Ground Truth Labels.

Annotator 1 Annotator 2 Overall
Method Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic)
Baseline 0.735 (Inline graphic0.005) 0.576 (Inline graphic0.005) 0.736 (Inline graphic0.005) 0.586 (Inline graphic0.005) 0.736 (Inline graphic0.005) 0.581 (Inline graphic0.005)
HM [10] 0.725 (Inline graphic0.005) 0.564 (Inline graphic0.005) 0.723 (Inline graphic0.005) 0.572 (Inline graphic0.005) 0.724 (Inline graphic0.005) 0.568 (Inline graphic0.005)
FDA [11] 0.729 (Inline graphic0.005) 0.568 (Inline graphic0.005) 0.729 (Inline graphic0.005) 0.579 (Inline graphic0.005) 0.729 (Inline graphic0.005) 0.574 (Inline graphic0.005)
Reinhard et al. [14] 0.734 (Inline graphic0.005) 0.573 (Inline graphic0.005) 0.736 (Inline graphic0.005) 0.584 (Inline graphic0.005) 0.735 (Inline graphic0.005) 0.579 (Inline graphic0.005)
Macenko et al. [16] 0.723 (Inline graphic0.005) 0.566 (Inline graphic0.005) 0.715 (Inline graphic0.005) 0.561 (Inline graphic0.005) 0.719 (Inline graphic0.005) 0.564 (Inline graphic0.005)
SPCN [18] 0.722 (Inline graphic0.005) 0.560 (Inline graphic0.005) 0.722 (Inline graphic0.005) 0.567 (Inline graphic0.005) 0.722 (Inline graphic0.005) 0.564 (Inline graphic0.005)
ACD [19] 0.732 (Inline graphic0.005) 0.573 (Inline graphic0.005) 0.729 (Inline graphic0.005) 0.579 (Inline graphic0.005) 0.731 (Inline graphic0.005) 0.576 (Inline graphic0.005)
Stain Jitter [27] 0.739 (Inline graphic0.005) 0.580 (Inline graphic0.005) 0.737 (Inline graphic0.005) 0.587 (Inline graphic0.005) 0.738 (Inline graphic0.005) 0.584 (Inline graphic0.005)
RandStainNA [29] 0.739 (Inline graphic0.005) 0.580 (Inline graphic0.005) 0.741 (Inline graphic0.005) 0.591 (Inline graphic0.005) 0.740 (Inline graphic0.005) 0.586 (Inline graphic0.005)
SCA (proposed) 0.745 (Inline graphic0.005) 0.586 (Inline graphic0.005) 0.745 (Inline graphic0.005) 0.595 (Inline graphic0.005) 0.745 (Inline graphic0.005) 0.591 (Inline graphic0.005)
SCL (proposed) 0.754 (Inline graphic0.005) 0.594 (Inline graphic0.005) 0.757 (Inline graphic0.005) 0.606 (Inline graphic0.005) 0.756 (Inline graphic0.005) 0.600 (Inline graphic0.005)

Overall, the best performing method was SCL, with an F1 score of 0.756 (Inline graphic0.005) and PQ score of 0.600 (Inline graphic0.005). This was followed by SCA, with an overall F1 score of 0.745 (Inline graphic0.005) and PQ score of 0.591 (Inline graphic0.005). All stain augmentation methods performed significantly better than the baseline for both F1 scores (Stain Jitter: Inline graphic, RandStainNA: Inline graphic, SCA: Inline graphic, SCL: Inline graphic) and PQ scores (Stain Jitter: Inline graphic, RandStainNA: Inline graphic, SCA: Inline graphic, SCL: Inline graphic). In contrast, stain normalisation approaches were associated with equivalent F1 (Reinhard: Inline graphic, SPCN: Inline graphic) and PQ (Reinhard: Inline graphic) scores, or worse F1 (HM: Inline graphic, FDA: Inline graphic, Macenko: Inline graphic, ACD: Inline graphic) and PQ (HM: Inline graphic, FDA: Inline graphic, Macenko: Inline graphic, SPCN: Inline graphic, ACD: Inline graphic) scores.

The results for nuclei segmentation are shown in Table II.

TABLE II. Performance on Nuclei Segmentation Using Different Methods to Handle Stain Variation. The Best Performance is Denoted in Bold. The Bootstrapped 95 Confidence Intervals are Shown in Brackets. The Overall Performance is the Mean Performance Across the Four Datasets.

CoNSeP CRAG GlaS PanNuke Overall
Method Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic)
Baseline 0.671 (Inline graphic0.010) 0.505 (Inline graphic0.008) 0.614 (Inline graphic0.003) 0.471 (Inline graphic0.002) 0.691 (Inline graphic0.003) 0.531 (Inline graphic0.003) 0.711 (Inline graphic0.009) 0.539 (Inline graphic0.007) 0.672 (Inline graphic0.006) 0.512 (Inline graphic0.005)
HM [10] 0.645 (Inline graphic0.012) 0.479 (Inline graphic0.010) 0.567 (Inline graphic0.003) 0.430 (Inline graphic0.003) 0.668 (Inline graphic0.004) 0.507 (Inline graphic0.003) 0.676 (Inline graphic0.011) 0.511 (Inline graphic0.009) 0.639 (Inline graphic0.008) 0.482 (Inline graphic0.006)
FDA [11] 0.597 (Inline graphic0.015) 0.438 (Inline graphic0.011) 0.506 (Inline graphic0.004) 0.382 (Inline graphic0.003) 0.657 (Inline graphic0.004) 0.496 (Inline graphic0.003) 0.624 (Inline graphic0.013) 0.465 (Inline graphic0.01) 0.596 (Inline graphic0.009) 0.445 (Inline graphic0.007)
Reinhard et al. [14] 0.646 (Inline graphic0.011) 0.482 (Inline graphic0.009) 0.603 (Inline graphic0.003) 0.460 (Inline graphic0.002) 0.666 (Inline graphic0.004) 0.510 (Inline graphic0.003) 0.692 (Inline graphic0.009) 0.522 (Inline graphic0.007) 0.652 (Inline graphic0.007) 0.494 (Inline graphic0.005)
Macenko et al. [16] 0.631 (Inline graphic0.013) 0.472 (Inline graphic0.010) 0.518 (Inline graphic0.004) 0.391 (Inline graphic0.003) 0.665 (Inline graphic0.003) 0.503 (Inline graphic0.003) 0.674 (Inline graphic0.011) 0.507 (Inline graphic0.009) 0.622 (Inline graphic0.008) 0.468 (Inline graphic0.006)
SPCN [18] 0.613 (Inline graphic0.013) 0.458 (Inline graphic0.010) 0.522 (Inline graphic0.004) 0.394 (Inline graphic0.003) 0.667 (Inline graphic0.004) 0.504 (Inline graphic0.003) 0.640 (Inline graphic0.013) 0.477 (Inline graphic0.010) 0.611 (Inline graphic0.009) 0.458 (Inline graphic0.007)
ACD [19] 0.644 (Inline graphic0.013) 0.484 (Inline graphic0.010) 0.527 (Inline graphic0.004) 0.403 (Inline graphic0.003) 0.702 (Inline graphic0.003) 0.538 (Inline graphic0.003) 0.691 (Inline graphic0.011) 0.523 (Inline graphic0.009) 0.641 (Inline graphic0.008) 0.487 (Inline graphic0.006)
StainGAN [22] 0.500 (Inline graphic0.016) 0.362 (Inline graphic0.012) 0.552 (Inline graphic0.003) 0.414 (Inline graphic0.002) 0.540 (Inline graphic0.004) 0.388 (Inline graphic0.003) 0.568 (Inline graphic0.013) 0.420 (Inline graphic0.010) 0.540 (Inline graphic0.009) 0.396 (Inline graphic0.007)
Stain Jitter [27] 0.692 (Inline graphic0.009) 0.521 (Inline graphic0.008) 0.677 (Inline graphic0.002) 0.518 (Inline graphic0.002) 0.704 (Inline graphic0.003) 0.530 (Inline graphic0.003) 0.720 (Inline graphic0.007) 0.547 (Inline graphic0.006) 0.698 (Inline graphic0.005) 0.529 (Inline graphic0.005)
RandStainNA [29] 0.682 (Inline graphic0.009) 0.513 (Inline graphic0.008) 0.613 (Inline graphic0.003) 0.469 (Inline graphic0.002) 0.677 (Inline graphic0.003) 0.520 (Inline graphic0.003) 0.715 (Inline graphic0.008) 0.543 (Inline graphic0.007) 0.672 (Inline graphic0.006) 0.511 (Inline graphic0.005)
H&E Adversarial [34] 0.680 (Inline graphic0.010) 0.509 (Inline graphic0.008) 0.639 (Inline graphic0.003) 0.489 (Inline graphic0.002) 0.683 (Inline graphic0.003) 0.524 (Inline graphic0.003) 0.719 (Inline graphic0.009) 0.546 (Inline graphic0.007) 0.680 (Inline graphic0.006) 0.517 (Inline graphic0.005)
SCA (proposed) 0.695 (Inline graphic0.010) 0.524 (Inline graphic0.008) 0.685 (Inline graphic0.002) 0.526 (Inline graphic0.002) 0.719 (Inline graphic0.003) 0.545 (Inline graphic0.003) 0.723 (Inline graphic0.008) 0.549 (Inline graphic0.007) 0.706 (Inline graphic0.006) 0.536 (Inline graphic0.005)
SCL (proposed) 0.696 (Inline graphic0.010) 0.525 (Inline graphic0.008) 0.683 (Inline graphic0.002) 0.524 (Inline graphic0.002) 0.726 (Inline graphic0.003) 0.553 (Inline graphic0.002) 0.730 (Inline graphic0.007) 0.555 (Inline graphic0.007) 0.709 (Inline graphic0.006) 0.539 (Inline graphic0.005)

Similar to cell segmentation, SCL was the best performing method for nuclei segmentation, with an overall F1 score of 0.709 (Inline graphic0.006) and PQ score of 0.539 (Inline graphic0.005). This was followed by SCA with an overall F1 score of 0.706 (Inline graphic0.006) and PQ score of 0.536 (Inline graphic0.006). Both stain augmentation and stain adversarial methods performed significantly better than the baseline for both F1 and PQ scores (all Inline graphic). In contrast, all stain normalisation methods had significantly lower overall F1 and PQ scores (all Inline graphic).

C. Effect of Pre-Processing Datasets on Stain Augmentation

Both RandStainNA and SCA involve learning a distribution over the images in the training data to generate stain diversity. Rather than using the training data, it is possible to learn the stain distribution using a larger unlabelled dataset, which would allow models to learn stain variation not present in the training data. To evaluate the effect of using different datasets for pre-processing on segmentation performance, we pre-process RandStainNA and SCA on the MIDOG dataset and the whole Lizard dataset [13]. The results are shown in Table III.

TABLE III. Performance on Nuclei Segmentation Using Different Pre-Processing Datasets for Stain Augmentation Methods. DigestPath is the Training Data Used in the Other Experiments and is Shown for Reference. The Best Performances are Denoted in Bold. The Bootstrapped 95 Confidence Intervals are Shown in Brackets. The Overall Performance is Computed as the Mean Performance Across the Four Datasets.

CoNSeP CRAG GlaS PanNuke Overall
Method Dataset Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic) Inline graphic (Inline graphic)
RandStainNA DigestPath 0.682 (Inline graphic0.009) 0.513 (Inline graphic0.008) 0.613 (Inline graphic0.003) 0.469 (Inline graphic0.002) 0.677 (Inline graphic0.003) 0.520 (Inline graphic0.003) 0.715 (Inline graphic0.008) 0.543 (Inline graphic0.007) 0.672 (Inline graphic0.006) 0.511 (Inline graphic0.005)
SCA (proposed) DigestPath 0.695 (Inline graphic0.010) 0.524 (Inline graphic0.008) 0.685 (Inline graphic0.002) 0.526 (Inline graphic0.002) 0.719 (Inline graphic0.003) 0.545 (Inline graphic0.003) 0.723 (Inline graphic0.008) 0.549 (Inline graphic0.007) 0.706 (Inline graphic0.006) 0.536 (Inline graphic0.005)
SCL (proposed) DigestPath 0.696 (Inline graphic0.010) 0.525 (Inline graphic0.008) 0.683 (Inline graphic0.002) 0.524 (Inline graphic0.002) 0.726 (Inline graphic0.003) 0.553 (Inline graphic0.002) 0.730 (Inline graphic0.007) 0.555 (Inline graphic0.007) 0.709 (Inline graphic0.006) 0.539 (Inline graphic0.005)
RandStainNA MIDOG 0.676 (Inline graphic0.010) 0.508 (Inline graphic0.008) 0.625 (Inline graphic0.003) 0.479 (Inline graphic0.002) 0.685 (Inline graphic0.003) 0.527 (Inline graphic0.003) 0.708 (Inline graphic0.009) 0.538 (Inline graphic0.008) 0.674 (Inline graphic0.006) 0.513 (Inline graphic0.005)
SCA (proposed) MIDOG 0.693 (Inline graphic0.011) 0.523 (Inline graphic0.009) 0.700 (Inline graphic0.002) 0.537 (Inline graphic0.002) 0.715 (Inline graphic0.003) 0.540 (Inline graphic0.003) 0.726 (Inline graphic0.008) 0.551 (Inline graphic0.007) 0.709 (Inline graphic0.006) 0.538 (Inline graphic0.005)
SCL (proposed) MIDOG 0.696 (Inline graphic0.011) 0.524 (Inline graphic0.009) 0.695 (Inline graphic0.002) 0.533 (Inline graphic0.002) 0.723 (Inline graphic0.003) 0.552 (Inline graphic0.003) 0.725 (Inline graphic0.007) 0.551 (Inline graphic0.007) 0.710 (Inline graphic0.006) 0.540 (Inline graphic0.005)
RandStainNA Lizard 0.680 (Inline graphic0.010) 0.512 (Inline graphic0.008) 0.608 (Inline graphic0.003) 0.466 (Inline graphic0.002) 0.677 (Inline graphic0.003) 0.521 (Inline graphic0.003) 0.719 (Inline graphic0.008) 0.545 (Inline graphic0.007) 0.671 (Inline graphic0.006) 0.511 (Inline graphic0.005)
SCA (proposed) Lizard 0.697 (Inline graphic0.011) 0.525 (Inline graphic0.009) 0.696 (Inline graphic0.002) 0.535 (Inline graphic0.002) 0.726 (Inline graphic0.003) 0.554 (Inline graphic0.003) 0.715 (Inline graphic0.010) 0.544 (Inline graphic0.008) 0.709 (Inline graphic0.007) 0.540 (Inline graphic0.006)
SCL (proposed) Lizard 0.692 (Inline graphic0.010) 0.519 (Inline graphic0.009) 0.692 (Inline graphic0.002) 0.531 (Inline graphic0.002) 0.727 (Inline graphic0.009) 0.555 (Inline graphic0.002) 0.715 (Inline graphic0.011) 0.543 (Inline graphic0.007) 0.707 (Inline graphic0.008) 0.537 (Inline graphic0.005)

Overall, we observed better segmentation performance using images from the MIDOG or Lizard dataset for stain augmentation pre-processing, compared to using images from the training data. SCA performance significantly improved from an F1 score of 0.706 (Inline graphic0.006) and PQ score of 0.536 (Inline graphic0.005), to an F1 score of 0.709 (Inline graphic0.007) and PQ score of 0.540 (Inline graphic0.006), when using the Lizard dataset for pre-processing (Inline graphic). Specifically, the CRAG subset was associated with the greatest performance improvement, where the F1 score improved from 0.685 (Inline graphic0.002) to 0.696 (Inline graphic0.002), and PQ score improved from 0.526 (Inline graphic0.002) to 0.535 (Inline graphic0.002). Less consistent performance improvements were observed using SCL and RandStainNA. The best overall performance was associated with SCL pre-processed on MIDOG, with an F1 score improvement to 0.710 (Inline graphic0.006) (Inline graphic) and PQ score improvement to 0.540 (Inline graphic0.005) (Inline graphic).

IV. Discussion

Instance segmentation is a challenging task requiring fine-grained, pixel-level understanding, and with significant clinical applications such as cell counting, morphological abnormality detection and quantitative biomarker analysis. Through extensive evaluations, we found that stain augmentation and adversarial learning significantly outperform stain normalization methods on instance segmentation tasks, aligning with prior multi-center studies on classification tasks [8].

We proposed a novel stain augmentation method named SCA that extends upon the methods of Stain Jitter and RandStainNA. Rather than using a single, empirically determined stain colour matrix, we used Macenkos method to extract individual stain colour matrices for each image. We leveraged the diversity in stain colour matrices to generate realistic stain-specific variation (Fig. 5), and observed performance benefits over other methods to handle stain variation across Massons trichrome-stained cardiomyocytes (Table I) and H&E-stained nuclei segmentation (Table II). Realistic stain augmentation is crucial to avoid corrupting clinically important information and to facilitate disentanglement of meaningful stain information from stain color variation introduced by stain protocol differences. Instead of using the training data for preprocessing, we explored learning the stain distribution from external data and observed performance benefits (Table III). This provides a convenient mechanism to overcome limited stain diversity in the training data by learning the stain distribution on a larger, more diverse dataset, without the need for labels.

To integrate stain augmentation and stain adversarial learning for handling stain variation, we developed stain consistency learning, a framework that encourages the model to learn stain colour invariant features while preserving sensitivity to stain concentration differences. This method demonstrated the best performance overall across both datasets (Tables I and II).

Alongside performance, SCL offers several advantages over prior methods. Firstly, neither the proposed augmentation nor loss function require hyperparameter tuning, unlike stain augmentation approaches such as Stain Jitter, which has two hyperparameters [27], and stain normalisation approaches such ACD, which has five hyperparameters [19]. Secondly, SCL is applied only during training, avoiding inference-time overhead and structural changes to the images. Thirdly, SCL does not require modifications to the neural network architecture and can therefore be more easily integrated into existing frameworks, in contrast to stain adversarial approaches which require an additional auxiliary output. Finally, in the era of foundation models, dataset size and diversity are central to achieve robust generalisation, and SCL is well suited for integration into such training pipelines, scaling naturally with dataset size and improving stain diversity for underrepresented stains.

For future work, there are several areas where SCL can be extended. Firstly, dataset balancing methods could further improve the learning of a distribution that represents diverse stain appearances. Secondly, it would be useful to evaluate our framework on other image recognition tasks, to determine whether our method can also provide performance benefits to other tasks. Finally, we demonstrated that SCL improves robustness to intra-stain variation, but it would be useful to extend this framework to also handle inter-stain variation.

V. Conclusion

We proposed Stain Consistency Learning (SCL), a novel framework that combines stain-specific augmentation with a consistency loss to address stain variation in digital pathology segmentation. Through the first large-scale comparison of ten stain-handling methods across Massons trichrome and H&E datasets, SCL consistently achieved superior performance. We also demonstrated that leveraging larger unlabeled datasets further enhances robustness. SCL offers practical advantages: no hyperparameter tuning, no inference-time cost, and seamless integration into existing models. Future work will explore extending SCL to address inter-stain variation and broader digital pathology tasks, paving the way for more robust and generalizable AI systems in clinical practice.

Supplementary Materials

Supplementary Materials
supp1-3687108.pdf (11MB, pdf)

Funding Statement

The work of Guang Yang was supported in part by the European Research Council Innovative Medicines Initiative under Grant 101005122, in part by Horizon 2020 under Grant 952172, in part by the Medical Research Council under Grant MC/PC/21013, in part by the Royal Society under Grant IEC/NSFC/211235, in part by the NVIDIA Academic Hardware Grant Program, in part by the SABER project supported by Boehringer Ingelheim Ltd, NIHR Imperial Biomedical Research Centre under Grant RDA01, in part by The Wellcome Leap Dynamic resilience program (co-funded by Temasek Trust), in part by the UK Research and Innovation guarantee funding for Horizon Europe Marie Skodowska-Curie Actions Postdoctoral Fellowships under Grant EP/Z002206/1, in part by a UK Research and Innovation Medical Research Council Research Grant, TFS Research Grants under Grant MR/U506710/1, in part by the Swiss National Science Foundation under Grant 220785, and in part by a UK Research and Innovation Future Leaders Fellowship under Grant MR/V023799/1 and Grant UKRI2738.

Footnotes

1

VersaTile: A Framework for Instance Segmentation. Available at: https://github.com/TissueImageAnalytics/VersaTile.

Contributor Information

Michael Yeung, Email: michael.yeung21@imperial.ac.uk.

Sean YW Tan, Email: sean.tan@nhs.net.

Guang Yang, Email: g.yang@imperial.ac.uk.

References

  • [1].Robboy S. J.et al. , Pathologist workforce in the United States: I. development of a predictive model to examine factors influencing supply, Arch. Pathol. Lab. Med., vol. 137, no. 12, pp. 1723–1732., 2013. [DOI] [PubMed] [Google Scholar]
  • [2].Alsubaie N., Sirinukunwattana K., Raza S. E. A., Snead D., and Rajpoot N., A bottom-up approach for tumour differentiation in whole slide images of lung adenocarcinoma, Proc. SPIE, vol. 10581, 2018, Art. no. 105810E. [Google Scholar]
  • [3].Cui M. and Zhang D. Y., Artificial intelligence and computational pathology, Lab. Investigation, vol. 101, no. 4, pp. 412–422., 2021. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [4].Lu C.et al. , A prognostic model for overall survival of patients with early-stage non-small cell lung cancer: A multicentre, retrospective study, Lancet Digit. Health, vol. 2, no. 11, pp. e594–e606., 2020. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [5].Berb M. A.et al. , Computational pathology in 2030: A Delphi study forecasting the role of AI in pathology within the next decade, EBioMedicine, vol. 88, 2023, Art. no. 104427. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [6].Ciompi F.et al. , The importance of stain normalization in colorectal tissue classification with convolutional networks, in Proc. IEEE 14th Int. Symp. Biomed. Imag., 2017, pp. 160–163.. [Google Scholar]
  • [7].Roy S., Jain A. kumar, Lal S., and Kini J., A study about color normalization methods for histopathology images, Micron, vol. 114, pp. 42–61., 2018. [DOI] [PubMed] [Google Scholar]
  • [8].Tellez D.et al. , Quantifying the effects of data augmentation and stain color normalization in convolutional neural networks for computational pathology, Med. Image Anal., vol. 58, 2019, Art. no. 101544. [DOI] [PubMed] [Google Scholar]
  • [9].Neumann A. and Neumann L., Color style transfer techniques using hue, lightness and saturation histogram matching, in Proc. First Eurographics Conf. Computat. Aesthetics Graph., Visualization Imag., 2005, pp. 111–122.. [Google Scholar]
  • [10].Coltuc D., Bolon P., and Chassery J.-M., Exact histogram specification, IEEE Trans. Image Process., vol. 15, no. 5, pp. 1143–1152., May 2006. [DOI] [PubMed] [Google Scholar]
  • [11].Yang Y. and Soatto S., FDA: Fourier domain adaptation for semantic segmentation, in Proc. IEEE/CVF Conf. Comput. Vis. Pattern Recognit., 2020, pp. 4085–4095.. [Google Scholar]
  • [12].Yang C., Guo X., Chen Z., and Yuan Y., Source free domain adaptation for medical image segmentation with Fourier style mining, Med. Image Anal., vol. 79, 2022, Art. no. 102457. [DOI] [PubMed] [Google Scholar]
  • [13].Aubreville M.et al. , Mitosis domain generalization in histopathology imagesThe MIDOG challenge, 2022, arXiv:2204.03742. [DOI] [PubMed]
  • [14].Reinhard E., Adhikhmin M., Gooch B., and Shirley P., Color transfer between images, IEEE Comput. Graph. Appl., vol. 21, no. 5, pp. 34–41., Jul./Aug. 2001. [Google Scholar]
  • [15].Ruifrok A. C.et al. , Quantification of histochemical staining by color deconvolution, Anal. Quantitative Cytol. Histol., vol. 23, no. 4, pp. 291–299., 2001. [PubMed] [Google Scholar]
  • [16].Macenko M.et al. , A method for normalizing histology slides for quantitative analysis, in Proc. IEEE Int. Symp. Biomed. Imag.: Nano Macro, 2009, pp. 1107–1110.. [Google Scholar]
  • [17].Rabinovich A., Agarwal S., Laris C., Price J., and Belongie S., Unsupervised color decomposition of histologically stained tissue samples, in Proc. Adv. Neural Inf. Process. Syst., 2003, vol. 16. [Google Scholar]
  • [18].Vahadane A.et al. , Structure-preserving color normalization and sparse stain separation for histological images, IEEE Trans. Med. Imag., vol. 35, no. 8, pp. 1962–1971., Aug. 2016. [DOI] [PubMed] [Google Scholar]
  • [19].Zheng Y., Jiang Z., Zhang H., Xie F., Shi J., and Xue C., Adaptive color deconvolution for histological WSI normalization, Comput. Methods Programs Biomed., vol. 170, pp. 107–120., 2019. [DOI] [PubMed] [Google Scholar]
  • [20].Goodfellow I.et al. , Generative adversarial networks, Commun. ACM, vol. 63, no. 11, pp. 139–144., 2020. [Google Scholar]
  • [21].BenTaieb A. and Hamarneh G., Adversarial stain transfer for histopathology image analysis, IEEE Trans. Med. Imag., vol. 37, no. 3, pp. 792–802., Mar. 2018. [DOI] [PubMed] [Google Scholar]
  • [22].Shaban M. T., Baur C., Navab N., and Albarqouni S., StainGAN: Stain style transfer for digital histological images, in Proc. IEEE 16th Int. Symp. Biomed. Imag., 2019, pp. 953–956.. [Google Scholar]
  • [23].Kang H.et al. , StainNet: A fast and robust stain normalization network, Front. Med., vol. 8, 2021, Art. no. 746307. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [24].Choi Y., Choi M., Kim M., Ha J.-W., Kim S., and Choo J., StarGAN: Unified generative adversarial networks for multi-domain image-to-image translation, in Proc. IEEE Conf. Comput. Vis. Pattern Recognit., 2018, pp. 8789–8797.. [Google Scholar]
  • [25].Nazki H., Arandjelovic O., Um I. H., and Harrison D., MultiPathGAN: Structure preserving stain normalization using unsupervised multi-domain adversarial network with perception loss, in Proc. 38th ACM/SIGAPP Symp. Appl. Comput., 2023, pp. 1197–1204.. [Google Scholar]
  • [26].Cohen J. P., Luck M., and Honari S., Distribution matching losses can hallucinate features in medical image translation, in Proc. Int. Conf. Med. Image Comput. Comput.- Assist. Intervention, 2018, pp. 529–536.. [Google Scholar]
  • [27].Tellez D.et al. , Whole-slide mitosis detection in H&E breast histology using PHH3 as a reference to train distilled stain-invariant convolutional networks, IEEE Trans. Med. Imag., vol. 37, no. 9, pp. 2126–2136., Sep. 2018. [DOI] [PubMed] [Google Scholar]
  • [28].Wagner S. J.et al. , Structure-preserving multi-domain stain color augmentation using style-transfer with disentangled representations, in Proc. Int. Conf. Med. Image Comput. Comput.-Assist. Intervention, 2021, pp. 257–266.. [Google Scholar]
  • [29].Shen Y., Luo Y., Shen D., and Ke J., RandStainNA: Learning stain-agnostic features from histology slides by bridging stain augmentation and normalization, in Proc. Int. Conf. Med. Image Comput. Comput.-Assist. Intervention, 2022, pp. 212–221.. [Google Scholar]
  • [30].Vasiljevi J., Feuerhake F., Wemmert C., and Lampert T., Towards histopathological stain invariance by unsupervised domain augmentation using generative adversarial networks, Neurocomputing, vol. 460, pp. 277–291., 2021. [Google Scholar]
  • [31].Scalbert M., Vakalopoulou M., and Couzini-Devy F., Test-time image-to-image translation ensembling improves out-of-distribution generalization in histopathology, in Proc. Int. Conf. Med. Image Comput. Comput.-Assist. Intervention, 2022, pp. 120–129.. [Google Scholar]
  • [32].Li F., Hu Z., Chen W., and Kak A., A Laplacian pyramid based generative H&E stain augmentation network, 2023, arXiv:2305.14301. [DOI] [PubMed]
  • [33].Otlora S., Atzori M., Andrearczyk V., Khan A., and Mller H., Staining invariant features for improving generalization of deep convolutional neural networks in computational pathology, Front. Bioeng. Biotechnol., vol. 7, 2019, Art. no. 198. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [34].Marini N., Atzori M., Otlora S., Marchand-Maillet S., and Mller H., H&E-adversarial network: A convolutional neural network to learn stain-invariant features through hematoxylin & eosin regression, in Proc. IEEE/CVF Int. Conf. Comput. Vis., 2021, pp. 601–610.. [Google Scholar]
  • [35].Graham S.et al. , Lizard: A large-scale dataset for colonic nuclear instance segmentation and classification, in Proc. IEEE/CVF Int. Conf. Comput. Vis., 2021, pp. 684–693.. [Google Scholar]
  • [36].Graham S.et al. , CoNIC: Colon nuclei identification and counting challenge 2022, 2021, arXiv:2111.14485.
  • [37].Graham S.et al. , HoVer-Net: Simultaneous segmentation and classification of nuclei in multi-tissue histology images, Med. Image Anal., vol. 58, 2019. Art. no. 101563. [DOI] [PubMed] [Google Scholar]
  • [38].Nielles-Vallespin S.et al. , Assessment of myocardial microstructural dynamics by in vivo diffusion tensor cardiac magnetic resonance, J. Amer. College Cardiol., vol. 69, no. 6, pp. 661–676., 2017. [DOI] [PMC free article] [PubMed] [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Supplementary Materials

Supplementary Materials
supp1-3687108.pdf (11MB, pdf)

Articles from IEEE Open Journal of Engineering in Medicine and Biology are provided here courtesy of Institute of Electrical and Electronics Engineers

RESOURCES