Learning ECG Representations via Poly-Window Contrastive Learning

Yi Yuan, Joseph Van Duyn, Runze Yan, Zhuoyi Huang, Sulaiman Vesal, Sergey Plis, Xiao Hu, Gloria Hyunjung Kwak, Ran Xiao, Alex Fedorov

Abstract

Self-supervised learning (SSL) has emerged as a powerful paradigm for medical time-series analysis, reducing the dependency on expensive expert annotations. However, standard contrastive learning frameworks often rely on pairwise comparisons that fail to fully exploit the temporal redundancy inherent in physiological signals. This paper presents a "poly-window" contrastive learning framework for electrocardiogram (ECG) representation learning. By extracting and maximizing agreement across multiple temporal windows from a single recording, the proposed method encourages the model to learn stable, physiologically relevant features. Experimental results on the PTB-XL dataset demonstrate that this approach achieves state-of-the-art performance while significantly reducing pre-training time and epoch requirements.

Introduction

Deep learning has significantly advanced automated ECG analysis, yet the performance of these models typically scales with the availability of high-quality, labeled datasets. In the clinical domain, obtaining such labels is a bottleneck due to the expertise and time required for annotation. Contrastive learning, a subset of self-supervised learning, offers a solution by pre-training models on unlabeled data to learn robust latent representations.

Traditional contrastive methods, such as SimCLR, typically utilize a pairwise approach: two augmented views of a single sample are generated, and the model is trained to maximize their similarity. While effective for images, this approach may be suboptimal for 10-second ECG recordings. ECG signals possess a rich, repetitive structure where underlying pathologies persist throughout the recording, while noise and artifacts are often transient. By comparing only two random crops, standard methods may fail to capture the full physiological context. This paper addresses this limitation by introducing a multi-view framework designed to exploit the temporal consistency of cardiac dynamics.

Methodology

Poly-Window Framework

The core innovation of this work is the Poly-Window Contrastive Learning framework. Rather than extracting only two views, the method extracts $M$ temporal windows (e.g., 4, 6, or 8) from a single ECG recording. This multi-view approach is inspired by Slow Feature Analysis (SFA), which posits that meaningful signals change slowly over time compared to noise. By forcing the model to find agreement across multiple distinct segments of the same ECG, the network is incentivized to prioritize "slow," temporally invariant cardiac features over "fast," transient local fluctuations.

Architecture and Objective

The framework utilizes a 1D variant of the ResNet-18 architecture to encode temporal windows into a latent space. To maintain computational efficiency as the number of windows increases, the authors modified the standard contrastive loss. Instead of computing independent similarities for every possible pair of positive windows—which would result in $O(M^2N^2)$ complexity—the framework aggregates the similarities of all positive windows for a given anchor using a statistical mean (arithmetic or geometric). This optimization reduces the complexity to $O(MN)$, ensuring the memory footprint remains manageable even with 8 windows per sample.

Experimental Setup

Dataset

The framework was evaluated using the PTB-XL dataset, a comprehensive collection of 21,837 clinical 12-lead ECG recordings. Each recording is 10 seconds long and sampled at 100Hz. The dataset was utilized for both self-supervised pre-training and subsequent linear evaluation.

Downstream Task

The primary evaluation metric was multi-label superclass classification into five clinical categories: Normal, Myocardial Infarction, ST/T Change, Conduction Disturbance, and Hypertrophy. This task tests the model's ability to extract diagnostically relevant features from the learned representations.

Results and Discussion

Performance and Efficiency

The 8-window configuration achieved state-of-the-art results on the PTB-XL superclass classification task, reaching an AUROC of 0.891 and an F1 score of 0.680. This outperformed the 2-view SimCLR baseline (0.888 AUROC) and other specialized contrastive methods like TSSL (0.872 AUROC) and CLOCS (0.784 AUROC).

Beyond accuracy, the poly-window approach demonstrated remarkable training efficiency:

  • Convergence Speed: The 8-window model reached peak performance in just 32 epochs, whereas the 2-window baseline required 128 epochs.
  • Wall-Clock Time: Despite the increased computational load per step from processing more windows, the drastic reduction in total epochs resulted in a 14.8% reduction in total pre-training time (4.6 minutes vs. 5.4 minutes on an NVIDIA A100 GPU).

Physiological Insights

Ablation studies revealed that a crop size of 0.64 seconds (64 time-points) was optimal for representation learning. This "Goldilocks" window size corresponds roughly to a single cardiac cycle. Crops significantly shorter than this lack sufficient temporal context, while significantly longer crops may capture multiple heartbeats, potentially diluting the dynamic features the model aims to extract.

Conclusion

Poly-window contrastive learning provides a more efficient and effective way to learn ECG representations by leveraging the inherent temporal redundancy of physiological signals. By increasing the number of views and aggregating their similarities, the model achieves superior diagnostic performance with a fraction of the training epochs required by standard methods. While this study focused on 12-lead ECGs within the PTB-XL dataset, the framework is model-agnostic and holds potential for application in single-lead wearables and other physiological time-series like EEG.

Summary updated

BibTeX
@inproceedings{yuan2025learning,
  author = {Yi Yuan and Joseph Van Duyn and Runze Yan and Zhuoyi Huang and Sulaiman Vesal and Sergey Plis and Xiao Hu and Gloria Hyunjung Kwak and Ran Xiao and Alex Fedorov},
  title = {{Learning ECG Representations via Poly-Window Contrastive Learning}},
  booktitle = {BHI},
  year = {2025},
  url = {https://openreview.net/forum?id=zgiylJ5LwD},
}
Figure