Source-linked AI summary

SleepEEGNet: Automated Sleep Stage Scoring with Sequence to Sequence Deep Learning Approach

Sajad Mousavi, Fatemeh Afghah, U. Rajendra Acharya

arXiv:1903.02108v1eess.SPcs.LGq-bio.QM

TL;DR

Manual sleep-stage scoring is time-consuming and limited by inter-rater reliability, while deep-learning methods face class imbalance in sleep datasets. SleepEEGNet addresses these challenges with a single-channel EEG sequence-to-sequence model combining CNNs, attention, bidirectional recurrence, and class-balanced losses. Across evaluated channels, it reportedly outperformed listed algorithms, with 84.26% overall accuracy, 79.66% macro F1-score, and Cohen’s Kappa coefficient = 0.79.

  • Problem

    Manual scoring of long EEG recordings is time-consuming and depends on inter-rater agreement, while sleep datasets present class imbalance.

  • Method

    SleepEEGNet combines CNN feature extraction, bidirectional recurrent sequence modeling, attention, and losses that treat misclassified errors equally across sleep stages.

  • Results

    The model outperformed the listed state-of-the-art algorithms across Fpz-Cz and Pz-Oz channels on all evaluation metrics.

  • Takeaways & Limitations

    The model is presented as a generic approach for sequential biomedical signal problems that also have class imbalance, such as heartbeat classification for arrhythmia detection.

  • Takeaways & Limitations

    The method requires sufficient training samples, a sequence of 30-s EEG epochs at each time step, and retraining for other EEG channels.

Abstract

from arXiv · show

Electroencephalogram (EEG) is a common base signal used to monitor brain activity and diagnose sleep disorders. Manual sleep stage scoring is a time-consuming task for sleep experts and is limited by inter-rater reliability. In this paper, we propose an automatic sleep stage annotation method called SleepEEGNet using a single-channel EEG signal. The SleepEEGNet is composed of deep convolutional neural networks (CNNs) to extract time-invariant features, frequency information, and a sequence to sequence model to capture the complex and long short-term context dependencies between sleep epochs and scores. In addition, to reduce the effect of the class imbalance problem presented in the available sleep datasets, we applied novel loss functions to have an equal misclassified error for each sleep stage while training the network. We evaluated the proposed method on different single-EEG channels (i.e., Fpz-Cz and Pz-Oz EEG channels) from the Physionet Sleep-EDF datasets published in 2013 and 2018. The evaluation results demonstrate that the proposed method achieved the best annotation performance compared to current literature, with an overall accuracy of 84.26%, a macro F1-score of 79.66% and Cohen's Kappa coefficient = 0.79. Our developed model is ready to test with more sleep EEG signals and aid the sleep specialists to arrive at an accurate diagnosis. The source code is available at https://github.com/SajadMo/SleepEEGNet.

I. INTRODUCTION

Sleep stage scoring is laborious and depends on inter-rater agreement, motivating automated systems. Existing deep-learning methods still face class imbalance, while SleepEEGNet addresses these issues with sequence modeling and class-balanced losses.

  • Motivation: Manual scoring of approximately 8-hour EEG recordings is tedious and time-consuming for sleep experts.Experts label fixed-length EEG epochs according to established sleep-scoring standards.
  • Motivation: Human-based annotation relies heavily on inter-rater agreement, motivating automatic scoring with high accuracy.
  • Research gap: Deep-learning sleep-stage classifiers continue to suffer from class imbalance in available sleep datasets.The imbalance limits the use of machine-learning techniques for sleep-stage classification.
  • Contribution: SleepEEGNet combines CNN feature extraction, sequence-to-sequence modeling, and new losses that treat misclassification errors equally across sleep stages.The sequence model includes bidirectional recurrent processing and attention to use temporal context and relevant input regions.
  • Contribution: The paper evaluates automated sleep-stage scoring using single-channel EEG signals.

II. METHODOLOGY

The method preprocesses continuous single-channel EEG by dividing it into labeled 30-s epochs and normalizing each epoch. These steps are intentionally simple and omit filtering and noise removal.

  • Input preparation: The method takes a sequence of 30-s EEG epochs as input.
  • Input preparation: Continuous raw single-channel EEG is segmented into 30-s epochs, and each epoch receives a sleep-stage label from the annotation file.
  • Normalization: Each 30-s epoch is normalized to zero mean and unit variance.
  • Preprocessing scope: Preprocessing does not use filtering or noise-removal methods.

B. The architecture

The architecture combines CNNs with an encoder-decoder sequence-to-sequence model to score sleep stages from EEG epochs. CNN filters capture temporal and frequency information, while recurrent components model long- and short-term dependencies.

  • Overall architecture: The proposed model uses an RNN sequence-to-sequence architecture together with a CNN for automatic sleep-stage scoring.The sequence-to-sequence design follows encoder-decoder principles.
  • Overall architecture: Figure 1 illustrates the sequence-to-sequence deep-learning network architecture used for automated sleep-stage scoring.
  • CNN feature extraction: CNNs use small filters for temporal information and large filters for frequency information.Variable filter sizes provide a trade-off between time-domain and frequency-domain feature extraction.
  • CNN feature extraction: The CNN contains two sections, each built from four consecutive one-dimensional convolutional layers with ReLU nonlinearities.The first layer is followed by max pooling and dropout.
  • Encoder-decoder model: The encoder processes the input sequence, while the decoder computes the category of each 30-s EEG epoch.LSTM units capture complex long- and short-term context dependencies between inputs and targets.

C. Bidirectional recurrent neural network

SleepEEGNet uses bidirectional recurrent units to process sequence information in both temporal directions. This gives the current state access to previous and future inputs simultaneously.

  • Bidirectional processing: BiRNN units process sequence data in both forward and backward directions.
  • Bidirectional processing: Bidirectional processing lets the current state access previous and future input information simultaneously.This addresses the restriction of standard unidirectional RNNs to previous input states.
  • BiRNN output: The BiRNN output is computed as a weighted sum of the outputs from the two directional networks.
  • BiRNN equations: The forward and backward hidden states are computed with tanh recurrent updates using the input and direction-specific previous states.The cited equations define separate forward and backward hidden-state recurrences.
  • BiRNN illustration: Figure 3 depicts a bidirectional recurrent neural network with T time steps.

D. Attention Decoder

The attention decoder generates sleep-stage labels epoch by epoch while weighting encoder outputs to emphasize the most relevant parts of the input sequence.

  • Attention computes importance weights for encoder hidden states and combines them into a context vector.The weights are probabilities, and the weighted hidden states form the context representation.
  • At each decoding step, attention combines the encoder representation with the decoder’s hidden state to focus on important input regions.
  • During training, the decoder receives the target sequence shifted by one, beginning with <SOD> and ending at <EOD>.
  • During testing, the decoder feeds each generated label into the next decoding step and outputs class probabilities over sleep stages.

E. Loss calculation

The paper introduces multi-class MFE and MSFE losses to reduce the dominance of majority sleep stages by weighting class errors equally.

  • The proposed loss functions treat each misclassified sample equally, regardless of whether it belongs to a majority or minority class.
  • MFE and MSFE extend previously proposed mean false error losses to the multi-class sleep-stage classification task.
  • Unlike MSE, which gives majority classes greater influence in imbalanced data, MFE and MSFE consider errors from all classes equally.The class-specific error is aggregated across the available sleep-stage classes.

III. EXPERIMENTAL RESULTS

The experiments use two versions of the Physionet Sleep-EDF dataset, comprising polysomnographic sleep recordings from two study populations.

  • Sleep-EDF version 1, contributed in 2013, contains 61 polysomnograms, while version 2, contributed in 2018, contains 197.
  • The datasets include studies of age effects on sleep in healthy individuals and temazepam effects on sleep.
  • Sleep-EDF provides whole-night polysomnogram recordings sampled at 100 Hz.
  • Table I reports the number of sleep stages in each Sleep-EDF dataset version.

B. Experimental Design

The experimental design addresses class imbalance through oversampling and specialized losses, then evaluates the model with repeated fold-based training and testing.

  • The Sleep-EDF stage distribution is imbalanced, with W and N2 occurring much more often than other stages.
  • The dataset is oversampled with SMOTE to bring the numbers of sleep stages closer to balance.SMOTE generates synthetic minority samples using similarities among existing minority examples.
  • The model uses 20-fold cross-validation for Sleep-EDF version 1 and 10-fold cross-validation for version 2.
  • Training uses RMSProp with mini-batches of 20, learning rate α = 0.0001, maximum 400 epochs, and L2 regularization β = 0.001.

C. Evaluation Metrics

The evaluation uses multiple classification metrics, including macroaveraged F1-score, alongside confusion matrices and performance comparisons across EEG channels and algorithms.

  • The evaluation includes overall accuracy, precision, recall, specificity, Cohen’s Kappa coefficient, and F1-score.
  • Macroaveraged F1-score sums per-class F1-scores over the number of sleep stages.
  • Tables II and III report confusion matrices and per-class performance for Fpz-Cz and Pz-Oz EEG channels, respectively.
  • Table IV compares the proposed approach with other state-of-the-art algorithms.

D. Results and Discussion

SleepEEGNet outperformed listed state-of-the-art algorithms across both evaluated EEG channels under inter-patient evaluation, while attention maps and hypnograms provide interpretable examples of its scoring behavior. The authors also identify class imbalance and limited channel coverage as important practical considerations.

  • Per-stage performance: The model performed better on W1, N2, N3, and REM than on N1, although its N1 results exceeded those of other state-of-the-art algorithms.The authors relate the weaker N1 performance to the smaller number of N1 stages in the dataset.
  • Performance comparison: SleepEEGNet outperformed the listed state-of-the-art algorithms on both Fpz-Cz and Pz-Oz channels across all evaluation metrics under the inter-patient paradigm.The authors also evaluated Sleep-EDF 2018 without comparison because they found no comparable prior work.
  • Hypnogram comparison: Around 85% of a subject’s manually scored and automatically scored hypnograms were reported as matching over approximately 8 hours of sleep.Figure 5 compares a sleep expert’s hypnogram with the hypnogram generated by the proposed method.
  • Attention analysis: Attention maps identify which input epochs are important for scoring sleep stages, with the network using almost the exact corresponding epoch in the illustrated examples.Figure 4 shows attention maps for two EEG-epoch sequences and their corresponding sleep-stage scores.
  • Design rationale: The sequence-to-sequence design, BiRNNs, attention mechanism, and MFE/MSFE loss functions were presented as explanations for performance gains and reduced class-imbalance effects.The loss functions aim to give each sleep stage an equal misclassified-error effect during training.
  • Broader applicability: The method was described as generic for other inherently sequential biomedical problems with class imbalance, including heartbeat classification for arrhythmia detection.The authors also mention possible future extension to multimodal PSG signals including EEG, EOG, and EMG.
  • Limitations: The model requires sufficient training samples, a sequence of 30-s EEG epochs at each time step, and retraining for evaluation on other EEG channels.The reported evaluation used only Fpz-Cz and Pz-Oz channels from Physionet Sleep-EDF datasets.

IV. CONCLUSION

The paper presents SleepEEGNet as an automated sleep-stage annotation algorithm combining convolutional, recurrent, attention, and class-imbalance-aware components. It reports the highest sleep-stage scoring performance among the compared algorithms and suggests applications to other biomedical signals.

  • Method: SleepEEGNet combines deep CNNs with an encoder-decoder network using bidirectional recurrent neural networks and attention mechanisms for automated sleep-stage annotation.The architecture is designed to score sleep stages from EEG signals.
  • Contribution: The new loss calculation approaches reduce class-imbalance effects and boost performance, especially for the more difficult N1 sleep stage.The conclusion connects the loss design with improved handling of imbalanced sleep-stage data.
  • Results: SleepEEGNet yielded the highest performance for the sleep-stage scoring task among the existing algorithms presented in Table IV.The authors describe the proposed model as significantly outperforming the compared algorithms.
  • Applications: The model can be applied to biomedical applications such as arrhythmia detection using ECG, epilepsy detection using EEG and EMG, and posture analysis using EMG.These applications are presented as examples of biomedical problems involving imbalanced data.
Loading 1903.02108v1…