Ejemplo n.º 1
0
def isCorrect(fileName):  # ABP waveform , EV1000 SV search function
    result = False
    vrFile = vr.VitalFile(fileName)
    time, date = vrFile.get_numbers('SV', 'EV1000')
    for trk in vrFile.trks.values():
        if trk['name'].find('IBP1') >= 0:
            result = True
            break
        elif trk['name'].find('IBP5') >= 0:
            result = True
            break
        elif len(time) != 0 and len(date) != 0:
            result = True
            break
    return result
def get_parameters(filename):

    vrfile = vr.VitalFile(filename)
    IBPflag = 0
    ABPflag = 0
    IBPname = ''
    ecg_name = ''
    for trk in vrfile.trks.values():  # find event track
        # print(trk['name'],tname)
        if trk['name'].find('IBP1') >= 0:
            IBPflag = 1
            IBPname = 'IBP1'
            break
        elif trk['name'].find('IBP5') >= 0:
            IBPflag = 1
            IBPname = 'IBP5'
            break

    for trk in vrfile.trks.values():  # find event track
        # print(trk['name'],tname)
        if trk['name'].find('ART1_SBP') >= 0:
            ABPflag = 1

    if IBPflag == 0 or ABPflag == 0:
        print('ABP not Exist')
        return [], [], []
    result = []

    result.append(vrfile.get_samples(IBPname))
    result.append(vrfile.get_samples('PLETH'))
    result.append(vrfile.get_samples('ECG1'))
    result.append(vrfile.get_numbers('HR'))
    result.append(vrfile.get_numbers('ART1_MBP'))
    result.append(vrfile.get_numbers('ART1_DBP'))
    result.append(vrfile.get_numbers('ART1_SBP'))
    time_dbp, dbp = vrfile.get_numbers('ART1_DBP')
    time_sbp, sbp = vrfile.get_numbers('ART1_SBP')
    if len(dbp) > len(sbp):
        map = (np.array(dbp[:len(sbp)]) + np.array(sbp)) / 2
        time = time_sbp
    else:
        map = (np.array(dbp) + np.array(sbp[:len(dbp)])) / 2
        time = time_dbp

    return np.array(result), np.array(time), map
Ejemplo n.º 3
0
def read_D2_PCG(room_name, filename):
    time_PCG = np.array([])
    PCG = np.array([])
    for f in filename:

        vrfile = vr.VitalFile(f)
        svvflag = 0
        pcgflag = 0
        ecg_name = ''
        for trk in vrfile.trks.values():  # find event track
            # print(trk['name'],tname)
            dname = vrfile.devs[trk['did']]
            if dname['name'] == 'EV1000':

                if trk['name'].find('SVV') >= 0:
                    svvflag = 1
                    break

        if svvflag == 0:
            print('SVV not Exist')
            return [], [], [], []

        for trk in vrfile.trks.values():  # find event track
            # print(trk['name'],tname)
            dname = vrfile.devs[trk['did']]
            if dname['name'] == 'DI-155':

                if trk['name'].find('VOLT') >= 0:
                    pcgflag = 1
                    break

        if pcgflag == 0:
            return [], [], [], []

        time_PCG, PCG = vrfile.get_samples('VOLT')
        time_ABP, ABP = vrfile.get_samples('ART2')

    return time_PCG, PCG, time_ABP, ABP
Ejemplo n.º 4
0
def findMachineInfo(target, machineName=None, machineName2=None):
    # print("target type is : ",type(target))
    # count = 0
    # selfData=['/mnt/CloudStation/F-08/200810/F-08_200810_080534.vital', '/mnt/CloudStation/F-08/200810/F-08_200810_104015.vital']
    resultTime = []
    resultData = []
    num_cores = multiprocessing.cpu_count()
    # parResult = parmap.map(vr.VitalFile, target, pm_pbar=True, pm_processes=5)
    if type(target) is type("s"):
        parResult = vr.VitalFile(target)
    else:
        with Pool(4) as p:
            parResult = p.map(vr.VitalFile, target)

    tempDic = {
        'machineName': machineName,
        'machineName2': machineName2,
        'vrFile': parResult
    }
    print(parResult)
    # print(len(parResult))
    if type(parResult) is list([1, 2]):
        for i in parResult:
            time, data = getData(i, machineName, machineName2)
            # print(data[0].shape)
            if time is not None or time != None:
                resultTime = np.append(resultTime, time)
                resultData = np.append(resultData, data)
        #     count+=1
    else:
        time, data = getData(parResult, machineName, machineName2)
        if time is not None or time != None:
            resultTime = np.append(resultTime, time)
            resultData = np.append(resultData, data)

    return resultTime, resultData
Ejemplo n.º 5
0
accurateFile

for i in range(30):
    temp = accurateFile.pop()
    if '2008' in temp:
        # if isCorrect(temp) : # -> True
        date.append(temp[28:34])
        roomName.append(temp[23:27])

print(date, roomName)

vrfile = cf.search_filepath(roomName, date)
vrfile
vrfile2 = vrfile.pop()
vrfile2
vrfileTemp = vr.VitalFile(vrfile2)
vrfile2
print(vrfileTemp)
vrfile = list(vrfile)
vrfileList = []
num_cores = multiprocessing.cpu_count()  # cpu count
pool = multiprocessing.Pool(num_cores)  # using process
splited_data = np.array_split(vrfile, num_cores)
splited_data = [x.tolist() for x in splited_data]
vrfileList = parmap.map(vr.VitalFile,
                        splited_data,
                        pm_pbar=True,
                        pm_processes=num_cores)

while (True):
    time, temp = vrfileTemp.get_numbers('SV', 'EV1000')
Ejemplo n.º 6
0
    teststr = teststr.replace("None", "")

    for i in roomDir:
        tempSplit = i.split('/')
        if tempSplit[5].find(teststr) != -1:
            vrfile.append(i)

    return vrfile


print("start")
tempVrfile = searchDateRoom("D-01", 20, 8, 26)

print("loading")
tempVital = vr.VitalFile(tempVrfile[0])
dtname = tempVital.vital_trks()

a = "AUDIO"
bb, bbb = tempVital.get_samples("AUDIO")

tempVrfile = vital.VitalFile(tempVrfile[0], sels=dtname[0])

dt, dd = tempVrfile.get_samples(dtname[0], interval=0.0008)
len(dd)

duration = 1.0
fs = 400.0
samples = int(fs * duration)
t = np.arange(samples) / fs
signal = chirp(t, 20.0, t[-1], 100.0)
Ejemplo n.º 7
0
import jyLibrary as jy
import datetime
import matplotlib.pyplot as plt
import numpy as np
import vr_reader_fix as vr

svDB,cursor=jy.dbIn()
room_name="D-01"
a = jy.searchDateRoom(room_name,20,8)
adrress="/mnt/data_generator/abpsvjy/"

for i in range(len(a)) :
    # abpTime,abpData = jy.findMachineInfo(a[i],None,"IBP1")
    # svTime,svData = jy.findMachineInfo(a[i],None,"SV")
    vrFile=vr.VitalFile(a[i])
    abpTime,abpData=vrFile.get_samples("IBP1")
    svTime,svData=vrFile.get_numbers("SV",)

    if len(svTime) == 0 or len(abpTime) == 0 :
        print("length issue")
        continue

    svTime=jy.timeChange(svTime,lateTime=9)
    abpTime=jy.timeChange(abpTime,"UTC")

    if len(svTime) >= 90 :
        startTime = jy.timeBinarySearch(svTime,datetime.datetime.timestamp(svTime[0]+datetime.timedelta(minutes=30)))
        endTime = jy.timeBinarySearch(svTime,datetime.datetime.timestamp(svTime[-1]-datetime.timedelta(minutes=30)))
        print("svTime length is ",len(svTime))
        svTime=svTime[startTime:endTime]
        svData=svData[startTime:endTime]
Ejemplo n.º 8
0
import vr_reader_fix as vr
import check_filepath as cf
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt2

default_path = "/mnt/Data/CloudStation/"
file = 'D-02/200221/'

#os.listdir(default_path+file)

selcted_file = default_path + file + 'D-02_200221_082405.vital'
vrfile = vr.VitalFile(selcted_file)

#time, ABP = vrfile.get_samples('PLETH')

#plt.plot(time[1000000:1000000+1250],ABP[1000000:1000000+1250])
#plt.show()

#time, temp = vrfile.get_numbers('AWAY_RR')
#plt.plot(time,temp)
#plt.show()
rooms = ['D-02']
date = ['200221']
a = cf.search_filepath(rooms, date)
aa = a.pop()
vrfileTemp = vr.VitalFile(aa)
time, temp = vrfileTemp.get_numbers('SV', 'EV1000')
#time2, temp2 = vrfileTemp.get_numbers('SV','Vigilance')
print(time)
print(temp)
plt.plot(time, temp)
Ejemplo n.º 9
0
    cnt = 0

    cnt = 0
    for j in range(len(filenames)):
        if (os.path.getsize(filenames[j]) > 5000000):
            filenames2.append(filenames[j])
            print(filenames[j])
        else:
            print("small file")

    if len(filenames2) == 0:
        continue

    filename = filenames2
    file = filenames2.pop()

    vrfile = vr.VitalFile(file)

    for trk in vrfile.trks.values():  # find event track
        # print(trk['name'],tname)
        dname = vrfile.devs[trk['did']]

        if trk['name'].find('ECG_II') >= 0:
            svvflag = 1
            break

#    time_ECG, ECG = vrfile.get_samples('ECG_II')
#    time_ABP, ABP = vrfile.get_samples('ART2')

#    plt.plot(ECG[20000:20000+10000])
#    plt.show()