vitaldb-bench¶
The timing and data-quality audit of VitalDB: the scripts behind most studies in this atlas, the clock model and corrected-time reader, the per-case labels, and resumable TimeNet builds with their fidelity checks.
| Repository | github.com/metrology-atlas/vitaldb-bench |
| Branch | main |
| Visibility | public |
| Licence | MIT |
| Language | Python 3.11+ |
| Related | vitaldb-reader, TimeNet, physiosync, lineaccess, vitaldb-resolution |
What it is¶
vitaldb-bench measures how far every time stamp in the VitalDB release can be trusted, and builds databases that carry what was found as labels. It has two halves.
- The installed package (
vitaldb_bench) builds TimeNet databases from the .vital files in short, resumable chunks, reads tracks back out, checks every stored value and time against the source files, and benchmarks the builds. It also holds the clock model and a corrected-time reader: a view of a build in which every SNUADC and BIS sample carries its corrected time and an error distribution. - The analysis scripts (
tools/) produced the tables and figures of the timing audit. Each reads the .vital files directly, writes per-case output that stays on the analysis machine, and then aggregates it. Only aggregates and figures are published (results/).
Its scripts read the .vital files with vitaldb-reader and also use physiosync (timing corrections) and lineaccess (pressure-line accesses); the builds also need TimeNet.
No VitalDB data are in the repository: only code, aggregate results and figures. To reproduce a result,
download the release from PhysioNet and point the scripts' --root at it.
Its part in the atlas¶
Most studies in this atlas were run with its scripts, and the Code section of each study names them. Several atlas pages come straight from it:
- The timing budget behind the synchronisation planner is the model in
tools/pair_timing_budget.py: each source's offset range and interval became one standard deviation (the atlas now uses each form's uncertainty budget instead), and the planner's coherence limit, grid and window sizing follow from it. - The home page's timing chart began as the 'accuracy against resolution' figure of
tools/time_source_accuracy_figure.py; the atlas now draws bias against standard uncertainty from its own data (the old script is kept under its cited name). - The clock fits that the The stamp sawtooth model for SNUADC and BIS study validated are made by
tools/clock_model_fit.pyand read through the correct package. - The time of day of each case (Recovering the time of day) is recovered by
vitaldb_bench/case_clock.py.
The atlas is meant to become the single source of these numbers: the plan is for the package and scripts to read the atlas JSON rather than keep their own copies.
Install¶
pip install -e . # the package: numpy, vitaldb-reader, timenet, timenet-connectors
pip install -e ".[tools]" # plus the analysis scripts' dependencies (scipy, pandas, physiosync, lineaccess, ...)
pytest -q
Each script's docstring gives its commands and says what it reads and writes;
python tools/<script>.py --help lists its options.
What is in it¶
The package¶
build.py |
Resumable TimeNet builds in time-boxed chunks, with a choice of how samples are placed in time. |
stores.py |
Reads a track of a case back out of a build, in a common shape for comparison. |
fidelity.py |
Checks every stored track of every built case against the shared reader, value by value and time by time. With the reset reordering on, the reference is reordered the same way. |
perf.py |
Size, read-speed and downstream-equivalence benchmarks of two builds of the same cases. |
clock_model.py |
The clock model: per-track fit tables written beside a build, and a corrected view of a TimeNet build. Each fit records the sample order it was made on. |
correct/ |
Timing correction applied when data are read: clock models (clock.py), error distributions (dist.py) and the reader CorrectedStore (layer.py), which refuses a fit made on a different sample order. |
case_clock.py |
Recovers each case's clock time of day; the date stays hidden. |
label_families.py |
The derived label families (delay groups, line accesses, lab draws, BIS smoothing ...): where each family's rows come from and what its labels mean. |
timenet_labels.py |
Writes the label families into a TimeNet build as record annotations. |
timing_report.py |
Per-track summary of the rates a resync-timed build estimated (aggregates only). |
Scripts not tied to one study¶
pair_timing_budget.py |
Timing budget for combining two or more time sources: the model the atlas planner implements. Reads no data. |
time_source_accuracy_figure.py |
The original 'accuracy against resolution' figure for every kind of time stamp (superseded). |
timestamp_resolution.py |
Temporal resolution of every kind of time stamp (aggregates only). |
device_map_figure.py |
The device and timing-relationship diagram used as the system overview. |
sync_figures.py |
Redraws the clock re-synchronisation figures of the drift document from cached per-case rows. |
gen_tools_page.py |
Writes the scripts reference page from each script's docstring. |
Folders and documents¶
tools/ |
All analysis scripts (about 90). Short provenance helpers are in tools/adhoc/. |
results/ |
Aggregate results and figures only; no per-case data. |
scripts/ |
Shell drivers for time-boxed build chunks. |
| Scripts reference | Every script in tools/ with what it does. |
| Reproduce the results | Which script made which file in results/, and the two-step pattern (per-case pass, then aggregate). |
| Corrected times | Reading a build with corrected times and their uncertainty. |
| Timing budget | Planning a multi-signal analysis (the text behind the planner). |
| Availability | The availability rule: no value may be used before it could have been known. |
| Timing modes | How builds place samples in time (nominal, file, resync) and what each costs. |
| VitalDB timing guide (PDF) | The longer write-up of the timing audit. |
Studies that use it¶
| Study | Code | Summary |
|---|---|---|
| Anaesthesia record times are rounded up | tools/emr_markers.py |
Anaesthesia start and end entered on a 5-minute mark sit 90–290 s later, against device markers, than entries typed to the minute. Rounding up to the next 5 minutes fits every one of 11 markers better than rounding to the nearest or down. |
| Arterial line accesses in the pressure waveform | tools/line_access_scan.py, tools/lab_draw_labels.py |
Flushes, zeroing and blood draws leave clear signatures in the arterial pressure. A detector finds them in the waveform alone (about one access per hour) and matches 77% of lab draws to an access within 15 minutes, against 26% for random times. |
| Arterial pressure against the monitor's 240 Hz cycle | tools/art_cycle_and_co2_grid.py, tools/art_cycle_and_co2_grid_plot.py |
The arterial pressure's steps follow a 240 Hz output cycle that runs 23–55 ppm off the SNUADC clock. If its timing followed that cycle it would slide against the ECG by 4.17 ms each turn, or drift by up to 200 ms an hour. Neither happens: arterial pressure keeps time with the ECG to within about 1 ms. |
| Arterial pressure as a check on the PPG correction | tools/art_check.py, tools/ppg_slips_art_check.py |
Arterial pressure is sampled by the same converter but has no frame and no sawtooth, so every PPG slip leaves ECG→ABP unchanged. Against it, detected slips are 97–100% real and tier A leaves about 2 ms of drift mid-tooth. |
| Blood-gas analyser against the central laboratory, on the same draw | tools/lab_bg_vs_central.py |
Sodium, potassium, glucose and haematocrit from the theatre blood-gas analyser against the central laboratory, in 1,248 pairs where the central panel was stamped within 15 minutes of the blood gas. The blood gas reads lower: sodium by 3.0 mmol/L, potassium by 0.3 mmol/L, haematocrit by 0.7 points and glucose by 4 mg/dL (medians). Each lab variable holds both analysers' results, so a pooled analysis mixes these offsets. |
| Body mass index, derived from its inputs | tools/bmi_spread_figure.py |
Body mass index computed from the posteriors of height, weight. |
| Clock corrections in every file | tools/syncscan.py, tools/syncanalyze.py, tools/frequent_steps_summary.py |
A scan of all 6,388 files for the jumps where the recorder re-synchronises a device's stamps. Each device type has its own correction signature; only SNUADC and BIS correct clearly enough to measure their drift. |
| Closing loops in the timing graph | tools/loop_closure_art.py, tools/clock_edges.py, tools/solar_length_check.py, tools/clock_reconcile.py, tools/clock_reconcile_figs.py, examples/solar_route_check.py, tools/primus_drift_probe.py |
Where two independent routes reach the same clock, the offsets around the loop must sum to zero. Three measured loops close within their noise; the BIS loop closes up to a constant latency; the proposed EMR loop is not a loop at all. Adjusted as a network over the whole release, every loop type closes on average, including two that reach the SNUADC through the PC-stamped Solar8000 numerics instead of its own stamps. |
| Cuff against arterial mean pressure, paired at the cuff's moment | examples/cuff_vs_arterial.py, examples/run_scan.sh |
12,238 cuff readings against the arterial line in 2,283 patients. A cuff reading belongs to its stamp. Over the cohort the cuff has no bias at any pressure, but each patient's cuff sits a constant offset from their line (SD 10.2 mmHg between patients), as large as the scatter within a patient (SD 9.4 mmHg). |
| Drug effects as a clock check | tools/drug_effect_latency.py |
Infusion pumps, the rapid infuser and the cerebral oximeter share no waveform with the reference. Drug effects that follow infusions at plausible delays (propofol to BIS in about 2 minutes, fluid to CVP in about 30 s) bound their clocks to well within a minute of the recorder. |
| End-tidal and arterial CO₂, and SpO₂ and SaO₂, compared at the draw | examples/blood_gas_gradients.py |
4,281 blood gases compared with the monitor at the estimated draw. Within patients, changes in arterial CO₂ follow changes in end-tidal CO₂ with a correlation of 0.74 at the draw against 0.54 at the lab stamp, and agreement peaks at the draw for CO₂ and for oximetry. PaCO₂ − EtCO₂ is a median 7 mmHg, set mostly by each patient; SaO₂ − SpO₂ is hidden by the 100% ceiling for three gases in four. |
| Finding and placing each PPG frame slip | tools/sawtooth_char.py, tools/slip_concept_figure.py |
First of a series characterising the ECG–PPG sawtooth in detail (with The PPG sawtooth and its correction as the overview, The PPG sawtooth's period, its phase jumps, and the reversed sawtooth and Where the PPG sawtooth stops next). A new detector tests every point of a series of three fiducials per pulse for a sharp, persistent step of exactly one frame, confirms it against arterial pressure, uses the grid of the other slips and the earlier fit's slips as priors, and places each slip between two fiducials. Built on a benchmark of 273 recordings and run on all 5,714 with ECG lead II and PLETH. On held-out injected ground truth in 219 recordings it finds 88% of slips (the earlier fit 89%) with 3 false slips (the earlier fit 38) and places them two and a half times as closely. It also finds slips that lose a frame instead of gaining one. A blinded manual labelling of 172 real events, weighted to the whole release, puts its precision at 0.95 against 0.72 for the earlier fit, and its recall at 0.88 against 0.94. The final slip finder and correction, built on this detector, are in The rebuilt PPG slip finder and its correction. |
| Gaps and unbroken segments in every waveform | tools/signal_events.py, tools/signal_events_collect.py, tools/continuity_figs.py, tools/continuity_sync.py |
Every gap and every unbroken segment in the 6,388 recordings, per waveform. The curves are not smooth: a cliff at about 18 s in every device but the CardioQ marks the recorder's pauses, SNUADC segments stop at 5 hours, Primus segments at about 2.0 hours and BIS segments at about 2.3 hours (each device's correction cycle), and BIS's short gaps grow with the time since the last one (clock resynchronisations, not lost data). |
| How often each device is corrected | tools/clock_correction_periods.py |
The devices re-synchronise in different ways: SNUADC when its drift reaches about half a second, BIS on a fixed 8,192 s timer, and the Primus by small steps about every two hours that do not keep up with its drift (+105 ppm, measured later by breath matching). |
| How the BIS index trails its EEG | tools/bis_index_delay.py, tools/bis_smoothing_labels.py |
Modelling the BIS index as a lagged mix of EEG features shows a trailing average that ends about 3 s before the index's stamp, after its EEG window ends: about 16 s long in half the cases (the 15 s smoothing setting) and about 30–60 s in most others. Half the response weight is older than 30 s. |
| How the Primus AWP is stamped, and which breath the lag locks onto | tools/primus_awp_anchor.py, tools/primus_sync_accuracy.py, tools/primus_breath_id.py, tools/primus_vent_events.py, tools/primus_breath_rule.py, tools/primus_numbers.py, tools/primus_awp_anchor_figs.py, tools/primus_anchor_check.py, examples/ppv_by_breath.py |
The Primus airway-pressure stamps are an anchor plus a sample count; the anchor holds across the regular pauses and is reset, with an error of up to about ±2 s, at irregular gaps. Separately, about a quarter to a third of the stretches in the release-wide breath matching were measured a whole breath off, which inflated the apparent per-recording offset. Each stretch's breath is now set from pauses in ventilation or a rule, and the breath error that remains is stated on its own. Most of the AWP's lead over the breath is real on the recorder's timeline, bounded by the PC-stamped PIP numerics. |
| How the Primus airway pressure is written at 62.5 Hz | tools/waveform_survey.py, tools/primus_awp_repeats.py, tools/primus_awp_records.py, tools/primus_awp_vs_co2.py, tools/primus_awp_sim_chain.py, tools/primus_awp_sim_score.py, tools/primus_awp_sim_queue.py, tools/primus_awp_repeats_plot.py |
About one stored airway-pressure sample in nine repeats the previous one, in a fixed pattern of lines that is the same in every recording and does not drift. It is made before the data reach the file, by a scheme tied to the Primus clock but separate from CO₂'s, and not a plain hold, cascade or queue. A stored value is at most about one sample old. |
| How the Solar8000 computes its heart rate | tools/hr_derivation.py |
Solar8000 HR recomputed from the ECG's R peaks in 633 recordings: 60 over a mean of the last 8 R–R intervals that leaves out intervals far from their median, truncated. It beats a median of the same intervals in 599 recordings and the neighbouring windows of 7 and 9 intervals in most. The window is 6.6 s of ECG at the median rate, so HR's support is a count of beats, not a span of seconds. |
| How the Solar8000 computes its pulse rate | tools/pleth_hr_derivation.py, examples/run_scan.sh |
PLETH_HR recomputed from the plethysmogram's pulses in 6,151 recordings: a mean of the last 10 pulse intervals that leaves out intervals far from their median, rounded, ready 3.7 s after the window ends (5th–95th percentile 2.6–4.8 s) and stamped at the next 2 s poll. It wins in 99% of the recordings reproduced best. Its window is centred about 8.9 s before the stamp, further before the stamp (earlier) than the atlas's earlier form for it assumed (7.8 s); the comparison with heart rate puts it at 9.5 s, an open question. |
| How the Vital Recorder stamps SNUADC records, tested against the release | tools/vital_recorder_rules_check.py |
The Vital Recorder counts SNUADC samples from the PC time and compares the count with the PC clock at every read: a count behind by up to 0.5 s is filled with blank time, one behind by more starts a new segment, and one ahead by more than 0.5 s loses its excess samples and restarts from the PC time. These rules account for all three SNUADC modes in the release: step mode is a fast converter, frequent-correction mode a slow one, and a recording with no correction a fast one that never gains half a second within a segment. |
| How the monitor numerics are computed, over the whole release | tools/numeric_derivation_pilot.py, tools/numeric_derivation_agg.py, tools/numeric_derivation_readout.py, tools/spo2_event_pilot.py, tools/spo2_event_agg.py, examples/stage3_batch2_compare.py |
The numeric-derivation pilot repeated on every recording (6,388) and the SpO₂ dropout timing on 6,152. Each numeric describes a short window that ends before its stamp: HR 8 beats (How the Solar8000 computes its heart rate), pleth HR about 10 beats, arterial pressure 2–4 beats, CVP about 5 s, ETCO₂ and PIP one breath, RR about 30 s. Solar8000 HR is truncated, not rounded, in 98.8% of recordings. |
| How the monitors compute their numbers | tools/numeric_intervals.py, tools/numeric_derivation_pilot.py |
Recomputing each monitor numeric from its own waveform finds a short, simple algorithm for every one (a median, an exponential average or a time mean over 3–30 s) and a delay of 2–9 s behind the newest data it uses. The pilot's Primus fits are superseded; across the release every numeric's median delay is positive (Numeric delays are fixed within a case, different between cases). |
| Identifying the recording setup of every case | tools/setup_assign.py, tools/frame_an.py |
Recognising which equipment made each recording, from its serial ports and, where those fall short, from clock fingerprints, so that per-setup values can be used for every case. |
| Mains hum as an outside clock, and the recording PCs against the grid | tools/mains_hum.py, tools/mains_phase.py, tools/mains_hum_plot.py, examples/sim_stamp_clock_onecorr.py, examples/setup_rate_check.py |
The SNUADC waveforms carry the mains hum at 120 and 360 Hz in 39% of recordings. The grid is regulated to its nominal frequency, so the hum is a clock outside the recording, and through it the recorder PC's rate against the grid can be measured where the SNUADC's own rate is known, from the recording's whole teeth or its setup's: the PCs run slow, about 13 ppm, and two stations stand apart (−57 and +7 ppm). One-correction "rates", line fits through one step, were dropped (9 November). |
| Message sizes and the steps between records | tools/record_scan.py, tools/record_sizes_agg.py, tools/record_steps_collect.py, tools/record_steps_figs.py |
Every record in every waveform: SNUADC writes messages of 100 samples (0.2 s), Primus 30 (0.48 s), BIS 16 (0.125 s), CardioQ no fixed size. In SNUADC and BIS, backward steps outnumber gaps by about a hundred to one (Primus 5–25 to one, CardioQ about one to one); they come from a few recordings with duplicated or interleaved records. Primus AWP gaps are whole lost messages (CO₂ gaps mostly are not); most SNUADC and BIS gaps are not. |
| Monitor clocks in the waveforms' spectral lines | tools/waveform_survey.py, tools/monitor_lines.py, tools/sawtooth_char.py |
Differences of the raw converter counts carry lines from the monitor's analogue outputs: a 240 Hz line in arterial pressure and plethysmogram (an output clock running 23–56 ppm slow against the SNUADC, the same in both), and a 30 Hz family in the plethysmogram on the oximeter's frame clock, whose 120 Hz member also reaches ECG and arterial pressure. Arterial pressure's 240 Hz pattern comes 0.37 ms before the plethysmogram's. First seen in six files; rebuilt on 273 recordings with public code. |
| Monitor numerics recomputed from the waveforms, as a check of their delays | examples/pr_window_routes.py, examples/sim_pr_window_routes.py, tools/numeric_recompute_lag.py, examples/sim_recompute_lag.py |
The Solar8000's heart rate and pulse rate, recomputed from the ECG and the plethysmogram with the atlas's windows and fitted delays, against the monitor's own values: in 6,145 recordings both monitor numerics change about 1 s later than the delay convention predicts (HR 0.96 s, PLETH_HR 1.23 s), although the test recovers a lag of zero on synthetic data. Their mean delays may therefore be up to about 1 s longer than the timing forms state. The same work found that the comparison of pulse rate with heart rate read its lag at the edges of 2 s steps, which biased it upwards. |
| Numeric delays are fixed within a case, different between cases | tools/numeric_delay_variability.py, tools/numeric_delay_labels.py |
With each numeric's algorithm held fixed, delays were fitted for every case and every 30-minute block. They do not drift within a case, but 40–70% of their variance lies between cases, so a single population delay is wrong by up to 2 s for HR and 1 s for the others. Each case gets its own delay label. |
| One device delay for the PLETH across the release | tools/pat_offset_census.py |
The stored ECG-to-PLETH delay was measured in 5,536 recordings, to the foot and to the steepest upstroke of each pulse. It has one peak (655.0 ms to the foot, 715 ms to the upstroke, in the median recording), no clusters by recording setup or SNUADC port, and no shift along the case order: one global device delay, 385 ms with an adopted R-to-foot finger PAT of 270 ms, fits the whole release, as Ruffolo et al. found in their own data. |
| Paced ECG as an independent clock | tools/paced_screen.py, tools/paced_breaks.py |
Fixed-rate pacing gives a clock the recording chain cannot touch. Timing paced beats on three timelines shows that each SNUADC step-mode correction loses about 19 ms of signal, and that nothing else breaks the sample stream. |
| Paced beats in the BIS EEG | tools/paced_bis_spikes.py, tools/paced_bis_spikes_control.py, tools/paced_bis_windows.py, tools/paced_bis_plot.py |
In the six paced recordings with BIS, the EEG averaged around paced beats shows beat-locked activity beyond every random-time control in some 3-minute windows, and in two recordings a sharp deflection that repeats exactly at the pacing period. Whether pacing artefact or the heart's own trace, it could time the BIS against SNUADC to a few ms. |
| Physical units, shared drift and time order | tools/syncanalyze.py, tools/drift_units.py |
Device drift rates cluster into units: about 8 SNUADC boards and 8–18 BIS monitors. Part of the drift is shared by both devices of a case and changes between cases: the recorder PC's own rate. Case order carries no time information. |
| Pulse rate against heart rate, paired at the moment each describes | examples/hr_vs_pulse_rate.py, examples/pr_window_routes.py, examples/run_scan.sh |
The Solar8000's pulse rate against its heart rate in 6,386 recordings. They agree with no bias (limits of agreement −11.7 to +11.7 /min), and disagree more as the rate rises. Their changes line up 2.4 s later in recordings whose HR is in the early delay group than in the late one, the gap between the groups' delays: the two HR delay groups seen again, in a signal independent of the ECG. The comparison also places PLETH_HR's window: centred about 9.5 s before its stamp. |
| Rare devices against SNUADC | tools/rare_device_sync.py, tools/vigilance_window.py |
CardioQ, EV1000, Vigileo and Vigilance each get a link to the SNUADC timeline: beat matching for the CardioQ, mean arterial pressure alignment for the EV1000 and Vigileo, and a long-window fit for Vigilance's averaged heart rate. |
| Recorder PC clock steps and recording pauses | tools/pc_clock_steps.py, tools/pc_step_check.py, …/adhoc/pc_steps_summary.py |
A step of the recorder PC clock would move every record the PC stamps on arrival (the Solar8000 and Primus numerics) for good, against the waveforms the devices stamp from their own sample counts. None of 0.5 s or more shows in any of the 6,388 files: simultaneous delays of the numerics, up to 23 s, are recorder stalls, after which the numerics sit where they were, and what moves everything together is recording pauses. |
| Recorder PC time adjustments from the mains hum (negative result) | tools/ntp_mains_pilot.py, tools/ntp_mains_pilot2.py, tools/ntp_mains_pilot3.py |
Comparing PC time (from SNUADC stamp corrections) with grid time (from the hum phase) could in principle show when the recorder PC's clock is adjusted. In VitalDB it cannot: the recordings that correct often enough have hum too weak to track. |
| Records out of order at SNUADC resets, and where the lost time goes | tools/clock_model_fit.py, …/adhoc/reset_gapscan.py, …/adhoc/reset_glitch.py, …/adhoc/reset_gssum.py |
At every SNUADC reset the five records after it are written out of order: two continue the old timing and three start the new. Put back in order, the waveform runs on with no samples missing; the 18–20 ms lost at each reset goes missing inside the last old-timing record, and an extra zero sample follows. |
| Recovering the time of day | vitaldb_bench/case_clock.py |
The release shifts every case to start at 2100-01-01 00:00 UTC, removing the date and the time of day. The time of day (Korean local time) can be recovered to the minute from the admission date and the seconds of the EMR times. |
| SNUADC against the PC-stamped heart rate | tools/numeric_clock_check.py |
A 66-recording pilot of the route from the SNUADC clock to the recorder PC through the PC-stamped Solar8000 heart rate, superseded by the whole-release The SNUADC clock through the Solar8000 numerics, whole release. Its pooled rates were aggregated by a step that was not saved and do not reproduce from the saved per-recording output; they are kept as history, not for use. |
| SNUADC stamp arithmetic | tools/snuadc_stamp_census.py |
Between corrections the SNUADC block stamps run −0.95 ppm against the sample count: each 0.2 s increment is about 0.19 µs short. This, not clock drift, is the "about −1 ppm" seen in frequent-correction mode. |
| Shared bursts between the ECG and the EEG | tools/shared_artifacts.py, tools/direct_rate_from_bursts.py, tools/shared_bursts_slopes.py, tools/burst_figures.py |
Electrocautery and muscle bursts appear in both the SNUADC ECG and the BIS EEG. Cross-correlating their envelopes gives the offset between the two devices' stamps every 10 minutes: about −0.8 s, in a sawtooth that follows both clocks' corrections. |
| SpO₂ and pulse rate latency from step events | tools/spo2_event_pilot.py |
SpO₂ cannot be recomputed from one plethysmogram, so its timing comes from events that change the PLETH abruptly. SpO₂ lags the recorded PLETH by about 4 s and then smooths over roughly 10–20 s. |
| The BIS EEG's 60 Hz line is not mains hum | tools/mains_hum.py, tools/bis_line_tests.py, tools/mains_phase.py, tools/bis_line_minutes.py, tools/bis_line_plot.py |
The BIS EEG carries a strong line near 60 Hz in about half of the recordings, but it does not follow the grid: it wanders by about 150 ppm from minute to minute, unrelated to the grid seen through SNUADC. It cannot check the BIS clock. |
| The CO₂ sampling-line delay | tools/co2_sampling_line.py |
Breath by breath, the stored Primus CO₂ waveform trails the airway pressure by a median 3.60 s (IQR 3.45–3.79 s): the time the gas takes to travel down the sidestream sampling line. It is steady within a recording and across the release, and it is why the ETCO₂ numeric is stamped about 3 s sooner than the peak pressure against their own waveforms. |
| The PPG hardware delay and the adopted pulse arrival time | tools/pat.py, tools/pat_summary.py, tools/setup_offsets.py, tools/pat_offset_census.py, tools/raw_pat_by_setup.py |
VitalDB's raw ECG→PPG pulse arrival time is about 0.4 s longer than physiology. Splitting it into a hardware delay (one value for the release; One device delay for the PLETH across the release) and a physiological part needs an adopted value from studies that sampled ECG and PPG on one clock: about 270 ms for anaesthetised adults. |
| The PPG sawtooth and its correction | tools/tier_bench.py, tools/ppg_fix_check.py, tools/ppg_sawtooth_figures.py |
The ECG→PPG delay creeps at 18–52 ppm and jumps up by one 33.3 ms frame at each slip, every 11–31 minutes. First of the sawtooth series. Its first correction, a tooth-by-tooth fit (physiosync's detect method), was essentially exact where confident on injected test data; it has been replaced as the atlas default by the rebuilt correction of The rebuilt PPG slip finder and its correction, which brings finger PAT closer to arterial PAT, and is kept here as history. |
| The PPG sawtooth's period, its phase jumps, and the reversed sawtooth | tools/sawtooth_char.py |
Second of the sawtooth series (Finding and placing each PPG frame slip finds the slips). Within a recording the slips fall on a grid of one tooth length, piecewise: the grid holds for long runs and then jumps. On all 5,714 recordings the jumps move the phase by a whole number of quarter teeth far more often than by chance (375 of 548 without a break in the signal, against 132; 79 of 146 across one, against 35), and sharp steps of a fraction of a frame in the PPG chain lock to quarter frames too: the slips appear to be made in units of a quarter frame, 1/120 s. Within a run the grid is not exact: slips scatter by about 2 s around it, mostly anchored to it. Two setups run the sawtooth backwards. Cuff inflations do not explain the jumps. |
| The PPG's 30 Hz frame clock | tools/frame_an.py, tools/pat_res.py, tools/pat_res_figure.py |
ECG and PPG fiducials resolve to one 2 ms sample, but PPG fiducials taken on raw samples lock to a hidden 33.3 ms frame grid. Scanning for it finds the oximeter's frame clock to about 1 ppm, a fixed fingerprint of each recording setup. |
| The Primus CO₂ update grid | tools/waveform_survey.py, tools/art_cycle_and_co2_grid.py, tools/art_cycle_and_co2_grid_plot.py |
The stored CO₂ changes about every 40 ms: a 24.974 Hz update grid that is not locked to the 62.5 Hz samples and slides through a full update every 40 s or so. Each stored value describes a 40 ms interval that closed 0–40 ms before its stamp. |
| The Primus stamp step at each airway-pressure pause | tools/primus_pause_steps.py, tools/primus_co2_gaps.py, tools/primus_pause_aware.py, tools/clock_route_figs.py, examples/primus_pause_steps_table.py |
Measured directly at 2,488 pauses in 1,021 recordings: where CO₂ carries on through the AWP pause (74%), the Primus stamps barely step (median 0 ms, p10–p90 −164 to +188 ms, close to the no-pause controls); where CO₂ stops too (26%), they step by up to seconds. No step undoes the drift built up since the last pause. |
| The Primus ventilator against SNUADC, by breaths | tools/vent_sync_pilot.py, tools/primus_drift_probe.py, tools/primus_sync_accuracy.py, tools/primus_numbers.py, tools/primus_pause_aware.py, tools/vent_match_figure.py, tools/primus_ptt_arm.py, examples/ppv_by_breath.py |
Each breath shows in the Primus airway pressure and, through the chest, in SNUADC's central venous pressure. Tracking that lag puts the Primus on the SNUADC timeline to about 55 ms over the whole release, with a line per stretch between its AWP pauses (49 ms in the pilot). At scale it measures the Primus drifting a median +105 ppm against the recorder PC between its AWP pauses, with steps at the pauses that do not reset it. |
| The SNUADC clock through the Solar8000 numerics, whole release | tools/solar_snuadc_clock.py, tools/solar_length_check.py, tools/clock_route_figs.py, examples/solar_route_check.py |
On the SNUADC's own sample count, the delay from the waveform to the PC-stamped Solar8000 heart rate and mean arterial pressure ramps at the SNUADC's drift against the PC, measured without its stamps or resets. In recordings with whole reset intervals it agrees with them from 6 h (median difference per recording +1.7 ppm, 333 recordings; +7.8 ppm over all 582, with the shorter ones biased). It is too noisy per recording, and in recordings under 6 h its rate is biased toward zero; from 6 h it is unbiased against the resets and joins the clock network as an edge (Closing loops in the timing graph). |
| The SNUADC firmware | tools/wrap_test.py, tools/wrap_checks.py |
The public SNUADC firmware explains the board's timing: it sends no time stamps, samples on its 16 MHz crystal, loses time rather than bunching samples after a stall, reads its channels one after another, and truncates its values. The predicted fault at the wrap of its microsecond counter is real but intermittent: over the whole release, the PPG and arterial timelines step together 4,295 s apart about five times as often as at other spacings, at roughly one wrap in four, and not at all on some ports. |
| The SNUADC rate from the mains hum, where the stamps cannot give it | tools/mains_hum.py, tools/hum_snuadc_rate.py |
57% of recordings carry no SNUADC stamp correction, so the working reference runs on a borrowed rate. Checked against the BIS through a second, independent path, the stamp model's rate (model5, capped by the recorder's 0.5 s rule) drifts by 9.5 ppm (23 ms/h, median). The mains hum gives each such recording its own rate, 12.0 ppm (29 ms/h): it cut the drift from 31 ppm on the earlier model (model3), but on model5 it only trims the tail. |
| The cardiac artefact in the BIS EEG | tools/eeg_sync_pilot.py, tools/eeg_cardiac_recheck.py |
The BIS EEG carries a weak electrical trace of every heartbeat. Too weak for beat-by-beat matching, it shows clearly when averaged on the ECG's R peaks, and gives a second SNUADC–BIS timing reference that agrees with the bursts to about 16 ms. |
| The heartbeat in the Primus airway signals | tools/airway_heartbeat_pilot.py |
A pilot in 30 recordings for a heartbeat-locked route from the Primus to the SNUADC. Airway pressure shows the heartbeat in 10% of windows only. CO₂ shows a heartbeat-locked trace in 61% of windows, tight to 19 ms, but its lag does not follow the Primus drift, so it cannot time the Primus. Closed as a clock route. |
| The rebuilt PPG slip finder and its correction | tools/correction_vs_art.py, tools/ppg_fix_check.py, tools/ppg_sawtooth_figures.py, tools/slip_rebuild.py, tools/slip_tiers.py, tools/correction_labels.py, tools/contested_view.py, tools/tier_i_check.py, tools/tooth_check.py, tools/label_quality.py, scripts/run_slip_rebuild_full.sh |
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"). |
| The stamp sawtooth model for SNUADC and BIS | 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 |
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. |
| Time zeros and loaded subsets | tools/time_zeros.py |
A VitalDB time "from the start" depends on which tracks were loaded: loading a subset moves the zero to that subset's first record, seconds or hours later. The arrhythmia database's annotations count from the full file's zero. |
| Two heart-rate delay groups, one poll apart | tools/numeric_delay_labels.py, …/adhoc/hr_group_ports/ |
Solar8000 heart rate reaches the recorder either about 1.9 s or about 4.17 s after its window ends: one 2 s poll apart. The group belongs to the recording PC, stays fixed through a case, and on some PCs varies from case to case. |
| Value resolution of every signal | tools/waveform_survey.py, tools/signal_events.py, tools/signal_events_agg.py, tools/record_scan.py, tools/numeric_agg.py |
How finely every waveform and numeric track in the release records its values. The SNUADC waveforms are 10-bit codes, though VitalRecorder's documentation describes the SNUADC as 12-bit; Primus waveforms use about 11 bits of 12; BIS EEG is a 16-bit grid of 0.05 µV. Numerics are 32-bit floats on decimal grids of 1, 0.1, 0.01 or 0.001, one per track; settings sit on coarser grids of 10 or 100. |
| What each break in the stamps is | tools/step_classify.py, tools/step_classify_agg.py, tools/step_join_null.py |
Every step between waveform records in the release, sorted by mechanism: written twice, a SNUADC clock reset, interleaved streams, a pause shared by every device, whole messages, less than a message, or a fraction of a message beyond whole ones. A continuity test with controls shows which classes lose data: shared pauses and most longer SNUADC gaps do; steps under one message, and SNUADC's lone one-message steps, mostly do not. |
| What frequencies each waveform carries | tools/spectra_scan.py, tools/spectra_agg.py, scripts/run_spectra.sh |
The power spectrum of every waveform, minute by minute, across all 6,388 recordings. The ECG reaches SNUADC through a low-pass of about 20 Hz, fourth order, the same on every unit; the BIS EEG stops abruptly near 47 Hz; the plethysmogram and pressures carry almost nothing above 10–20 Hz, so their fitted roll-off cannot be told from the end of their own content. Mains hum is rare and no notch filter shows. Most ECG recordings end with about ten minutes of noise, as the recordings are cut ten minutes after the ECG heart rate stops. The CO₂ waveform carries a line near 25 Hz from its update grid, and a quarter of plethysmograms a line at 24.5 Hz. |
| What the lab timestamp marks | tools/lab_draw_labels.py, tools/line_access_summary.py, scripts/run_line_access.sh |
VitalDB's lab time is a per-specimen timestamp: not the draw, and not the result. Blood gases are stamped 3–12 minutes after the draw, central-lab panels about 8–24 minutes after it, and the result follows a turnaround the release does not record. |
| What the stored waveform values say about the recording chain | tools/waveform_deltas.py, tools/waveform_deltas_summary.py, tools/output_cycle_fold.py, tools/waveform_staircase_plot.py, tools/output_cycle_fold_plot.py, tools/bis_grid_plot.py, tools/primus_holds_plot.py |
Successive differences of every stored waveform, over the whole release, show how each one was converted: no slew bound or coarse lattice, a 240 Hz output cycle in the arterial pressure and plethysmogram but not the ECG, the BIS EEG on an exact 0.05 µV grid, and the Primus waveforms resampled from slower internal rates. |
| When each device's clock is corrected, in every recording | tools/correction_schedules.py, tools/step_classify.py, tools/step_classify_agg.py |
From the steps between records in all 6,388 recordings: the BIS is corrected every 8,192 s and the Primus every 7,230 s, on their own timers (the first correction comes at any time after the device starts); the SNUADC is reset when its count gets half a second ahead of the PC, the recorder's rule (How the Vital Recorder stamps SNUADC records, tested against the release). With the full rerun of the correction fit, it gives each device's drift against the recorder PC in 4,728 BIS and 2,728 SNUADC recordings, and shows that the Primus's 20–23 s AWP pauses belong to its correction cycle. Every rate here is relative to the recorder PC, whose own clock drifts and is corrected. |
| Where the PPG sawtooth stops | tools/sawtooth_char.py |
Third of the sawtooth series (Finding and placing each PPG frame slip, The PPG sawtooth's period, its phase jumps, and the reversed sawtooth), rebuilt on 2 November and run on the full release on 3 November. With the new slip detector and the slip grid, stretches of 1.5 teeth or more without a slip are fewer than first reported: 1,072 stretches, 469 hours, in 796 of 5,714 recordings. Most of those inside a recording are two teeth long, and where the slips on either side lie on one grid, the step the grid predicts is usually there, missed because a ramp or a disturbance coincided with it. Where the phase moves across a stretch, it moves by quarter teeth. Some stretches look flat; the frame clock keeps its rate and phase through them; and the 586 recordings without any one-frame step show no hidden sawtooth, though many drift slowly. |
Observations it handles¶
| Observation | Status | Summary |
|---|---|---|
| Eight recordings store whole messages twice | established | In 8 recordings 15–48% of the waveform records are byte-for-byte copies of the record before them, with the same timestamp: case 15, case 364, case 1946, case 3865, case 4857, case 5414, case 5595 and case 5619. SNUADC, Primus and BIS are affected equally, so the recorder, not a device, wrote them twice. |
| Every case starts at 2100-01-01 00:00 UTC | established | The release shifts each case to the same start, removing the date and the time of day. Within a case all times keep their spacing. |
| Five records out of order at every SNUADC reset | established | At each step-mode reset the five records after it are written in the wrong order: two continue the old timing and three start the new, interleaved. Read in file order, or sorted by stamp, one second of signal is scrambled. |
| Primus waveform gains are wrong in every recording, for CO₂ or for AWP | established | Recordings store the Primus waveforms with one of three sets of scale factors. Checked against the Primus's own ETCO₂ and PIP numerics in all 6,388 recordings, CO₂ fits only 0.075 mmHg per code and AWP only 0.1 mbar per code with offset −20, so most recordings overstate CO₂ by a third, and the others overstate AWP by about 3% (950 recordings) or understate it about fourfold (26). |
| The Primus AWP stops for about 21 s every 7,230 s | established | In 5,502 recordings the Primus airway-pressure waveform has gaps of 19–23.5 s (whole messages of 0.48 s, mostly 21.12 s) that recur every 7,230 s, the Primus's correction interval; a clock correction follows about 21.6 s after. The CO₂ waveform carries on through 90% of them (74% of the pauses measurable for the step below). The 21 s of AWP are lost, not merely re-stamped. |
| In 34 files the SNUADC records overlap throughout | open | In 34 files the SNUADC records step back over their neighbours far more often than resets explain: in 20 of them 4–95% of all record junctions overlap, by up to about 100 ms. The reset-order rule matches there by coincidence. |
| In some recordings two unrelated streams are interleaved in one track | open | In 7 recordings 64–95% of the records alternate between two streams: each record continues the one two before it, not the one before, and the two streams do not match each other. SNUADC and BIS in case 2219, case 2379, case 2640, case 4836, case 5327 and case 5617; SNUADC in case 1939. In case 94, case 945, case 1132, case 3195 and case 5700 4–7% of SNUADC records interleave. |
Worked examples¶
| Example | Side | Status | Summary |
|---|---|---|---|
| A regression that carries rounding uncertainty through | value | current | Acute kidney injury after surgery against intraoperative urine output (mL/kg/h), fitted once on the recorded numbers and once per draw from the true-value distributions: the rounding moves 14% of cases across the oliguria threshold, but widens the confidence interval of the cohort's regression by at most 4%. |
| Cuff pressure against the arterial line | both | current | 12,238 cuff readings against the arterial line at the cuff's own moment, in 2,283 patients: no bias over the cohort (−0.1 mmHg), but each patient's cuff reads a constant 10 mmHg (SD) above or below their line, and half the arterial readings below 65 mmHg are not below 65 by cuff. |
| End-tidal to arterial CO₂, and pulse oximetry against blood gas, at the right moment | time | current | For 4,281 blood gases, reading the monitor when the blood was drawn rather than at the lab stamp makes changes in end-tidal CO₂ track changes in arterial CO₂ far better (within-patient correlation 0.74 against 0.54), and agreement peaks exactly at the estimated draw. Oximetry shows the same timing (agreement peaks at the draw), but the 100% ceiling hides the size of the oximetry gradient for three gases in four. |
| Intraoperative fluid balance as a distribution | value | current | Fluids in minus fluids out, each a heaped charted volume, as a distribution per case: the recording alone makes a balance uncertain by about ±60 mL, and by ±190 mL when the blood loss was written as a round 500 mL. |
| Minutes of hypotension per patient, from the monitor and from the waveform | both | current | Minutes with MAP below 65 mmHg in 3,476 recordings, from the monitor's numeric and from the arterial waveform's beats: the two routes to one pressure differ by several mmHg per patient, which moves half of all patients' minutes by 5 or more and a fifth of their labels, and the numeric's averaging hides short dips in most patients. |
| Oliguria labels for a prediction model | value | current | One label per patient, oliguric or not, from three rounded numbers: 10% of labels are uncertain and 2.6% are expected to be wrong, which sets a floor under the error any model can be measured to have. A typical model is barely affected; a good one is. |
| Post-induction hypotension, from the charted start and from the devices | time | current | The charted anaesthesia start comes a median 14 minutes before the patient is induced; measured from it, "hypotension within 20 minutes of induction" is found in 27% of 2,913 patients, against 51% from the devices' induction, and the label changes for a quarter of patients. |
| 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. |
| 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. |
| Urine output in mL/kg/h as a distribution | value | current | Intraoperative urine output per kilogram per hour, from three rounded inputs, as a probability distribution per case: one case in ten cannot be placed confidently on either side of 0.5 mL/kg/h. |
Mentioned in¶
- Worked example: Pulse arrival time in two correction steps
- Clock link: BIS against the recorder PC
- Observation: Every case starts at 2100-01-01 00:00 UTC
- Software: Analysis workspace
- Software: physiosync
- Software: TimeNet
- Software: vitaldb-reader
- Studie: Recovering the time of day
- Studie: Clock corrections in every file
- Studie: Gaps and unbroken segments in every waveform
- Studie: How often each device is corrected
- Studie: When each device's clock is corrected, in every recording
- Studie: Pulse rate against heart rate, paired at the moment each describes
- Studie: What the lab timestamp marks
- Studie: Closing loops in the timing graph
- Studie: Monitor clocks in the waveforms' spectral lines
- Studie: Monitor numerics recomputed from the waveforms, as a check of their delays
- Studie: How the Solar8000 computes its pulse rate
- Studie: The PPG's 30 Hz frame clock
- Studie: The PPG hardware delay and the adopted pulse arrival time
- Studie: The rebuilt PPG slip finder and its correction
- Studie: How the Primus airway pressure is written at 62.5 Hz
- Studie: The Primus CO₂ update grid
- Studie: The Primus stamp step at each airway-pressure pause
- Studie: Recorder PC clock steps and recording pauses
- Studie: Records out of order at SNUADC resets, and where the lost time goes
- Studie: Identifying the recording setup of every case
- Studie: The SNUADC firmware
- Studie: The stamp sawtooth model for SNUADC and BIS
- Studie: The SNUADC clock through the Solar8000 numerics, whole release
- Studie: SNUADC stamp arithmetic
- Studie: Value resolution of every signal
- Studie: The Primus ventilator against SNUADC, by breaths
- Studie: How the Vital Recorder stamps SNUADC records, tested against the release
- Studie: What frequencies each waveform carries
References¶
- Harris CR, Millman KJ, van der Walt SJ, et al. Array programming with NumPy. Nature. 2020;585(7825):357-362. ↗
- Virtanen P, Gommers R, Oliphant TE, et al. SciPy 1.0: fundamental algorithms for scientific computing in Python. Nat Methods. 2020;17(3):261-272. ↗
- McKinney W. Data structures for statistical computing in Python. In: Proceedings of the 9th Python in Science Conference. 2010. p. 56-61. ↗
- The pandas development team. pandas-dev/pandas: Pandas. Zenodo. ↗
- Hunter JD. Matplotlib: a 2D graphics environment. Comput Sci Eng. 2007;9(3):90-95. ↗
- Apache Software Foundation. Apache Arrow (PyArrow). ↗
- Raasveldt M, Mühleisen H. DuckDB: an embeddable analytical database. In: Proceedings of the 2019 International Conference on Management of Data (SIGMOD '19). ACM; 2019. p. 1981-1984. ↗
- Makowski D, Pham T, Lau ZJ, Brammer JC, Lespinasse F, Pham H, Schölzel C, Chen SHA. NeuroKit2: a Python toolbox for neurophysiological signal processing. Behav Res Methods. 2021;53(4):1689-1696. ↗
- Bota P, Silva R, Carreiras C, Fred A, Plácido da Silva H. BioSPPy: a Python toolbox for physiological signal processing. SoftwareX. 2024;26:101712. ↗
- Kozea / CourtBouillon. CairoSVG. ↗
- Krekel H, Oliveira B, Pfannschmidt R, Bruynooghe F, Laugher B, Bruhin F. pytest. 2004. ↗