SSRL-ECG is a self-supervised representation learning framework for ECG-based cardiovascular disease classification in low-data regimes. It combines domain-adaptive augmentations engineered specifically for cardiac signals with SimCLR and BYOL pretraining frameworks, enabling accurate multi-label classification with as few as 1,747 labeled samples from the PTB-XL dataset.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Tumo505/SSL-for-ECG-classification/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Set up your Python environment and install the
ssrl-ecg package with all dependencies.Quickstart
Run SSL pretraining and fine-tuning end-to-end in under 30 minutes.
SSL Concepts
Understand SimCLR, BYOL, and why self-supervised learning excels with limited labels.
API Reference
Explore the full Python API — models, augmentations, losses, and utilities.
What is SSRL-ECG?
Standard supervised learning for ECG diagnosis requires large amounts of labeled data — a bottleneck in clinical settings where expert annotation is expensive and time-consuming. SSRL-ECG addresses this by pretraining a 1D CNN encoder on unlabeled ECGs using contrastive objectives, then fine-tuning on just 10% of labels. The framework achieves:| Method | AUROC | F1 | Sensitivity | Specificity |
|---|---|---|---|---|
| Supervised (Focal + Oversample) | 0.8606 | 0.5750 | 0.6772 | 0.9357 |
| SimCLR + Augmentations | 0.8717 | 0.6448 | 0.6831 | 0.9411 |
| BYOL + Augmentations | 0.8565 | 0.6301 | 0.6648 | 0.9278 |
Key Features
Domain-Adaptive Augmentations
7 ECG-specific augmentations: frequency warping, medical mixup, bandpass filtering, CutMix, motion artifacts, per-channel noise, and temporal dropout.
SimCLR Pretraining
Contrastive learning with NT-Xent loss on unlabeled ECGs. Achieves 0.8717 AUROC after fine-tuning on 10% labels.
BYOL Pretraining
Momentum-based self-supervised learning as an alternative to contrastive approaches.
Label Scarcity Benchmark
Systematic comparison of SSL vs. supervised learning across label fractions from 1% to 100%.
Multi-Seed Validation
Statistical robustness via 10 random seeds with 95% confidence intervals.
Transfer to MIT-BIH
External validation on the MIT-BIH arrhythmia dataset for out-of-distribution robustness.
Getting Started
Prepare PTB-XL data
Download the PTB-XL dataset and place it under
data/PTB-XL/ following the expected folder structure.Project Structure
Thessrl_ecg package lives under src/ssrl_ecg/ and provides both importable Python modules and CLI entry points invokable via python -m ssrl_ecg.<module>.
Training Scripts
train_ssl_simclr, train_ssl_byol, train_supervised, train_finetuneModels
ECGEncoder1DCNN, SimCLRModel, BYOLModel, ResNet1D, ECGClassifierAugmentations
ECGAugmentations, ContrastiveAugmentationPipelineEvaluation
evaluate, label_scarcity_benchmark, analyze_datasets