示例#1
0
# 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")

#-----FEATURES-----

windows = win.generate_dummy_windows(t_driver, 20, 10)
features = GSR.extract_features(phasic_d, t_driver, DELTA, windows)
tools.dict_to_csv(features, "./output/feat_" + filename[7:-4] + ".csv")

# tools.prepare_json_to_plot_time(t_driver, [driver, phasic_d, tonic_d], ["Driver", "Phasic", "Tonic"])
# plt.figure(2)
# plt.plot(t_driver, np.c_[tonic_d, driver, phasic_d])
# plt.legend(["Tonic", "Driver", "Phasic"])
# plt.title("Processed GSR")
# plt.xlabel("Time (s)")
# plt.ylabel("GSR (uS)")
# plt.show()
示例#2
0
T2=2
MX=1
DELTA=0.02
FS=4
nFS=4

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

# gsr_data=tools.downsampling(gsr_data, FS, 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 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, FS=FS)
windows=win.generate_dummy_windows(len(phasic_d), 80, 10)
features = GSR.extract_features(phasic_d, t_driver, DELTA, windows)
# features.to_csv("./output/feat_"+filename[7:-4]+".csv")
tools.prepare_json_to_plot_time(t_driver, [driver, phasic_d, tonic_d], ["Driver", "Phasic", "Tonic"])
# plt.figure(2)
# plt.plot(t_driver, np.c_[tonic_d, driver, phasic_d])
# plt.legend(["Tonic", "Driver", "Phasic"])
# plt.title("Processed GSR")
# plt.xlabel("Time (s)")
# plt.ylabel("GSR (uS)")
# plt.show()
plt.figure(1)
plt.plot(data.timestamp, data[lables_acc])
plt.legend(lables_acc)
plt.xlabel("Time (ms)")
plt.ylabel("Acceleration (m/s^2)")
plt.title("Accelerometer")
plt.figure(2)
plt.plot(data.timestamp, data[lables_gyr])
plt.legend(lables_gyr)
plt.xlabel("Time (ms)")
plt.ylabel("Angular Speed (degree/s)")
plt.title("Gyroscope")
plt.figure(3)
plt.plot(data.timestamp, data[lables_mag])
plt.legend(lables_mag)
plt.title("Magnetometer")
plt.ylabel("uT")
plt.xlabel("Time (ms)")
plt.show()

# data=inertial.convert_units(data, lables[1:], coeff=empaticaAccCoeff)
# print data
windows=win.generate_dummy_windows(len(data), 100, 50)
feats_acc=inertial.extract_features_acc(data, windows, fsamp=sensfsamp, col_acc=lables_acc)
feats_gyr=inertial.extract_features_gyr(data, windows, fsamp=sensfsamp, col_gyr=lables_gyr)
feats_mag=inertial.extract_features_mag(data, windows, fsamp=sensfsamp, col_mag=lables_mag)
feats=pd.concat([feats_acc, feats_gyr, feats_mag], axis=1)
print feats.shape
feats.to_csv("./output/feat_"+filename[7:-4]+".csv")

示例#4
0
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")

#-----FEATURES-----

windows=win.generate_dummy_windows(t_driver, 20, 10)
features = GSR.extract_features(phasic_d, t_driver, DELTA, windows)
tools.dict_to_csv(features, "./output/feat_"+filename[7:-4]+".csv")

# tools.prepare_json_to_plot_time(t_driver, [driver, phasic_d, tonic_d], ["Driver", "Phasic", "Tonic"])
# plt.figure(2)
# plt.plot(t_driver, np.c_[tonic_d, driver, phasic_d])
# plt.legend(["Tonic", "Driver", "Phasic"])
# plt.title("Processed GSR")
# plt.xlabel("Time (s)")
# plt.ylabel("GSR (uS)")
# plt.show()