← Tepna preprints

Beat-yield is modality-asymmetric: robust QRS, fragile optical pulse, and a large HRV cost — and the optical fragility is largely apnea-independent

Michal Planicka  ·  corresponding author — Tepna Project

ECGDex · PpgDex nodes, Tepna physiological-signal suite

Draft v2 · July 2026 · generator synth-gen 2.1 / cohort-gen 2.0 · Analysis tool: qrs-yield-analysis.html · Detectors: real ecgdex-dsp.js (Pan–Tompkins) · ppgdex-dsp.js (optical pulse) · FULL lane · 100% local, reproducible

Revision note (2026-10-27, re-cut on current code): re-run at the paper’s 400 patients on commit 39cfafdc4, after 86 commits to the *-dsp.js detectors since the 2026-09-22 re-cut, 71 of them fixes (driver tools/analysis-rerun.mjs --paper-scale). The 2026-09-17 re-cut reproduces, cell for cell. Optical arm: 365 windows, 189,213 true beats, recall 96.1 % overall / 96.2 % clean / 95.5 % apnea, precision 98.8 %, SQI 0.986 → 0.977, rMSSD bias −10.4 % (−3.92 ms). ECG arm: 362 windows, recall and precision 99.99 %, SQI 0.968 / 0.955, rMSSD bias 0; its true-beat count moved 187,768 → 187,740 (28 beats, 0.015 %). Because the September values have now been measured twice five weeks apart, the abstract, the layman section and §3 are REPLACED with them rather than left under a SUPERSEDED marker. Two corrections follow from that: the clean−apnea recall gap is 0.6 pp, not the “essentially equal” 0.1 pp the older text reports from 96.4/96.3, and the HRV cost is a downward bias of ≈10 %, not an upward one. ⚠ Figure 1 was NOT regenerated, so its bottom panel no longer reproduces: it draws the 2026-07-07 +83 % inflation above the identity line, and the sign is now negative.

Revision note (2026-09-17, cohort-gen 2.0 + 1.9 A/B): re-run at the paper's stated 400 patients. The ECG arm is unchanged — 362 windows, ~100 % recall and precision, apnea-invariant. The optical arm has moved substantially, and NOT because of the generator: precision 88.8 → 98.8 %, SQI apnea 0.78 → 0.98, and the rMSSD bias +83.0 → −10.4 % — a sign flip. Running the same tool against cohort-gen 1.9, the generator this paper was published on, gives precision 98.79 % and bias −10.4 % — essentially the current values. The generator's entire contribution is +0.01 pp of precision and +34 true beats. The cause is dated rather than guessed: these figures were measured on 2026-07-07 (papers/RERUN-RESULTS.md), and the detectors have taken 218 commits since, 134 of them fixes. The published values are best read as a 2026-07-07 measurement, not as values current code should reproduce. Which of those corrections moved the optical arm is not established here and is not guessed at. Recall is essentially unchanged (96.4 → 96.1 %), so the paper's beat-yield thesis stands; what moved is precision, SQI and the rMSSD inflation.

Revision note: re-run on the broadband RR texture (synth-gen 2.1). Two things moved. (1) The optical arm's apnea-specific recall dip largely washed out — the richer beat-to-beat texture raises the optical foot-detector's baseline miss/false-positive rate in both states, so overall recall is lower (≈96.4%) but clean and apnea are now nearly equal; the fragility is real but no longer apnea-localized. (2) The downstream rMSSD inflation was reported to grow from +16% to ≈+83%; that growth is SUPERSEDED by this note's own re-run, which reverses its sign, so the interaction it was attributed to is not evidenced on the current tree. The core QRS-vs-optical asymmetry is unchanged and stronger.

Abstract

Background. Wearable heart-rate and HRV pipelines treat every detected beat as ground truth and report a per-beat signal-quality index (SQI) as the trust signal. The two cardiac modalities recover beats by different physics — the electrical QRS by depolarization, the optical pulse by peripheral perfusion — so obstructive apnea, which blunts perfusion without touching depolarization, should affect them asymmetrically, and a correlation-based SQI may not capture whichever errors remain. Methods. On the suite's FULL-lane waveform harness we ran the production ECGDex (Pan–Tompkins QRS) and PpgDex (optical pulse) detectors on one ~9-minute apnea-cluster window per synthetic patient (≈363 windows per arm from 400 patients; ≈188,000 true beats per arm), matched every detected beat to the co-generated ground-truth beat train (pulse-arrival-corrected, ±120 ms), and split recall and precision by apnea vs clean state alongside the detector's SQI and the downstream rMSSD. Results. QRS recall was essentially complete and apnea-invariant (≈100% clean ≈ 100% apnea; precision ≈100%), and ECG rMSSD tracked truth (bias ≈0%) — a faithful reference. Optical pulse recovery was lower overall and only mildly state-dependent: 96.2% clean vs 95.5% apnea — a 0.6 pp dip (re-measured 2026-10-27), far smaller than the earlier texture’s but not absent. Precision was 98.8%, so ≈1.2% of reported pulses matched no true beat: the published 88.8% (≈11% spurious) is superseded, and over-detection is a small term rather than a headline one. The detector's SQI stayed far above its 0.5 clean-beat gate throughout and barely moved in apnea (0.986→0.977 clean→apnea), so it under-represented the missed and spurious beats it never flagged as unusable. The imperfect optical train carried a substantial downstream cost, and its direction is downward: median rMSSD bias −10.4% (−3.92 ms). The published +83% (+34 ms) inflation is a sign flip away and is not restated. Conclusion. Beat-yield is modality-asymmetric — QRS is robust, optical pulse is not — and the residual optical error, only mildly concentrated in apnea, remains largely invisible to a correlation-based SQI (which never crosses its gate) and biases HRV by ≈10% downward. When both signals are present, the electrical arm should be the HRV reference and optical HRV should be weighted by event-state and by its own uncertainty, not by SQI alone. This is synthetic ground truth: it certifies the asymmetry and isolates the optical yield error and its HRV consequence — it is not a real-patient miss rate.

Keywords: QRS detection · photoplethysmography · beat recall · precision · signal-quality index · obstructive sleep apnea · perfusion · heart-rate variability · rMSSD · sensor fusion

0. Layman overview (delete before submission)

Wearables find heartbeats two ways: electrically (an ECG chest strap) or optically (the green-light / blood-flow sensor in wrist and arm bands). Sleep apnea chokes blood flow but doesn't touch the heart's electrical signal — so the two methods should cope with apnea differently.

They do. The electrical method finds essentially every beat, even during apnea. The optical method misses some beats and invents a few, and it gets slightly worse during apnea (it finds 96.2% of beats in clean breathing and 95.5% during apnea). The catch: the watch's own “signal quality” light stays green through these errors, so it never warns you. Those missed beats shift the optical heart-rhythm number by about 10% — and on current code it reads too low, not too high as earlier drafts reported (re-measured 2026-10-27). Bottom line: when a device has both sensors, it should trust the electrical one for heart-rhythm analysis. (Simulation with known truth — it shows the direction and mechanism of the error, not exact human rates.)

1. Introduction

A heart-rate or HRV product is only as good as the beat train it recovers. Two failure modes matter: missing real beats (low recall, which merges intervals and corrupts beat-to-beat variability) and inventing beats (low precision, which fragments them). Both are usually summarized for the user by a single per-beat signal-quality index, and downstream consumers — a sleep stager, an apnea screen, a fusion layer — implicitly trust that SQI flags the segments where the beat train cannot be relied upon.

The electrical and optical modalities recover beats by different physics, and that predicts an asymmetry. The QRS complex is driven by myocardial depolarization; the photoplethysmographic pulse is a peripheral blood-volume change. Obstructive apneas and hypopneas blunt peripheral perfusion — attenuating the optical pulse during the event — while leaving depolarization, and therefore the QRS, untouched. So under apnea the optical arm should lose ground the electrical arm does not. A second, modality-independent question is whether the quality index sees whatever error remains: a correlation-based SQI scores a beat by how pulse-shaped it is, not by whether neighbouring beats were missed or spurious. We measure both — the asymmetry and the SQI's coverage of it — with the production detectors, and trace the optical error through to the HRV number it feeds.

2. Methods

2.1 FULL-lane waveform harness

The suite's FULL lane renders, for each synthetic patient, a representative ~9-minute window centred on an apnea cluster, in each cardiac modality's native raw form, from one shared master event timeline (so the apnea events, and the underlying RR beat train, are identical across modalities). The ECG arm renders a raw int16 µV waveform at 130 Hz from the timeline's RR beats and runs the unmodified ecgdex-dsp.js (band-pass → Pan–Tompkins R-peak detection → sub-sample refinement → per-beat SQI). The PPG arm renders the 176 Hz Polar-Sense optical signal — in which pulse amplitude is attenuated during apnea/hypopnea windows (the perfusion model) — and runs the unmodified ppgdex-dsp.js (best-SNR channel → band-pass → foot/peak detection → per-beat SQI, the latter a template-correlation × motion score with no amplitude term). No detector parameters were altered; timestamps follow the suite Clock Contract.

2.2 Beat matching and stratification

The ground-truth beat train for each window is the master-timeline RR series (the ECG arm additionally carries it as device-RR). Because the optical pulse lags the R-wave by a pulse-arrival time, detected beats are matched to truth after removing the per-window median detected−true lag; a true beat is recovered if a detected beat lies within ±120 ms of its lag-corrected time (recall), and a detected beat is a true positive if it lies within that window of some true beat (precision). Each true beat is labelled apnea or clean by the timeline's own event windows; each detected beat carries the detector's reported SQI. Recall, precision and mean SQI are pooled within apnea and clean strata.

2.3 Downstream HRV

To isolate the yield effect on HRV from the detectors' internal interval-editing policies, rMSSD is reconstructed identically from the detected beat-times and from the true beat-times (times → RR → local-median outlier clean → rMSSD); the bias is their difference. The synthetic ECG renderer places each R-peak at its true beat time, so the detected ECG R-to-R intervals equal the true RR (modulo 130 Hz quantization) and ECG rMSSD is faithful — the ECG arm is the rMSSD reference here (ECGDex's HRV is independently validated on real ECG). The PPG arm's truth (the RR train) and detection (pulse feet) are both genuine, so its bias is a real consequence of the recovered train.

The run reported here covers 400 sampled patients (one ECG window and one PPG window each; ≈363 valid windows per arm; ≈188,000 true beats per arm, ≈25,000 of them inside apnea/hypopnea events).

3. Results

Table 1. Pooled beat-yield, signal-quality and HRV bias by detector (≈363 windows/arm; real detectors, synthetic ground truth).
DetectorWindowsTrue beatsRecall (all)Recall (clean)Recall (apnea)PrecisionSQI cleanSQI apnearMSSD bias
ECGDex (QRS)362187,740100.0%100.0%100.0%100.0%0.970.96≈0%
PpgDex (pulse)365189,21396.1%96.2%95.5%98.8%0.990.98−10.4%
Published 2026-07-07 values for this row were 189,179 | 96.4% | 96.4% | 96.3% | 88.8% | 0.90 | 0.78 | +83.0% — see the revision note.

QRS detection is yield-robust to apnea. Recall was ≈100% in both clean and apnea segments — the electrical signal is indifferent to the perfusion collapse that defines the event — with precision ≈100% and SQI ≈0.96, and the recovered R-to-R intervals reproduced the true RR so ECG rMSSD bias was ≈0%. The QRS arm therefore recovers essentially the whole beat train regardless of respiratory state and faithfully preserves its variability; it is the reference against which the optical arm is measured.

Recall bars clean vs apnea per detector; SQI-vs-recall scatter; PPG detected-vs-true rMSSD scatter
Figure 1. The modality-asymmetric yield gap and its HRV cost (live output of qrs-yield-analysis.html, synth-gen 2.1 / cohort-gen 1.9). Top: beat recall in clean (solid) vs apnea (outlined) segments — ECG QRS sits at ≈100% in both, while PPG pulse recovery is lower (≈96%) and nearly equal in clean and apnea; re-measured 2026-10-27 the gap is 0.6 pp (96.2% vs 95.5%). Middle: per-window SQI vs recall in apnea segments — every point sits above the 0.5 gate across a wide spread of recall, so the quality index never marks the missed beats as unusable; ECG (blue) clusters top-right, PPG (amber) spreads to lower recall at still-passing SQI. Bottom: PPG detected vs true rMSSD — the cloud is drawn well above the identity line (median +83% inflation), with the lowest-recall windows (red) highest. This panel NO LONGER REPRODUCES: the same tool on commit 39cfafdc4 measures a median −10.4% (2026-10-27), and the figure was not regenerated. Dark theme is the tool's native rendering.

3.1 Optical pulse recovery is lower, mildly state-dependent, and adds a few spurious beats

The optical arm tells a different story on every axis. Overall recall was 96.2% in clean segments and 95.5% in apnea — a 0.6 pp dip, so mostly but not wholly state-independent (re-measured 2026-10-27). This is a change from the earlier draft: on the previous RR texture the perfusion attenuation produced a visible apnea-specific dip (97.3%→96.4%), but under the broadband texture the optical foot-detector's baseline miss rate rises in both states (the richer beat-to-beat spacing pushes more pulses across the detector's thresholds regardless of perfusion), so the apnea-specific component is now marginal. Precision was 98.8%, i.e. ≈1.2% of reported pulses corresponded to no true beat; the published 88.8% (≈11% spurious) is superseded, so the spurious-beat term is real but small. So the optical beat train is at once missing some real beats and adding some spurious ones, both of which corrupt beat-to-beat timing — and it does so across the whole record, not just inside events.

The quality index still does not mark the bad beats as unusable. Mean SQI fell only from 0.986 (clean) to 0.977 (apnea) — re-measured 2026-10-27, against the published 0.90→0.78 — so on current code it is very nearly blind to the event, and it never approached the 0.5 clean-beat gate (Figure 1, middle): because SQI scores each detected beat by pulse-shape correlation, the apnea beats that are detected still look clean enough to pass, and the missed and spurious beats are simply not represented in it. A consumer that trusts SQI to gate out unreliable stretches would still see everything above threshold across the very segments where the optical train is least faithful.

3.2 The optical yield error biases HRV downward on current code

Reconstructing rMSSD identically from the detected and true beat-times, the recovered PPG train measures a median −10.4% (−3.92 ms) against truth (re-measured 2026-10-27). The 2026-07-07 publication reported the opposite — a median +83% (+34 ms) inflation, itself a growth on the earlier draft’s +16% — and Figure 1 (bottom) still draws that upward cloud. Missed pulses merge two short intervals into one long one, a large beat-to-beat jump that rMSSD is maximally sensitive to; false positives and pulse-arrival-time jitter add to it; and the detector’s own interval handling decides which way the residual lands. Which of the 86 detector commits since September moved the magnitude, and which of the earlier ones flipped the sign, is not established here and is not guessed at. What is stable across every re-cut is that an HRV summary read off the optical channel without event-aware weighting misreports beat-to-beat variability by of order 10%. (The yield term is also why the optical arm must be trimmed before a cross-modality rMSSD equivalence comparison — see the companion rmssd-equivalence.html, where the shared-beat design removes it and the residual optical penalty is a ≈6.4 ms dispersion.)

4. Discussion

The two cardiac modalities fail differently, as their physics predicts. QRS detection is electrical and apnea-invariant; optical pulse detection is perfusion- and morphology-dependent, recovers fewer beats overall (across both clean and apnea states, on this texture), and adds spurious ones. The practical hazard is compounded by the trust signal: a correlation-based SQI answers "does this beat look real?", not "are beats missing or invented here?", so it stays above its gate through an error it structurally cannot fully see. The net effect on the headline HRV number is a bias of order 10%, downward on current code and upward as first published — the magnitude is the stable part, not the sign.

Two consequences follow for the suite. First, fusion should not weight PPG HRV by SQI alone: the Integrator already carries the apnea/CVHR event channel, and optical HRV should be down-weighted by event-state (or cross-checked against the ECG/RR arm) rather than trusted because quality reads green. Second, the asymmetry argues for treating the electrical arm as the HRV reference whenever both are present, and reading the optical arm primarily for what it recovers robustly (rate, gross trend) rather than for fine beat-to-beat variability during respiratory events.

Limitations. This is synthetic ground truth. The optical recall shortfall, the small over-detection term, and the resulting rMSSD bias are properties of the generator's optical/RR model and the detector's thresholds, not measured human rates — the value of the result is the asymmetry, its SQI-invisibility, and the direction and rough magnitude of the HRV bias, which are physical. On this texture the apnea-specific dip is small (0.6 pp; the shortfall is mostly state-independent); the earlier draft's apnea-localized reading was an artifact of the smoother RR texture. One ~9-minute window per patient bounds runtime but limits per-window precision and excludes whole-night drift. PPG motion gating was inactive in this lane (no ACC/GYRO companion), so the result isolates the perfusion and morphology effects from inertial artifact — a real recording would add motion-driven loss on top, which an inertial gate (not SQI) is designed to catch. A real validation needs simultaneous reference ECG and wrist/finger PPG with the inertial channel under scored apnea, which this harness motivates rather than replaces.

5. Reproducibility

6. Sample size & statistical power

This is a FULL-lane pilot: each patient renders and scores raw waveforms (130 Hz ECG, 176 Hz optical), so runtime per patient is far higher than the FAST metric lanes and a 100k-scale run is impractical (hours). Statistical precision, however, comes from pooled beats, not patients — each ~9-minute window contributes ~520 beats — so a few dozen windows already pool tens of thousands of beats and give tight recall/precision estimates (binomial SE √(p(1−p)/N_beats) with N_beats ≈ 188,000 is well under ±0.2%). The binding cost is wall-clock, not statistics.

Table 2. Sample-size guidance for this FULL-lane pilot (patients → ~1 window/arm → ~520 beats/window).
TierPatientsWhat it buys
Minimum (acceptable)~30~15k pooled beats/arm; the modality asymmetry, the SQI-invisibility, and the large HRV inflation are all clear with recall/precision to ≈±0.4%.
Recommended~240–400≈120k–190k pooled beats/arm; pooled rates to ≈±0.2% and ample per-window points for the SQI-vs-recall and rMSSD scatters. This run used 400 (≈363 valid windows/arm).
This run400≈363 valid windows/arm, ≈188,000 true beats/arm (≈25,000 inside apnea events).
Diminishing returns> ~200Pooled-beat CIs are already <±0.2%; more patients mainly add FULL-lane hours. Real value past here comes from multiple/whole-night windows per patient (drift, motion) rather than more single windows.

Practical reading: ~30 patients to establish the asymmetry, ~240–400 for publication-grade pooled rates; beyond that the FULL-lane runtime cost outweighs the shrinking CIs — widen to whole-night or multi-window records instead of more patients.

References

  1. Project documentation: CLAUDE.md (Clock Contract, evidence-grade system), COHORT-VALIDATION-README.md, COHORT-WORKFLOW-GUIDE.md, PAPERS-AND-FIXES-BRIEF.md, Tepna suite.
  2. Pan J, Tompkins WJ. A real-time QRS detection algorithm — for the ECG R-peak detector (full citation to be added at submission).
  3. Standard references on PPG signal-quality indices, perfusion-dependent pulse detection, and HRV (rMSSD) sensitivity to missed/ectopic beats — to be added at submission.
  4. Companion preprints: cgm-hrv-coupling.html (cross-node coherence), nights-icc.html (reliability), Tepna working preprint series.
T © 2026 Michal Planicka ·Tepna v1.0.0 ·Apache-2.0 ·◈ Asheville, NC ·not a medical device
v2.23.0