Skip to content

vitaldb-reader

Reads VitalDB .vital files at native resolution, with this atlas's corrections as separate, versioned steps: reset records in sampling order, corrected scale factors, samples placed by count, and the timing model.

Repository github.com/metrology-atlas/vitaldb-reader
Branch main
Visibility public
Licence MIT
Language Python 3.11+ (numpy)
Related vitaldb-bench, TimeNet

What it is

The reader keeps every track at the resolution and in the dtype the file stores it, in file order, with record times in absolute file time, and resamples nothing. Each correction the atlas found is its own module with a version, so an analysis can say exactly which it applied:

It was first written as a VitalDB connector for TimeNet (TimeNet); the reader became its own package so that the scripts behind this atlas (vitaldb-bench) can be run from public code. The .vital format is VitalDB's, documented in vitalutils; the reader is an independent implementation.

Install

pip install "vitaldb-reader @ git+https://github.com/metrology-atlas/vitaldb-reader@0.1.0"

What is in it

Reading

vital_file.py Reads the .vital container (devices, tracks, records, exact record times) in file order.

Corrections

resets.py Finds the reset clusters in an SNUADC track and puts their records back in sampling order.
scales.py Corrected gain and offset where the stored scale factors are wrong.
timing_model.py Delay and window of each monitor numeric; resolution of the clinical times.

Timing and values

timing.py Runs and segments of each waveform track; samples placed by count; nominal rates.
resolution.py Value resolution of each track, converter limits and near-duplicate records.

Tests

test_resets.py Tests of the reordering rule, including the variant clusters.

Studies that use it

Study Code Summary
Records out of order at SNUADC resets, and where the lost time goes …/vitaldb_reader/resets.py, tests/test_resets.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.

Observations it handles

Observation Status Summary
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).
SNUADC stamps run −0.95 ppm against the sample count established Between corrections each 0.2 s record stamp increment is about 0.19 µs short: stamps run −0.95 ppm from the sample count in 88% of files (both SNUADC modes). It is arithmetic, not clock drift. The other 12% sit above it, mostly between −0.90 and −0.72 ppm.

Mentioned in