Batch Processing

To read or batch process data from multiple vital files, you must use a programming language. You can do this with the help of the utilities that are installed with Vital Recorder.

For example, vital_recs.exe is a utility program for batch extraction of data. This allows you to extract data samples from vital files in any programming language you are familiar with.

Open vital file with Python

import csv

import subprocess

ipath = "1.vital"

interval = 1

p = subprocess.Popen('vital_recs.exe -h "{}" {}'.format(ipath, interval), stdout=subprocess.PIPE)

output = p.communicate()[0].decode("utf-8")

for row in csv.reader(output.splitlines()):

    print(row)

Open vital files using Python and Pandas libraries

import io

import subprocess

import pandas as pd

ipath = "1.vital"

interval = 1

p = subprocess.Popen('vital_recs.exe -h "{}" {}'.format(ipath, interval), stdout=subprocess.PIPE)

df = pd.read_csv(io.StringIO(p.stdout.read().decode('utf-8')), index_col=0)

print(df)

Extract vital file tracks of specific folder with Python and Pandas

import io

import os

import csv

import subprocess

import pandas as pd

rootdir = r"//Vitalnew/vital_data/Monthly_Confirmed/SNUH_OR"

for dir, dirs, files in os.walk(rootdir):

    for file in files:

        ipath = '{}/{}'.format(dir, file)

        cmd = 'vital_trks {}'.format(ipath)

        p = subprocess.Popen(cmd, stdout=subprocess.PIPE)

        df = pd.read_csv(io.StringIO(p.stdout.read().decode('utf-8')), comment='#')

        devs = []

        for index, row in df.iterrows():

            if row['tname'] != 'SV':

                continue

            devs.append(row['dname'])

        if not devs:

            continue

        print('{},{}'.format(ipath[len(rootdir)+1:], ','.join(devs)))

Open vital file in R

load_vital <- function (path, interval=1) {

  cmd <- paste0("vital_recs.exe -h ", path, " ", interval)

  return (read.csv(pipe(cmd)))

}

# load vital file and get samples at 1 sec interval

vit <- load_vital("1.vital", 1)

# print maximum arterial pressure

print(max(vit$SNUADC.ART1, na.rm=TRUE))