Abstract
Abstract
Sleep is a key factor in almost every physiological process, yet scoring tools lag behind innovations in basic to clinical research. New automated algorithms are trained on narrow datasets, typically healthy adult mouse or human, and fail to generalise, leaving labs to fall back on slow, laborious, and often poorly reproducible manual scoring. Here we introduce Nyx, an unsupervised framework built on principal component analysis that flexibly clusters epochs into sleep states, akin to how spike-sorting algorithms cluster single-neuron activity. Validated on about 8,000 hours spanning 19 independent datasets, it generalises across species, lifespan, recording modalities, and altered sleep architectures, matching human inter-scorer agreement. Beyond this, Nyx opens new ground for modern sleep research: classifying NREM subtypes in rodents, revealing states that cut across canonical boundaries in non-mammalian species, and enabling real-time, closed-loop manipulation. Distributed as an open-source package with a graphical user interface, Nyx offers an accessible, explainable framework built to scale with the pace of innovation itself.