AMAE: Adaptation of Pre-trained Masked Autoencoder for Dual-Distribution Anomaly Detection in Chest X-Rays

Behzad Bozorgtabar, Dwarikanath Mahapatra, Jean-Philippe Thiran

Introduction

Unsupervised Anomaly Detection (UAD) in medical imaging has traditionally been framed as a One-Class Classification (OCC) problem. In this paradigm, models are trained exclusively on "normal" images to learn a normative distribution, with any deviation at test time flagged as an anomaly. However, this approach fails to utilize the vast quantities of unlabeled data available in clinical environments—data that often contains a mixture of healthy and pathological cases.

Existing methods that attempt to incorporate unlabeled data often struggle to differentiate between subtle pathological features and benign anatomical variations. To address this, the authors introduce AMAE (Adaptation of Pre-Trained Masked Autoencoder), a two-stage framework designed for a "dual-distribution" setting. AMAE leverages both guaranteed normal data and unlabeled datasets to build a more robust and clinically relevant detector.

Methodology

The AMAE framework operates in two distinct stages, moving from synthetic anomaly detection to a refined dual-distribution adaptation.

Stage 1: Proxy Task for Synthetic Anomalies

The first stage establishes a baseline using synthetic data. The authors utilize a Vision Transformer (ViT) encoder pre-trained via Masked Autoencoding (MAE) on a massive dataset of 300,000 X-rays. By freezing this encoder, they preserve high-quality, in-domain feature representations.

To simulate anomalies, the framework employs AnatPaste, an anatomy-aware augmentation technique. AnatPaste creates synthetic anomalies by "pasting" lung patches from one region into another, mimicking the appearance of localized pathologies. A lightweight MLP classifier is then trained to distinguish these synthetic anomalies from real normal images.

Stage 2: MAE Inter-Discrepancy Adaptation

The second stage transitions from synthetic to real-world data distributions. The classifier from Stage 1 is used to assign pseudo-labels to the unlabeled dataset, categorizing images as either "Pseudo-labeled Normal" or "Pseudo-labeled Abnormal."

Using these labels, the system trains two separate MAE modules:

  • Module A (Normal Specialist): Trained on a combination of guaranteed normal and pseudo-normal images.
  • Module B (Abnormal Specialist): Trained exclusively on pseudo-abnormal images.

Inference via Inter-Discrepancy: Unlike traditional autoencoders that rely on reconstruction error (which can be unreliable if the model generalizes too well to anomalies), AMAE uses the inter-discrepancy between the two modules. At test time, an image is passed through both specialists. If the modules disagree significantly on the reconstruction of a specific region, that region is flagged as anomalous. This "disagreement" mechanism is significantly more effective at identifying subtle pathologies.

Experimental Results

AMAE was evaluated against three major public chest X-ray (CXR) benchmarks, achieving new state-of-the-art (SOTA) results across the board:

  1. RSNA Pneumonia Detection Challenge: AMAE achieved an AUC of 91.4% and an Average Precision (AP) of 91.7%, a substantial improvement over the previous SOTA (DDAD-AE at 81.5% AUC).
  2. VinDr-CXR: On this large-scale dataset with expert radiologist annotations, the model reached 86.1% AUC, outperforming the best baseline (f-AnoGAN at 76.3%).
  3. NIH-CXR: In the initial stage, the model reached 95.0% AUC, surpassing other self-supervised methods such as NSA and AnatPaste.

Furthermore, the authors demonstrated that the model is highly robust to the "Anomaly Ratio" within the unlabeled set. As the percentage of abnormal images in the unlabeled data increases, the performance of the Stage 2 adaptation improves consistently, proving that the model effectively learns from the "noise" of unlabeled clinical data.

Key Insights

  • The Value of Unlabeled Data: AMAE demonstrates that unlabeled data is a valuable resource rather than a nuisance. Even imperfect pseudo-labels provide a stronger signal for real-world pathologies than synthetic data alone.
  • Discrepancy vs. Error: Shifting the detection metric from reconstruction error to inter-module discrepancy allows the model to catch subtle anomalies that standard autoencoders might inadvertently reconstruct correctly.
  • In-Domain Pre-training: The success of the ViT encoder highlights that pre-training on medical images (in-domain) is far superior to using ImageNet (out-of-domain) weights for specialized tasks like chest X-ray analysis.

Conclusion and Future Work

AMAE represents a significant step toward practical, unsupervised medical anomaly detection by successfully bridging the gap between synthetic training and real-world unlabeled data. While the current framework requires an initial set of guaranteed normal images, the authors aim to extend this into a fully unsupervised scheme in the future, potentially removing the need for any initial annotations or guaranteed normal sets.

Summary updated

BibTeX
@inproceedings{bozorgtabar2023amae,
  author = {Behzad Bozorgtabar and Dwarikanath Mahapatra and Jean-Philippe Thiran},
  title = {{AMAE: Adaptation of Pre-trained Masked Autoencoder for Dual-Distribution Anomaly Detection in Chest X-Rays}},
  booktitle = {International Conference on Medical Image Computing and Computer-Assisted Intervention},
  year = {2023},
  url = {https://openreview.net/forum?id=lDMs8U9tiO},
}
Figure