bioRxivBioengineeringPreprint
Postprocessing-Enhanced Machine Learning for Reliable Real-Time Sleep Staging in Closed-Loop Neuromodulation
Tony Sungjin Chae, Jinmo JeongiD, Kai Wing Kevin TangiD, William D. Moscoso-BarreraiD, Benjamin BairdiD, Xue-Xin WeiiD, José del R. MillániD, Huiliang WangiD
Abstract
Real-time sleep stage classification is important for closed-loop neuromodulation at certain stages during sleep, yet current models often yield noisy and unstable outputs that risk false triggers. These fluctuations, especially near stage boundaries, can compromise the safety and reliability of stimulation. Existing methods frequently rely on model-specific architectures or require extensive tuning to maximize precision, which limits their generalizability and hinders deployment in real-time systems. To address this, we propose a lightweight, classifier-independent post-processing pipeline that stabilizes predictions without modifying the underlying classifier. Our method first applies temporal smoothing to predicted sleep-stage probabilities, followed by conservative control logic to enhance stimulation precision. We evaluate four smoothing techniques: Moving Average (MA), Exponential Smoothing (ES), Kalman Filtering (KF), and a novel Weighted Exponential Smoothing (WES), on a 29-subject open-source sleep dataset. To capture the trade-offs between stability and responsiveness, we introduce new real-time evaluation metrics. We identify an optimal smoothing intensity range and assess three control strategies: probability thresholding, naive waiting, and entropy constraint, as well as a hybrid method combining high confidence and low uncertainty. Smoothing improves generalization and robustness: under both low and high synthetic noise ({sigma} > 0.2), smoothed outputs retain 10-15% higher precision and recall across all stages. Control logic further enhances reliability: our hybrid method achieves 80% (Wake), 96% (N2), 98% (N3), and 86% (REM) precision. Finally, we introduce a stage-transition constraint matrix to suppress biologically implausible transitions (e.g., REM[->] N3), to further stabilize outputs during evidence accumulation, with potential applications in objective sleep quality assessment. To our knowledge, this is the first study to systematically characterize real-time trade-offs between smoothing, latency, and control logic in sleep staging. Overall, our generalizable framework is expected to improve safety, interpretability, and deployment feasibility of real-time sleep classification for both clinical and wearable closed-loop neuromodulation systems.
- Citations
- 1
Reproducibility ledger
Nobody has reported trying to reproduce this paper yet. Did you replicate an experiment or run the code? Your report saves the next lab a week.
Sign in to file a reproducibility report.
Related papers
- Real-time detection of N2 and N3 sleep from scalp and intracranial EEG
Mahmoud Alipour, Wim van Drongelen, … David Satzer·bioRxiv·Nov 6, 2026
- TRUSTWORTHY SLEEP STAGING FROM EEG: DEEP ENSEMBLES, MCDROPOUT, AND PREDICTIVE CALIBRATION
Samiksha BC, Dana Vrajitoru·bioRxiv·Aug 23, 2025
- An accessible and versatile deep learning-based sleep stage classifier
Jevri Hanna, Agnes Flöel·Frontiers in NeuroinformaticsPeer-reviewed·Mar 1, 2023
- Automatic sleep staging by a hybrid model based on deep 1D-ResNet-SE and LSTM with single-channel raw EEG signals
Weiming Li, Junhui Gao·PeerJ Computer SciencePeer-reviewed·Sep 26, 2023
- Pupil dynamics-derived sleep stage classification of a head-fixed mouse using a recurrent neural network
Goh Kobayashi, Kenji F. Tanaka, Norio Takata·The Keio Journal of MedicinePeer-reviewed·Jan 1, 2023
- Automatic Wake-Sleep Stages Classification using Electroencephalogram Instantaneous Frequency and Envelope Tracking
M. Rahbar Alam, R. Sameni·bioRxiv·May 13, 2020