betaFeedback

WorksComputer Science

Contrastive uncertainty learning for robust multi-structure segmentation in lower-pelvic MR

Abstract

Boundary delineation of anatomical structures in prostate MRI is often compromised by regional ambiguity. Automated segmentation methods relying on global overlap loss functions tend to be insensitive to surface deviations, leading to significant errors in ambiguous regions. Most existing uncertainty-aware methods treat uncertainty as a post-hoc quality indicator or prediction filter. We propose Contrastive Uncertainty Learning (CUL), a supervised framework that uses predictive uncertainty to directly guide representation learning. Using Monte Carlo Dropout, CUL identifies voxel-wise uncertainty and structures the embedding geometry accordingly: low-uncertainty, correctly predicted features form stable voxels while high-uncertainty or misclassified features are actively repelled, preventing feature collapse at difficult boundaries. We evaluate CUL on a 589-scan 3D prostate MRI multi-structure segmentation task (8 anatomical structures) using a ViT with UperNet decoder architecture. Average Dice (83.38%83.38\%) remains comparable to the baseline (83.35%83.35\%), while surface distance decreases significantly (p<0.001p<0.001) across 6 of 8 anatomical structures. A hard-case analysis reveals a 22×22{\times} asymmetry between significantly improved and degraded cases (18.8%18.8\% vs 0.9%0.9\%). Ablation studies show that removing uncertainty-guided sample selection eliminates improvements for the transition zone, while replacing the contrastive objective with a boundary loss additionally removes bladder improvements, demonstrating that both uncertainty-guided sampling and the contrastive objective are essential for the observed gains. These findings demonstrate that the proposed uncertainty-guided representation learning is a useful mechanism for reducing the risk of extreme errors in safety-critical medical segmentation

Introduction

Deep learning based segmentation is becoming important for quantitative analysis of prostate MRI, enabling automated delineation of prostate zones and associated structures for prostate cancer diagnosis, risk stratification, and treatment planning [1]. Despite strong average performance, convolutional and transformer models often fail on boundary ambiguous cases, producing large boundary deviations that are not fully reflected by global overlap metrics [2]. A key challenge lies in learning representations that remain robust in regions of high predictive uncertainty, typically near boundaries where standard losses such as Dice or cross-entropy do not explicitly incorporate confidence information.

Predictive uncertainty estimates represent model confidence and are widely used in medical image analysis. Bayesian approximations, including Monte Carlo dropout [3] and deep ensembles [4], correlate uncertainty with segmentation error and support quality assurance, error detection, and selective prediction in safety-critical applications.

Uncertainty has also been incorporated into training strategies, particularly in semi-supervised segmentation. In teacher–student frameworks, uncertainty is used to filter unreliable pseudo-labels or weight consistency losses to mitigate confirmation bias [5]. Uncertainty guided contrastive learning similarly excludes high uncertainty pixels from positive pair construction to stabilise representations [6, 7]. Prototype based and memory based approaches construct class prototypes from confident regions while preventing ambiguous voxels from contaminating cluster centres [8]. These methods improve robustness when labelled data are limited, using uncertainty as a filtering or weighting mechanism.

Directly using uncertainty to structure embedding geometry in fully supervised segmentation remains underexplored, particularly for intrinsically ambiguous multi-structure MRI segmentation.

Contrastive learning provides a principled mechanism for structuring representation space. Self-supervised frameworks such as MoCo [9], SimCLR [10], and supervised contrastive learning [11] demonstrate their ability to shape embeddings. Contrastive learning at the pixel and voxel levels has been adopted in segmentation to enhance intra-class compactness and inter-class separation. However, these methods typically define positive pairs solely by class identity or spatial proximity, without considering predictive confidence.

We hypothesise that structuring embedding space based on predictive uncertainty can reduce catastrophic boundary deviations while preserving overall segmentation accuracy. Confident same-class voxels should anchor compact clusters, whereas high-uncertainty voxels should be prevented from distorting these regions of feature space. We therefore propose Contrastive Uncertainty Learning (CUL), a supervised contrastive uncertainty learning framework that: (1) treats predictive uncertainty as a representation level supervisory signal rather than solely a post-hoc reliability estimate or filtering mechanism; (2) structures representation geometry by aligning low uncertainty same class voxel features while preventing ambiguous high uncertainty features from collapsing into confident clusters; (3) demonstrates significant surface distance (SD) improvement across 6 of 8 anatomical structures (p<0.001p < 0.001), with a 22×22 \times asymmetry between significantly improved and degraded hard cases; and (4) validates each component’s contribution via two ablations: removing uncertainty guidance achieves 5/8 significant SD anatomical structures; replacing the contrastive term with a boundary loss achieves 4/8, confirming uncertainty guided selection as the decisive factor, improving transition zone, while the contrastive mechanism additionally accounts for bladder. To our knowledge, uncertainty has not been explicitly used as a contrastive structuring signal to improve segmentation robustness.

Overview of the proposed Contrastive Uncertainty Learning framework

Figure 1. Overview of the proposed Contrastive Uncertainty Learning (CUL) framework. Prostate MRI is processed by a segmentation network to produce voxel wise predictions and an associated uncertainty map. Voxel embeddings are partitioned into low and high uncertainty regions and used to construct contrastive pairs. Low-uncertainty same-class features are pulled together, while high-uncertainty or misclassified features are repelled, improving boundary robustness.

Method

Model Architecture

For our proposed CUL, we use a 3D model based on a Vision Transformer (ViT) encoder pretrained [12] using masked autoencoding, followed by a UperNet head [13] adapted for the segmentation task. For specific formulation of model architecture, let x∈RD×H×Wx \in\mathbb{R}^{D \times H \times W} denote the T2W MRI input and y∈RC×D×H×Wy \in\mathbb{R}^{C \times D \times H \times W} the voxel-wise ground-truth masks. The encoder-adapter stack produces multi-scale (ss) spatial features {F(s)}s=14=fθ(x)\{F^{(s)}\}_{s=1}^{4} = f_{\theta}(x) which are decoded using the UperNet decoder into voxel-wise logits Z=gϕ({F(s)})∈RC×D×H×WZ = g_{\phi}(\{F^{(s)}\}) \in\mathbb{R}^{C \times D \times H \times W}. Segmentation probabilities are then defined as P=softmax⁡(Z)P = \operatorname{softmax}(Z). For the baseline segmentation we have a Dice + Cross-Entropy (DiceCE) loss: Lseg=LDiceCE(Z,y)\mathcal{L}_{\mathrm{seg}} = \mathcal{L}_{\mathrm{DiceCE}}(Z, y).

Predictive Uncertainty Estimation. For computing our proposed CUL loss, we first compute predictive uncertainty map using Monte Carlo (MC) Dropout in the decoder. Specifically, given M(=5)M(=5) stochastic forward passes, let P(m)P^{(m)} be the probability map from pass mm. The predictive entropy for voxel-wise uncertainty map is then computed as U=−∑c=1CPˉclog⁡(Pˉc+ϵ)U=-\sum_{c=1}^{C}\bar{P}_c\log(\bar{P}_c+\epsilon) where Pˉ=1M∑m=1MP(m)\bar{P}=\frac{1}{M}\sum_{m=1}^{M}P^{(m)} is predictive probability, C=8C=8 is the number of segmentation classes (zones), PcP_c is the probability for class cc and ϵ\epsilon is numerical constant for stability. The map is normalised per sample: U~=U−min⁡(U)max⁡(U)−min⁡(U)+ϵ\tilde{U}=\frac{U-\min(U)}{\max(U)-\min(U)+\epsilon}.

Contrastive Uncertainty Learning (CUL)

Uncertainty Guided Sampling and Pair Construction: Using the uncertainty map, CUL operates on decoder features (before the final classifier), which are projected into a contrastive embedding space. We first define the low-uncertainty mask and prediction-error map:

Mlow=1(U~<τ),Emap=1(y^≠y),(1)M_{\mathrm{low}}=\mathbb{1}\left(\tilde{U}<\tau\right),\quad E_{\mathrm{map}}=\mathbb{1}(\hat{y}\ne y), \tag*{(1)}

where τ(=0.5)\tau(=0.5) is a fixed uncertainty threshold and y^\hat{y} is the predicted label. From these, we define an anchor pool and a negative pool:

Manchor=Mlow⋅(1−Emap),Mneg=1((1−Mlow)+Emap>0).(2)M_{\mathrm{anchor}}=M_{\mathrm{low}}\cdot(1-E_{\mathrm{map}}),\quad M_{\mathrm{neg}}=\mathbb{1}\left((1-M_{\mathrm{low}})+E_{\mathrm{map}}>0\right). \tag*{(2)}

Terminology: Anchors are voxels (epe_p) sampled from decoder features using the mask ManchorM_{\mathrm{anchor}}, corresponding to low-uncertainty and correctly predicted regions. For each anchor, a positive sample is defined as a same-class voxel drawn from the anchor pool, excluding the anchor itself when possible. Negatives (ene_n) are sampled using MnegM_{\mathrm{neg}}, comprising voxels that are either high-uncertainty or misclassified, and are not restricted to different-class locations.

Uncertainty-Aware Contrastive Loss: Projected features (anchors and negatives) are ℓ2\ell_2-normalised, and for each anchor epie_p^{i}, one positive ep(i)ie_{p(i)}^{i} is sampled from the same-class confident set, and a set of negatives NiN_i is sampled using MnegM_{\mathrm{neg}}. The contrastive term is then computed voxel-wise as:

LCUL−ctr(i)=−log⁡exp⁡(sim⁡(epi,ep(i)i)/T)exp⁡(sim⁡(epi,ep(i)i)/T)+∑k∈Niexp⁡(sim⁡(epi,eki)/T)(3)\mathcal{L}_{\mathrm{CUL-ctr}}^{(i)}=-\log\frac{\exp(\operatorname{sim}(e_p^{i},e_{p(i)}^{i})/T)}{\exp(\operatorname{sim}(e_p^{i},e_{p(i)}^{i})/T)+\sum_{k\in N_i}\exp(\operatorname{sim}(e_p^{i},e_k^{i})/T)} \tag*{(3)}

where TT is a learnable temperature parameter. The full training objective is defined as sum of DiceCE and CUL (weighted by learnable parameter λctr\lambda_{\mathrm{ctr}}):

L=Lseg+λctrLCUL−ctr\mathcal{L}=\mathcal{L}_{\mathrm{seg}}+\lambda_{\mathrm{ctr}}\mathcal{L}_{\mathrm{CUL-ctr}}.

Experiments and Results

Dataset and Experimental Setup: For our experiments, we employ a multi-institute pelvis MR dataset [14], consisting of 589 T2W 3D MRI input samples of size (D=64D=64, H=256H=256, W=256W=256) with anatomy/zone masks. In total, there are 8 anatomical structures; bladder, bone, obturator internus, central gland, transition zone, rectum, seminal vescicle and neurovascular bundle. The dataset was split into train, validation and test sets (412, 60, 117) and the inputs were preprocessed and augmented using standard preprocessing and augmentation (centre cropping, rotation, flipping, zooming and intensity normalisation). Training used an NVIDIA A40 GPU for 100 epochs with learning rate 1e−41e-4. The Dice with cross entropy loss was adopted to train our baseline segmentation model using the Adam optimiser. Batch size was set to 4 with 5 Monte Carlo (MC) samples computed for the uncertainty map during training. For performance evaluation, we use Dice, Hausdorff-distance and Surface Distance, capturing the overall overlap as well as worst-case boundary errors and surface errors. To isolate each component’s contribution, we evaluate two ablations under identical training conditions: a class-based variant replacing uncertainty-guided anchor selection with ground-truth class identity only; and a boundary loss variant replacing the contrastive term with a Kervadec-style distance-transform boundary loss.

Overall Quantitative Performance: Table 1 summarises overall segmentation performance across 117 test cases. CUL achieves comparable Dice performance to the baseline (0.8338 vs 0.8335), indicating that uncertainty-aware contrastive learning does not on average degrade global overlap. As CUL specifically focuses on boundary deviations, we observe consistent improvement in boundary sensitive metrics. Mean HD95 decreases from 5.93 mm to 5.41 mm, and mean surface distance (SD) decreases from 1.61 mm to 1.42 mm.

MetricBaselineCULClass-BasedClassic BL
Dice (↑\uparrow)0.8335 ±\pm 0.06470.8338 ±\pm 0.06510.8331 ±\pm 0.06370.8338 ±\pm 0.0634
HD95(mm) (↓\downarrow)5.9343 ±\pm 8.14145.4130 ±\pm 4.88295.3736 ±\pm 4.65585.6253 ±\pm 5.2306
SD(mm) (↓\downarrow)1.6076 ±\pm 2.51011.4190 ±\pm 1.81351.4385 ±\pm 1.88731.4641 ±\pm 1.9188

Table 1. Overall segmentation performance for Baseline, CUL, and the two ablations. SD(mm) is significantly improved which is consistent with CUL’s design: predictive uncertainty concentrates at local boundary regions, so improvement manifests in surface-sensitive metrics rather than in global overlap (Dice) or gross deviation extremes (HD95(mm)).

The HD95 standard deviation is notably reduced (8.14 →\rightarrow 4.88 mm), suggesting suppression of extreme outliers, though formal variance testing (Brown-Forsythe p=0.538p=0.538) does not confirm this at α=0.05\alpha=0.05, likely reflecting limited statistical power at n=117n=117; we therefore treat it as a descriptive finding. Paired Wilcoxon signed-rank testing confirms that SD reduction is statistically significant (p<0.0001p<0.0001), while Dice (p<0.181p<0.181) and HD95 (p<0.816p<0.816) median shifts are not. Dice is expected to remain unchanged because CUL targets local boundary uncertainty rather than volumetric overlap. Although HD95 is not significant, its mean decreases by 0.49 mm and variance is descriptively reduced, suggesting suppression of extreme outliers despite limited statistical power.

Case-Wise Performance Distribution: To characterise model behaviour beyond aggregate statistics, we analyse per-case performance (Table 2) across 117 test cases. A case is classified as notably improved or degraded if its mean metric change across all 8 structures exceeds a fixed medically critical absolute threshold (SD: ±0.1 mm; HD95: ±0.5 mm). Dice improves in 54.7% of cases versus 45.3% degraded, indicating only a modest net overlap gain. In contrast, boundary-sensitive metrics show clear asymmetry. HD95 improves in 56.4% of cases (+15 net), while SD improves in 67.5% of cases (+41 net). When considering significant changes, SD exhibits strong directional bias: 18.8% of cases show significant reduction compared to only 0.9% significant increase (22 vs 1 cases). This 22× ratio suggests asymmetric boundary refinement rather than random fluctuation. Figure 2 demonstrates the case where CUL has improved the boundary uncertainty the most (HD95=17.11 vs 4.09) and also the most degraded case (HD95=10.97 vs 12.80).

MetricImproved / Degraded (%)Sig+ / Sig- (%)Ratio
Dice (↑\uparrow)64 / 53 (54.7 / 45.3)––
HD95(mm) (↓\downarrow)66 / 51 (56.4 / 43.6)12 / 8 (10.3 / 6.8)1.5×
SD(mm) (↓\downarrow)79 / 38 (67.5 / 32.5)22 / 1 (18.8 / 0.9)22×

Table 2. Case-wise performance distribution (n=117n=117). Significant improvement/degradation thresholds: SD ±0.1 mm, HD95 ±0.5 mm.

Qualitative comparison between an improved case (top) and a degraded case (bottom)

Figure 2. Qualitative comparison between an improved case (top) and a degraded case (bottom). The top row highlights CUL’s role as geometric “insurance”, where it effectively corrects extreme boundary outliers in cases characterised by high regional ambiguity (e.g. central gland and both neurovascular bundles). CUL organises representations to stabilise boundaries by anchoring confident regions and isolating ambiguity. This visualisation demonstrates the framework’s capacity to correct significant spatial deviations while maintaining the integrity of stable predictions.

Hard-Case Robustness Analysis: We stratify cases using the median baseline HD95 threshold (4.00) to distinguish easy and hard subsets (Table 3). CUL achieves the largest boundary improvement in hard cases, with a mean HD95 reduction of 1.113 mm, whereas easy cases exhibit only marginal change (≈ 0).

SubsetnnΔ\DeltaHD95 (mm)
Easy (<4.0032)58≈ 0
Hard (≥4.0032)59−1.1131

Table 3. HD95(mm) change stratified by baseline difficulty (median=4.0032).

Structure-wise Analysis: Table 4 reports mean surface distance per anatomical structure (paired Wilcoxon,α\alpha=0.05). CUL achieves significant SD improvement in 6/8 structures:bladder, bone, central gland, rectum, transition zone, and neurovascular bundle. Obturator internus and seminal vesicle show no significant change;both have inter-subject variance exceeding three times their mean, suggesting high case to case variability. Dice remains largely unchanged across all structures(∣Δ∣|\Delta|<0.004). HD95 reaches significance only for rectum (pp=0.004). Notably, the largest quantitative SD gains appear in bone(−0.16 mm) and central gland(−0.61 mm).

StructureBaselineCULClass-BasedClassic BL
Bladder1.17 ± 1.820.85{sup}***0.86{sup}*0.87
Bone1.20 ± 1.941.03{sup}***1.02{sup}***1.01{sup}***
Obturator Int.1.43 ± 3.471.371.301.37
Central Gland2.50 ± 13.41.89{sup}***2.10{sup}***2.02{sup}**
Transition Zone1.59 ± 1.131.50{sup}**1.551.58
Rectum1.22 ± 0.981.15{sup}***1.14{sup}***1.13{sup}***
Seminal Vesicle1.78 ± 5.431.651.621.81
NVB1.97 ± 2.291.93{sup}***1.92{sup}***1.92{sup}***
Sig. structures6/85/84/8

Table 4. Per-structure SD (mm ↓), n=117, paired Wilcoxon vs. Baseline. *p<0.05, **p<0.01, ***p<0.001.

Ablation Study: To isolate the contribution of each CUL component, Table 4 also reports the two ablations. The class-based ablation (uncertainty guided selection removed) reaches 5/8 significant structures, failing only on transition zone (pp=0.676) which CUL improves (pp=0.002). This shows uncertainty guidance provides additional benefit beyond class-based contrastive learning. The boundary loss ablation reaches only 4/8, additionally failing to improve bladder (pp=0.115), suggesting geometric loss augmentation cannot replicate uncertainty-guided contrastive structuring. The stepwise pattern, CUL 6/8 > class-based 5/8 > boundary loss 4/8, isolates uncertainty guided sample selection as the decisive factor for transition zone, and the contrastive mechanism as the decisive factor for bladder.

Discussion and Conclusion

For our multi-structure MRI segmentation, we propose a supervised contrastive framework for improving geometric robustness, by estimating predictive uncertainty as a representation-level supervisory signal.

Our experiments on a multi-organ prostate MRI segmentation task show that CUL maintains comparable global overlap performance to the baseline, while consistently improving boundary-sensitive metrics. Case-wise and difficulty-stratified analyses further reveal that CUL yields the strongest benefits on hard cases characterised by large boundary deviations. Moreover, comparison with the two ablations clarifies the source of these gains, isolating the uncertainty guided mechanism as the key driver of CUL’s improvements in the transition zone.

These improvements have practical implications for radiotherapy planning. In pelvic organ segmentation, surface distance errors of even a few millimetres can translate to incorrect planning target volume (PTV) margins, affecting dose coverage and organ at risk (OAR) sparing. Similar precision requirements are of importance for targeted biopsy and focal therapy. The significant SD reductions, directly targets the boundary precision that affects contour acceptance in clinical workflows. The 22×22 \times asymmetry between significant improvements and significant degradations in SD further suggests CUL reduces the tail of outlier errors that typically require manual re-contouring. Future work includes adaptive uncertainty thresholding, additional ablations, and integration with multi-scale, domain-robust training.

References

  1. [1]B. Turkbey and M. A. Haider, “Deep learning-based artificial intelligence applications in prostate mri: brief summary,” The British Journal of Radiology, vol. 95, no. 1131, p. 210 ค?563, 2022.DOI
  2. [2]M.-K. Fassia et al., “Deep learning prostate mri segmentation accuracy and robustness: a systematic review,” Radiology: Artificial Intelligence, vol. 6, no. 4, p. e230138, 2024.DOI
  3. [3]Y. Gal and Z. Ghahramani, “Dropout as a Bayesian approximation: Representing model uncertainty in deep learning,” International Conference on Machine Learning (ICML), 2016.arxiv.org/abs/1506.02142
  4. [4]B. Lakshminarayanan, A. Pritzel, and C. Blundell, “Simple and scalable predictive uncertainty estimation using deep ensembles,” NeurIPS, 2017.arxiv.org/abs/1612.01474
  5. [5]Y. Ouali, C. Hudelot, and M. Tami, “Semi-supervised semantic segmentation with cross-consistency training,” in IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2020, pp. 12674–12684.arxiv.org/abs/2003.09005
  6. [6]T. Wang, J. Lu, Z. Lai, J. Wen, and H. Kong, “Uncertainty-guided pixel contrastive learning for semi-supervised medical image segmentation,” in Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence (IJCAI), 2022, pp. 1444–1450.DOI
  7. [7]Y. Hua, X. Shu, Z. Wang, and L. Zhang, “Uncertainty-guided voxel-level supervised contrastive learning for semi-supervised medical image segmentation,” International Journal of Neural Systems, vol. 32, no. 4, p. 2250016, 2022.DOI
  8. [8]X. Chen, J. Yao, R. Zhang et al., “Class prototypes for semi-supervised medical image segmentation,” in Medical Image Computing and Computer-Assisted Intervention (MICCAI), 2022.
  9. [9]K. He, H. Fan, Y. Wu, S. Xie, and R. Girshick, “Momentum contrast for unsupervised visual representation learning,” in IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2020, pp. 9729–9738.arxiv.org/abs/1911.05722
  10. [10]T. Chen, S. Kornblith, M. Norouzi, and G. Hinton, “A simple framework for contrastive learning of visual representations,” in International Conference on Machine Learning (ICML), 2020, pp. 1597–1607.arxiv.org/abs/2002.05709
  11. [11]P. Khosla, P. Teterwak, C. Wang, A. Sarna, Y. Tian, P. Isola, A. Maschinot, C. Liu, and D. Krishnan, “Supervised contrastive learning,” in Advances in Neural Information Processing Systems (NeurIPS), vol. 33, 2020, pp. 18661–18673.arxiv.org/abs/2004.11362
  12. [12]Y. Wang, Y. Xu, W. Yi, S. U. Saeed, N. Thorley, A. Ng, Y. Zhou, W. Yan, D. Barratt, S. Punwani, V. Kasivisvanathan, M. Emberton, D. C. Alexander, and Y. Hu, “Profound: A moderate-sized vision foundation model for multi-task prostate imaging,” 2026. [Online]. Available: https://arxiv.org/abs/2603.03961
  13. [13]T. Xiao, Y. Liu, B. Zhou, Y. Jiang, and J. Sun, “Unified perceptual parsing for scene understanding,” in Proceedings of the European Conference on Computer Vision (ECCV), 2020, pp. 418–434.
  14. [14]Y. Li, Y. Fu, I. J. Gayo, Q. Yang, Z. Min, S. U. Saeed, W. Yan, Y. Wang, J. A. Noble, M. Emberton et al., “Prototypical few-shot segmentation for cross-institution male pelvic structures with spatial registration,” Medical Image Analysis, vol. 90, p. 102935, 2023.DOI

Paper details

vlnc:W_una87ny5
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 10

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents