XSleepFormer: A Compact CNN-Transformer for EEG Sleep Stage Classification with Cross-Subject and Cross-Age Generalization
摘要
Accurate EEG-based sleep stage classification is crucial for diagnosing sleep disorders; however, manual annotation remains time-consuming and subjective. Recent deep learning models have improved performance, but key challenges persist, particularly in modeling long-range temporal dependencies, handling class imbalance, and ensuring generalization across subjects and age groups. This work addresses these limitations by introducing XSleepFormer, a hybrid deep learning architecture designed for generalizable sleep staging. It combines a CNN-based embedding generator for efficient temporal compression with a Transformer encoder for capturing long-range dependencies. To enhance minority class performance and resilience to distributional shifts, the model integrates Focal Loss, MixUp augmentation, and Virtual Adversarial Training (VAT). XSleepFormer is evaluated on the Sleep-EDF dataset across three realistic scenarios: within-subject, cross-subject, and cross-age generalization. XSleepFormer achieves 83.11% accuracy (AUC = 0.966) in within-subject, 84.58% (AUC = 0.975) in cross-subject, and maintains >83.7% accuracy in elderly cohorts aged 65–80 and 80+. Compared to SOTA SleepStagerBlanco and SleepStagerChambon, XSleepFormer demonstrates consistent gains across all metrics, confirming its suitability for real-world clinical deployment.