Harnessing EHRs for Diffusion-Based Anomaly Detection on Chest X-Rays

Harim Kim, Yuhan Wang, Minkyu Ahn, Heeyoul Choi, Yuyin Zhou, Charmgil Hong

Introduction

Unsupervised Anomaly Detection (UAD) represents a significant frontier in medical imaging, offering the potential to identify pathological deviations without the need for exhaustive, manually labeled datasets. However, a persistent challenge in image-only UAD is anatomical variability. Normal physiological differences—such as those stemming from a patient's BMI, age, or height—can often be misinterpreted as anomalies by standard diffusion models. These models lack the necessary context to understand that an "unusual" appearance might be perfectly normal for a specific individual.

To address this, we present Diff3M, the first diffusion-based framework that integrates chest X-rays with structured Electronic Health Records (EHRs). By conditioning the image reconstruction process on clinical context, Diff3M learns to distinguish between benign anatomical variations and true pathologies, setting a new standard for multi-modal medical anomaly detection.

Methods: The Diff3M Framework

The core of Diff3M lies in its ability to leverage multi-modal data to guide the denoising process. The architecture consists of two primary innovations designed to integrate clinical context into the generative process:

  1. Image-EHR Cross-Attention (IECA): This module processes tabular EHR data—including age, sex, BMI, and blood pressure—through a specialized feature tokenizer. A cross-attention mechanism then aligns these clinical features with image features, creating a "conditional embedding." This embedding informs the model of the expected "normal" appearance for a patient with that specific clinical profile.
  2. Pixel-level Checkerboard Masking (PCM): To ensure the model actively utilizes the EHR context rather than relying on local pixel correlations, a static checkerboard mask is applied during the reconstruction phase. This forces the model to reconstruct masked regions based on global semantic information provided by the EHR-guided embeddings.
Overview of the Diff3M architecture, highlighting the integration of EHR data and the checkerboard masking strategy.

The framework utilizes a dual-network approach: a Noise Prediction (NP) network and a Masked Pixel Generation (MPG) network. Both are built upon the Denoising Diffusion Implicit Model (DDIM) framework to ensure efficient sampling and high-quality image reconstruction.

Experimental Setup and Datasets

Diff3M was rigorously evaluated on two large-scale, gold-standard chest radiography datasets:

  • CheXpert: 16,969 "normal" samples were used for training.
  • MIMIC-CXR / MIMIC-IV: 29,310 "normal" samples were used. This dataset is particularly valuable as it allows for the direct pairing of X-rays with rich clinical metadata, including BMI, height, weight, and vitals.

In both datasets, "normal" was defined by the No Finding label. During the testing phase, all other disease classes were treated as anomalies to evaluate the model's detection capabilities.

Results and Analysis

Diff3M achieves state-of-the-art (SOTA) performance across major benchmarks, significantly outperforming both traditional feature-based methods and existing diffusion-based models.

Quantitative performance comparison of Diff3M against baseline methods on CheXpert and MIMIC datasets.

Key Findings:

  • Quantitative Superiority: As shown in the results table, Diff3M (Ours$_{demo,ehr}$) achieved an AUROC of 0.617 and an AUPRC of 0.821 on the MIMIC dataset. On CheXpert, it reached an AUPRC of 0.931, demonstrating a clear advantage over image-only diffusion models like DiAD and feature-based methods like PatchCore and MambaAD.
  • The Importance of BMI: Ablation studies revealed that BMI is a critical feature, receiving the highest attention weights within the IECA module. This confirms that body composition is a primary driver of the visual variations that often lead to false positives in standard UAD models.
  • Context-Aware Reconstruction: Qualitative analysis indicates that Diff3M is more effective at "healing" anomalous artifacts—such as tumors or pleural effusions—into anatomically plausible normal tissue during the reverse diffusion process. By contrast, standard DDPMs often fail to produce consistent reconstructions when faced with significant pathologies.

Conclusion

By bridging the gap between medical imaging and clinical records, Diff3M provides a more robust and context-aware approach to anomaly detection. The integration of EHR data allows the model to account for individual patient variability, reducing false positives and improving diagnostic accuracy. While the current model relies on structured EHR data, future research will explore the incorporation of unstructured data, such as physician notes and lab results, to further enhance the system's clinical utility.

Summary updated

BibTeX
@inproceedings{kim2025harnessing,
  author = {Harim Kim and Yuhan Wang and Minkyu Ahn and Heeyoul Choi and Yuyin Zhou and Charmgil Hong},
  title = {{Harnessing EHRs for Diffusion-Based Anomaly Detection on Chest X-Rays}},
  booktitle = {International Conference on Medical Image Computing and Computer-Assisted Intervention},
  year = {2025},
  doi = {10.1007/978-3-032-04947-6\_23},
}
Figure