PpgDex (raw PPG) · ECGDex (raw ECG) nodes, Tepna physiological-signal suite
Background. A wearable HRV pipeline decides which epochs to trust using a signal-quality index (SQI) computed from the optical signal alone. Choosing among candidate gates requires ground truth, and the natural experiment is to pool every epoch from every night and ask which gate best separates the epochs whose HRV turned out wrong. We show that this natural experiment gives the wrong answer, and gives it confidently. Data. 1,488 five-minute epochs from 20 simultaneous Polar H10 chest-ECG + Polar Verity Sense armband-PPG overnight recordings, one subject. An epoch is “catastrophic” if its optical rMSSD deviates from the simultaneous ECG by more than 25% (158 epochs, 10.6%). Results. Three candidate gates were scored by their ability to rank catastrophic epochs below good ones. Pooled across nights, beat coverage wins decisively (AUC 0.737, p = 7×10⁻²³) and the shipped per-beat SQI is barely distinguishable from a coin flip (AUC 0.556). Clustered within nights — the correct analysis, since epochs from one night are not independent — the ranking exactly reverses: the shipped SQI is best (median AUC 0.763, Wilcoxon p = 0.014) and beat coverage is worst and not significant (0.629, p = 0.106). The reversal is an ecological fallacy: coverage varies strongly between nights and tracks which nights are bad, so pooling lets between-night variation masquerade as within-night discrimination, while the SQI's night-specific scale is washed out by the same pooling. Applied as an actual gate within each night, the SQI reduces the 90th-percentile |ΔrMSSD| from 25.8% to 21.4% at 70% retention, whereas coverage makes the median error worse (4.43% → 4.89%). Conclusion. Signal-quality gates for wearable HRV must be evaluated within recording, not on pooled epochs. The pooled analysis here would have prompted replacing a working gate with one that is actively counterproductive. Note added 2026-11-24: §3.5 restates this table from a committed producer over a different epoch grid, where the reversal does NOT reproduce although beat coverage still ranks last within nights. §3.6 restates the retention curves on that same grid, where the behaviour above DOES reproduce: the SQI improves both statistics at every step and coverage makes the median worse.
Keywords: signal quality index · photoplethysmography · heart-rate variability · ecological fallacy · Simpson's paradox · clustered data · AUC · wearables · method evaluation
A wrist or arm sensor cannot always be trusted, so the software scores each five-minute stretch and throws away the ones it thinks are bad. We had a chest strap giving the true answer, so we could check which scoring method actually catches the bad stretches. Doing the obvious thing — dumping every stretch from every night into one pile and comparing — said the software's own score was almost useless and that a different measure was much better. But stretches from the same night are not independent observations, and once we compared within each night, the answer flipped completely: the software's own score was the best one, and the “better” alternative turned out to be the worst. The pile-everything-together version was measuring differences between nights and mistaking them for the ability to spot a bad stretch. This matters beyond our sensor: the wrong analysis was easy, fast, produced a tiny p-value, and would have led us to delete a working feature and replace it with something that makes results worse.
Every consumer-wearable HRV pipeline contains a gate: some reference-free statistic that decides which stretches of a recording are trustworthy enough to report. Because the gate is what stands between a user and a confidently wrong number, choosing the right one matters more than most tuning decisions. And because gates are cheap to compute and easy to swap, the choice is usually made empirically — collect data with a reference, label the epochs the reference says went wrong, and pick whichever candidate statistic separates them best.
That procedure has a defect that is well known in epidemiology and almost never mentioned in wearable-signal work: the epochs are clustered. A night contributes eighty-odd epochs that share a sensor placement, a skin-contact quality, a perfusion state, and a subject posture distribution. Treating them as 1,488 independent observations is not merely optimistic about the p-value; it can change which candidate wins, because a statistic that mostly encodes “which night is this” will separate pooled labels without having any ability to rank epochs inside a night — which is what a gate actually has to do.
This paper documents that failure occurring, on real data, in a direction that would have caused real harm to a working pipeline. It is a negative methodological result with a positive corollary: the gate the pooled analysis condemned is, correctly analysed, the best of the three.
One subject wore a Polar H10 chest ECG and a Polar Verity Sense optical armband simultaneously for 26 nights; 20 yield a paired analysis of 1,488 five-minute epochs (121.5 h). Optical beats come from the production PPGDSP detector (three-LED consensus, intersecting-tangent foot timing); ECG R-peaks from Pan–Tompkins with sub-sample refinement, validated at 0.244 ms fiducial jitter. Alignment is re-estimated per epoch, because a single global affine map between two independent BLE clocks fails across a whole night. Full acquisition and alignment detail is in the companion paper, Optical HRV against chest ECG on thirty overnight recordings.
An epoch is catastrophic when its optical rMSSD (Task Force of the ESC/NASPE 1996) deviates from the simultaneous ECG rMSSD by more than 25%. 158 of 1,488 epochs (10.6%) qualify. Note added 2026-10-28: those two counts are this paper’s own v2-era population and are NOT re-cut here. The companion paper has since been re-cut from a committed producer over 30 nights and reads 283 of 1,961 epochs (14.4%) catastrophic by the same ±25 % rule, so the two papers quote different populations of the same corpus until this one is re-cut too. The threshold is a judgement, chosen because it is far outside the corpus's typical +4% bias and corresponds to an error that would change a user-facing interpretation; §4 reports sensitivity to it.
All three are computed from the optical signal alone, with no reference, and all three are already available in the shipped export. Signal-quality indices of this kind are standard for wearable optical and electrical channels (Orphanidou et al. 2015; Elgendi 2016):
Pooled. All 1,488 epochs in one set; AUC computed once as the probability that a randomly chosen good epoch scores above a randomly chosen catastrophic one; significance by Mann–Whitney U.
Night-clustered. AUC computed separately within each night that contains at least three catastrophic and three good epochs (10 of 20 nights qualify), then summarised across nights; significance by Wilcoxon signed-rank of the per-night AUCs against 0.5. This is the analysis that matches the deployed decision — a gate operates inside one recording, on that recording's own epochs.
Retention curves apply each gate within each night at a per-night percentile, so a night is never wholly deleted by a between-night level shift, and report the resulting median and 90th-percentile |ΔrMSSD| over the retained epochs.
| Gate | Pooled AUC | Pooled p | Night-clustered AUC (median, IQR) | Nights > 0.5 | Clustered p |
|---|---|---|---|---|---|
| Mean SQI (shipped) | 0.556 worst | 0.011 | 0.763 best [0.645, 0.791] | 9/10 | 0.014 |
| LED agreement | 0.642 | 8×10⁻¹⁰ | 0.700 [0.610, 0.760] | 10/10 | 0.002 |
| Beat coverage | 0.737 best | 7×10⁻²³ | 0.629 worst [0.561, 0.729] | 8/10 | 0.106 n.s. |
The pooled analysis is not merely noisy — it is decisive, and decisively wrong. Beat coverage's pooled p of 7×10⁻²³ is the most significant result in the table, and it belongs to the only gate that fails to reach significance once clustering is respected. Conversely the shipped SQI, which the pooled analysis places at 0.556 — close enough to 0.5 that it reads as “this feature does nothing” — is the best gate available, above chance on 9 of the 10 evaluable nights.
The mechanism is an ecological fallacy (Robinson 1950). Beat coverage varies strongly between nights: nights where the armband sat poorly lose a large fraction of beats to the three-LED consensus and also generate most of the catastrophic epochs. Pooling therefore lets a between-night level difference do the separating, and the pooled AUC largely measures “can this statistic tell a bad night from a good night” — a real but different ability. Within a night, coverage is nearly constant and carries little information about which of that night's epochs went wrong.
The shipped SQI has the opposite structure. Its absolute level is night-specific — it depends on perfusion, skin contact and template shape, which shift between wearings — so pooling smears the good epochs of a low-SQI night into the bad epochs of a high-SQI night and destroys the signal. Within a night, where the offset is common, it ranks epochs well. A gate is always deployed within a recording, so the within-night behaviour is the one that matters and the pooled number is not merely imprecise but answering a different question.
| Gate | Retention | Median |ΔrMSSD| | p90 |ΔrMSSD| |
|---|---|---|---|
| none | 100% | 4.43% | 25.80% |
| Mean SQI | 90% | 4.22% | 22.85% |
| 80% | 4.09% | 22.62% | |
| 70% | 3.92% | 21.43% | |
| LED agreement | 90% | 4.15% | 25.17% |
| 80% | 4.03% | 23.62% | |
| 70% | 3.95% | 23.41% | |
| Beat coverage | 90% | 4.39% | 24.79% |
| 80% | 4.70% worse | 24.56% | |
| 70% | 4.89% worse | 23.44% |
The retention curves confirm the clustered ranking behaviourally rather than by AUC. Mean SQI improves both the median and the tail monotonically as it discards more data. Beat coverage improves the tail slightly while making the median worse — it is discarding epochs that were fine and keeping epochs that were not, which is what a gate carrying mostly between-night information does when applied within a night. Had the pooled analysis been acted on, the pipeline would have replaced a gate that helps with one that is, on the metric that matters most to a user, actively harmful.
An honest reading of Table 2 is that no gate here is transformative: the best available option removes 30% of the data to move the median error from 4.43% to 3.92% and the tail from 25.8% to 21.4%. That is worth having and worth reporting honestly, but it is not the difference between a usable and an unusable pipeline. The companion paper shows why — epoch error is governed almost entirely by fiducial jitter (per-night R² = 0.964), and none of these three gates measures jitter directly. The gate literature's implicit promise, that a good SQI can rescue a noisy optical arm, is not borne out at these effect sizes; the productive route is reducing jitter, not filtering harder.
Table 1 above is a Draft v2 measurement, and until now the repository held no tool that wrote its population (§5). tools/ppi-jitter-vs-ecg.mjs --pooling now produces this comparison from committed code. It scores the same three gates under the same ±25 % label, pooled and within nights, and it emits a tepna.verdict/1 over the result. The produced grid is not this paper’s grid, and no cell above is restated. The producer reads 1,199 epochs over 13 nights, of which 61 (5.1 %) are catastrophic, against the 158 of 1,488 over 20 nights reported in §2.2. Table 3 states both sets of cells side by side.
| Gate | Pooled AUC | Pooled p | Night-clustered AUC (median, IQR) | Nights > 0.5 | Clustered p | Table 1 |
|---|---|---|---|---|---|---|
| Mean SQI (shipped) | 0.875 | 5×10⁻²³ | 0.861 [0.685, 0.948] | 11/12 | 0.001 | 0.556 / 0.763 |
| LED agreement | 0.852 | 5×10⁻²⁷ | 0.892 [0.733, 0.936] | 11/12 | 0.002 | 0.642 / 0.700 |
| Beat coverage | 0.651 worst | 7×10⁻⁵ | 0.577 [0.549, 0.749] worst | 10/12 | 0.176 n.s. | 0.737 / 0.629 |
The inversion does not reproduce. Pooled, the produced grid ranks the shipped SQI first and beat coverage last. Clustered, it ranks LED agreement first and beat coverage last. Beat coverage is last on both analyses, so there is no reversal to document. The verdict object therefore reads status: FAIL against a criterion stated before the run: that the published order reversal reproduces with every cell within 0.05 AUC. The worst cell is the shipped SQI’s pooled figure, 0.875 produced against 0.556 published.
What survives, and what does not. The paper’s conclusion survives the change of grid: beat coverage is still the gate whose advantage is pooled-only, it still loses most of its discrimination under clustering (0.651 → 0.577), and it still fails to reach significance there. The mechanism of §3.2 is therefore visible on produced data. What does not survive is this paper’s instance of the failure. On the produced grid the pooled analysis does not place coverage first, so it would not have misled anyone, and the headline reversal cannot be reproduced from the repository. The contribution that reproduces is the direction — evaluate within recording, and coverage ranks last — not the six published cells.
Why the grids differ, and why neither is wrong. The producer rides the epoch grid of the fiducial-jitter arm, which re-estimates alignment per epoch and admits a night on its own minimum-epoch rule. That grid labels 5.1 % of epochs catastrophic where this paper labels 10.6 %, so the two populations are two measurements of one corpus and never one measurement restated (the same disagreement §2.2 records for the companion paper). A reader who wants this paper’s exact cells needs this paper’s grid, which has no producer; a reader who wants produced cells can run one command.
The command, and what it binds to. node tools/ppi-jitter-vs-ecg.mjs --dir <captures> --device verity --pooling, run at commit 89e0d8107 on 2026-11-24, prints Table 3, the population, the excluded night with its reason, and the verdict object. No number in this section is bound by a CLAIM marker yet, because a marker binds one number to one committed artifact and this paper’s per-epoch table stays off the repository (§5). Binding the produced cells to a committed verdict artifact is the next step for this paper, not something this section claims.
Table 2 above was the paper’s other producerless measurement. tools/ppi-jitter-vs-ecg.mjs --retention now produces it from committed code. It applies each of the three gates within each night, keeps that night’s best-scoring epochs at 90, 80 and 70 % retention, and reads the median and the p90 of the absolute per-epoch rMSSD error over what survives. It rides the same grid as §3.5 — 1,199 epochs over 13 nights — so, as there, no cell of Table 2 is restated. Table 4 states the produced curves.
| Gate | Retention | Kept | Median |ΔrMSSD| | p90 |ΔrMSSD| | Table 2 |
|---|---|---|---|---|---|
| None (ungated) | 100 % | 1199 | 2.51 % | 13.96 % | 4.43 / 25.8 |
| Mean SQI (shipped) | 90 % | 1081 | 2.33 % | 10.41 % | 4.22 / 22.85 |
| 80 % | 958 | 2.13 % | 9.00 % | 4.09 / 22.62 | |
| 70 % | 840 | 1.96 % | 7.43 % | 3.92 / 21.43 | |
| LED agreement | 90 % | 1081 | 2.31 % | 10.44 % | 4.15 / 25.17 |
| 80 % | 958 | 2.09 % | 9.17 % | 4.03 / 23.62 | |
| 70 % | 840 | 1.95 % | 8.53 % | 3.95 / 23.41 | |
| Beat coverage | 90 % | 1081 | 2.48 % | 11.90 % | 4.39 / 24.79 |
| 80 % | 958 | 2.50 % | 11.93 % | 4.70 / 24.56 | |
| 70 % | 840 | 2.61 % worse than ungated | 11.93 % | 4.89 / 23.44 |
The behaviour reproduces, cell for cell in direction. The shipped SQI improves both statistics at every step: the median falls 2.51 → 2.33 → 2.13 → 1.96 % and the p90 falls 13.96 → 10.41 → 9.00 → 7.43 %. Beat coverage makes the median worse as it retains less, 2.48 → 2.50 → 2.61 % against an ungated 2.51 %. Those are the two legs §3.3 claims, and the verdict object reads status: PASS over 1,199 of 1,199 epochs against a criterion stated before the run: zero violations of “the shipped SQI improves both statistics monotonically and beat coverage harms the median”. §3.5 refused its criterion on this same grid; this one holds.
Two things the produced curves say that Table 2 does not. First, coverage harms the median while leaving the p90 flat (11.90, 11.93, 11.93 %): it discards epochs the median cares about and keeps the tail it was meant to cut, which is a sharper statement of §3.2’s mechanism than a worsening median alone. Second, LED agreement tracks the shipped SQI on the median to within 0.02 percentage points at every retention, and falls behind it only in the tail at 70 % (8.53 against 7.43 %). Table 2’s cells put LED ahead of SQI in the tail at 70 % (23.41 against 21.43), so the produced grid reverses the ranking of the two good gates even while it confirms which gate is bad.
The levels differ, and for the reason §3.5 gives. Every produced number sits far below its published counterpart — 2.51 % ungated against 4.43 %, 13.96 % against 25.8 % — because the producer labels 5.1 % of its epochs catastrophic where this paper labels 10.6 %. The two are two measurements of one corpus, never one measurement restated. A reader comparing a produced cell with a published one is comparing grids, so the claim that reproduces is the direction of each curve, not its height.
The command, and what it binds to. node tools/ppi-jitter-vs-ecg.mjs --dir <captures> --device verity --retention, run on 2026-11-24 under the commit its own verdict object names, prints Table 4, the population, and that verdict. As in §3.5, no number here carries a CLAIM marker, because this paper’s per-epoch table stays off the repository (§5).
The general rule. Evaluate a signal-quality gate the way it will be deployed. If it decides among epochs inside one recording, score it inside one recording and aggregate the per-recording scores. Pooling epochs across recordings answers “can this statistic distinguish good recordings from bad ones,” which is a legitimate question — night-level triage is useful — but it is not the question a per-epoch gate is asked, and on this corpus the two questions have opposite answers.
Why it is easy to get wrong. The pooled analysis is the path of least resistance in every respect: it is one line of code, it uses all the data, it yields large n and tiny p-values, and its conclusion (“your bespoke quality index is no better than chance; use this simple coverage number instead”) is exactly the kind of parsimonious finding that feels like a discovery. Nothing about it looks like a mistake from the inside. The only warning sign available without the clustered analysis is that the winning statistic is one whose variance is obviously dominated by between-recording differences — a structural observation, not a statistical one.
Sensitivity to the label threshold. The inversion is not an artifact of the 25% cut. Raising or lowering it changes the number of catastrophic epochs and hence the precision of both analyses, but coverage's advantage is pooled-only and the SQI's advantage is clustered-only across the range tested, because the mechanism is structural rather than threshold-dependent. We report the 25% result as primary and note that a threshold low enough to label a large fraction of epochs would make the comparison uninformative in both analyses.
tools/ppi-jitter-vs-ecg.mjs --pooling, restated in §3.5 — and it does not reproduce the inversion. Table 2 now has a producer too — tools/ppi-jitter-vs-ecg.mjs --retention, restated in §3.6 — and its behavioural claim does reproduce, on the same grid that refused Table 1’s. The companion paper Fiducial jitter sets a floor on optical HRV does carry a committed producer, tools/ppi-jitter-vs-ecg.mjs, whose own note at :511 records why its catastrophic population (283 of 1,961 epochs over 30 nights) disagrees with the 158 of 1,488 reported here: the two arms ride different epoch grids, so the counts are two measurements and never one measurement restated.ppgdex-dsp.js and ecgdex-dsp.js, run unmodified in a co-loaded realm, so gate values are exactly those the shipped app computes.papers/ppg-ecg-hrv-validation.html — the 20-night optical-vs-ECG agreement study and the fiducial-jitter model.CLAUDE.md (Clock Contract, evidence-grade system), Tepna suite.