Introduction
Sleep scoring is the fundamental process of categorizing sleep into distinct stages—such as Rapid Eye Movement (REM) and non-REM stages (N1, N2, N3)—to diagnose sleep disorders. Traditionally, this task requires sleep experts to manually review hours of Polysomnography (PSG) data, a process that is both labor-intensive and prone to inter-scorer variability. While automated deep learning models have shown promise, they often suffer from the "black box" problem, where their decision-making processes are opaque to clinicians. Furthermore, identifying the N1 transition stage remains a significant challenge due to its infrequent occurrence in training data.
SleepXAI addresses these hurdles by introducing a unified deep learning framework that achieves state-of-the-art accuracy using a single-channel EEG signal while providing physiological explanations for its classifications.
Methodology
The SleepXAI architecture consists of three integrated components designed to mimic the expertise of human scorers:
- Sleep Encoder (1D-CNN): A one-dimensional Convolutional Neural Network acts as a feature extractor, processing 30-second epochs of raw univariate EEG signals to identify both low-level and high-level temporal patterns.
- Sleep Labeler (CRF): To capture the sequential nature of sleep, a Conditional Random Field (CRF) layer is employed. Unlike standard classifiers that treat epochs in isolation, the CRF learns the "grammar" of sleep transitions, significantly improving the identification of rare stages like N1 by leveraging temporal context.
- Explainability (Modified Grad-CAM): The framework adapts Gradient-weighted Class Activation Mapping (Grad-CAM) for 1D time-series data. This allows the model to generate heatmaps over raw EEG signals, highlighting the specific features that influenced its prediction.
The model was rigorously evaluated using the Sleep-EDF (2013) dataset, focusing on the Fpz-Cz and Pz-Oz EEG channels.
Results and Discussion
SleepXAI achieved a top-tier overall accuracy of 86.8% on the Fpz-Cz channel. Notably, it outperformed existing state-of-the-art models in N1 stage classification by 16.3%, demonstrating the efficacy of the CRF layer in handling class imbalance through temporal modeling.
A critical finding was the alignment between the model’s internal logic and established clinical guidelines. As shown in the figure above, different sleep stages are characterized by distinct waveforms. When SleepXAI predicted the N2 stage, the modified Grad-CAM heatmaps consistently highlighted physiological markers such as sleep spindles and K-complexes—the same features required by the American Academy of Sleep Medicine (AASM) manual for manual scoring. This transparency transforms the model from a "black box" into a collaborative tool that clinicians can validate visually.
The model performed better on the frontal Fpz-Cz channel compared to the Pz-Oz channel. This is consistent with sleep physiology, as many defining markers, including delta waves and K-complexes, are most prominent in the frontal regions of the brain.
Conclusion
SleepXAI represents a significant advancement in automated sleep scoring by combining high-performance classification with clinical interpretability. By identifying the specific brainwave patterns driving its decisions, the model fosters the trust necessary for clinical adoption. Future research will focus on expanding the framework to include multi-modal PSG signals (e.g., EOG and EMG) and validating the model on more diverse, global datasets to ensure generalizability across different populations and health conditions.
Summary updated