PpgDex (raw PPG) · ECGDex (raw ECG) · OxyDex (oximetry) nodes, Tepna physiological-signal suite
Background. A companion simulation paper (rmssd-equivalence) showed, on synthetic ground truth, that ECG- and RR-derived rMSSD are interchangeable while the optical arm is unbiased-but-noisier. Its stated next step was a real simultaneous ECG + PPG comparison. Data. One subject wore a Polar H10 chest ECG and a Polar Verity Sense wrist PPG together across four overnight sessions (~5.5–7.2 h each; 16–21 k beats/night), with a Wellue O2Ring finger oximeter as a third corner on the deepest night. Every metric is derived from raw signal by the production detectors (ECGDSP Pan–Tompkins QRS; PPGDSP 3-LED consensus optical beats), aligned by the suite's floating wall-clock. Results. The pipeline's own quality gate — computed with no reference — split the four nights cleanly into two it trusted and two it flagged. On the two trusted nights, optical HRV matched chest ECG almost exactly: beat-to-beat rMSSD bias −0.2 ms (−0.6%), beat counts within 0.05% (10 beats in 20,671), SD1 within 1.9%. Whole-record SDNN ran +46% high, an SDANN/baseline-wander inflation reduced to +2.3% by a quality-gated per-5-min median (sdnnRobust); SD2 +54%→+4.1% and band power +89%→+6.9% by the same mechanism. On the two flagged nights (analyzable 56–57%, correction 36–42%), whole-record optical rMSSD was uninterpretable (137 / 144 ms vs an ECG truth of 36–37 ms) — and the gate flagged exactly those nights, with no ECG consulted. Conclusion. On real overnight data, engineered optical HRV is ECG-grade for beat-to-beat metrics when the pipeline says it is trustworthy; long-term dispersion is inflated but correctable by segment-wise aggregation; and the residual, genuinely-limited bands (VLF, motion-driven HF) are best carried as a graded per-metric confidence rather than a blanket flag. This is a single-subject real-data pilot, not a population accuracy rating.
Keywords: heart-rate variability · rMSSD · SDNN · photoplethysmography · chest ECG · method comparison · Bland–Altman · pulse-transit-time · SDANN · signal-quality gating · graded confidence · consumer wearables
Wrist and finger sensors read your pulse with light; a chest strap reads the heart's electrical signal directly and is the trusted “truth.” We wore both to bed for several nights and asked: does the light-based heart-rhythm score agree with the electrical one? Answer, on the good nights: yes, almost perfectly — the beat-to-beat rhythm score matched to within one percent, and the two devices even counted the same number of heartbeats to within ten out of twenty thousand. One longer-term “spread” number ran high on the light sensor, but for a fixable reason (slow drift of the light signal, not the heartbeat itself), and a smarter way of averaging brought it back in line. The most important part: on two bad nights the wrist sensor produced nonsense — and the app knew it was nonsense on its own, before ever seeing the chest strap, and marked those nights as untrustworthy. So the practical lesson isn't “light sensors are perfect”; it's “a good light-sensor pipeline knows when to trust itself.” This is one person over four nights — a demonstration the method works, not a product accuracy rating.
Heart-rate variability from a wrist or finger photoplethysmogram (PPG) is attractive because the hardware is cheap and unobtrusive, but optical pulse timing is a mechanical, downstream proxy for the electrical heartbeat that an ECG records directly. The suite's simulation paper Three independent detectors, one tachogram established, on synthetic beats scored by the real detectors, that ECG- and RR-derived rMSSD are interchangeable (bias −0.02 ms) while the optical arm is unbiased in the mean but several-fold noisier — a variance penalty, not a bias. That paper's Reproducibility section named its own sequel: a simultaneous reference-ECG + PPG cohort … to convert the pipeline-equivalence result into a clinical PRV-vs-HRV comparison.
This paper is that sequel on real data, and extends it in two directions the simulation did not cover: the long-term / frequency-domain metrics (SDNN, SD2, spectral power), and the behaviour of the pipeline's own signal-quality confidence when the ground truth is available to check it against.
Three questions are asked directly, because a chest ECG worn on the same body is the reference for inter-beat timing: (i) do optical beat-to-beat metrics agree with ECG on real overnight data; (ii) can the known long-term optical inflation be corrected rather than merely flagged; and (iii) does the pipeline's reference-free confidence actually separate the nights where optical HRV is trustworthy from the nights where it is not?
One subject wore three devices together overnight: a Polar H10 chest strap (single-lead ECG, ~130 Hz), a Polar Verity Sense wrist band (3-LED PPG, ~176 Hz), and — on the deepest night — a Wellue O2Ring finger oximeter (SpO₂ + 1 Hz pulse). Raw waveforms were captured with Polar Sensor Logger. Every HRV number is derived from raw signal by the production detectors, never a vendor summary: ECG heart-beat train by ECGDSP (Pan–Tompkins QRS), optical beat train by PPGDSP (three-LED consensus foot detection — a beat is kept only where ≥2 of 3 LEDs agree within ±50 ms — then Malik correctRR). Both then feed the identical time-domain, Poincaré and Lomb–Scargle HRV code, so any disagreement is attributable to the front end.
The devices share no clock or timezone but each stamps local civil time, stored as UTC-normalized floating wall-clock milliseconds (tMs = Date.UTC(y,mo−1,d,h,mi,s)), so two devices recording the same wall-clock second yield the same tMs by construction. Per-5-min epochs are aligned by tMin intersection; whole-record comparators use each summary's wholeRecordRMSSD / wholeRecordSDNN per its windowNote.
Whole-record SDNN folds in SDANN — the drift between 5-min segment means — which optical baseline wander and pulse-transit-time (PTT) modulation inflate. The suite computes two additive, back-compatible alternatives (whole-record sdnn unchanged): sdnnIndex (mean of per-5-min SDNN) and sdnnRobust (the quality-gated median of per-5-min SDNN — epochs with motionIndex>0.5 or ledAgreementPct<67 dropped, <3-epoch fallback). sd2Robust is rebuilt from sdnnRobust and the clean beat-to-beat SD1; lf/hf/lfhfRobust are gated medians of per-epoch bands. VLF is deliberately not robust-corrected (a 5-min epoch cannot resolve <0.04 Hz).
PpgDex marks whole-record HRV low-confidence when analyzablePct<60 or correctionRatePct>20 — quantities it computes from the optical signal alone, with no ECG. The suite additionally emits a graded 0–1 hrv.confidence per metric family, each scored by the driver that predicts that metric's error (motion→HF, posture/baseline→VLF/SDNN, coverage+correction→beat-to-beat). This paper treats the gate as a classifier and asks whether it agrees with the ECG-measured error.
Two nights passed the reference-free gate (analyzable 98%, correction 6–10%, mean SQI 0.91–0.92); two failed (analyzable 56–57%, correction 36–42%, SQI 0.49–0.53). This split, computed from the optical signal alone, turns out to be exactly the split between agreement and nonsense against ECG (§3.2, §3.4).
| Night | Dur (min) | ECG beats | PPG beats | Analyzable | Correction | Gate | ECG rMSSD | PPG rMSSD |
|---|---|---|---|---|---|---|---|---|
| 2026-07-06 | 401 | 19,922 | 19,926 | 98% | 9.8% | trusted | 40.1 | 40.4 |
| 2026-07-07 | 421 | 20,671 | 20,661 | 98% | 5.8% | trusted | 37.8 | 37.1 |
| 2026-07-01 | 432 | 21,087 | 16,480 | 56% | 36.4% | flagged | 37.4 | 136.8 |
| 2026-07-02 | 333 | 16,107 | 27,620 | 57% | 42.3% | flagged | 35.9 | 143.9 |
Pooling the two trusted nights, optical rMSSD carried a mean bias of −0.2 ms (−0.6%) against chest ECG, and the beat counts agreed to 0.02% and 0.05% (4 beats in 19,922; 10 beats in 20,671). On the deepest night (07-07) SD1 agreed to +1.9%, lnRMSSD to +0.4%, pNN50 to +1.4%, and mean HR to +1.8%. This is a real-data confirmation of the simulation paper's central finding — optical rMSSD is unbiased in the mean — now with the mean bias pinned below one percent on true overnight recordings rather than synthetic windows.
paper-multinight.json.On the trusted nights, whole-record SDNN ran +46% above ECG — the expected SDANN/baseline-wander inflation. Reporting the quality-gated per-5-min median (sdnnRobust) instead reduced the gap to +2.3% against the ECG per-5-min-median truth. On the deepest night the same mechanism corrected SD2 (+54%→+4.1%) and Lomb–Scargle band power (+89%→+6.9%); per-epoch LF alone agreed to +0.7%, confirming that the whole-record spectral inflation is slow between-segment drift, not a genuine spectral error.
| Metric | Whole-record vs ECG | Robust vs ECG | Robust estimator |
|---|---|---|---|
| SDNN | +46% | +2.3% | sdnnRobust (gated median) |
| SD2 | +54% | +4.1% | sd2Robust |
| Band power (LF+HF) | +89% | +6.9% | gated-median LF+HF |
| VLF | +62% | — (not corrected) | graded confidence, capped 0.7 |
Two bands are deliberately not corrected because their excess has no detectable, subtractable cause on this data. Per-epoch SDNN excess showed near-zero correlation with everything the device records (motion r=−0.03, LED disagreement r=0.02) — it is a baseline optical property present even in the cleanest low-motion epochs — so VLF, which is dominated by that slow drift, stays flagged. Residual HF excess, by contrast, was motion-driven (+43% in high-motion epochs vs +12% in low), so a stricter low-motion HF median (hfRobustLowMotion) and a motion-scored HF confidence are emitted. In place of a single binary flag the export now carries a 0–1 confidence per metric family, each tied to its own driver; VLF is capped at 0.7 because single-site optical VLF is baseline-limited even when clean — a real property, not a defect to hide.
Treated as a binary classifier of night usability, the reference-free gate labelled the two nights whose optical rMSSD error was ±0.5 ms as trusted and the two whose error was +99 and +108 ms as flagged — a clean separation with no overlap, and with the ECG never consulted by the gate. On the flagged nights the optical detector had catastrophically mis-counted (07-01 missed 22% of beats; 07-02 over-detected by 71%), which is precisely what drives the analyzable/correction quantities the gate reads. The robust SDNN estimator did not rescue these nights (07-01 sdnnRobust 104.7 ms vs an ECG truth of 47.3) — correctly, because they are genuinely uninterpretable, and the confidence score says so. The practical result is that optical HRV becomes usable not by being universally accurate but by the pipeline knowing, from the optical signal alone, when to trust itself.
On the deepest night a Wellue O2Ring finger oximeter recorded the same session. Mean heart rate across the three independent modalities — chest electrical, wrist optical, finger optical — agreed to under 1 bpm (ECG 49.1, PPG 50.0, O2Ring 49.2). The O2Ring samples at ~1 Hz and cannot produce beat-to-beat HRV, so it is a rate-and-oxygenation check only; it also confirmed the night was physiologically clean (SpO₂ mean 95.6%, 0.1% of time <90%), ruling out desaturation load as a confounder of the HRV agreement above.
Three practical rules follow. (1) Engineered optical beat-to-beat HRV (rMSSD, SD1, pNN50) is interchangeable with chest ECG on real overnight recordings when quality-gated — the real-data confirmation the simulation paper called for, with mean bias below 1%. The engineering that achieves this (3-LED consensus detection, foot timing, Malik correction) is what converts the raw optical arm's variance penalty into ECG-grade agreement on good nights. (2) The long-term optical inflation (SDNN/SD2/band power) is an SDANN/baseline artifact, not a beat error, and is largely removed by segment-wise robust aggregation — a pure reporting change, no new sensing. (3) The bands that remain limited (VLF, motion-driven HF) are best surfaced as a graded, cause-tied confidence than as a blanket flag, and — most importantly — the pipeline's reference-free quality gate is a trustworthy self-classifier of night usability, which is what makes single-site optical HRV safe to consume downstream.
uploads/ — ECGDex_<date>_summary.json + PpgDex_<date>_summary.json for 2026-07-01/02/06/07, plus the 07-07 O2Ring CSV. Each summary is itself derived from raw signal by the production detectors.ecgdex-dsp.js (ECGDSP Pan–Tompkins QRS) and ppgdex-dsp.js (PPGDSP.analyze — 3-LED consensus + correctRR), shared time-domain / Poincaré / Lomb–Scargle HRV code.sdnnRobust / sd2Robust / lf,hf,lfhfRobust / hfRobustLowMotion / hrv.confidence computed in ppgdex-dsp.js (mirrored in ppgdex-app.js buildV2); gate = analyzablePct<60 || correctionRatePct>20.paper-multinight.json: whole-record and per-5-min-median agreement per night, robust-SDNN recomputed from PPG epochs by the shipped gate, and the gate's pass/fail label.ppg-ecg-hrv-validation-analysis.html (unbundled, touches neither gate) and extend to the full 20-night tri-device corpus across motion regimes for a powered Bland–Altman.This draft is a four-night pilot on one subject, of which the pipeline deems two usable — deliberately below any published-agreement threshold. Two sample-size axes matter, and they diminish at very different points.
The trusted-night rMSSD agreement (bias −0.6%) is a paired within-subject comparison; its precision is set by the number of trusted paired nights n. Standard method-comparison theory fixes the scaling: the confidence interval on the bias narrows as ≈1/√n, and the interval on each limit of agreement as ≈1.71·SD/√n. So the returns are steep early and flat late.
| Tier | Trusted nights | What it buys |
|---|---|---|
| This pilot | 2 | Paired direction only: bias <1%, beats <0.05%. No interval. |
| Minimum (usable LoA) | ~12–15 | First defensible 95% limits of agreement on rMSSD; bias CI ≈ ±1 ms. Enough to state “interchangeable, quiet sleep, one subject”. |
| Recommended | ~25 | LoA and bias CI stabilize to ≈±0.3 ms; the SDNN-whole→sdnnRobust correction gets a per-night distribution, not two points. Diminishing returns begin here. |
| Beyond | > ~30 | Within-subject LoA is essentially pinned; each further single-subject night adds <5% CI width. Marginal. |
The point where more nights stop helping is ~25–30 trusted nights on one subject: past there the within-subject limits of agreement are pinned and the marginal night is nearly information-free. But that ceiling only closes the within-subject question. It says nothing about between-subject generalization or motion robustness — and those are exactly what a single deep subject cannot buy at any n. So beyond ~30 nights the value shifts decisively from depth to breadth: more subjects (the between-subject variance the pilot cannot see) and more motion regimes (every night here is quiet sleep; the two flagged nights show the failure mode but not a graded motion sweep). The suite's existing how-many-windows power analysis already quantified the intra-night window count for the reference-free σ work on this same corpus; the analogue here is a multi-subject, motion-stratified extension, for which the 20-night tri-device archive is the starting substrate, not the finish line.
papers/rmssd-equivalence.html — three-detector rMSSD equivalence on shared synthetic beats.papers/sigma-no-reference.html — reference-free per-device σ (three-cornered hat) on the same device corpus.CLAUDE.md (Clock Contract, evidence-grade system), Tepna suite.