Decoding the human sleep cycle.
ZERO HOUR is an open-source research project that asks a simple question: how does sleep actually work, and how well can we measure it, model it and explain it with the sensors we already carry?
It covers sleep detection, sleep need, sleep debt, circadian rhythm, daily energy and sleep regularity. The goal is an independent, transparent and scientifically grounded sleep intelligence engine.
Important
ZERO HOUR is a research and wellness project. It is not a medical device and does not diagnose, treat or prevent any condition.
I'm curious about how things work under the surface. When a phone says "you slept 6 h 42 min" or "your energy dips at 3 pm", I want to know where that number came from:
- What was measured, and what was assumed?
- Which model turned raw signals into a sentence about my body?
- How confident should I be in it?
- What happens when the data is missing?
Sleep is a good place to ask these questions. The science is deep and mostly public: actigraphy, the two-process model, circadian oscillators, cumulative sleep-loss studies. Yet most sleep tools give you the answer without the reasoning, and you can't inspect, test or improve them.
ZERO HOUR is my attempt to do the opposite:
- Understand the science properly, from the original papers rather than summaries.
- Rebuild it in the open as explicit, testable models instead of black boxes.
- Measure how well it works on public datasets, and say honestly where it doesn't.
- Improve on it. Combine signals better, personalise baselines, handle uncertainty, and explain every output.
I treat this as research first and software second. Every claim gets an evidence label, every constant gets a citation, and an unknown is written down as unknown.
| # | Question | Why it's interesting |
|---|---|---|
| Q1 | How accurately can sleep be detected from phone and wearable signals alone (movement, steps, screen use, charging)? | Phones are everywhere, but phone-only sleep detection has almost no open, validated code. |
| Q2 | How much sleep does this person need, and can it be estimated from their own history? | Population guidance ("7–9 h") hides large individual differences. |
| Q3 | What is a good model of sleep debt: how it builds up, how it is repaid, how far back it reaches? | Lab studies (e.g. Van Dongen 2003) show that chronic restriction accumulates, but no open implementation exists for everyday data. |
| Q4 | Can a two-process model (sleep pressure plus circadian rhythm) predict daily energy peaks and dips from sleep timing alone? | It is a classic model (Borbély 1982), and turning it into useful daily guidance is still an open design problem. |
| Q5 | How regular is someone's sleep, and does regularity matter as much as duration? | The Sleep Regularity Index (Phillips 2017) links irregular sleep to worse outcomes. |
| Q6 | How should a sleep engine express uncertainty when sensors are missing or disagree? | Most tools never say "I don't know". |
question → literature → open-source survey → model spec → implementation → validation → explanation
↑ │
└──────────────── what failed, what surprised me, what's still unknown ───┘
- Evidence labels:
CONFIRMED,OBSERVED,INFERRED,HYPOTHESISorUNKNOWN. A hypothesis is never presented as a result. - Citations or experiments: every model parameter is backed by a published source or by our own reproducible experiment.
- Public data: validation uses open datasets (e.g. the Newcastle PSG + accelerometer set, Walch et al. 2019 on PhysioNet).
- Explicit maths, not LLM guesses: language models may explain results but never produce physiological numbers.
| Phase | Scope | State |
|---|---|---|
| 0 | Environment, tooling, repository foundation | ✅ Done |
| 1–4 | Literature review, algorithm survey, open-source landscape | ✅ First survey published (see below) |
| 5 | Behavioural studies: how sleep metrics respond to controlled inputs | 🔄 In progress |
| 6 | Research synthesis | Not started |
| 7 | Engine specification and implementation | Not started |
No engine code yet. Implementation starts once the algorithm specification
and validation methodology exist (docs/algorithms/, docs/methodology/).
- Algorithm literature: Cole-Kripke, Sadeh, van Hees, the Sleep Regularity Index, two- and three-process models, Kronauer/Forger oscillators, sleep debt and sleep need, with every citation checked.
- Open-source landscape: what exists, what licence it carries, what can be reused in an Apache-2.0 project, and what is missing.
- Primers: sleep science · circadian science.
Early findings from the survey:
- Open gaps: no maintained, clearly licensed open implementation exists for phone-usage sleep detection, cumulative sleep debt, or individual sleep-need estimation. That is where ZERO HOUR aims to contribute.
- Strong foundations already exist for actigraphy (GGIR, scikit-digital-health) and circadian modelling (the
circadianpackage), so we can build on them instead of starting from zero.
| Module | Question it answers | Planned basis |
|---|---|---|
engine/sleep-detection |
When was the person asleep? | Actigraphy (Cole-Kripke, Sadeh, van Hees), phone-usage signals, wearable sessions, ML sleep/wake classifiers |
engine/sleep-need |
How much sleep does this person need? | Individual baselines from sleep history |
engine/sleep-debt |
How far behind are they? | Rolling, weighted deficit against individual need |
engine/circadian |
Where is their biological clock right now? | Two-process model (Process S / Process C), light-driven oscillator models |
engine/recovery, engine/predictions |
How will energy vary across the day? | Homeostatic plus circadian interaction |
engine/regularity |
How consistent is their schedule? | Sleep Regularity Index, timing variability |
engine/explainability |
Why did the engine say that? | Per-output provenance, inputs and confidence |
- Scientific validity: every model and constant traces to public literature or to our own documented experiments.
- Explicit, testable models: deterministic, unit-tested code for every physiological output.
- Uncertainty first: every output carries a confidence value, which degrades honestly when data is missing.
- Privacy first, local first: computation runs on-device where practical. No personal health data ever enters this repository.
- Modular and reproducible: algorithms are swappable, benchmarked and validated against public datasets.
research/ literature notes, algorithm surveys, open-source landscape
engine/ the sleep intelligence engine (per-domain modules)
integrations/ Android, Health Connect, HealthKit, wearables
experiments/ datasets (pointers only), notebooks, models, benchmarks
docs/ architecture, algorithm specs, data dictionary, methodology, ADRs
tests/ unit, integration and algorithm-validation suites
scripts/ developer tooling
Curious too? See CONTRIBUTING.md. Questions, papers I've missed and challenges to my assumptions are all welcome. Security issues: SECURITY.md.