Self-supervised Contrastive Learning for EEG-based Sleep Staging

Xue Jiang, Jianhui Zhao, Bo Du, Zhiyong YuanIJCNN 2021

Introduction

Electroencephalography (EEG) is a cornerstone of clinical neurology, used extensively for sleep monitoring, epilepsy diagnosis, and brain-computer interfaces. However, the utility of deep learning in this domain is often hampered by a "labeling bottleneck." Annotating EEG data is an arduous task; a trained expert typically requires five hours of concentrated work to label just 24 hours of sleep recordings. Consequently, many deep learning models are constrained by the limited availability of high-quality annotated datasets.

To address this, this research introduces a self-supervised contrastive learning framework. By leveraging vast amounts of unlabeled clinical EEG data, the model learns robust, generalizable features of brain activity before any human-provided labels are introduced.

Methodology: Contrastive Learning for EEG

The core of the approach is a contrastive learning paradigm, similar to the SimCLR framework used in computer vision. The model is trained to recognize an original EEG signal across different transformed "views."

Transformations and Pretext Task

For each sample, two random transformations are applied to create a "positive pair." The model's objective is to maximize the similarity between these two views in a high-dimensional feature space while distinguishing them from other signals in the batch ("negative pairs"). The authors explored several EEG-specific augmentations, including:

  • Permutation: Shuffling the temporal order of signal segments.
  • Crop & Resize: Randomly cropping segments and resizing them to the original length.
  • Gaussian Noise and Time Warping: Adding stochastic variations to the signal.

Model Architecture

The "backbone" of the system is a deep 1D Convolutional Neural Network (CNN) consisting of 18 layers. This backbone extracts high-dimensional features from the raw input. During the self-supervised pre-training phase, a contrastive loss (NT-Xent) is used to optimize the network.

The proposed SSL framework showing the pre-training phase and subsequent downstream evaluation strategies (Frozen Backbone and Fine Tuning).

Following pre-training, the backbone can be evaluated in two ways: by freezing the weights to assess feature quality or by fine-tuning on a small labeled dataset for the final 5-stage sleep classification task (Wake, REM, N1, N2, and N3).

Datasets

The study utilized four public datasets to validate the framework:

  • Sleep-edf & Sleep-edfx: Standard benchmarks containing recordings from healthy subjects and those with mild sleep difficulties.
  • DOD-H & DOD-O (Dreem Open Datasets): Recordings from healthy sleepers and patients with obstructive sleep apnea, used primarily as additional unlabeled data to enhance the pre-training phase.

Key Insights and Results

The research yielded several critical findings regarding the efficacy of self-supervision in medical time-series data.

Transformation Composition

The choice of augmentations is vital. The authors found that the combination of Permutation and Crop & Resize proved most effective. This suggests that the model benefits from learning features that are invariant to local temporal shifts and scaling.

State-of-the-Art Performance

On the Sleep-edf dataset, the SSL-based method achieved an accuracy of 88.16% and an F1 score of 81.96%, outperforming established fully supervised models such as DeepSleepNet and U-Time.

Label Efficiency

One of the most significant advantages of this framework is its data efficiency. In limited-label experiments, the SSL pre-trained model achieved 66.21% accuracy with only 10 labeled samples per class. In contrast, a standard supervised model required 100 samples per class to reach the same performance level—a 10-fold improvement in data efficiency.

Comparison of classification accuracy between random initialization and SSL fine-tuning across varying numbers of labeled samples per class.

Discussion and Future Work

While the framework shows immense promise, challenges remain. t-SNE visualizations indicate that the model still struggles to distinguish between N1 (light sleep) and REM stages, likely due to their similar frequency-domain characteristics. Additionally, contrastive learning requires significant computational resources during the pre-training phase due to the need for large batch sizes.

Future work will focus on extending this framework to other physiological signals, such as ECG or EMG, and developing multi-task models capable of integrating diverse medical datasets with minimal labeling overhead.

Summary updated

BibTeX
@inproceedings{jiang2021self,
  author = {Xue Jiang and Jianhui Zhao and Bo Du and Zhiyong Yuan},
  title = {{Self-supervised Contrastive Learning for EEG-based Sleep Staging}},
  booktitle = {IJCNN},
  year = {2021},
  doi = {10.1109/ijcnn52387.2021.9533305},
}
Figure