{'fraction_non_alphanumeric': 0.027504700510341124, 'fraction_numerical': 0.007681976900349181, 'mean_word_length': 5.217768871075484, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
MaNi: Maximizing Mutual Information for Nuclei Cross-Domain Unsupervised Segmentation

In this work, we propose a mutual information (MI) based unsupervised domain adaptation (UDA) method for the cross-domain nuclei segmentation. Nuclei vary substantially in structure and appearances across different cancer types, leading to a drop in performance of deep learning models when trained on one cancer type and tested on another. This domain shift becomes even more critical as accurate segmentation and quantification of nuclei is an essential histopathology task for the diagnosis/ prognosis of patients and annotating nuclei at the pixel level for new cancer types demands extensive effort by medical experts. To address this problem, we maximize the MI between labeled source cancer type data and unlabeled target cancer type data for transferring nuclei segmentation knowledge across domains. We use the Jensen-Shanon divergence bound, requiring only one negative pair per positive pair for MI maximization. We evaluate our set-up for multiple modeling frameworks and on different datasets comprising of over 20 cancer-type domain shifts and demonstrate competitive performance. All the recently proposed approaches consist of multiple components for improving the domain adaptation, whereas our proposed module is light and can be easily incorporated into other methods (Implementation: https://github.com/YashSharma/MaNi ).


Introduction
Nuclei are the fundamental organizational unit of life. Accurate assessment of these nuclei in histopathology slides provides critical morphological information necessary for the quantitative analysis of multiple diseases. In the last decade, Convolutional Neural Network-based approaches have emerged as a promising solution in medical imaging tasks, and nuclei segmentation tasks [7,21]. However, they require a large amount of annotated data for any reliable training. Moreover, even with a large dataset, models are prone to be poor at generalizing learned knowledge from one cancer type to another. Pixel-level image annotations by a medical expert are required to expand to a new cancer type, making it difficult, expensive, and a time-consuming task. Therefore, there is a need for methods that can transfer learned information from existing cancer datasets to other domains without additional annotations. We tackle this problem, characterized as Unsupervised domain adaptation (UDA), to close the gap between the annotated source domain and unlabeled target domain by learning domain-invariant and task-relevant features.
It has been observed that trivially training a model on the source domain and evaluating on a target domain leads to sub-par performance owing to domain shift [8]. Moreover, the domain shift problem is widespread in medical image datasets due to different scanners, scanning protocols, and tissue types, among others. Hence, multiple strategies comprising of adversarial learning, pseudolabeling, consistency regularization, or data-augmentation have been proposed to tackle this limitation [8]. Among these, self-training has emerged as a competitive approach. Various de-noising strategies such as confidence thresholding, uncertainty estimation, or distance penalty between domains have been proposed. These strategies have led to gains, but they all rely on unlabeled data points closer to labeled data points for pseudo-label training since those are the points with high confidence and attempts to push the target distribution closer to the source. However, forcing the target-domain distribution towards the source-domain distribution can destroy the latent structural patterns of the target domain, leading to a drop in performance. We hypothesize that instead of using these approaches, using an information-theoretic distance can lead to better alignment between the domains.
Contrastive learning (CL) has seen wide success in representation learning with applications ranging from unsupervised pre-training to multi-modal alignment [22]. The basic idea of CL is to push together the latent distribution of similar samples and push away the latent distribution of dissimilar samples. Wang et al. [25] adopted a supervised, pixel-wise contrastive learning algorithm and treated pixels belonging to the same class as positive pairs and pixels from dissimilar classes as negative pairs, observing significant gains in semantic segmentation performance. We take inspiration from their work and expand the idea of contrasting similar class pixels against dissimilar class pixels for UDA.
In summary, our paper makes the following contributions: 1) We propose a simple Jensen-Shannon Divergence-based contrastive loss for UDA in nuclei semantic and instance segmentation tasks. The proposed loss maximizes the mutual information between the representations of ground truth nuclei pixels from the labeled source dataset and the pseudo-labeled nuclei pixels in the target data. 2) We demonstrate our approach using different architectures and for over 20 cancer-type domain shifts establishing that the inclusion of the MI loss leads to competitive gain over recently proposed methods.

Unsupervised Domain Adaptation
UDA is a well-studied problem in literature where two of the widely adopted techniques are adversarial learning and self-training. In Adversarial learning, researchers attempt to align source data representation with target data representation via discriminator training. Hoffman et al. [11] proposed a cycle-consistent adversarial domain adaptation (DA) method for enforcing cycle-consistency between domains. [17] used a category-level adversarial network for enforcing semantic consistency between each class. Tsai et al. [23] developed a patch alignment method for DA by adversarially pushing the feature representations of clustered patches together. Vu et al. [24] used an entropy-based adversarial training approach for aligning weighted self-information distributions of different domains. Yang et al. [26] showed improvement in domain alignment by iteratively defensing against pointwise adversarial perturbations for domains.
In Self-training, pseudo-labels are iteratively generated on target datasets using the model trained on labeled source datasets and used for retraining. Recent papers have incorporated different de-noising strategies for improving the accuracy of pseudo-labels. Zhang et al. [29] used category centroids from the source domain for pseudo-labeling the target data and used the distance to centroids for training. Zhang et al. [28] denoised pseudo-label by online correcting them according to the relative feature distance to the prototypes. Zou et al. [30] used class-wise normalized confidence scores for generating pseudo-labels with balanced class distribution for self-training. Zou et al. [31] proposed a confidence regularization for smoothing the prediction via regularizer loss minimization.
We highlight the relevant works extending the above approaches for UDA in nuclei segmentation. Yang et al. [27] used adversarial domain discriminator and cyclic adaptation with pseudo labels for UDA. Further, they utilized weak labels to improve nuclei instance segmentation and classification. Haq et al. [9] used adversarial learning loss and reconstruction loss on output space for UDA for cell segmentation. Li et al. [15] extended [9] and applied a selfensembling method with a student-teacher framework for imposing consistency loss along with reconstruction and adversarial training. In another branch of works, [16] performed UDA from microscopy to histopathology images by synthesizing target-type images using CycleGAN followed by an inpainting module before applying adversarial adaptation. However, this approach requires pixellevel translation for synthesizing target-like images before a segmentation module and uses instance-level information for the mutual information-based feature alignment, constraining its adoption to only instance segmentation. Therefore, we limit our work and first test it extensively for tissue/ cancer type domain shifts and leave microscopy to histopathology adaptation for future works. Further, our proposed MI-based feature alignment strategy can be used for both semantic and instance segmentation problems.

Contrastive Learning and Mutual Information
Contrastive learning (CL) methods are being widely adopted for classification and segmentation tasks of different modalities. For semi-supervised segmentation, Alonso et al. [1] used positive-only CL for enforcing the segmentation network to yield similar pixel-level feature representation for same-class samples between labeled and unlabeled datasets. Hu et al. [13] for MRI and CT image segmentation pretraining used global contrastive loss on unlabeled images and supervised local contrastive loss on limited labeled images. For volumetric medical segmentation, Chaitanya et al. [2] leveraged similarity across corresponding slices in different volumes for defining positive and negative pairs for contrastive loss. They used infoNCE bound for CL, requiring a large number of negative samples for training. For tackling this dependency, Peng et al. [20] maximized mutual information (MI) on categorical distribution by projecting the continuous feature embedding to clustering space. They used encoder representation for global regularization and, for local regularization, maximized MI between neighboring feature vectors at multiple intermediate levels.
Our work maximizes the MI between similar classes using labeled source images and pseudo-labeled target images. Concurrent to our work, Chaitanya et al. [3] proposed an end-to-end semi-segmentation framework by defining a local pixel-level contrastive loss between pseudo-labels of unlabeled sets and limited labeled sets. They randomly sample pixels from each image to address the computational limitations of running CL for all the pixels. In contrast, we use average pooling at the class level for considering all the pixels of labeled and unlabeled images. Further, we use JSD bound instead of InfoNCE for MI estimation and focus on domain adaptation tasks. Shrivastava et al. [22] in their work for visual representation learning from textual annotation, demonstrated that the JSD-based bound enables the MI maximization at a smaller batch size with just one negative sample. Also, [10] demonstrated in their extended analysis that JSD is insensitive to the number of negative samples, while infoNCE shows a decline as the number of negative samples decreases, motivating us to choose JSD bound for MI estimation.

Problem Set-Up
In our work, we tackle the problem of unsupervised domain adaptation for nuclei segmentation, where we have labeled source domain data and unlabeled target domain data coming from different cancer types. Our labeled source data has N s images (x s , y s ) and our unlabeled target domain has N t images (x t ).

Segmentation Loss and Mutual Information Maximization
We use a combination of dice loss and binary cross-entropy loss for supervised segmentation training (L seg ). For mutual information (MI) maximization, we use Jensen-Shannon Divergence (JSD)-based lower bound proposed in [10]. This bound allows us to estimate the MI with just one negative example for each positive example. In our framework, we define nuclei pixels in the source domain with nuclei pixels in the target domain as positive pairs while background pixels in the source domain with nuclei pixels in the target domain as a negative pair.
We use a simple 1×1 convolution network with the same number of input and output channels, followed by batch normalization and ReLU as the projection head. The output of the backbone network is passed to the projection head for generating representation for MI loss. Projected feature representation and segmentation labels are used for MI maximization. Since labels are not available for the target domain, we use a segmentation network output from the same iteration as pseudo-labels. Typically, we would like to contrast all the positive pair pixels with negative pair pixels. However, for computational feasibility, we mean pool the projected representations using the segmentation labels to get aggregated background and nuclei pixel representations. Further, mean pooled source nuclei representation with mean pooled target nuclei representation is treated as a positive pair, whereas mean pooled background pixel representation with mean pooled target nuclei representation is treated as a negative pair. We define our JSD estimator as: where z s is mean pooled source nuclei representation, z t is mean pooled target nuclei representation, z s is mean pooled background representation for the source sample, and sp(z) = log(1+e z ) is the softplus function. Here, T ω : Z s ×Z t → R is a discriminator network with trainable parameters ω which are jointly optimized to distinguish between a paired-sample from a joint distribution (positive pair) and a paired sample from product of marginals (negative pair). For discriminator network, we use the concat architecture proposed in [10].

Training
As shown in Figure 1, our architecture is divided into 4 parts -1) backbone encoder-decoder network (θ b ), 2) segmentation head (θ s ) for generating segmentation masks, 3) projection head (θ p ) for generating feature representations for MI maximization and 4) discriminator network (T ω ) for estimating MI.
We divide our training into 2 steps. In step 1, for warming up the model and achieving reasonable pseudo-labels for target data, we pretrain the backbone network (θ b ) and segmentation head (θ s ) using source data on segmentation loss. In step 2, we continue the training the model with the MI loss between labeled source data points and pseudo-labeled target data points.
where Z s and Z t are mean pooled nuclei representation for source and target respectively, and X pair define randomly paired source and target image for MI maximization.

Dataset and Implementation
We evaluate our approach using the similar setting used in [15] for Nuclei Semantic Segmentation and [27] for Nuclei Instance Segmentation. In [15], authors used the Kidney Renal Clear Cell Carcinoma (KIRC) dataset [14], Triple Negative Breast Cancer Cell (TNBC) dataset [18], and Stomach adenocarcinoma (STAD) [12] of the TCIA repository. There are 486 images of 400 × 400 pixel In [27], the authors used colorectal nuclear segmentation and phenotype dataset (CoNSep) [7] as the source domain and PanNuke dataset [5] comprising 19 cancer types as the target domain for UDA in nuclei instance segmentation and classification task. As used in their paper, we use labeled CoNSep and the first split of PanNuke for training, second split for validation, and third split for testing. We focused on the instance segmentation task and didn't use classification labels for training. We use HoverNet as the backbone encoder-decoder network with MI maximization module included in the nuclei segmentation branch. We report Dice Score, Aggregate Jaccard Index (AJI), Panoptic Quality (PQ), Detection Quality (DQ), and Segmentation Quality (SQ) for comparison.
All experiments are carried out in PyTorch using 1 A100 GPU for nuclei semantic segmentation and 4 A100 GPUs for nuclei instance segmentation. For the nuclei semantic segmentation experiment, we train the model for 1000 iterations using only segmentation loss and 9000 iterations with both segmentation and MI maximization loss. We use a batch size of 4, Adam optimizer with a learning rate of 1e − 3, and rotation augmentation. We randomly pair labeled source images with unlabeled target images during the MI maximization step. For nuclei instance segmentation experiment, we follow the training details provided in [27] and [7]. We extend our approach only for nuclei instance segmentation and will focus on classification in our future work. First, we freeze the encoder and train the decoder for 50 epochs, with the first 10 epochs only using segmentation loss and the subsequent 40 epochs using both segmentation and MI loss. Then we unfreeze and train the whole network for 50 epochs with both losses. We use a batch size of 16 and Adam optimizer with a learning rate of 1e − 4.

Evaluation
Nuclei Semantic Segmentation - Table 1 compares our approach with recently proposed approaches for UDA for nuclei semantic segmentation 1 . MaNi outperforms all other approaches for both TNBC to KIRC/ TCIA shift and TCIA to KIRC/ TNBC shift. The next best performing approach proposed in [15] uses multiple components consisting of a discriminator and a reconstruction network, consistency regularization between perturbed target images, and post-processing with CRF. While MaNi only uses the MI maximization module with segmentation loss for training, reducing the complexity of the architecture. We attribute high gains to the MI module's ability to transfer nuclei segmentation knowledge from labeled source pixels to pseudo-labeled target pixels.
Nuclei Instance Segmentation -Results for UDA in nuclei instance segmentation from CoNSep data to PanNuke data is reported in Table 2 2 . MaNi performs competitively to the best performing approach. MaNi demonstrates superior performance over PQ, DQ, and AJI, highlighting that our approach can detect and segment more nuclei accurately and suffers less from the issue of false negatives. While in terms of SQ and Dice Score, MaNi is competitive to other approaches.

Ablation Studies
We study the impact of different weightage on the MI loss for training. As shown in Table 3, the default choice of 1 performs best. The impact of MI loss dilutes 1 Other approach results reported using best self-implementation 2 Other approach results reported from [27] with reduction in weight, leading to a drop in performance. Further, we study how replacing the average pooling approach with the max-pooling approach or sampling random pixels approach (N=4), as done in [3], impacts performance. Average pooling performs superior to other approaches.

Conclusion
In this paper, we propose a JSD-based MI loss for UDA for Nuclei Semantic Segmentation and Instance Segmentation. We perform comprehensive experiments with different architecture -UNet and HoverNet and for different cancer-type domain shifts -TNBC to TCIA/KIRC, TCIA to KIRC/TNBC, and CoNSep to PanNuke. We highlight that our method leads to gain for both semantic segmentation and instance segmentation. We plan to extend this approach for nuclei classification tasks and subsequently to general imaging tasks in our future work.