Abstract
The rise of multisensor wearable devices offers a unique opportunity for the objective inference of sleep outside laboratories, enabling longitudinal monitoring in large populations. To enhance objectivity and facilitate cross-cohort comparisons, sleep detection algorithms in free-living conditions should rely on personalized but device-agnostic features, which can be applied without laborious human annotations or sleep diaries. We developed and tested a heart rate-based algorithm that captures inter- and intra-individual sleep differences, does not require human input and can be applied in free-living conditions. The algorithm was evaluated across four study cohorts using different research- and consumer-grade devices for over 2,000 nights. Against sleep diaries, the algorithm yielded a mean squared error (MSE) of 0.04 to 0.06 and a total sleep time deviation of -2.70 (± 5.74) and 12.80 (± 3.89) minutes. Our findings suggest that the heart rate-based algorithm can reliably and objectively infer sleep under longitudinal, free-living conditions, independent of the wearable device used.
Introduction
While wearables have made sleep tracking ubiquitous, most research-grade and consumer algorithms face a major scalability hurdle: they often require "ground truth" labels from sleep diaries or manual annotations to be accurate. Furthermore, many existing models are trained on "monophasic" sleepers and fail to account for shift workers or daytime naps.
Polysomnography (PSG), the gold standard for sleep measurement, is expensive and limited to lab settings. Actigraphy (accelerometer-based tracking) is the common alternative, but it struggles to distinguish between quiet wakefulness and actual sleep without diary input. This paper proposes a "hands-off" approach that works across different hardware and diverse lifestyles without requiring user logging.
Methodology
The core of the proposed method is the Empirical Cumulative Distribution Function (ECDF) of an individual’s heart rate (HR). The pipeline consists of three primary stages:
- Personalized Thresholding: Instead of using a fixed HR value, the algorithm calculates a daily HR profile for each user. It identifies sleep by looking for periods where the HR drops below a specific quantile (optimized at 0.35 for free-living data), allowing the model to adjust for differences in fitness, age, or illness.
- Refinement via Volatility: To sharpen the detection of sleep onset and offset, the algorithm uses HR volatility (a rolling 10-minute standard deviation). Since HR becomes significantly more stable during sleep, high volatility periods near the edges of the detected window are used to "trim" the sleep block.
- Smoothing and Labelling: A 5-minute rolling median filter is applied to remove short-term noise and transients before final sleep window labelling.
Experimental Setup
The authors validated their approach across four diverse cohorts, totaling over 2,000 nights of data:
- UK Biobank Validation Study (BBVS): 158 participants in free-living conditions using multiple sensors.
- MESA (Multi-Ethnic Study of Atherosclerosis): 1,154 participants using lab-based PSG and wrist actigraphy.
- PhysioNet Apple Watch Study: 22 participants wearing a consumer-grade Apple Watch concurrently with PSG.
- MMASH: 20 participants using HR straps and accelerometers in free-living conditions.
Results
The HR-based algorithm consistently outperformed traditional accelerometry-based "angle change" algorithms in free-living environments.
- Accuracy in the Wild: In the BBVS study, the algorithm showed a Total Sleep Time (TST) deviation of only -0.60 minutes compared to sleep diaries, with an MSE of 0.06.
- Comparison to PSG: In lab studies (MESA), the HR approach yielded an MSE of 0.10 and a TST deviation of -33.15 minutes. Notably, it outperformed sleep diaries themselves, which tended to underestimate sleep offset by nearly 30 minutes.
- Consumer Hardware Viability: On Apple Watch data, the algorithm achieved an MSE of 0.06, proving its effectiveness for consumer-grade PPG (photoplethysmography) sensors.
Discussion and Conclusion
A key insight of this work is that sleep is better defined by a drop in HR relative to one's own daily range rather than an absolute threshold. This makes the algorithm inherently device-agnostic. Furthermore, by combining the ECDF threshold with HR volatility, the algorithm successfully separates sedentary wakefulness from actual sleep—a classic failure point for movement-only sensors.
While the algorithm performs best with a full 24-hour heart rate trace, its ability to infer sleep without actigraphy or diary annotations represents a significant step forward for longitudinal population studies. The implementation is available as an open-source Python package to encourage further research integration.
Summary updated