Skip to content

The rebuilt PPG slip finder and its correction

Fourth of the sawtooth series (Finding and placing each PPG frame slip finds the slips, The PPG sawtooth's period, its phase jumps, and the reversed sawtooth their grid, Where the PPG sawtooth stops where it stops). The slip finder is rebuilt around one rule: correct a step only when the evidence that it is a frame slip is strong, because a wrong correction puts a false step into real physiology. It judges each candidate on the shape of the pulse and, where there is one, on the arterial line, and corrects only one-frame steps. Checked against 172 blinded manual labels, a review of 174 corrections and sawtooths injected into real recordings, it called no held-out slip-free event a slip and 98% of the corrections reviewed were judged right. Its correction was then tested end to end against the arterial line in 2,976 recordings, which showed the first version made a third of them worse; rebuilt so each tooth closes exactly, it brings finger PAT closer to arterial PAT than the earlier method (median spread 9.46 against 11.17 ms in sawtooth recordings, 13.95 uncorrected), though it leaves more recordings worse than uncorrected (7.3% against 2.9%). physiosync 0.3.2, fit_ecg_ppg_delay(method="rebuilt").

Date 2026-11-13
Status current
Methods Clocks carried in the signal, One event, two clocks
Techniques Beat matching, Phase-step detection, Sawtooth fit, Null controls, Predict, then test
Clocks Pulse oximeter frame clock, SNUADC sample clock
Devices Solar8000 monitor, SNUADC
Variables Plethysmogram (SNUADC), ECG lead II (SNUADC), Arterial pressure (SNUADC), PPG sawtooth tooth, PPG timing quality

Background

The blinded labels showed the sawtooth's slips can be found far more precisely than the earlier fit (physiosync's detect) finds them (weighted precision 0.95 for the new detector of Finding and placing each PPG frame slip against 0.72 for physiosync's, recall 0.88 against 0.94), and that its misses are mostly steps a single fiducial series cannot judge: noisy beats, irregular rhythm, or a physiological change at the same moment. Correcting smaller and less certain steps would recover some slips but would also start correcting real changes in pulse arrival time. The rebuild therefore looks for more evidence at each step rather than looser thresholds, and leaves a step uncorrected rather than correct physiology.

Data

  • Development set: 324 recordings ($W/slip_rebuild/cases.json): the 169 holding a labelled event, 150 hosts of injected sawtooths and named cases.
  • Whole release: the 5,714 recordings of Finding and placing each PPG frame slip (ECG lead II, PLETH, arterial pressure where present; the longest continuous stretch of each, up to 90 minutes).
  • Manual labels: the 172 blinded events of Finding and placing each PPG frame slip, drawn by which detector found them, labelled on ECG→PPG, ART→PPG and ECG→ART per beat. The odd-numbered half fitted the pulse-shape rule; the even half is held out.
  • Correction review: 107 teeth drawn by tier from the development set (seed 1), each shown blinded as the measured delay before and after correction; every correction in them (174) judged right, wrong or can't tell, and every missed step drawn by hand (36).
  • Injected sawtooths: fast (15–55 ppm, written into the PLETH waveform of recordings without slips, from Finding and placing each PPG frame slip; "clean hosts" leaves out hosts that run a sawtooth of their own) and slow (4–12 ppm, 120 slip-free hosts, $W/slip_rebuild/slow_inj), where a recording holds only one or two slips.

Method

Commands (vitaldb-bench tools/slip_rebuild.py, v26): quality --root $R --scan $W/sawtooth_char/scan_full --cases CASES --out $W/slip_rebuild/quality, then fit --scan $W/sawtooth_char/scan_full --quality $W/slip_rebuild/quality --cases CASES --rates $W/sawtooth_stats/recordings.csv --modes $W/results/sync_full/snuadc_mode_label.json --rule $W/label_quality_final/summary.json --out FIT.jsonl and eval [--clean-hosts] --fit FIT.jsonl --key $W/sawtooth_char/labels/key.json --verdicts $W/label_eval_final/label_verdicts.json --slips $W/sawtooth_char/full/slips.jsonl --scan $W/sawtooth_char/scan_full --out DIR; the tiers with tools/slip_tiers.py --fit FIT.jsonl --scan $W/sawtooth_char/scan_full --out DIR. Whole release: bash scripts/run_slip_rebuild_full.sh (WSL; into $W/slip_rebuild/full3). Slow injections: inject-slow then fit and eval-slow on $W/slip_rebuild/slow_inj. The correction check: tools/ppg_fix_check.py --method rebuilt --scan $W/sawtooth_char/scan_full --quality $W/slip_rebuild/quality --rates $W/sawtooth_stats/recordings.csv --modes $W/results/sync_full/snuadc_mode_label.json --rule $W/label_quality_final/summary.json --cases $W/ppg_correction_check/cases266.json --out $W/ppg_correction_check/check_rebuilt6_pP.jsonl --adopted-pat 0.27 --part P --of 2 --time-budget 140 (P = 0, 1, rerun until complete; $W/ppg_correction_check/run_rebuilt_chunk.sh), the parts concatenated into $W/ppg_correction_check/check_rebuilt6.jsonl, then tools/ppg_sawtooth_figures.py check --scan $W/ppg_correction_check/check_rebuilt6.jsonl --units $W/results/sync_full/units.csv --modes $W/results/sync_full/snuadc_mode_label.json --examples 2156 6241 1094 --out $W/ppg_correction_check/rebuilt6. Tier I: tools/tier_i_check.py --fit $W/slip_rebuild/full3/fit.jsonl --teeth $W/slip_rebuild/full3/tiers/teeth.csv --rates $W/sawtooth_stats/recordings.csv --creep $W/sawtooth_char/scan_full --out $W/slip_rebuild/full3/tier_i. The review: tools/correction_labels.py sample, eval, check and rescore. Teeth against injected ones: tools/tooth_check.py.

  • Beat quality. Each beat's QRS and R-aligned pulse against the local median beat (correlation at least 0.9 for both), regular R–R, no clipping; beats failing the gate leave the delay series (an ungated fit where fewer than 600 points remain). R peaks refined against the local QRS template.
  • Steps. The delay series of every foot, upstroke and peak; at each point a one-frame step against none, with the breathing modulation fitted as a nuisance term.
  • The tooth. A chain of strong steps one tooth apart (dynamic programming over tooth lengths 300–4,000 s and the setup's tooth as a prior); twice the tooth only if the slips it leaves out are clearly absent.
  • Judging each predicted slip. The pulse before and after: the shift that best aligns the two median pulses (a slip moves the pulse by a frame, about 31 ms, and leaves the QRS still) and how well they match after it; a rule fitted on the odd half of the labels (shape cannot be judged when more than half the beats are unlike the median beat or 10% have irregular R–R; a match of 0.95 after the best shift). A one-frame step at a predicted slip stands unless the pulse clearly did not move.
  • The arterial line and the heart rate. At each judged step, ECG→PPG, ECG→ART and ART→PPG and the heart rate 3–30 s either side. An arterial slip (ART→PPG steps 0.6–1.4 frames with ECG→ART flat, under 0.3 frame) confirms a step the shape could not judge; the circulation (ECG→ART steps 0.3 frame or more the same way as ECG→PPG, with ART→PPG under 0.6 frame) vetoes a step the shape did not confirm; without arterial confirmation, a heart-rate change of 20 /min or more vetoes.
  • Slips that cannot be timed. Where a predicted slip has slip-like evidence but cannot be placed, one slip in a 5–95% interval with a probability (tempered 0.05 for the probability and 0.02 for the times, set on the injections). Corrected as a ramp across the interval, weighted by the probability.
  • What counts as a sawtooth. Two confirmed slips. Where no sawtooth is fitted but confirmed slips exist, a search from them at the recording's own tooth (the spacing of two same-way slips; else frame ÷ drift when the recording creeps at 3 ppm or more; else the setup's median). A sawtooth found that way corrects its creep only when three or more slips are confirmed; on two, the tooth is reported and nothing is corrected.
  • Drift. Where no sawtooth is fitted, the delay's slope with a free step at each slip, reported (with its spread in slip-free recordings, 6.5 ppm), not corrected.
  • Tiers, per tooth: A, both edges confirmed slips; B, an edge a one-frame step the shape cannot judge; C, an edge placed only within an interval; U, unresolved (a weak predicted slip inside, a step the other way at an edge, or longer than 1.5 teeth); I, slips reported but not corrected (isolated slips, or a tooth from two slips); N, no slip.
  • The correction (physiosync 0.3.2 delay_at, tools/slip_tiers.py v6), chosen by the arterial check below: where a sawtooth's creep is corrected, each slip steps the delay a frame (a slip placed only within an interval by its probability, as a ramp across the interval), each stretch between two slips the sawtooth's way creeps back by exactly a frame over its own length, and the partial teeth at the ends at frame ÷ the fitted tooth; tier U teeth are held at the median, not corrected; tier I recordings are not corrected at all.
  • End to end against the arterial line (tools/correction_vs_art.py scan --scan $W/sawtooth_char/scan_full --fit $W/slip_rebuild/full3/fit.jsonl --out $W/correction_vs_art/v5_part_K.jsonl --part K --of 2, then agg): finger PAT minus arterial PAT, per beat (the R peak cancels), has no sawtooth of its own. Its spread (robust SD of 30 s window medians) under each correction, on every recording of the scan with an arterial upstroke on at least half its beats.

Results

  • End to end against the arterial line (2,976 recordings; $W/correction_vs_art/agg_v6, the same numbers as agg_v5). Spread of finger minus arterial PAT, median (IQR; 90th centile), and the share of recordings left more than 2 ms worse than uncorrected:
Recordings with a sawtooth (1,867) Spread, ms Worse than uncorrected
Uncorrected 13.95 (12.35–16.84; 21.95) —
Earlier method (physiosync detect) 11.17 (6.88–15.25; 21.99) 2.9%
Rebuilt, first version (0.3.1) 10.86 (5.91–22.02; 50.9) 28.9%
Rebuilt, final (0.3.2) 9.46 (5.70–14.67; 22.03) 7.3%

Over all 2,976 the final correction leaves a median 11.72 ms (earlier method 11.95, uncorrected 14.01) and improves 42.0% of recordings by more than 2 ms (earlier 40.3%). In the 866 recordings with slips but no corrected sawtooth (602 without a sawtooth, 264 with a tooth from two slips) it changes nothing, by design; the earlier method, which corrects some of them, improves their median by about 1–2 ms. The first version's errors had three causes, each found with this check: one creep rate for the whole recording (a tooth a few percent off adds up over the teeth), creep carried through unresolved stretches without slips, and steps corrected without their creep in tier I (which turns a sawtooth that stays within a frame into a ramp: worse than uncorrected in 45% of tier I and 69% of two-slip recordings). Its local checks (the step at each slip, the slope inside each tooth, the review of single teeth) could not see drift built up over a recording. The options were compared on the same recordings; the ranking is the same on odd- and even-numbered recordings.

A constant creep rate per recording is the physically plausible model (the rate is fixed per setup and stable within a recording, The PPG sawtooth and its correction), so it was tested too, with the rate taken from the slips themselves so that creep and steps balance from the first slip to the last (frame × net steps ÷ their time apart; const in the tool, $W/correction_vs_art/agg_v6). With the same other choices it is worse than closing each tooth on its own slips: median 10.62 ms against 9.46 in sawtooth recordings, 90th centile 22.96 against 22.03, 11.0% against 7.3% made worse. Neither rate is fitted to the PAT values, so physiology inside a tooth does not set it; a tooth's own spacing absorbs the effect of a missed, false or misplaced slip on that tooth, where one rate spreads it. - Held-out labels: 25 of 31 real slips found, 0 of 28 slip-free events called a slip (all 172: 51 of 63 and 1 of 59). The earlier physiosync fit, at the same events: 20 of 31 and 4 of 28. - The correction review (174 corrections): 151 judged right, 3 wrong, 20 can't tell: 98% of those decided right (A 58/1/3, B 38/0/3, C 3/1/5, U 30/1/3, I 22/0/6). Every correction judged right is kept by the final version. - The steps the reviewer drew as missed (36 in 24 teeth), checked on the arterial line: 6 are arterial slips (ART→PPG one frame, ECG→ART flat; 3 now found), 2 the circulation (ECG→ART moves; not found, as intended), 5 neither (sub-frame steps of 10–18 ms on the PPG side with ECG→ART flat; never corrected), 23 without a clean arterial line (16 frame-sized; several with heart-rate changes of 10–43 /min at the step). - Line checks cannot see a slip. Mains (60 Hz), the 240 Hz monitor line and the 30 Hz frame complete a whole number of cycles in one frame (2, 8 and 1), so a one-frame slip leaves no phase step in any of them. Dropped as a check, by reasoning rather than measurement. - Both directions are on the PPG side. At shape-confirmed slips with an arterial line, ECG→ART carries the step at 1% of upward and 4% of downward slips: reversed sawteeth are a PPG phenomenon too. - Fast injections (development set, all hosts): 616 slips found, 9 false; placement 95th centile 0.90 s (physiosync's earlier fit 2.46 s on the whole release); tooth within 2% in 97% of fitted injected sawtooths. Whole release: 1,897 of 2,252 found, 15 false (clean hosts 1,556 of 1,759, 11 false); placement 95th centile 0.92 s; tooth within 2% in 362 of the 375 fitted injected sawtooths whose creep is corrected. - Slow injections (120 hosts, 106 slips): 69 found, 9 false; of 15 hosts with two injected slips, 9 fitted as a sawtooth with the right tooth. The drift reported against the injected rate: median error −0.5 ppm (10–90% −13 to +7). - Tier I creeps: a slow sawtooth. On the final whole-release run tier I holds two groups ($W/slip_rebuild/full3/tier_i). 1,289 recordings have slips but no sawtooth (1,515 slips; 1,120 recordings with one); the arterial line confirms 87% of their slips where there is one (572 of 657); 1,017 have only upward slips, 157 only downward, 115 both. 453 are sawteeth whose tooth rests on two slips (1,000 slips; arterial line 61 slip, 19 neither); their fitted tooth has a median 33.6 minutes (IQR 22.9–47.7), 1.5 times the setup's (IQR 1.0–2.3). Measured as the delay's slope with a free step at each slip (upward recordings), both creep the sawtooth's way: a median 4.9 ppm (IQR −1.0 to 11.4) without a sawtooth and 9.5 (3.1–15.0) with a two-slip tooth, against 21.8 (12.4–37.7) in the other sawtooth recordings and 0.4 (−3.8 to 4.9) in recordings without a slip. Most are the setup's sawtooth running slowly, with one or two slips in 90 minutes. (On v22, before the two-slip teeth were split off, the gaps between same-way slips fell on whole teeth of the setup's tooth twice as often as at half teeth, 213 against 103 of 723; too few such gaps remain to test, 11 against 7 of 84.) - A tooth from two slips is often wrong. In v25, a sawtooth found from two slips' spacing had the wrong tooth in 9 of 22 injected whole-release recordings (a missed slip between them doubles it; a slip of another process shortens it), and its creep correction could then leave more error than none. From v26 such teeth report their creep; wrong teeth with creep corrected fall from 9 to 1 ($W/slip_rebuild/tooth_check_v26_anchored). Asking the same shape test at the midpoint did not help: it judged the missed slip "no slip" again. Since 0.3.2 such recordings are not corrected at all (the arterial check above). - The correction check (265 of the 266 recordings of The PPG sawtooth and its correction's check, final correction; $W/ppg_correction_check/rebuilt6): the 663 whole-frame steps corrected measure a median 31.9 ms before correction and −0.5 after (median size 2.0 ms; half way between steps, where there is no slip, 1.7). The slope inside the teeth falls from −28.6 to +1.2 ppm (154 recordings whose creep is corrected). The share of corrected steps leaving more than 15 ms is 3.2% for confirmed slips (18 of 556), 11% off the grid (6 of 56), and 3.2% half way between steps (17 of 524). The sawtooth's rate does not follow the SNUADC drift (|r| under 0.2 in every version; an earlier r = −0.22 is not reproduced). - An arterial gate is not supported (reasoned null, $W/slip_rebuild/dev/slip_rebuild_dev_v27.py, not adopted). Split by the arterial verdict, the corrections that leave more than 15 ms in the check are concentrated where a clean arterial line does not show a PPG slip: slips the other way without arterial confirmation (11 of 14; with it, 1 of 9) and off-grid slips where the line says "neither" (6 of 9). A version that stops correcting these (38 steps in the 324 development recordings) was scored on the evidence not used to set it: the held-out labels are unchanged, 3 injected slips are lost (616 to 613 found), and 4 corrections the reviewer judged right are dropped (two in case 3303, whose arterial upstroke moves with every slip) while both corrections judged wrong are still made. The check's 15-ms measure probably sees physiology at those steps. The corrections stand. - Whole release (v26, $W/slip_rebuild/full3): 5,714 recordings fitted, none failed; 3,642 with a sawtooth (275 reversed), 453 of them with their creep reported; 18,283 slips. By time, tier A 41.4%, B 4.2%, C 0.4%, U 12.2%, I 29.5%, N 12.3%; by each recording's worst tooth, A 1,379, B 419, C 46, U 1,345, I 1,742, N 783. Injected sawtooths fitted with a wrong tooth and their creep corrected fall from 21 to 13 ($W/slip_rebuild/tooth_check_full3); the 12 not from the anchored search are broad or setup-prior fits.

Parameter Value Status From
Finger minus arterial PAT spread after the PPG correction, all recordings compared 11.72 ms (IQR 7.18 to 16.62; n = 2976; 42% of recordings more than 2 ms better than uncorrected, 4.6% more than 2 ms worse) measured The rebuilt PPG slip finder and its correction
Finger minus arterial PAT spread after the PPG correction 9.46 ms (IQR 5.70 to 14.67; n = 1867; of 2,976 recordings compared; 7.3% left more than 2 ms worse than uncorrected (detect 11.17 ms, 2.9%)) measured The rebuilt PPG slip finder and its correction
Finger minus arterial PAT spread after the earlier PPG correction 11.17 ms (IQR 6.88 to 15.25; n = 1867; of 2,976 recordings compared; 2.9% left more than 2 ms worse than uncorrected) measured The rebuilt PPG slip finder and its correction
Finger minus arterial PAT spread, uncorrected, all recordings compared 14.01 ms (IQR 12.02 to 17.43; n = 2976) measured The rebuilt PPG slip finder and its correction
Finger minus arterial PAT spread, uncorrected 13.95 ms (IQR 12.35 to 16.84; n = 1867; of 2,976 recordings compared) measured The rebuilt PPG slip finder and its correction

Discussion

The rebuild trades a little recall for a large gain in confidence: on held-out labels it finds as many real slips as before and calls no slip-free event a slip, and nearly every correction a reviewer could decide was right. The evidence it adds is independent of the step itself: the pulse's shape tests the PPG chain alone, the arterial line splits the delay into its circulatory and PPG parts, and the heart rate flags physiology. What it leaves undone is deliberate: sub-frame steps on the PPG side are real (the arterial line is flat across them) but too small to separate from physiology, and the drift of recordings without a sawtooth is reported rather than corrected. The two-slip tooth is the clearest case of the rule: two slips fix the steps but not the creep between them.

Tier I changes the reading of "no sawtooth": most such recordings run the same sawtooth slowly, at a quarter to a half of the setup's usual rate, so a recording of 90 minutes holds one or two slips. Correcting their steps without their creep made them worse, so they are reported, not corrected; their error stays within about a frame.

The arterial check is the one test that sees the correction whole. It changed the correction more than any other: closing each tooth on its own slips, as the earlier method did, matters more than finding each slip precisely. The final correction is better than the earlier method for a typical recording and as good in its worst tenth, but it leaves more recordings worse than uncorrected (7.3% against 2.9%), and the arterial line is itself evidence inside both fits, so the check is not wholly independent.

Limitations

The development set contains the labelled events and the shape rule was fitted on half of them, so the held-out half and the injections are the honest measures. The injected sawtooths are written into slip-free recordings, which may be quieter than typical. The review covers 107 teeth from one fit; its "can't tell" share (11%) bounds what a reviewer can see in a delay trace. Without an arterial line (about half the recordings) only the pulse shape and the heart rate judge a step.

Open questions

  • Sub-frame steps on the PPG side (unexplained phenomenon). Five of the drawn misses are steps of 10–18 ms in ECG→PPG with ECG→ART flat: inside the PPG chain but smaller than a frame. Whether they are partial slips, a change of the monitor's PPG filtering, or something else is open; they are never corrected.
  • Slips the other way, and off the grid (next step). In the correction check, half the corrected slips against the sawtooth's direction (12 of 23) and 15% of the off-grid ones leave a step of more than 15 ms, against 4–6% for confirmed slips and for places without a slip. Some are probably not slips, or not whole ones. Requiring the arterial line for them is the obvious test.
  • Flag steps the arterial line does not confirm (next step). Rather than drop them, the teeth beside a slip the other way without arterial confirmation, or an off-grid or unjudged step where a clean line says "neither" or "circulation", could be marked tier U, so a user can leave those intervals out. Deferred until after v2.
  • Mixed directions in tier I (next step). 185 tier I recordings (v22) have isolated slips both ways: a reversed sawtooth starting or stopping, two processes, or transients.
  • The remaining wrong corrections (next step). Two corrections the reviewer judged wrong are still made: one a slip the other way, one a 23 ms step.
  • A separate methods paper (next step). The method, its three checks and the slow sawtooth are enough for a paper of their own; this page would then summarise it.

Worked examples

Example Side Status Summary
Pulse arrival time against blood pressure, before and after synchronisation time current In 3,270 recordings, PAT tracks systolic pressure only once each pulse is paired with its own beat: the hourly correlation moves from a mean of −0.05 to −0.21 (88% of recordings negative), reproducing Ruffolo et al. 2025 in a second dataset; paired naively, PAT is a heart-rate signal.
Pulse arrival time in two correction steps time current As stored, the ECG-to-finger PAT in VitalDB is about 0.72 s, far beyond any physiological value, because a device delay of about 0.39 s and a frame-slip sawtooth sit inside it. Removing the sawtooth narrows finger minus arterial PAT from 13.6 to 11.1 ms in the median case, and removing one global delay brings PAT to about 0.33 s to the upstroke, keeping the differences between patients.

Code

Figures

Three long PAT traces of measured and corrected values beside six aggregate histograms and scatter plots.
The final rebuilt correction on the cases of The PPG sawtooth and its correction's check (case 2156, case 6241, case 1094, panels a–c; grey the corrected slips, orange dashed slips placed only within an interval, corrected as ramps). Across 265 recordings the 663 whole-frame steps corrected shrink from 31.9 ms to −0.5 ms (median) and the slope inside the teeth from −29 to +1 ppm (154 recordings whose creep is corrected); the sawtooth rate groups by setup, not by SNUADC drift (panels d–i).