nnOOD: A Framework for Benchmarking Self-supervised Anomaly Localisation Methods

Matthew Baugh, Jeremy Tan, Athanasios Vlontzos, Johanna P. Müller, Bernhard Kainz

Abstract

The wide variety of in-distribution and out-of-distribution data in medical imaging makes universal anomaly detection a challenging task. Recently a number of self-supervised methods have been developed that train end-to-end models on healthy data augmented with synthetic anomalies. However, it is difficult to compare these methods as it is not clear whether gains in performance are from the task itself or the training pipeline around it. It is also difficult to assess whether a task generalises well for universal anomaly detection, as they are often only tested on a limited range of anomalies. To assist with this we have developed nnOOD, a framework that adapts nnU-Net to allow for comparison of self-supervised anomaly localisation methods. By isolating the synthetic, self-supervised task from the rest of the training process we perform a more faithful comparison of the tasks, whilst also making the workflow for evaluating over a given dataset quick and easy. Using this we have implemented the current state-of-the-art tasks and evaluated them on a challenging X-ray dataset.

Introduction

Detecting anomalies in medical images, such as subtle pathologies in chest X-rays, is a critical yet challenging task. While supervised learning excels at identifying specific, known diseases, it often fails to detect "universal" anomalies—novel or rare conditions not present in the training set. Consequently, research has shifted toward self-supervised learning (SSL), where models are trained on healthy data augmented with synthetic anomalies (e.g., CutPaste or Foreign Patch Interpolation).

A significant hurdle in this field is the lack of a level playing field. Performance gains are often conflated with variations in the training pipeline, such as choice of optimizer, learning rate, or data augmentation strategies. This "pipeline noise" makes it nearly impossible to isolate the effectiveness of the synthetic anomaly task itself.

The nnOOD Framework

To address these inconsistencies, we introduce nnOOD, a framework built upon the "no-new-U-Net" (nnU-Net) philosophy. nnU-Net is renowned for its ability to automatically configure architectures and preprocessing based on dataset fingerprints. nnOOD extends this capability to Out-of-Distribution (OOD) detection by standardizing the training environment.

Overview of the nnOOD framework, illustrating the integration of nnU-Net's automated configuration with modular self-supervised tasks.

The framework incorporates several key design choices to ensure fair and effective benchmarking:

  • Standardized Pipeline: By fixing hyperparameters like optimizers and architectures, the only variable becomes the synthetic task.
  • Early Stopping on Synthetic Data: To prevent overfitting to the artifacts of synthetic anomalies, training stops based on a moving average of Average Precision (AP) on a synthetic validation set.
  • Positional Encoding (ConvCoord): Since anatomical normality is location-dependent, coordinate channels are added to provide spatial context.
  • Anomaly Oversampling: 30% of training patches are forced to contain synthetic anomalies to ensure sufficient exposure to "abnormal" examples.

Experimental Results

We evaluated nnOOD using the ChestX-ray14 dataset, training exclusively on healthy samples and testing on 14 different thorax diseases. Pathology bounding boxes served as proxy anomaly masks for evaluation.

Comparative Performance

The benchmarking of various state-of-the-art tasks revealed significant performance disparities. Natural Synthetic Anomalies (NSA) emerged as the clear leader, nearly doubling the Average Precision of simpler methods.

Task AUROC (Male PA) AP (Male PA)
FPI 0.515 0.075
CutPaste 0.484 0.071
PII 0.554 0.084
NSA 0.718 0.162
NSA (Mixed) 0.714 0.167

Qualitative Analysis

Visual inspection of the localization heatmaps supports the quantitative findings. Methods that produce sharp, unnatural edges—such as CutPaste and FPI—often fail to generalize to real medical pathologies, which rarely exhibit such geometric discontinuities. In contrast, NSA shows superior alignment with ground truth labels by generating more realistic synthetic transitions.

Qualitative comparison of anomaly localization across different self-supervised tasks on the Male PA dataset.

Key Insights

  • The "Seamlessness" Hypothesis: Success in universal anomaly detection appears linked to how naturally synthetic anomalies blend into the background. NSA and Poisson Image Interpolation (PII), which use gradient blending, outperform "cruder" methods.
  • Task Difficulty and Training Dynamics: Simpler tasks like CutPaste reach their performance ceiling rapidly (e.g., 27 epochs), whereas the subtle nuances of PII require significantly longer training (over 300 epochs).
  • Spatial Context: The inclusion of positional encoding was vital, as many medical anomalies are defined by normal tissues appearing in abnormal locations.

Discussion and Future Work

While nnOOD provides a robust benchmarking platform, challenges remain. The use of bounding boxes as ground truth is inherently noisy, as they often encompass healthy tissue. Furthermore, current methods focus primarily on patch blending. Future research should explore more complex synthetic anomalies, such as tissue deformations or warping, which may more accurately simulate a broader range of medical conditions. Despite the progress made by NSA, a performance gap still exists between self-supervised and fully supervised models, highlighting the ongoing need for more realistic synthetic anomaly generation.

Summary updated

BibTeX
@inproceedings{baugh2022nnood,
  author = {Matthew Baugh and Jeremy Tan and Athanasios Vlontzos and Johanna P. Müller and Bernhard Kainz},
  title = {{nnOOD: A Framework for Benchmarking Self-supervised Anomaly Localisation Methods}},
  booktitle = {UNSURE @ MICCAI},
  year = {2022},
  doi = {10.1007/978-3-031-16749-2\_10},
}
Figure