NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

MAEDiff: Masked Autoencoder-enhanced Diffusion Models for Unsupervised Anomaly Detection in Brain Images

Rui Xu, Yunke Wang, Bo DuarXiv 2024 · DOI

Abstract

Unsupervised Anomaly Detection (UAD) in medical imaging aims to identify lesions by learning the distribution of healthy anatomy, bypassing the need for expensive manual annotations. While Diffusion Models (DMs) have shown promise in high-fidelity reconstruction, they often struggle with fine structural details and global contextual consistency. This paper introduces MAEDiff, a novel framework that integrates a Masked Autoencoder (MAE) into a diffusion-based pipeline. By employing a hierarchical patch-based approach and cross-attention mechanisms, MAEDiff effectively leverages global context to reconstruct healthy brain tissue from anomalous scans. Evaluated on the BraTS21 and MSLUB datasets, MAEDiff achieves state-of-the-art performance in segmenting brain tumors and Multiple Sclerosis lesions.

Introduction

The detection and segmentation of brain lesions, such as tumors or Multiple Sclerosis (MS) plaques, are fundamental to clinical diagnosis. Traditional supervised learning models require thousands of expert-annotated images, which are difficult to acquire. UAD offers a scalable alternative by training models exclusively on healthy data to learn "normal" anatomical patterns. During inference, the model attempts to reconstruct a healthy version of a potentially diseased input; the residual difference between the original and reconstructed images reveals anomalies. However, standard diffusion models often suffer from "contextual blindness," failing to use global brain structure to inform local patch reconstruction. MAEDiff addresses this by bridging the gap between local texture and global structure.

Methodology

MAEDiff introduces a hierarchical and context-aware reconstruction process designed to preserve anatomical fidelity while removing anomalies.

Hierarchical Patch Partitioning

Instead of processing the entire image at once, MAEDiff divides the brain into a hierarchy of upper-level overlapping patches (for the diffusion process) and sub-level non-overlapping grids (for feature extraction). This allows the model to handle high-resolution data efficiently.

MAE-Enhanced U-Net

The core innovation is the integration of a Masked Autoencoder (MAE), built with Vision Transformer (ViT) blocks, into the standard Diffusion U-Net. During training, the model masks portions of the feature map; the MAE module then uses cross-attention to help the diffusion process "fill in the blanks" based on the surrounding healthy anatomy. This forces the model to perform counterfactual reasoning—asking what a region should look like if it followed the rules of the healthy tissue surrounding it.

The MAEDiff framework overview, illustrating (a) patch-wise training with hierarchical partitioning and (b) sequential patch-wise inference for full-image reconstruction.

Simplex Noise and Sequential Inference

To better mimic the spatial characteristics of actual medical anomalies, the authors utilize Simplex noise instead of standard Gaussian noise. During testing, a sequential inference strategy slides across the brain image, reconstructing overlapping patches and averaging them to create a smooth, high-fidelity healthy reference image.

Experimental Results

The model was trained on the IXI dataset (560 healthy scans) and evaluated on BraTS21 (1,251 tumor scans) and MSLUB (30 MS scans).

Quantitative Performance

MAEDiff set new benchmarks for unsupervised brain anomaly detection:

  • BraTS21 (Tumors): Achieved a 42.07% DICE score, outperforming the previous state-of-the-art (pDDPM) by approximately 1%.
  • MSLUB (MS Lesions): Achieved a 9.61% DICE score, significantly higher than standard Autoencoders (7.10%).

Qualitative Analysis

Visual results demonstrate that MAEDiff is highly effective at removing large lesions while preserving underlying healthy brain folds (sulci and gyri). Unlike previous models that often leave "ghost" artifacts of the lesion, MAEDiff's context-driven approach produces a cleaner reconstruction.

Qualitative results comparing MAEDiff reconstructions and anomaly maps against ground truth (GT) for unhealthy and healthy brain slices.

Discussion and Conclusion

A key insight from the study is that the structured masking of the MAE is essential for performance; adding global attention without masking actually decreased accuracy. This suggests that forcing the model to reason about spatial relationships is critical for medical UAD. While the patch-based diffusion process is computationally intensive, MAEDiff represents a significant advancement in high-fidelity, label-free lesion detection. Future work will explore cross-domain generalization and methods to focus computational effort on suspicious regions to improve efficiency.

Summary updated

BibTeX
@misc{xu2024maediff,
  author = {Rui Xu and Yunke Wang and Bo Du},
  title = {{MAEDiff: Masked Autoencoder-enhanced Diffusion Models for Unsupervised Anomaly Detection in Brain Images}},
  year = {2024},
  eprint = {2401.10561},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2401.10561},
}
Figure