← Tepna preprints

Pooling epochs inverts signal-quality gate rankings: a wearable-HRV cautionary result, and the vindication of a gate it condemned

Michal Planicka  ·  corresponding author — Tepna Project

PpgDex (raw PPG) · ECGDex (raw ECG) nodes, Tepna physiological-signal suite

Draft v1 · July 2026 · Companion to ppg-ecg-hrv-validation (Draft v2) · Inputs: 1,488 ECG-referenced optical epochs over 20 nights · 100% local, reproducible

Abstract

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

0. Layman overview (delete before submission)

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.

1. Introduction

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.

2. Methods

2.1 Corpus and ground truth

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.

2.2 The label

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.

2.3 Candidate gates

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):

2.4 The two analyses

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.

3. Results

3.1 The ranking inverts

Table 1. Gate discrimination of catastrophic epochs (|ΔrMSSD| > 25%), same 1,488 epochs, two analyses. Pooled significance by Mann–Whitney U; night-clustered by Wilcoxon signed-rank of per-night AUCs against 0.5 (n = 10 evaluable nights). The order reverses completely.
GatePooled AUCPooled pNight-clustered AUC (median, IQR)Nights > 0.5Clustered p
Mean SQI (shipped)0.556 worst0.0110.763 best [0.645, 0.791]9/100.014
LED agreement0.6428×10⁻¹⁰0.700 [0.610, 0.760]10/100.002
Beat coverage0.737 best7×10⁻²³0.629 worst [0.561, 0.729]8/100.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.

3.2 Why it inverts

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.

3.3 What each gate buys when actually used

Table 2. Gates applied within each night at a per-night retention percentile, over all 1,488 epochs. Lower is better. Ungated median |ΔrMSSD| = 4.43%, p90 = 25.80%.
GateRetentionMedian |ΔrMSSD|p90 |ΔrMSSD|
none100%4.43%25.80%
Mean SQI90%4.22%22.85%
80%4.09%22.62%
70%3.92%21.43%
LED agreement90%4.15%25.17%
80%4.03%23.62%
70%3.95%23.41%
Beat coverage90%4.39%24.79%
80%4.70% worse24.56%
70%4.89% worse23.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.

3.4 Effect sizes are modest either way

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.

3.5 The same table on the produced grid (added 2026-11-24)

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.

Table 3. The produced grid: 1,199 epochs over 13 nights, 12 of them evaluable for a within-night AUC (one night carries no catastrophic epoch). Pooled significance by the tie-corrected normal approximation to Mann–Whitney U; clustered by Wilcoxon signed-rank of per-night AUCs against 0.5. The last column repeats Table 1 for comparison, pooled / clustered. The order does not reverse here.
GatePooled AUCPooled pNight-clustered AUC (median, IQR)Nights > 0.5Clustered pTable 1
Mean SQI (shipped)0.8755×10⁻²³0.861 [0.685, 0.948]11/120.0010.556 / 0.763
LED agreement0.8525×10⁻²⁷0.892 [0.733, 0.936]11/120.0020.642 / 0.700
Beat coverage0.651 worst7×10⁻⁵0.577 [0.549, 0.749] worst10/120.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.

3.6 The retention curves on the produced grid (added 2026-11-24)

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.

Table 4. The produced retention curves: each gate applied within each night, over 1,199 epochs and 13 nights. “Kept” is the epoch count surviving the retention cut summed over nights; the cut is taken per night, so the three gates keep the same count and differ only in which epochs. The last column repeats Table 2’s published cell at the same retention, median / p90. The behaviour the paper claims reproduces here.
GateRetentionKeptMedian |ΔrMSSD|p90 |ΔrMSSD|Table 2
None (ungated)100 %11992.51 %13.96 %4.43 / 25.8
Mean SQI (shipped)90 %10812.33 %10.41 %4.22 / 22.85
80 %9582.13 %9.00 %4.09 / 22.62
70 %8401.96 %7.43 %3.92 / 21.43
LED agreement90 %10812.31 %10.44 %4.15 / 25.17
80 %9582.09 %9.17 %4.03 / 23.62
70 %8401.95 %8.53 %3.95 / 23.41
Beat coverage90 %10812.48 %11.90 %4.39 / 24.79
80 %9582.50 %11.93 %4.70 / 24.56
70 %8402.61 % worse than ungated11.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).

4. Discussion

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.

Limitations. One subject and one device pair, so “night” and “wearing” are confounded with each other and nothing here estimates between-subject gate behaviour. Only 10 of 20 nights contain enough catastrophic and good epochs to yield a within-night AUC, so the clustered analysis rests on 10 paired observations and its intervals are wide — the direction of the inversion is robust, the exact AUC values are not. The catastrophic label is a threshold on a continuous error and inherits that arbitrariness. The three candidate gates were chosen because they already exist in the shipped export, not because they are the best conceivable gates; a jitter-proxy gate would likely outperform all three and was not tested. Finally, this is a single instance of an inversion, not an estimate of how often the pooled analysis misleads in general — the contribution is the demonstration and the mechanism, not a rate.

5. Reproducibility

6. References

  1. Companion paper: papers/ppg-ecg-hrv-validation.html — the 20-night optical-vs-ECG agreement study and the fiducial-jitter model.
  2. Robinson WS. Ecological correlations and the behavior of individuals. Am Sociol Rev. 1950;15(3):351–357.
  3. Simpson EH. The interpretation of interaction in contingency tables. J R Stat Soc B. 1951;13(2):238–241.
  4. Elgendi M. Optimal signal quality index for photoplethysmogram signals. Bioengineering. 2016;3(4):21.
  5. Orphanidou C, et al. Signal-quality indices for the electrocardiogram and photoplethysmogram: derivation and applications to wireless monitoring. IEEE J Biomed Health Inform. 2015;19(3):832–838.
  6. Task Force of the ESC/NASPE. Heart rate variability: standards of measurement, physiological interpretation and clinical use. Circulation. 1996;93(5):1043–1065.
  7. Project documentation: CLAUDE.md (Clock Contract, evidence-grade system), Tepna suite.
v2.37.0