A real-time sleep scoring framework for closed-loop sleep manipulation in mice

Dillon Huffman, Asma'a Ajwad, Farid Yaghouby, Bruce F. O’Hara, Sridhar Sunderam

Research output: Contribution to journalArticlepeer-review

1 Scopus citations


Subtle changes in sleep architecture can accompany and be symptomatic of many diseases or disorders. In order to probe and understand the complex interactions between sleep and health, the ability to model, track, and modulate sleep in preclinical animal models is vital. While various methods have been described for scoring experimental sleep recordings, few are designed to work in real time – a prerequisite for closed-loop sleep manipulation. In the present study, we have developed algorithms and software to classify sleep in real time and validated it on C57BL/6 mice (n = 8). Hidden Markov models of baseline sleep dynamics were fitted using an unsupervised algorithm to electroencephalogram (EEG) and electromyogram (EMG) data for each mouse, and were able to classify sleep in a manner highly concordant with manual scoring (Cohen’s Kappa >75%) up to 3 weeks after model construction. This approach produced reasonably accurate estimates of common sleep metrics (proportion, mean duration, and number of bouts). After construction, the models were used to track sleep in real time and accomplish selective rapid eye movement (REM) sleep restriction by triggering non-invasive somatosensory stimulation. During REM restriction trials, REM bout duration was significantly reduced, and the classifier continued to perform satisfactorily despite the disrupted sleep patterns. The software can easily be tailored for use with other commercial or customised methods of sleep disruption (e.g. stir bar, optogenetic stimulation, etc.) and could serve as a robust platform to facilitate closed-loop experimentation. The source code and documentation are freely available upon request from the authors.

Original languageEnglish
Article numbere13262
JournalJournal of Sleep Research
Issue number4
StatePublished - Aug 2021

Bibliographical note

Funding Information:
This work was supported by National Institutes of Health grant NS083218. The authors would like to thank Kevin Dohonue, PhD, Anuj Agarwal, PhD, and Michael Lhamon, PhD of Signal Solutions, LLC, for their support with the MouseQwake sensory stimulation system used in this study, and Robert Schor, PhD, University of Rochester, for his advice on LabVIEW programming.

Publisher Copyright:
© 2021 European Sleep Research Society


  • automated sleep scoring
  • closed loop
  • hidden Markov models
  • machine learning
  • open source
  • sleep restriction

ASJC Scopus subject areas

  • Cognitive Neuroscience
  • Behavioral Neuroscience


Dive into the research topics of 'A real-time sleep scoring framework for closed-loop sleep manipulation in mice'. Together they form a unique fingerprint.

Cite this