Sleep data scoring is a crucial and primary step for diagnosing sleep disorders to know the sleep stages from the PSG signals. This study uses supervised contrastive learning with a self-attention mechanism to classify sleep stages. We propose a deep learning framework for automatic sleep stage classification, which involves two training phases: (1) the feature representation learning phase, in which the feature representation network (encoder) learns to extract features from the electroencephalogram (EEG) signals, and (2) the classification network training phase, where a pre-trained encoder (trained during phase I) along with the classifier head is fine-tuned for the classification task. The PSG data shows a non-uniform distribution of sleep stages, with wake (W) (around 30% of total samples) and N2 stages (around 58% and 37% of total samples in Physionet EDF-Sleep 2013 and 2018 datasets, respectively) being more prevalent, leading to an imbalanced dataset. The imbalanced data issue is addressed using a weighted softmax cross-entropy loss function that assigns higher weights to minority sleep stages. Additionally, an oversampling technique (the synthetic minority oversampling technique (SMOTE) (Chawla et al., 2002)[1] ) is applied to generate synthetic samples for minority classes. The proposed model is evaluated on the Physionet EDF-Sleep 2013 and 2018 datasets using Fpz-Cz and Pz-Oz EEG channels. It achieved an overall accuracy of 94.1%, a macro F1 score of 92.64, and a Cohen’s Kappa coefficient of 0.92. Ablation studies demonstrated the importance of triplet loss-based pre-training and oversampling for enhancing performance. The proposed model requires minimal pre-processing, eliminating the need for extensive signal processing expertise, and thus is well-suited for clinicians diagnosing sleep disorders.
Read full abstract