Unsupervised Contrastive Analysis for Salient Pattern Detection using Conditional Diffusion Models

Cristiano Patrício, Carlo Alberto Barbano, Attilio Fiandrotti, Riccardo Renzulli, Marco Grangetto, Luís F. Teixeira, João C. Neves

Abstract

Detecting anomalies in medical imaging, such as brain tumors or lesions, is often hindered by the scarcity of labeled pathological data. This paper introduces an unsupervised framework that combines self-supervised contrastive learning with conditional diffusion models to perform salient pattern detection. By training a target-invariant encoder on healthy anatomical data, the system extracts core structural features while remaining robust to anomalies. A conditional diffusion decoder then uses these features to reconstruct a "healthy" version of the input scan. Anomalies are localized through a saliency map generated by the absolute difference between the original and reconstructed images. The proposed method achieves state-of-the-art performance on challenging benchmarks, including BraTS21 and the NOVA dataset.

Introduction

Traditional Contrastive Analysis (CA) identifies anomalies by comparing a target group (unhealthy) against a background group (healthy). However, the high cost and difficulty of obtaining large, accurately labeled datasets of specific pathologies limit the scalability of supervised approaches. Unsupervised Anomaly Detection (UAD) offers a promising alternative by learning a "normal" baseline from healthy data alone. While previous generative models like GANs and VAEs have been explored, they often suffer from blurry reconstructions or training instability. This work leverages the high-fidelity generation capabilities of diffusion models to address the challenge of reconstructing a patient-specific healthy anatomy for precise anomaly localization.

Methodology

The proposed framework consists of a two-stage unsupervised pipeline designed to isolate and reconstruct healthy anatomical patterns.

Target-Invariant Encoder

A ResNet-50 encoder is trained using a self-supervised contrastive loss ($\epsilon$-InfoNCE). To ensure the encoder is "invariant" to anomalies, heavy data augmentations—such as random cutout and Gaussian noise—are applied to healthy images during training. This process forces the encoder to ignore transient or anomalous-looking patches and focus on the underlying common anatomical structures ($z_{bg}$).

Conditional Diffusion Decoder

The latent features from the encoder serve as a "blueprint" for a conditional diffusion model. During inference, the model receives a noisy version of the input image and uses the latent features to guide the denoising process. The objective is to produce a reconstruction ($\hat{x}_0$) that preserves the patient's unique, non-pathological anatomy while replacing any anomalies with healthy tissue patterns.

Overview of the proposed contrastive-guided conditional diffusion model architecture and inference process.

Inference and Localization

Anomaly detection is performed by calculating the saliency map ($\Delta_{SM}$), defined as the absolute difference between the original image ($x_0$) and the reconstruction ($\hat{x}_0$). High-intensity regions in this map indicate potential pathologies, providing an interpretable "heat map" for clinical review.

Experimental Results

The model was validated across several datasets, including CelebA for proof-of-concept, IXI for background reference, and BraTS21 and MSLUB for clinical benchmarks. It was also tested on the NOVA benchmark, which contains 281 rare and diverse pathologies.

Quantitative Performance

The model achieved state-of-the-art (SOTA) results on the BraTS21 dataset with a Dice score of 50.97%, outperforming existing diffusion-based methods. On the rigorous NOVA benchmark, the model reached an mAP30 of 18.57, a significant improvement over the 11.51 achieved by the previous best-performing conditional diffusion model (cDDPM).

Qualitative Analysis

Qualitative evaluations on the NOVA benchmark demonstrate that the model produces more spatially focused and accurate bounding boxes compared to baselines. While other models often produce fragmented or undersized predictions, the proposed method accurately delineates complex pathological boundaries.

Qualitative comparison of anomaly localization on the NOVA benchmark. The proposed method (Ours) shows superior alignment with ground truth (green) compared to DDPM variants.

Conclusion

This work demonstrates that combining contrastive conditioning with diffusion models effectively addresses the challenges of unsupervised anomaly detection in brain MRIs. By ensuring the reconstruction is tethered to the specific patient's anatomy, the model provides high-fidelity, interpretable saliency maps. Future work will explore extending the framework to 3D volumes and integrating multimodal MRI sequences to further enhance clinical utility.

Summary updated

BibTeX
@article{patricio2026unsupervised,
  author = {Cristiano Patrício and Carlo Alberto Barbano and Attilio Fiandrotti and Riccardo Renzulli and Marco Grangetto and Luís F. Teixeira and João C. Neves},
  title = {{Unsupervised Contrastive Analysis for Salient Pattern Detection using Conditional Diffusion Models}},
  journal = {Pattern Recognition Letters},
  year = {2026},
  doi = {10.1016/j.patrec.2025.11.014},
}
Figure