Source-linked AI summary
CLOCS: Contrastive Learning of Cardiac Signals Across Space, Time, and Patients
Dani Kiyasseh, Tingting Zhu, David A. Clifton
TL;DR
Healthcare generates abundant unlabelled physiological data, while high-quality clinical labels are difficult to obtain. CLOCS uses patient-specific contrastive learning across ECG time segments and leads, and outperforms BYOL and SimCLR on downstream tasks while producing representations that can quantify patient similarity.
Problem
High-quality labels for abundant clinical physiological data are difficult to procure, while existing contrastive methods generally define shared context at the instance rather than patient level.
Method
CLOCS is a family of self-supervised contrastive pre-training methods that encourages representations from same-patient ECG segments and leads to be similar.
Results
CLOCS outperforms BYOL and SimCLR in linear evaluation and fine-tuning on downstream tasks, including cardiac arrhythmia classification.
Takeaways & Limitations
CLOCS produces patient-specific representations that can be used to quantify patient similarity for diagnosis or understanding medical conditions.
Takeaways & Limitations
The demonstrated transfer uses the same ECG input modality, leaving cross-modal transfer as an open direction.
Abstract
from arXiv · showhide
The healthcare industry generates troves of unlabelled physiological data. This data can be exploited via contrastive learning, a self-supervised pre-training method that encourages representations of instances to be similar to one another. We propose a family of contrastive learning methods, CLOCS, that encourages representations across space, time, \textit{and} patients to be similar to one another. We show that CLOCS consistently outperforms the state-of-the-art methods, BYOL and SimCLR, when performing a linear evaluation of, and fine-tuning on, downstream tasks. We also show that CLOCS achieves strong generalization performance with only 25\% of labelled training data. Furthermore, our training procedure naturally generates patient-specific representations that can be used to quantify patient-similarity.
1. Introduction
CLOCS addresses the difficulty of using abundant unlabelled physiological data by defining patient-specific contrastive learning methods for ECG signals. It exploits temporal and spatial information and outperforms BYOL and SimCLR on downstream cardiac arrhythmia classification.
- Healthcare produces abundant unlabelled physiological data, but obtaining high-quality clinical labels is practically infeasible.
- CLOCS redefines shared context at the patient level rather than restricting it to views of the same instance.This design aims to learn patient-specific representations from multiple physiological recordings.
- CLOCS exploits temporal and spatial information in ECG signals through a family of patient-specific contrastive learning methods.Here, spatial information refers to projections of the heart’s electrical signal onto multiple leads.
- CLOCS outperforms BYOL and SimCLR in linear evaluation and fine-tuning on downstream cardiac arrhythmia classification tasks.
2. Related Work
Prior self-supervised work learns representations from temporal structure, augmentations, or multiple views, largely treating shared context as belonging to the same instance. Medical time-series work has explored patient representations and ECG pretext tasks, but not this contrastive patient-level framing.
- Contrastive learning commonly uses temporal prediction, data augmentations, and multiple views to define positive examples.Its standard formulation combines positive and negative examples, transformations, and a noise contrastive estimation loss.
- Image-focused contrastive methods generally interpret shared context as arising from the same data instance.
- DeepPatient learns patient representations from electronic health records, while Sarkar and Etemad use ECG-based pretext classification tasks for affective computing.
- CLOCS extends this landscape by treating shared context as occurring at the patient level in physiological recordings.
3. Background
Contrastive learning transforms unlabelled instances into views whose representations are encouraged to match when they share context and separate from other instances. Similarity is quantified between representations, commonly with cosine similarity, to promote transformation invariance.
- A learner fθ maps each D-dimensional input x to an E-dimensional representation h.
- Each unlabelled instance is exposed to transformation operators TA and TB to create transformed views.These transformations may include augmentations such as random cropping and flipping.
- Views derived from the same original instance form a positive pair when their transformations preserve class information.Their representations are encouraged to be similar and dissimilar to representations from other instances.
- Cosine similarity can quantify agreement between representations in a positive pair.Maximizing this similarity encourages representations to become invariant to transformations of the same instance.
4. Methods
CLOCS defines positive pairs using shared patient identity while exploiting temporal and spatial invariances in ECG recordings. Its CMSC, CMLC, and CMSMLC variants pair adjacent segments, aligned leads, or both, and optimize a patient-specific contrastive objective.
- Positive and Negative Pairs of Representations: CLOCS redefines positive pairs as transformed recordings from the same patient, while recordings collected years apart or in drastically different scenarios may share less context.
- Transformation Operators: ECG transformations are chosen to capture temporal and spatial invariances.Temporal invariance assumes nearby segments share cardiac context; spatial invariance assumes aligned leads reflect the same cardiac function.
- Contrastive Multi-segment Coding: CMSC forms positive pairs from adjacent, non-overlapping temporal segments of an ECG recording.
- Contrastive Multi-lead Coding: CMLC forms positive pairs from different temporally aligned lead projections of the same cardiac electrical signal.
- Contrastive Multi-segment Multi-lead Coding: CMSMLC jointly pairs non-overlapping temporal segments and different lead projections to exploit both ECG invariances.
- Patient-Specific Noise Contrastive Estimation Loss: The patient-specific loss encourages same-patient representations to be similar and representations from different patients to be dissimilar using cosine similarity and temperature scaling.Positive pairs are identified by patient IDs in a K × K similarity matrix.
5. Experimental Design
The experiments use four labelled ECG-arrhythmia datasets, patient-level splits, and self-supervised pre-training that exploits temporal and multi-lead structure. Representations are evaluated through frozen-feature linear evaluation and downstream fine-tuning against several baselines.
- Datasets: Experiments use four ECG datasets containing cardiac-arrhythmia labels, including multi-lead PhysioNet 2020 and Chapman data for pre-training.The datasets differ in patient counts, lead structure, and numbers of arrhythmia classes.
- Datasets: All datasets are split by patient ID into 60% training, 20% validation, and 20% test sets, preventing patients from appearing across splits.
- Pre-training: CMSC uses non-overlapping temporal segments, while CMLC uses multiple leads and CMSMLC combines temporal segments with multiple leads.CMSC uses K × S × 2 batches; CMLC uses K × S × L; CMSMLC uses K × 2S × L.
- Pre-training: Pre-training uses either four selected leads or all 12 leads, with equal exposure to patients and instances across methods.The four-lead configuration uses II, V2, aVL, and aVR.
- Evaluation: The downstream task is cardiac-arrhythmia classification, evaluated with frozen representations for linear evaluation and adaptable parameters for transfer capabilities.The task has applications including screening, treatment guidance, and surgical eligibility assessment.
- Baselines and perturbations: Comparisons include random, supervised, and MT-SSL initialization alongside BYOL and SimCLR, with ECG time-series perturbations tested because SimCLR depends on them.Perturbations include Gaussian noise, temporal or value flipping, and spectrogram masking; training uses τ = 0.1 for contrastive learning.
6. Experimental Results
Across linear evaluation and fine-tuning, CLOCS methods generally outperform BYOL and SimCLR, remain effective with limited labels, and produce more patient-specific representations. Results also show that performance depends on the CLOCS variant, embedding dimension, and labelled fraction.
- Linear evaluation: CMSC outperforms SimCLR across perturbation types and counts in linear evaluation on PhysioNet 2020 using four leads.The worst CMSC result, FlipY with AUC = 0.661, exceeds the best SimCLR result, Gaussian → SAt with AUC = 0.636.
- Linear evaluation: CMSC outperforms BYOL and SimCLR on Chapman and PhysioNet 2020 in linear evaluation using 50% labelled data and E = 128.On Chapman, CMSC reaches AUC = 0.896 versus SimCLR's 0.738, a 15.8% improvement.
- Transfer capabilities: Depending on the downstream dataset, CMSC or CMSMLC outperforms BYOL and SimCLR during fine-tuning at F = 0.5.For Chapman pre-training and Cardiology fine-tuning, CMSMLC reaches AUC = 0.717, a 4.1% improvement over SimCLR.
- Transfer capabilities: CMLC performs consistently worse than CMSC and CMSMLC, while CLOCS outperforms SimCLR in at least 75% of experiments on average.With all 12 leads, CMSC outperforms all other methods in at least 90% of experiments.
- Label efficiency: 25% of labelled data with CMSC initialization outperforms 100% with random initialization during fine-tuning on two datasets.The comparison is based on consistently higher validation AUC during and at the end of training.
- Embedding dimension: CMSC performance rises from AUC ≈ 0.66 to ≈ 0.69 as E increases from 32 to 128, while random initialization and SimCLR remain near ≈ 0.63 and ≈ 0.65.The reported CMSC behaviour occurs despite using F = 0.25 labelled data.
- Labelled fraction: CMSMLC outperforms its counterparts at every labelled fraction, reaching AUC = 0.732 versus SimCLR's 0.718 at F = 1 and 0.675 versus 0.652 at F = 0.25.Increasing labelled data benefits all methods, but CMSMLC retains the advantage under scarce labels.
- Patient-specific representations: CMSC yields lower intra-patient distances and greater separation from inter-patient distances than SimCLR at E = 128.The distributions are evaluated using pairwise Euclidean distances on PhysioNet 2020 representations.
7. Discussion and Future Work
CLOCS learns patient-specific representations by aligning ECG segments and leads from the same patient, and it outperforms BYOL and SimCLR across downstream evaluations. The discussion highlights patient-similarity analysis and future extensions to multimodal transfer and contrastive learning.
- Discussion: CLOCS aligns representations across temporal segments and spatial leads belonging to the same patient.The spatial views are projections of the heart’s electrical signal onto different leads.
- Discussion: CLOCS outperforms BYOL and SimCLR in both linear evaluation and fine-tuning on downstream tasks.The conclusion also holds under varied perturbations and different numbers of leads.
- Future Work: Patient-specific representations can quantify patient similarity to assist diagnosis or clarify medical conditions.The paper proposes validating these representations by comparing patients known to be similar.
- Future Work: The study transfers parameters only between tasks sharing the ECG modality, leaving cross-modal transfer as an open direction.The authors specifically propose testing whether contrastive self-supervision transfers from one modality to another.
- Future Work: Future multimodal extensions could align temporally matched ECG and PPG segments or treat oxygen saturation and respiratory rate as spatial views.The proposed scope includes cardiac ultrasound, brain MRI, ICU vitals, and other physiological modalities.
A.2.1. SELF-SUPERVISED PRE-TRAINING
The appendix specifies input and supervised-training dimensions for the self-supervised experiments. Inputs are represented as N × S × L, while multi-lead supervised sample sizes are reported using four leads.
- Input dimensions: Inputs are expressed as N × S × L, where N is the number of instances, S is frame length, and L is the number of leads.When L is omitted, reported values use four leads, the primary experimental setting.
- Input dimensions: Self-supervised input dimensions use S = 2500 samples per instance, with L denoting the number of ECG leads.Table 3 describes these dimensions for training and validation across pre-training methods.
- Supervised training: Supervised-training instance counts for multi-lead datasets are reported for four leads: II, V2, aVL, and aVR.Counts for other lead configurations can be derived using a multiplicative factor.
B. Visualization of Data Augmentations
The paper visualizes ECG augmentations including noise, temporal reversal, signal negation, and SpecAugment masking. SpecAugment operates in the STFT domain, masks selected spectral or temporal bins, and reconstructs the time-domain signal with ISTFT.
- ECG augmentations: Gaussian Noise adds ε ∼N(0, σ) while choosing σ to preserve the original frame’s class.The reported σ values are 10 for Chapman and 0.01 for PTB-XL.
- ECG augmentations: FlipY reverses the ECG signal along its temporal dimension.This perturbation is motivated by self-supervision based on reversing the arrow of time.
- ECG augmentations: FlipX negates the signal magnitude, modeling inverted signals that can result from incorrectly connected physical leads.Figure 7 contrasts the unperturbed, noisy, temporally flipped, and x-axis-flipped segments.
- SpecAugment: SpecAugment masks spectral or temporal STFT components, sets masked complex entries to zero, and applies ISTFT to recover a time-domain signal.The visualizations show spectral and temporal masks and their corresponding time-series representations.
- SpecAugment: The masking width is w = 0.2 and repetitions are R = 1, balancing shared-context preservation against an overly easy contrastive task.A width w represents the fraction of spectral or temporal bins masked.
D.1. Pre-training and Evaluating using 4 leads
Using 4 leads, CMSC generally outperformed competing self-supervised methods across linear evaluation and fine-tuning experiments on Chapman and PhysioNet 2020. Performance remained strong with only 25% of labelled training data, although results varied by method, dataset, and embedding dimension.
- Linear evaluation: At F = 0.25 and E = 128, CMSC achieved AUC = 0.895 versus 0.727 for SimCLR, a 16.8% improvement.
- Linear evaluation: CMSC consistently outperformed other pre-training methods on Chapman and PhysioNet 2020 in linear evaluation.With F = 0.25 on Chapman, CMSC achieved AUC = 0.899 versus 0.667 for SimCLR.
- Fine-tuning: CMSC remained the strongest method across both datasets in several embedding-dimension settings, while performance gaps narrowed at E = 128.At F = 0.25 on Chapman, the CMSC–SimCLR gap was 13.2% for E = 128.
- Fine-tuning: Across other evaluated configurations, the CLOCS methods outperformed SimCLR in 20/24 (83%), 21/24 (88%), and 16/24 (66%) of experiments.
E.2. Pre-training, Fine-tuning, and Evaluating using 12 Leads
When pre-training, fine-tuning, and evaluation used all 12 leads, CMSC generally outperformed SimCLR across Chapman and PhysioNet 2020. The results also indicate that enforcing similarity across many diverse leads may hurt the performance of CMLC and CMSMLC relative to CMSC.
- Interpretation: Encouraging representations from a large and diverse set of leads to be similar might be detrimental, as CMLC and CMSMLC had poorer AUC than CMSC.
- Results: CMSC outperformed SimCLR in 22/24 (92%) of fine-tuning experiments using all 12 leads.
- Results: CMSC outperformed SimCLR in 21/24 (88%) of experiments in another all-12-lead evaluation configuration.
- Results: CMSC outperformed SimCLR in 24/24 (100%) of experiments in one all-12-lead configuration.
- Results: CMSC outperformed SimCLR in 22/24 (92%) of experiments in a further all-12-lead configuration.
F. Effect of τd on BYOL Implementation
The BYOL analysis examines how the target-network averaging parameter τd affects downstream generalization, while CMSC representations are assessed for patient-specific structure. Higher embedding dimensions increase pairwise distances but preserve separation between intra- and inter-patient representations.
- BYOL implementation: BYOL uses an online network and a target network whose parameters are an exponential moving average controlled by τd.
- Patient-specific representations: At E = 32, CMSC produced intra-patient distances with a mean of around 1, and distances shifted higher as E increased to 256.
- Patient-specific representations: Distinct intra-patient and inter-patient distance distributions indicate more similar representations within patients than across patients.
- Patient-specific representations: Figure 9 compares pairwise Euclidean distances for same-patient and different-patient representations in the PhysioNet 2020 validation set.