Unsupervised Anomaly Detection in Medical Images Using Masked Diffusion Model

Hasan Iqbal, Umar Khalid, Jing Hua, Chen Chen

Abstract

Identifying anomalies in brain MRI scans, such as tumors and multiple sclerosis lesions, is a complex task due to anatomical heterogeneity and the high cost of pixel-level labeling. Unsupervised Anomaly Detection (UAD) offers a promising alternative by training models solely on healthy samples to learn a normative representation of human anatomy. In this study, we introduce the Masked Diffusion Model (mDDPM), a self-supervised framework that utilizes masking-based regularization to improve the generative capabilities of diffusion models. By incorporating Masked Image Modeling (MIM) and Masked Frequency Modeling (MFM), mDDPM learns robust visual representations without the need for external classifier guidance. Our evaluations on the BraTS21 and MSLUB datasets demonstrate that mDDPM significantly outperforms existing fully and weakly supervised baselines, establishing a new state-of-the-art for unsupervised medical image anomaly detection.

Introduction

The detection of pathological structures in medical imaging is a cornerstone of diagnostic radiology. However, the development of automated systems for this task is often hindered by the requirement for large, expertly annotated datasets. Supervised deep learning models, while effective, are limited by their dependence on pixel-level labels, which are time-consuming to produce and often fail to generalize across the vast diversity of human brain anatomy.

Unsupervised Anomaly Detection (UAD) addresses these challenges by learning the distribution of "healthy" anatomy. By training only on healthy scans, these models learn to reconstruct normal brain structures. When presented with an anomalous scan (e.g., one containing a tumor), the model's inability to accurately reconstruct the abnormal region highlights the pathology. While Generative Adversarial Networks (GANs) and Variational Autoencoders (VAEs) have been used for this purpose, they often suffer from instability or produce blurry reconstructions. Denoising Diffusion Probabilistic Models (DDPMs) offer higher fidelity but typically require classifier guidance to maintain structural accuracy—a requirement that is difficult to satisfy in an unsupervised context.

The mDDPM Approach

The proposed mDDPM framework introduces self-supervised masking as a form of regularization, effectively replacing the need for classifier guidance. By forcing the model to reconstruct missing or corrupted parts of an image, it learns the underlying structural and textural patterns of healthy brain tissue.

Masking Strategies

The researchers explored three distinct masking techniques to guide the diffusion process:

  1. Image Patch-Masking (IPM): This strategy involves randomly masking pixel-level patches in the spatial domain. It encourages the model to learn spatial correlations and global context.
  2. Frequency Patch-Masking (FPM): Utilizing the Fast Fourier Transform (FFT), the model masks specific components in the frequency domain. This is the first application of MFM in diffusion models for medical imaging, allowing the model to capture both low-frequency global shapes and high-frequency textures.
  3. Frequency Patch-Masking CutMix (FPM-CM): This advanced variant mixes frequency-augmented patches back into the original clean image. These patches serve as synthetic anomalies, training the model to "heal" or remove abnormal features during the denoising process.

Inference and Anomaly Detection

During the inference phase, a potentially anomalous image is processed by the mDDPM. The model treats the pathology as a form of noise or a "masked" region and attempts to generate a healthy reconstruction. An anomaly map is then produced by calculating the pixel-wise absolute difference between the original input and the model's reconstruction.

Experimental Results

The mDDPM was trained on the IXI dataset (560 healthy T1/T2-weighted scans) and evaluated on two challenging benchmarks: BraTS21 for tumor detection and MSLUB for multiple sclerosis lesion detection.

Performance on BraTS21

The FPM-CM variant of mDDPM achieved a DICE score of 53.02% and an AUPRC of 59.04%. This represents a significant improvement over standard DDPM (40.82% DICE) and the previous state-of-the-art patched-DDPM (49.12% DICE). Qualitative analysis showed that mDDPM produces cleaner anomaly maps with fewer false positives in healthy tissue compared to traditional generative methods.

Performance on MSLUB

In the detection of smaller, more subtle lesions, mDDPM achieved a DICE score of 10.71%. While lower than tumor detection scores due to the difficulty of the task, it nearly doubled the performance of traditional VAE-based methods (6.63%).

Conclusion and Future Directions

The mDDPM framework demonstrates that self-supervised masking is a powerful tool for regularizing diffusion models in medical imaging. By leveraging both spatial and frequency domain information, the model achieves superior reconstruction of healthy anatomy, leading to more accurate anomaly detection.

While the iterative nature of diffusion models results in slower inference speeds compared to VAEs or GANs, the gains in detection accuracy are substantial. Future research will focus on transitioning from U-Net architectures to Masked Diffusion Transformers to better capture long-range anatomical relationships and further improve performance.

Summary updated

BibTeX
@inproceedings{iqbal2023unsupervised,
  author = {Hasan Iqbal and Umar Khalid and Jing Hua and Chen Chen},
  title = {{Unsupervised Anomaly Detection in Medical Images Using Masked Diffusion Model}},
  booktitle = {MLMI @ MICCAI},
  year = {2023},
  doi = {10.1007/978-3-031-45673-2\_37},
}
Figure