#!/usr/bin/env python3 """ Minimal example for reading the record files of this dataset. The files use the Vital file format. The easiest way to read them is the open-source `vitaldb` Python package: pip install vitaldb The files can also be opened for visual review with the free Vital Recorder software (https://vitaldb.net). """ import vitaldb PATH = 'vital/1-1.vital' # 1. list the tracks stored in the file vf = vitaldb.VitalFile(PATH) print('tracks:', vf.get_track_names()) print('length (s):', round(vf.dtend - vf.dtstart)) # 2. read one numeric track, resampled to a fixed 1-second grid. # Missing periods are returned as NaN. The output interval is chosen by the # user and is not the acquisition rate of the track. hr = vf.to_numpy(['Infinity/HR'], 1) print('heart rate samples:', hr.shape) # 3. read a waveform track at its stored sampling rate (500 Hz here; # check track_inventory.csv for the rate of each track in each file) ecg = vf.to_numpy(['SNUADCM/ECG_II'], 1 / 500) print('ECG samples:', ecg.shape) # 4. several tracks on the same time grid x = vf.to_pandas(['Infinity/HR', 'Infinity/PLETH_SPO2', 'Infinity/ART_MBP'], 1) print(x.head()) # Notes # - All timestamps have been shifted so that each case starts at # 2000-01-01 00:00:00 UTC. Relative timing within a case, including the gaps # between files of the same case, is preserved. # - Not every track is present in every file; see track_inventory.csv. # - Signals are provided as recorded. No filtering, artifact removal or # quality screening has been applied.