CLEF: Clinically-Guided Contrastive Learning for Electrocardiogram Foundation Models

Yuxuan Shu, Peter H. Charlton, Fahim Kawsar, Jussi Hernesniemi, Mohammad Malekzadeh · DOI

Introduction

Electrocardiograms (ECGs) are the cornerstone of cardiovascular diagnostics. With the proliferation of wearable devices, single-lead ECG monitoring has become ubiquitous. However, interpreting these signals remains difficult due to noise and the inherent loss of spatial information compared to standard 12-lead clinical setups.

Recent advancements in "foundation models"—large-scale models pretrained on massive unlabeled datasets—offer a potential solution. Yet, standard self-supervised learning (SSL) techniques often fail to leverage the rich clinical context (e.g., age, blood pressure, medical history) typically associated with ECG recordings. Standard SSL treats all distinct samples as equally "negative," ignoring the fact that patients with similar clinical risk profiles should ideally have more similar representations.

The CLEF Framework

To address these limitations, we introduce Clinically-Guided Contrastive Learning (CLEF). This framework integrates clinical domain knowledge into the pretraining process to develop more medically relevant ECG representations.

Clinically-Guided Objectives

The core of CLEF lies in two novel loss functions guided by clinical risk scores (e.g., SCORE2):

  1. Weighted Contrastive Loss ($L^w$): Unlike binary contrastive learning, $L^w$ adaptively weights negative pairs. It penalizes the model more heavily if it places ECG embeddings of patients with vastly different risk scores close together in the latent space.
  2. Dissimilarity Alignment Loss ($L^d$): This objective explicitly aligns the geometric distance between ECG embeddings with the "distance" in their clinical risk profiles, ensuring the latent space reflects medical reality.

Robustness and Lead-Agnosticism

To ensure applicability to diverse wearable formats, CLEF employs a random lead selection strategy during pretraining. By training on individual leads sampled from 12-lead data, the model learns robust, lead-agnostic features. Additionally, a missingness-aware mechanism handles incomplete clinical metadata, preventing unreliable risk estimates from degrading model performance.

The CLEF framework: (A) Clinically-guided pretraining using risk scores and missingness weights; (B) Performance overview of the CLEF-M model across 13 tasks.

Experimental Evaluation

We pretrained CLEF on the MIMIC-IV-ECG dataset, which contains 10-second 12-lead ECGs from over 161,000 patients. The model was evaluated across a comprehensive benchmark of 18 tasks spanning 7 datasets, including clinical benchmarks like PTB-XL and Chapman, as well as real-world wearable data from MUSIC and Icentia11K.

Key Results

CLEF consistently outperformed five state-of-the-art foundation model baselines and three standard SSL algorithms.

  • Diagnostic Accuracy: The medium-sized model (CLEF-M) achieved an average AUROC improvement of at least 2.6% over competing foundation models.
  • Regression Performance: In tasks such as estimating left ventricular ejection fraction (LVEF) or blood pressure, CLEF saw Mean Absolute Error (MAE) reductions of at least 3.2%.
  • Model Boosting: Beyond serving as a standalone foundation, CLEF objectives can be used to fine-tune existing models. For instance, applying CLEF to the KED baseline resulted in significant performance boosts across multiple downstream tasks.
Relative improvement in AUROC when applying CLEF objectives to the KED baseline (left) and performance across different model scales and leads (right).

Discussion and Conclusion

CLEF demonstrates that incorporating clinical metadata as a structural guide—rather than just an input feature—significantly enhances the medical utility of ECG foundation models. By bridging the gap between self-supervised learning and clinical reality, CLEF provides a robust foundation for both clinical diagnostics and consumer wearable applications. Future work will focus on expanding the diversity of pretraining datasets and exploring the application of clinically-guided learning to other physiological signals like photoplethysmography (PPG).

Summary updated

BibTeX
@misc{shu2025clef,
  author = {Yuxuan Shu and Peter H. Charlton and Fahim Kawsar and Jussi Hernesniemi and Mohammad Malekzadeh},
  title = {{CLEF: Clinically-Guided Contrastive Learning for Electrocardiogram Foundation Models}},
  year = {2025},
  eprint = {2512.02180},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.02180},
}
Figure