The stamp sawtooth model for SNUADC and BIS¶
Fitting each track's record stamps against its sample count as a drift with corrections (a sawtooth) puts SNUADC and BIS on one timeline without any artefact. Checked against shared bursts, the EEG–ECG timing error falls from about 790 ms on the recorded stamps to 33 ms with one constant per SNUADC mode in the pilot, and 40 ms over the whole release.
| Date | 2026-11-09 |
| Status | current |
| Methods | Reading the stamps, One event, two clocks |
| Techniques | Sawtooth fit, Windowed cross-correlation |
| Clocks | SNUADC sample clock, BIS clock, Recorder PC clock |
| Devices | SNUADC, BIS monitor, Vital Recorder |
| Variables | ECG lead II (SNUADC), BIS EEG |
Background¶
Between corrections a device stamps by its own sample count, so the offset between two devices ramps at the difference of their clock rates; the corrections pull each device back towards the recorder's clock. Both are visible in the stamps alone (Shared bursts between the ECG and the EEG).
Data¶
191 benchmark cases with BIS; validation on 143 cases with at least 5 good burst windows each way, and on 3,683 ten-minute windows in 165 cases. Later refitted on 250 cases with the signal lost at each SNUADC reset. Rerun on the whole release (19 October): all 5,520 recordings with ECG II and BIS EEG; with model3, 36,928 good burst windows in the 2,710 recordings with at least 5. Rerun on 9 November with setup-rate fallbacks (model4): 36,937 good windows in 2,716 recordings; and again that evening with the no-correction rate bound (model5, adopted): 36,946 good windows in 2,717 recordings.
Method¶
physiosync's stamp_clock takes each record's stamp minus the time given by the sample count. It estimates one rate
per recording from whole teeth (the drift each correction removes, divided by the time since the last), then one
offset per stretch between real gaps; corrected_times places every sample on that line. VitalDB rules: SNUADC
corrects downwards and BIS upwards, and steps the other way are gaps; a SNUADC track in frequent-correction mode
keeps its stamps. A step-mode track without a whole tooth takes its recording station's (setup's) rate, the median
of the setup's whole-teeth rates where it has at least 5, else its port's typical rate; a BIS track without one
takes its unit's mean rate, else its setup's, else its port's (model4, 9 November; vitaldb-bench
tools/fallback_rate.py). A SNUADC track with no correction at all can have gained less than 0.5 s over each
stretch between gaps: Vital Recorder re-anchors the count when it runs more than 0.5 s ahead of the recorder's
clock, and inserts blank samples when it falls behind (Lee 2026). So its borrowed
rate is capped at 0.5 s over its longest stretch (model5, 9 November; examples/snuadc_rate_bound.py
found 1,040 of 3,410 such recordings whose borrowed rate broke the bound, and a median drift left of +111 ms/h in
those without gaps). Until then (model3) a step-mode SNUADC track took its port's rate, which is poor where one
port serves stations whose converters differ, and a BIS that made corrections without a whole tooth kept
stamp_clock's line fit, which is not a rate (physiosync 0.3.4 rate_measured). Since 17 October the 17.7 ms lost at each SNUADC step-mode
correction is added back (Paced ECG as an independent clock).
Fallback rates: python tools/port_rates.py $W/correction_census/part_*.jsonl --ports $W/setups/ports.jsonl
--out-snuadc $W/port_rates/snuadc_step_rates_v3.json --out-bis $W/port_rates/bis_port_rates_v3.json --setup-min 5
--snuadc-ports-from $W/results/pat/snuadc_step_rates.json. Whole-release burst validation: P=4
STEP_RATES=$W/port_rates/snuadc_step_rates_v4.json BIS_RATES=$W/port_rates/bis_port_rates_v3.json bash
tools/run_burst_validation.sh model5 burst_validation_m5 (about 30 minutes; snuadc_step_rates_v4.json is v3 with
"no_correction_bound_s": 0.5), then python
tools/burst_validation_agg.py --inp $W/burst_validation_m5 --modes $W/results/sync_full/snuadc_mode_label.json
--ports $W/results/sync_full/snuadc_mode.json --variant model5 --out $W/burst_validation_m5. The BIS forms'
numbers: python tools/bis_numbers.py --stamps $W/burst_validation_stamps --model $W/burst_validation_m5
--model-variant model5 --out $W/bis_numbers/bis_numbers_m5.json. The bound check: python
examples/snuadc_rate_bound.py --modes $W/results/sync_full/snuadc_mode.json --step-rates
$W/port_rates/snuadc_step_rates_v3.json --burst $W/burst_validation_m4b/per_recording.csv --out
$W/port_rates/snuadc_rate_bound.json (on the uncapped rates and model4b on purpose: it is the check that led to
the cap).
How late the raw stamps sit: python tools/snu_raw_offset.py scan --root $R --units $W/results/sync_full/units.csv
--step-rates $W/port_rates/snuadc_step_rates_v3.json --every 10 --out $W/snu_raw_offset_v3/part.jsonl (resumable;
about 5 minutes), then python tools/snu_raw_offset.py agg $W/snu_raw_offset_v3/part.jsonl --out $W/snu_raw_offset_v3.
The error-by-level figure compares, on the same whole-release windows, the recorded stamps and the adopted model:
python tools/stamp_error_levels.py --stamps $W/burst_validation_stamps --model $W/burst_validation_m5 --variant
model5 --modes $W/results/sync_full/snuadc_mode_label.json --out $W/stamp_error_levels_m5 (summary.json and the
figure).
The validation figure then adds six example recordings, the constants by mode and the within-recording SDs:
python tools/burst_figures.py validation --stamps $W/burst_validation_stamps --model $W/burst_validation_m5 --variant model5
--modes $W/results/sync_full/snuadc_mode_label.json --levels $W/stamp_error_levels_m5/summary.json --out
$W/burst_figures_m5.
Results¶
- Whole teeth on 151 SNUADC and 184 BIS tracks of 191; the rates agree with the correction scan where that is plausible.
- Within-case SD of the EEG–ECG offset: 137 ms on the recorded stamps, 25 ms on the model (median); the bursts' own noise floor is about 11 ms. Ramps flatten (median slope 53 → 12 ms/h) and lag jumps fall from 1.5 to 0.38 per case.
- A constant offset is left: EEG minus ECG −803 ms in step mode (117 cases) and −690 ms in frequent-correction mode (29 cases), tight within a port or unit.
| Correction | Median error | p90 |
|---|---|---|
| Recorded stamps | 792 ms | 1,005 ms |
| Stamps minus one constant | 126 ms | 259 ms |
| Model minus one constant | 38 ms | 154 ms |
| Model minus the SNUADC mode's constant (leave-one-out; no artefact needed) | 33 ms | 116 ms |
| Model minus the case's own constant from its bursts | 16 ms | 67 ms |
| Whole release (19 October). The model's ECG–EEG burst check, rerun on every recording | ||
(tools/burst_validation_agg.py): |
- The constants hold: EEG minus ECG −804.5 ms in step mode (1,530 recordings; interquartile range −835 to −776) and −667.5 ms in frequent-correction mode (78), against −803 and −690 ms on the benchmark.
- Where both clocks have whole teeth (377 recordings) the result matches the benchmark: within-recording SD 18 ms, drift left 8.7 ms/h (median absolute slope). Against the step-mode constant, a typical window is off by 25 ms (median; p90 82 ms), against 35 ms (p90 135 ms) over all 1,530 step-mode recordings.
- Recordings with no SNUADC correction at all (1,099) were the weak spot. The first model read them as frequent-correction mode and gave the SNUADC no drift, but their EEG–ECG offset drifted by a median of −176 ms/h, the step-mode drift: these are step-mode recordings that end before the first reset.
- Giving them their port's step-mode rate fixes most of it (model2, rerun on every recording,
tools/sa_corrected.py). For these 1,096 recordings:
| Drift assumed 0 | Port's step-mode rate | |
|---|---|---|
| Within-recording SD (median) | 62 ms | 25 ms |
| Drift left (median slope) | −176 ms/h | −11 ms/h |
| Drift left (median absolute slope) | 183 ms/h | 74 ms/h |
| Error against the mode's constant (median; p90) | 81; 208 ms | 63; 177 ms |
What is left is spread both ways (p10–p90 −135 to +122 ms/h): each recording's SNUADC drifts at its own rate, not its port's median. - The same for the BIS (model3). A BIS that makes no correction also got zero drift. Giving it its port's median BIS rate against the recorder PC (+16 to +50 ppm by port, from the correction steps of the full release, never from the bursts) fixes the 236 recordings where that happens:
| BIS with no correction | Recordings | Drift left (median), model2 → model3 | Within-recording SD |
|---|---|---|---|
| Shorter than the 8,192 s BIS timer | 202 | −92 → −16 ms/h | 21 → 17 ms |
| Longer | 34 | −66 → −14 ms/h | 32 → 28 ms |
Over all recordings the gain is small (within-recording SD 23.9 → 23.4 ms; median absolute slope 42.6 →
40.3 ms/h), because few recordings are affected.
- Over all 2,707 recordings with model2: a median error of 42 ms against the mode's constant and 18 ms against
the recording's own constant (p90 151 and 79 ms); within-recording SD 24 ms (first model: 46, 22, 166, 106 and
34 ms).
- The previous model (model3, 19 October), over all 2,710 recordings with at least 5 good windows: EEG minus
ECG −804 ms in step mode (1,526 recordings; interquartile range −833 to −776), −660 ms in frequent-correction mode
(78), and −766 ms with no SNUADC correction (1,099). A median error of 42 ms against the mode's constant (p90 150
ms) and 17 ms against the recording's own constant (p90 79 ms); within-recording SD 23 ms. (The first bullet above
is the first model, before the recordings with no correction were given a rate.)
- Model4 (9 November): setup rates before port rates, and no line fits. Over 2,716
recordings: EEG minus ECG −805 ms in step mode (1,531; interquartile range −834 to −781), −665 ms in
frequent-correction mode (78) and −769 ms with no SNUADC correction (1,100). A median error of 40 ms against the
mode's constant (p90 145 ms) and 15 ms against the recording's own constant (p90 75 ms); within-recording SD 20 ms;
the drift left over a recording a median 28 ms/h (model3 40 ms/h; p90 127 against 130). A recording station's rate predicts a
recording's own rate to a robust SD of 0.75 ppm for the SNUADC and 1.45 ppm for the BIS
(examples/setup_rate_check.py); where a SNUADC track took its setup's rate the drift left
fell from a median 48 to 27 ms/h (750 recordings) and from 28 to 15 ms/h (243 with the BIS on its own teeth). Port
rates rebuilt from whole teeth alone made the recordings that still fall back to a port worse (their stations, too
slow to collect whole teeth, drift more slowly than the fast stations those medians are made of), so the adopted
rates keep the earlier port values with the new setup table (first model4 run against the adopted one,
$W/port_rates/m3_m4_compare.json and m3_m4b_compare.json).
- The adopted model (model5, 9 November): model4 with the no-correction rate bound. Only the 304 recordings
whose SNUADC rate was capped change: their drift left falls from a median 103 to 44 ms/h (p90 168 to 116;
signed, +100 to +35 ms/h, so the true rates sit somewhat below the bound, which is a maximum), better by more than
20 ms/h in 217 and worse in 13; every other recording is unchanged ($W/port_rates/m4b_m5_compare.py). Over 2,717
recordings: EEG minus ECG −805, −665 and −769 ms as in model4 (1,531, 78 and 1,101 recordings). A median error of
40 ms against the mode's constant (p90 138 ms) and 15 ms against the recording's own constant (p90 66 ms);
within-recording SD 20 ms; drift left a median 25.4 ms/h (p90 115). These are the values in
EEG–ECG constant after the stamp model and EEG–ECG timing error after the stamp model.
- How late the raw stamps sit (3 November, rerun 9 November with model4's rates; tools/snu_raw_offset.py). On every tenth
recording (637 with ECG II), each record's stamp minus the model's time for it, with a stamp just after a
correction taken as on time: step-mode recordings (257) sit a median 0.24 s late (p5–p95 0.03–0.49 s; tooth
height a median 0.50 s, p90 0.63 s; with port rates 0.26 s, 0.03–0.55 s, p90 0.70 s), small-correction-mode
recordings (380) within 13 ms. The SNUADC waveforms therefore have one raw-stamp form per mode
(snu-raw-step and snu-raw-frequent; for PLETH, pleth-raw-step and pleth-raw-frequent, with the oximeter's delay
added), replacing a single form whose 0.24 s (0.01–0.47 s) described step mode only. Pooled over both modes the
lateness is 0.07 s (0.003–0.47 s), a figure for no recording in particular.
What this looks like in one recording, together with the Primus:
| Parameter | Value | Status | From |
|---|---|---|---|
| BIS drift against the recorder PC | 25 ppm (p10–p90 12 to 50; 5th–95th 7.3–51.1 ppm; census fit of 4,728 recordings median 21.1 ppm) | measured | The stamp sawtooth model for SNUADC and BIS |
| SNUADC step-mode drift | −63 ppm (p10–p90 −79 to −44; 5th–95th −80.3 to −36.9 ppm; medians of −46 to −74 ppm by serial port) | measured | The stamp sawtooth model for SNUADC and BIS |
| EEG–ECG constant after the stamp model | −805 ms in step mode (1,531 recordings); −665 ms in frequent-correction mode (78) | measured | The stamp sawtooth model for SNUADC and BIS |
| SNUADC raw stamps in frequent-correction mode | 0.007 s (p5–p95 0.003 to 0.013; n = 380; 380 recordings, 15.1 million records; snu_raw_offset_v4/summary.json (small, anchored; v4 rates, 10 Nov, recorded run; the same in the 3 Nov and 9 Nov runs)) | measured | The stamp sawtooth model for SNUADC and BIS |
| SNUADC raw stamps in step mode | 0.24 s (p5–p95 0.03 to 0.49; n = 257; 257 step-mode recordings, 20.7 million records; snu_raw_offset_v4/summary.json (step, anchored; v4 rates, 10 Nov, recorded run, identical to the 9 Nov v3 run); with port fallback rates (3 Nov) 0.26 s, 0.03-0.55 s) | measured | The stamp sawtooth model for SNUADC and BIS |
| SNUADC step-mode correction interval | 2.08 h (5th–95th 1.65–3.57 h between resets; per-recording means p10–p90 1.68–3.07 h) | measured | The stamp sawtooth model for SNUADC and BIS |
| EEG–ECG timing error after the stamp model | median absolute error 40 ms, p90 138 ms; standard uncertainty 59 ms (robust SD, an upper bound); with the recording's own bursts 15 ms median, 25 ms SD | measured | The stamp sawtooth model for SNUADC and BIS |
Discussion¶
The model needs no artefact; the bursts only check it and supply the constant. With the constant for the case's SNUADC mode, a typical window lines up to about 40 ms over the whole release (33 ms in the pilot); with the recording's own bursts, to about 15 ms. These are the numbers behind the BIS EEG "after sync" timing in the planner.
Observations it supports¶
| Observation | Status | Summary |
|---|---|---|
| About 20 ms of signal lost at every SNUADC reset | established | At each step-mode reset the acquisition pauses for about 20 ms inside the last record before the new timing, and that time is never sampled: about 19 ms on the sample count (17.3–20.3 ms; Signal lost at a SNUADC step-mode correction), about 2 ms more once the filler sample is counted. Every record still holds 100 samples, so nothing in the file shows it. |
| SNUADC sends no time; the recorder stamps by count | established | The SNUADC board streams samples with no time stamps. Every SNUADC time in VitalDB is the recorder's model of the board's clock: the sample count at the nominal rate, pulled back when it drifts too far. |
| The EEG–ECG offset is fixed by the SNUADC correction mode | established | After the stamp model, BIS EEG stamps still sit early against the SNUADC ECG by a constant (EEG minus ECG): −805 ms in step mode and −665 ms in frequent-correction mode over the whole release, tight within a port or unit. The mode, a property of the setup, sets the constant. |
Limitations¶
Recordings that change correction mode partway, or have many gaps, still fail (p99 about 250 ms). The error distributions come from the bursts, so they include the probe's own noise.
Open questions¶
- Recordings without a SNUADC correction (next step). Giving the 1,096 recordings without a SNUADC correction their port's step-mode rate removed most of their drift (median −176 to −11 ms/h), but each still drifts at its own rate (p10–p90 −135 to +122 ms/h left). A per-recording rate cannot come from the stamps: with no correction they carry no information about the recorder PC (the census gives −1.0 ppm, the stamp arithmetic, for all of them). It needs a clock tied to the PC that shares events with the SNUADC (bursts against a BIS with whole teeth, in 122 recordings; calibration, so tested on held-out windows), or the setup's unit. Where the BIS has teeth the bursts imply the SNUADC drifts about −36 ppm rather than −63, the fast-BIS, slow-SNUADC pattern of When each device's clock is corrected, in every recording's open question. Vital Recorder's re-anchoring rule now bounds the rate from the stamps' silence: with no correction the converter gained less than 0.5 s over each stretch, which model5 uses as a cap (Lee 2026); the drift left by capped recordings suggests their rates sit a little below it.
- Recordings that change correction mode partway (unexplained phenomenon). Recordings that change correction mode partway still fail the model (p99 about 250 ms). Why a recording changes mode, and how to fit both parts, is open.
- Why the constant offset differs between modes (unexplained phenomenon). The EEG stamps sit −0.80 s from the ECG's (early) in step mode and −0.67 s in frequent mode after the model (whole release; −0.69 s in the pilot); why the constant differs between modes is not known.
Worked examples¶
| Example | Side | Status | Summary |
|---|---|---|---|
| Pulse pressure variation gated by ventilator breaths | time | current | Pulse pressure variation per ventilator breath, in 3,448 recordings: the ventilator's clock sits a median 1.8 s off the arterial line's, which moves half of all breaths' values by a point or more and scatters where in the breath the pulse pressure peaks; a recording's median PPV hardly changes. |
Code¶
- physiosync:
physiosync/stamps.py - vitaldb-bench:
tools/sa_corrected.py,tools/clock_model_fit.py,tools/burst_validation_agg.py,tools/stamp_error_levels.py,tools/fallback_rate.py,tools/port_rates.py,tools/bis_numbers.py,examples/setup_rate_check.py,tools/burst_figures.py,tools/snu_raw_offset.py,examples/snuadc_rate_bound.py
Figures¶