OptTTA: Learnable Test-Time Augmentation for Source-Free Medical Image Segmentation Under Domain Shift

Devavrat Tomar, Guillaume Vray, Jean-Philippe Thiran, Behzad BozorgtabarMIDL 2022

Abstract

As distribution shifts are inescapable in realistic clinical scenarios due to inconsistencies in imaging protocols, scanner vendors, and across different centers, well-trained deep models incur a domain generalization problem in unseen environments. Despite a myriad of model generalization techniques to circumvent this issue, their broad applicability is impeded as (i) source training data may not be accessible after deployment due to privacy regulations, (ii) the availability of adequate test domain samples is often impractical, and (iii) such model generalization methods are not well-calibrated, often making unreliable overconfident predictions. This paper proposes a novel learnable test-time augmentation, namely OptTTA, tailored specifically to alleviate large domain shifts for the source-free medical image segmentation task. OptTTA enables efficiently generating augmented views of test input, resembling the style of private source images and bridging a domain gap between training and test data. Our proposed method explores optimal learnable test-time augmentation sub-policies that provide lower predictive entropy and match the feature statistics stored in the BatchNorm layers of the pretrained source model without requiring access to training source samples. Thorough evaluation and ablation studies on challenging multi-center and multi-vendor MRI datasets of three anatomies have demonstrated the performance superiority of OptTTA over prior-arts test-time augmentation and model adaptation methods. Additionally, the generalization capabilities and effectiveness of OptTTA are evaluated in terms of aleatoric uncertainty and model calibration analyses. Our PyTorch code implementation is publicly available at https://github.com/devavratTomar/OptTTA.

Introduction

Deep learning models for medical image segmentation are notoriously sensitive to domain shift. A model trained on MRI scans from one specific scanner or hospital often fails when deployed in a different environment due to subtle variations in contrast, noise, or resolution. Standard solutions like Unsupervised Domain Adaptation (UDA) typically require access to the original source training data to bridge this gap. However, data privacy regulations (e.g., GDPR, HIPAA) often prevent the sharing of source data once a model is deployed, leading to the "source-free" challenge. While existing Test-Time Augmentation (TTA) methods attempt to help by averaging predictions over random transformations, these static policies do not adapt to the specific nature of the domain shift encountered.

Methodology

OptTTA (Learnable Test-Time Augmentation) addresses these challenges by treating the augmentation process as an optimization problem at inference time. Unlike model adaptation methods that update network weights, OptTTA modifies the input's appearance to better align with the model's training domain.

Overview of the OptTTA framework illustrating the Exploration and Exploitation phases.

The framework operates in two distinct phases:

  1. Exploration Phase: The system searches through a pool of augmentation sub-policies (combinations of brightness, contrast, blurring, etc.). It uses gradient descent to identify which transformations make the test data "fit" the model's internal expectations.
  2. Exploitation Phase: The top-k best-performing policies are selected and fine-tuned for the specific patient volume. The final segmentation is an ensemble of the model’s predictions across these optimized views.

To guide this optimization without ground-truth labels, OptTTA utilizes a loss function based on three components: matching BatchNorm statistics (using the frozen model's layers as a proxy for source data), minimizing conditional entropy (to encourage confidence), and maximizing class marginal entropy (to prevent trivial background-only predictions).

Results

The authors evaluated OptTTA on three challenging multi-center MRI datasets: Spinal Cord Grey Matter (SCGM), Multi-Centre Cardiac Segmentation (M&Ms), and Prostate MRI.

Qualitative evolution of the top sub-policy across different anatomies, demonstrating how target images are transformed to resemble the source domain style.

OptTTA consistently outperformed both standard TTA (e.g., RandAug) and model adaptation methods (e.g., TENT). On the Heart (M&Ms) dataset, OptTTA improved the average Dice score by 22.5% compared to the unadapted source model. On Spinal Cord data, it achieved a 9.2% improvement. Beyond accuracy, OptTTA significantly improved model calibration and reduced aleatoric uncertainty near organ boundaries, making the model's predictions more reliable for clinical use.

Discussion and Conclusion

OptTTA provides a robust, source-free mechanism for adapting medical imaging models to new domains. By focusing on input transformation rather than weight updates, it avoids the risks of catastrophic forgetting and model collapse. While the exploration phase introduces some computational overhead, the significant gains in segmentation accuracy and calibration justify its use in sensitive clinical applications. Future work may involve combining OptTTA with self-training strategies to further refine model performance in tandem with input augmentations.

Summary updated

BibTeX
@inproceedings{tomar2022opttta,
  author = {Devavrat Tomar and Guillaume Vray and Jean-Philippe Thiran and Behzad Bozorgtabar},
  title = {{OptTTA: Learnable Test-Time Augmentation for Source-Free Medical Image Segmentation Under Domain Shift}},
  booktitle = {MIDL},
  year = {2022},
  url = {https://openreview.net/forum?id=r6EsqDtVvK},
}
Figure