Diffusion Models for Medical Anomaly Detection

Julia Wolleb, Florentin Bieder, Robin Sandkühler, Philippe C. Cattin

TL;DR

This paper introduces a novel method for medical anomaly detection that uses Denoising Diffusion Implicit Models (DDIMs) to transform diseased medical images into "healthy" versions. By comparing the original diseased image with its synthetically generated healthy counterpart, the system creates highly detailed anomaly maps using only image-level labels (e.g., "sick" vs. "healthy") for training, bypassing the need for expensive pixel-wise manual annotations.

What Problem Does This Paper Address?

In medical imaging, obtaining pixel-wise "ground truth" annotations (where a radiologist colors in every pixel of a tumor) is incredibly time-consuming, expensive, and prone to human bias. Weakly supervised anomaly detection aims to solve this by training models using only image-level labels—simply knowing whether a whole scan contains a pathology or not.

Existing methods typically rely on Generative Adversarial Networks (GANs) or Variational Autoencoders (VAEs). However, GANs are notoriously difficult to train and often fail to preserve the fine anatomical details of the original patient. VAEs often produce blurry reconstructions. The challenge is to "re-paint" only the diseased part of an image while keeping the rest of the patient’s unique anatomy perfectly intact.

Methods

The authors leverage the power of Diffusion Models, specifically DDIMs, which have recently outperformed GANs in image synthesis. Their approach consists of two main phases:

  1. Training: They train a standard Diffusion Model (DDPM) and a simple binary classifier on a dataset of healthy and diseased images.
  2. Inference (The "Healthy" Translation):
    • Deterministic Noising: An input image (e.g., a brain with a tumor) is partially "noised" using a deterministic reversed sampling scheme. This encodes the anatomical structure into a latent noisy state.
  3. Classifier Guidance: During the denoising (reconstruction) process, the pre-trained classifier provides a "gradient" that steers the model. It essentially tells the model: "Reconstruct this image, but make it look like it belongs to the healthy class."
    • Anomaly Mapping: The final output is a synthetic "healthy" version of the same patient. The anomaly map is simply the absolute difference between the original input and this synthetic healthy output.

The use of DDIM (Implicit Models) is key here because it is deterministic. Unlike standard diffusion, which is stochastic (random), DDIM ensures that the "healthy" version retains the exact same background anatomy as the "diseased" version.

Datasets

The method was evaluated on two major medical benchmarks:

  • BRATS2020: A 3D brain Magnetic Resonance (MR) dataset. The authors used 2D axial slices across four sequences (T1, T1ce, T2, and FLAIR) to detect brain tumors.
  • CheXpert: A large-scale dataset of lung X-ray images, specifically used here to detect pleural effusions (fluid around the lungs).

Key Insights and Ideas

  • Anatomy Preservation via Determinism: The most significant "aha" moment is using the deterministic nature of DDIMs for image-to-image translation. By noising and then denoising the same image, the model acts as a highly specific "filter" that only changes the parts of the image the classifier identifies as "diseased."
  • The Latent Space "Sweet Spot": The authors found that the choice of noise level ($L$) is a critical trade-off. If $L$ is too low, the model doesn't have enough "freedom" to remove the tumor. If $L$ is too high, the model loses the patient's unique anatomical details and generates a generic healthy brain.
  • Simplicity of Training: Unlike GANs, which require complex loss functions (like cycle-consistency) and delicate hyperparameter balancing to prevent "mode collapse," this diffusion approach uses standard MSE loss and a simple classifier.

Key Results

  • Qualitative Superiority: Compared to VAEs and FP-GANs, the diffusion method produced much sharper, more realistic "healthy" reconstructions and more precise anomaly maps that closely matched the actual tumor shapes.
  • Quantitative Performance: On the BRATS2020 dataset, the model achieved high Dice scores (a measure of overlap with ground truth) and AUROC (Area Under the Receiver Operating Characteristic) scores. For example, at optimal settings ($L=500, s=100$), the model significantly outperformed the VAE baseline in both metrics.
  • Robustness: The model proved effective across different imaging modalities (MRI and X-ray) without requiring architecture changes.

Limitations and Future Work

  • Inference Speed: The primary drawback is computational cost. Generating a single translated image takes about 158 seconds. While this is acceptable for offline research, it is slow for real-time clinical applications. The authors suggest that skipping timesteps in the DDIM scheme could speed this up, though it might impact image quality.
  • Reconstruction Error Criticism: The authors acknowledge that using simple reconstruction error as an anomaly score is sometimes criticized in literature (as it doesn't always correlate perfectly with clinical significance). They suggest exploring other scoring methods, such as the log-likelihood of density estimation models, in future work.
  • Hyperparameter Sensitivity: The model's performance is sensitive to the gradient scale ($s$) and noise level ($L$), requiring careful tuning for different types of pathologies.

Summary updated

BibTeX
@inproceedings{wolleb2022diffusion,
  author = {Julia Wolleb and Florentin Bieder and Robin Sandkühler and Philippe C. Cattin},
  title = {{Diffusion Models for Medical Anomaly Detection}},
  booktitle = {International Conference on Medical Image Computing and Computer-Assisted Intervention},
  year = {2022},
  url = {https://openreview.net/forum?id=ckDqkvHFZF},
}
Figure