vitabel.io.vitaldb

Loading of VitalDB recordings (VitalRecorder *.vit files).

Attributes

Functions

track_to_timeseries(...)

Extracts a track from a vitaldb dataset and returns it as channel or label.

read_vitaldb_tracks(...)

Read all tracks of a VitalDB recording.

assign_vitaldb_labels(...)

Determine which VitalDB labels (string tracks) belong to which channels.

Module Contents

vitabel.io.vitaldb.logger
vitabel.io.vitaldb.track_to_timeseries(vit: vitaldb.utils.VitalFile, track_name: str, metadata: dict) → vitabel.timeseries.Channel | vitabel.timeseries.Label | None

Extracts a track from a vitaldb dataset and returns it as channel or label.

vitabel.io.vitaldb.read_vitaldb_tracks(filepath: pathlib.Path | str, metadata: dict | None = None) → tuple[list[vitabel.timeseries.Channel], list[vitabel.timeseries.Label]]

Read all tracks of a VitalDB recording.

Parameters:
filepath

The path to the recording. Must be a *.vit file.

metadata

Metadata of the resulting channels and labels. Defaults to {"source": "VitalDB-Recording"}.

Returns:
The channels (waveform and numeric tracks) and the labels (string tracks)
of the recording, in the order of the tracks in the file.
vitabel.io.vitaldb.assign_vitaldb_labels(labels: list[vitabel.timeseries.Label], channel_names: list[str]) → tuple[list[tuple[vitabel.timeseries.Label, list[str]]], list[vitabel.timeseries.Label]]

Determine which VitalDB labels (string tracks) belong to which channels.

The rules are based on observations, not on an in-depth study of the VitalDB format. Example channel names: PUMP2_RATE, PUMP2_CONC, PUMP2_PRES; corresponding label names: PUMP2_DRUG, PUMP2_RATE_UNIT, PUMP2_CONC_UNIT.

  1. If the label name without its trailing _<qualifier> is a channel name (PUMP2_RATE_UNIT), the label belongs to that channel.

  2. Otherwise, if it matches the name of several channels without their trailing qualifiers (PUMP2_DRUG), the label belongs to all of them.

  3. All remaining labels are global labels.

Labels belonging to channels are renamed to their qualifier (e.g., UNIT, DRUG).

Parameters:
labels

The labels to assign.

channel_names

The names of the available channels.

Returns:
A list of pairs (label, channel names) of labels to be attached to
the channels with the given names, and the list of global labels.