Accurate identification of sleep stages is essential for understanding sleep physiology and its role in neurological and behavioral research. Manual scoring of polysomnographic data, while reliable, is time-intensive and prone to variability. This study presents a novel Python-based algorithm for automated vigilance state scoring using single-channel electroencephalogram (EEG) recordings from rats and mice. The algorithm employs artifact processing, multi-band frequency analysis, and Gaussian mixture model (GMM)-based clustering to classify wakefulness, non-rapid, and rapid eye movement sleep (NREM and REM sleep, respectively). Combining narrow and broad frequency bands across the delta, theta, and sigma ranges, it uses a majority voting system to enhance accuracy, with tailored preprocessing and voting criteria improving REM detection. Validation on datasets from 10 rats and 10 mice under standard conditions showed sleep–wake state detection accuracies of 92% and 93%, respectively, closely matching manual scoring and comparable to existing methods. REM sleep detection accuracies of 89% (mice) and 91% (rats) align with previously reported (85–90%). Processing a full day of EEG data within several minutes, the algorithm is advantageous for large-scale and longitudinal studies. Its open-source design, flexibility, and scalability make it a robust, efficient tool for automated rodent sleep scoring, advancing research in standard experimental conditions, including aging and sleep deprivation.
Aging disrupts sleep, but how these changes are structured across circadian time, vigilance states, and sex remains poorly understood, because most prior studies used single-sex cohorts and few days of recordings. We continuously recorded 14 days of EEG/EMG in 24 C57BL/6J mice using a balanced 2 × 2 design (young vs. old; male vs. female; n = 6/group). A comprehensive multiscale analysis of the extended dataset enabled detailed reconstruction of 24 h sleep–wake architecture, better characterization of natural day-to-day variability including across multiple estrous cycles, and detection of rare bouts and transition events. Across seven levels of analysis, from circadian profiles to EEG spectral parameterization, the strongest aging effect was a dark-phase-specific 17–18% loss of theta-dominant active wake (TDW) in both sexes, with reciprocal increases in quiet wake (nTDW) and NREM sleep. We also identified a recurring N-shaped structural motif at the dark-to-light transition, where age-related and several sex-associated differences were most apparent. Broadly, old mice exhibited (i) shorter TDW bouts; (ii) a shift in NREM exit kinetics toward wakefulness; (iii) more brief and poorly consolidated “out-block” NREM episodes; and (iv) a slowing of waking theta and higher low-frequency TDW power. Variance decomposition indicated that statistical power depends more on sample size than on recording length. Together, aging reflects a coordinated, circadian-phase-specific reorganization of sleep–wake architecture. Sex-related and interaction findings should be interpreted as hypothesis-generating pending larger cohorts.