Esempio n. 1
0
# import matplotlib.pyplot as plt
import windowing as win

filename = "./data/GSR_F01_F.txt"

T1 = 0.75
T2 = 2
MX = 1
DELTA = 0.02
nFS = 16

gsr_data = tools.load_file(filename, header=8, sep=",")  # 8 ","
#TODO GAUSSIANA

gsr_data = tools.downsampling(gsr_data, nFS)
# plt.figure(1)
# plt.plot(gsr_data[:,0], gsr_data[:,1])
# plt.xlabel("Time (s)")
# plt.ylabel("GSR (uS)")
# plt.title("Raw GSR")
# t_gsr, gsr = GSR.remove_spikes(gsr_data[:,1], nFS)
t_gsr = gsr_data[:, 0]
gsr = gsr_data[:, 1]
print gsr.shape
# print t_gsr.shape, gsr.shape, gsr_data.shape
t_driver, driver, phasic_d, tonic_d = GSR.estimate_drivers(
    t_gsr, gsr, T1, T2, MX, DELTA)
outputlabels = ["timestamp", "driver", "phasic", "tonic"]

tools.array_labels_to_csv(
Esempio n. 2
0
if __name__ == '__main__':
    #user insertion, the path is substituted with database source
    # path = "/home/flavio/Work/PhysioWat/robaNoGit/data/Nicolasdata/"
    fileName = "./data/EKG_F01_M.csv"
    SAMP_F = 256
    
    #load data from the file
    rawdata = loadEKG(fileName)
    #DEBUG ONLY, create a new ideal timestamp
    temp_ts = np.arange(0, rawdata.shape[0]/SAMP_F, 1.0/SAMP_F)
    rawdata[:,0] = temp_ts
    #SAMP_F = int(round(1/(rawdata[1,0]-rawdata[0,0]))) se i dati di Nicola non avessero il timestamp buggato
    #downsampling
    #the user selects the parameters, with default suggested
    new_f = SAMP_F
    downsampled_data = ourTools.downsampling(rawdata, new_f, switch=False)

    #filter
    #the user selects the parameters, with default suggested
    filterType = None
    F_PASS = 0
    F_STOP = 0
    ILOSS = 0
    IATT = 0
    filtered_signal = ourFilters.filterSignal(downsampled_data, SAMP_F, passFr = F_PASS, stopFr = F_STOP, LOSS = ILOSS, ATTENUATION = IATT, filterType = filterType)
    '''
    #filter 2
    #the user selects the parameters, with default suggested
    start_good_beats = 1290 #this parameter hasn't a default, this number is only for the example used in this algorithm
    end_good_beats = 1360 #this parameter hasn't a default, this number is only for the example used in this algorithm
    plen_bef = 0.35
]
col_acc = ["ACCX", "ACCY", "ACCZ"]
col_gyr = ["GYRX", "GYRY", "GYRZ"]
col_mag = ["MAGX", "MAGY", "MAGZ"]

empaticaAccCoeff = 2 * 9.81 / 128
empaticafsamp = 32

sensAccCoeff = 8 * 9.81 / 32768
sensGyrCoeff = 2000 / 32768
sensMagCoeff = 0.007629
sensfsamp = 100

data = tools.load_file(filename, sep=',', header=1)

data = tools.downsampling(data, 50)

t = tools.selectCol(data, columns_in, "TIME")
acc = tools.selectCol(data, columns_in, col_acc)
gyr = tools.selectCol(data, columns_in, col_gyr)
mag = tools.selectCol(data, columns_in, col_mag)
lab = tools.selectCol(data, columns_in, "LAB")

acc = inertial.convert_units(acc, coeff=sensAccCoeff)
gyr = inertial.convert_units(gyr, coeff=sensGyrCoeff)
mag = inertial.convert_units(mag, coeff=sensMagCoeff)

# tools.array_labels_to_csv(np.column_stack([t, acc]), np.array(columns_in), "./output/preproc_"+filename[7:-4]+".csv")

#-----EXTRACT FEATURES-----
Esempio n. 4
0
#Simulate user app
if __name__ == '__main__':
    #user insertion, the path is substituted with database source
    path = "/home/flavio/Work/PhysioWat/robaNoGit/data/Nicola's_data/"
    fileName = "EKG_F01_F.txt"
    SAMP_F = 256
    
    #load data from the file
    rawdata = loadEKG(path + fileName)
    
    #downsampling
    #the user selects the parameters, with default suggested
    downsampling_ratio = 1
    new_f = SAMP_F / float(downsampling_ratio)
    downsampled_data = ourTools.downsampling(rawdata, SAMP_F, new_f)
    
    #filter
    #the user selects the parameters, with default suggested
    filterType = None
    F_PASS = 0
    F_STOP = 0
    ILOSS = 0
    IATT = 0
    filtered_signal = ourFilters.filterSignal(downsampled_data, SAMP_F, passFr = F_PASS, stopFr = F_STOP, LOSS = ILOSS, ATTENUATION = IATT, filterType = filterType)
    
    #extraction of IBI from preprocessed signal
    #the user selects the parameters, with default suggested
    delta = 0.2
    minFr = 40
    maxFr = 200
Esempio n. 5
0
# import matplotlib.pyplot as plt
import windowing as win

filename="./data/GSR_F01_F.txt"

T1=0.75
T2=2
MX=1
DELTA=0.02
nFS=16

gsr_data = tools.load_file(filename, header=8, sep=",") # 8 ","
#TODO GAUSSIANA

gsr_data= tools.downsampling(gsr_data, nFS)
# plt.figure(1)
# plt.plot(gsr_data[:,0], gsr_data[:,1])
# plt.xlabel("Time (s)")
# plt.ylabel("GSR (uS)")
# plt.title("Raw GSR")
# t_gsr, gsr = GSR.remove_spikes(gsr_data[:,1], nFS)
t_gsr = gsr_data[:,0]
gsr   = gsr_data[:,1]
print gsr.shape
# print t_gsr.shape, gsr.shape, gsr_data.shape
t_driver, driver, phasic_d, tonic_d= GSR.estimate_drivers(t_gsr, gsr, T1, T2, MX, DELTA)
outputlabels=["timestamp", "driver", "phasic", "tonic"]


tools.array_labels_to_csv(np.column_stack([t_driver, driver, phasic_d, tonic_d]), np.array(outputlabels), "./output/preproc_"+filename[7:-4]+".csv")
col_acc=["ACCX", "ACCY", "ACCZ"]
col_gyr=["GYRX", "GYRY", "GYRZ"]
col_mag=["MAGX", "MAGY", "MAGZ"]


empaticaAccCoeff=2*9.81/128
empaticafsamp=32

sensAccCoeff=8*9.81/32768
sensGyrCoeff=2000/32768
sensMagCoeff=0.007629
sensfsamp=100

data = tools.load_file(filename, sep=',', header=1)

data=tools.downsampling(data, 50)

t=tools.selectCol(data, columns_in, "TIME")
acc=tools.selectCol(data, columns_in, col_acc)
gyr=tools.selectCol(data, columns_in, col_gyr)
mag=tools.selectCol(data, columns_in, col_mag)
lab=tools.selectCol(data, columns_in, "LAB")

acc= inertial.convert_units(acc, coeff=sensAccCoeff)
gyr= inertial.convert_units(gyr, coeff=sensGyrCoeff)
mag= inertial.convert_units(mag, coeff=sensMagCoeff)

# tools.array_labels_to_csv(np.column_stack([t, acc]), np.array(columns_in), "./output/preproc_"+filename[7:-4]+".csv")

#-----EXTRACT FEATURES-----