Abstract
Classification of sleep stages is essential for assessing sleep quality and diagnosing sleep disorders. However, manual inspection of EEG characteristics for each stage is time-consuming and prone to human error. Although machine learning and deep learning methods have been actively developed, they continue to face challenges arising from the non-stationarity and variability of electroencephalography (EEG) and electrooculography (EOG) signals across diverse clinical configurations, often resulting in poor generalization. In this work, we propose SleepDIFFormer, a multi-channel differential transformer framework for heterogeneous EEG-EOG representation learning. SleepDIFFormer is trained across multiple sleep staging datasets, each treated as a source domain, with the goal of generalizing to unseen target domains. Specifically, it employs a Multi-channel Differential Transformer Architecture (MDTA) designed to process raw EEG and EOG signals while incorporating cross-domain alignment. Our approach mitigates spatial and temporal attention noise and learns a domain-invariant EEG-EOG representation through feature distribution alignment across datasets, thereby enhancing generalization to new domains. Empirically, we evaluated SleepDIFFormer on five diverse sleep staging datasets under domain generalization settings and benchmarked it against existing approaches, achieving state-of-the-art performance.
Introduction
Manual sleep scoring—the process of categorizing sleep into stages like REM or Deep Sleep (N3)—is the "gold standard" for diagnosing sleep disorders, but it is incredibly labor-intensive and prone to human error. While many AI models have been developed to automate this, they face a major hurdle: Domain Shift. EEG (brain) and EOG (eye) signals vary significantly depending on the hospital, specific hardware, electrode placement, and patient population. A model trained on one dataset often performs poorly on another. This paper addresses the challenge of Domain Generalization: creating a model that can be trained on multiple "source" datasets and perform reliably on a completely unseen "target" dataset.
Proposed Methodology
The authors introduce SleepDIFFormer, which leverages a novel architecture to act as "noise-canceling headphones" for complex biosignals. The framework consists of three main stages:
- Signal Embedding: A hierarchical convolutional module transforms raw, noisy 1D signals into a sequence of "tokens" for transformer processing.
- Multi-channel Differential Transformer Architecture (MDTA): Unlike standard Transformers using Multi-Head Self-Attention (MHSA), MDTA uses Differential Attention (DA). It calculates two separate attention maps and subtracts one from the other, canceling out common noise and amplifying salient features like sleep spindles or delta waves. This includes Differential Self-Attention (DSA) for individual channels and Differential Cross-Attention (DCA) to fuse EEG and EOG information.
- Domain Alignment: To ensure universal learning across hospitals, a multi-level alignment loss forces the model to match statistical properties (mean, covariance, and correlation) across all training datasets.
Experimental Results
The researchers evaluated SleepDIFFormer on five diverse, publicly available sleep datasets: SleepEDFx, HMC, ISRUC, SHHS-1, and P2018. The model was tested using a "leave-one-dataset-out" approach to strictly measure its ability to generalize to new domains.
SleepDIFFormer achieved state-of-the-art (SOTA) results in domain generalization, outperforming existing methods across nearly all metrics. As shown in the performance table, the model achieved an average accuracy of 76.32% and a Macro-F1 score of 71.83%, a significant improvement over previous leaders like SleepDG.
The model demonstrated particular robustness on the ISRUC dataset, which is notoriously difficult due to its unique electrode setup. Visualizing the attention weights confirmed that the model focuses on clinically relevant markers, such as 12–16 Hz spindles during Stage N2 and high-amplitude delta waves during Stage N3.
Conclusion
SleepDIFFormer advances automated sleep staging by effectively mitigating noise and domain shift. By mimicking human expert analysis through inter-channel synergy and focusing on salient biological markers via differential attention, it provides a robust solution for diverse clinical settings. Future work may involve incorporating additional modalities like Electromyography (EMG) and scaling the architecture toward a general-purpose EEG foundation model.
Summary updated