Subject-Aware Contrastive Learning for Biosignals

Joseph Y. Cheng, Hanlin Goh, Kaan Dogrusoz, Oncel Tuzel, Erdrin AzemiarXiv 2020

Abstract: Datasets for biosignals, such as electroencephalogram (EEG) and electrocardiogram (ECG), often have noisy labels and have limited number of subjects (<100). To handle these challenges, we propose a self-supervised approach based on contrastive learning to model biosignals with a reduced reliance on labeled data and with fewer subjects. In this regime of limited labels and subjects, intersubject variability negatively impacts model performance. Thus, we introduce subject-aware learning through (1) a subject-specific contrastive loss, and (2) an adversarial training to promote subject-invariance during the self-supervised learning. We also develop a number of time-series data augmentation techniques to be used with the contrastive loss for biosignals. Our method is evaluated on publicly available datasets of two different biosignals with different tasks: EEG decoding and ECG anomaly detection. The embeddings learned using self-supervision yield competitive classification results compared to entirely supervised methods. We show that subject-invariance improves representation quality for these tasks, and observe that subject-specific loss increases performance when fine-tuning with supervised labels.

Introduction

Machine learning for healthcare relies heavily on continuous time-series biosignals, such as brainwaves (EEG) or heart activity (ECG). However, labeling these high-dimensional signals is notoriously labor-intensive, requiring medical experts and remaining prone to human bias. While self-supervised learning (SSL) has revolutionized fields like computer vision and natural language processing by learning representations from unlabeled data, its application to biosignals is complicated by massive intersubject variability.

In typical biosignal datasets, which often feature fewer than 100 subjects, a signal from Patient A can look fundamentally different from Patient B even during the same physiological state. Standard SSL frameworks often inadvertently learn to identify the subject rather than the underlying physiological condition. This paper addresses these challenges by adapting contrastive SSL for biosignals through domain-specific data augmentations and "subject-aware" training techniques.

Methodology

The authors build on a standard momentum contrastive learning framework using the InfoNCE loss to maximize mutual information between two augmented views of the same data window. The core innovation lies in controlling how the model handles subject-specific information.

Subject-Aware Learning Framework

Because the "subject ID" is a free label available in most datasets, it can be used to guide the encoder's learning process. The proposed framework introduces two primary strategies:

  • Subject-Invariant SSL: This approach utilizes adversarial training. A secondary classifier ($C_{sub}$) attempts to predict the subject ID from the learned embedding $h$. The main encoder $G$ is penalized if this classifier succeeds, forcing it to discard subject-specific quirks and learn features that generalize across the population.
  • Subject-Specific SSL: This method modifies the contrastive loss so that negative samples are drawn exclusively from the same subject. This forces the model to focus on temporal changes and physiological states within a single individual rather than learning the differences between people.
Overview of the subject-aware self-supervised training pipeline and downstream task evaluation.

Biosignal-Specific Data Augmentations

Standard image augmentations do not translate directly to time-series data. The authors designed and evaluated several transformations, including temporal delay, bandstop filtering, signal mixing, and spatial shifts.

Visualizations of the proposed time-series data augmentations for biosignals.

Through empirical testing, temporal consistency emerged as the strongest signal. The most effective augmentation was temporal cutout, which involves replacing a random contiguous chunk of the time-series with zeros or noise. Forcing the model to recognize a physiological state despite missing or shifted temporal segments proved highly effective for capturing the non-stationary semantics of biosignals.

Experiments and Results

The methods were evaluated on two benchmark datasets: the PhysioNet Motor Imagery Dataset (EEG) for decoding imagined movements, and the MIT-BIH Arrhythmia Database (ECG) for detecting cardiac anomalies.

Key Findings

  • Augmentation Impact: On the EEG dataset, applying temporal cutout during SSL boosted downstream 4-class accuracy by +10.9% compared to SSL without augmentations.
  • Label and Subject Efficiency: SSL acts as a powerful regularizer. A linear classifier trained on top of a subject-invariant SSL model using data from just 4 subjects matched the performance of a fully supervised end-to-end model trained on 16 subjects.
  • Task-Specific Variability: The optimal strategy depends on the task. For EEG motor imagery, stripping away subject information (Subject-Invariant SSL) yielded the best generalization. Conversely, for ECG anomaly detection, where certain subject-specific traits correlate with cardiac conditions, keeping some subject information (Subject-Specific SSL) performed better.

Discussion and Future Work

The results demonstrate that SSL can match or exceed fully supervised methods while requiring significantly less labeled data. Fine-tuning a model initialized with Subject-Specific SSL achieved 53.9% accuracy on the 4-class EEG task, outperforming the supervised baseline of 50.6%. In ECG anomaly detection, the method matched or exceeded previous benchmarks, particularly in identifying rare ectopic beats.

A limitation of the adversarial approach is the need for careful tuning of the hyperparameter $\lambda$, which controls the strength of the subject penalty. Future work will explore expanding this framework to other modalities like EOG (eye movement) and EMG (muscle activity), potentially moving toward multimodal self-supervised learning to automatically extract features from raw clinical data at scale.

Summary updated

BibTeX
@misc{cheng2020subject,
  author = {Joseph Y. Cheng and Hanlin Goh and Kaan Dogrusoz and Oncel Tuzel and Erdrin Azemi},
  title = {{Subject-Aware Contrastive Learning for Biosignals}},
  year = {2020},
  eprint = {2007.04871},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2007.04871},
}
Figure