def test_detectpeak2(filename, node): """ Test detectpeak implemented in Python Returns ------- status: str "OK" or "ERROR" """ data = plot_imu.imu_load(filename) datanode = plot_imu.imu_extract(data, node, sensor_type=TYP_SENS) timea = np.transpose([datanode['time'], datanode['time'], datanode['time']]) sens = np.transpose([datanode['X'], datanode['Y'], datanode['Z']]) print len(timea), len(sens), len(datanode['X']) sens_norm = algo.compute_norm(sens) sens_filt = algo.moving_average(sens_norm, WINDOW_SIZE) #index_peak = algo.search_maxpeak(sens_filt) [time_peak, sens_peak] = algo.threshold_under_signal(timea, sens_filt, THRESHOLD) print "Step numbers=", len(sens_peak) plt.figure() plt.plot(timea[:, 0], sens[:, 0:3]) plt.title(TYP_SENS + node) plt.legend(('x', 'y', 'z'), bbox_to_anchor=(0, 1, 1, 0), ncol=2, loc=3, borderaxespad=0.) plt.figure() plt.title("Peak detection " + node) plt.plot(timea[:, 0], sens_norm) plt.plot(timea[:, 0], sens_filt) plt.plot(time_peak, sens_peak, "o") return "OK"
def test3(): """ Test3 """ from sensbiotk.io import iofox_deprec as fox import pylab as py print "Test Calibration" [_, acc, _, _] = fox.load_foximu_csvfile(FILETEST) norm_acc = algo.compute_norm(acc) py.plot(norm_acc) py.show() return
def test_pedometer(): """ Test pedometer implemented in Python Returns ------- status: str "OK" or "ERROR" """ from sensbiotk.io import iofox from sensbiotk.algorithms import basic as algo import pylab as py [timea, acc] = iofox.load_foxacc_csvfile("./data/walk1_acc.csv") [timea, acc] = algo.cut_signal(timea, acc, 12.0, 29.0) acc_norm = algo.compute_norm(acc) #acc_filt = algo.lowpass_filter(acc_norm, 2.0, 100.0) #acc_filt = algo.lowpass_filter2(acc_norm, 2.0, 200.0) acc_filt = algo.moving_average(acc_norm, 30) #acc_filt = algo.moving_average2(acc_norm, 50) index_peak = algo.search_maxpeak(acc_filt) [time_peak, acc_peak] = algo.threshold_signal(timea[index_peak], acc_filt[index_peak], 11.0) print "Step numbers=", len(acc_peak) py.figure() py.plot(timea[:, 0], acc[:, 0:3]) py.title("Walking 1 Accelerations") py.legend(('x', 'y', 'z'), bbox_to_anchor=(0, 1, 1, 0), ncol=2, loc=3, borderaxespad=0.) py.figure() py.title("Walking 1 Results") py.plot(timea[:, 0], acc_norm) py.plot(timea[:, 0], acc_filt) py.plot(time_peak, acc_peak, "o") py.figure() py.plot(np.diff(acc_filt)) py.plot(np.diff(np.sign(np.diff(acc_filt)) < 0)) py.show() return "OK"
def test_detectpeak(filename, node): """ Test detectpeak implemented in Python Returns ------- status: str "OK" or "ERROR" """ data = plot_imu.imu_load(filename) datanode = plot_imu.imu_extract(data, node, sensor_type=TYP_SENS) timea = np.transpose( [datanode['time'], datanode['time'], datanode['time']]) sens = np.transpose([datanode['X'], datanode['Y'], datanode['Z']]) print len(timea), len(sens), len(datanode['X']) sens_norm = algo.compute_norm(sens) sens_filt = algo.moving_average(sens_norm, WINDOW_SIZE) index_peak = algo.search_maxpeak(sens_filt) [time_peak, sens_peak] = algo.threshold_signal(timea[index_peak], sens_filt[index_peak], THRESHOLD) print "Step numbers=", len(sens_peak) plt.figure() plt.plot(timea[:, 0], sens[:, 0:3]) plt.title(TYP_SENS + node) plt.legend(('x', 'y', 'z'), bbox_to_anchor=(0, 1, 1, 0), ncol=2, loc=3, borderaxespad=0.) plt.figure() plt.title("Peak detection " + node) plt.plot(timea[:, 0], sens_norm) plt.plot(timea[:, 0], sens_filt) plt.plot(time_peak, sens_peak, "o") #plt.figure() #plt.plot(np.diff(sens_filt)) #plt.plot(np.diff(np.sign(np.diff(sens_filt)) < 0)) return "OK"
def compute_simple(data): """ Compute IMU accelerometer calibration parameters Parameters : ------------ data : numpy array of float data sensor in motion containing all the acquisition on three axis Returns ------- offset : numpy array of float (dim=3) offset parameter scale : numpy array of float (dim=3) scale parameters """ offset = [0, 0, 0] norm_acc = algo.compute_norm(data) val_scale = scale_fit_norm(norm_acc, 9.81) scale = [val_scale, val_scale, val_scale] return scale, offset
def test_freefall(): """ Test freefall detector implemented in Python Returns ------- status: str "OK" or "ERROR" """ from sensbiotk.io import iofox from sensbiotk.algorithms import basic as algo [timea, acc] = iofox.load_foxacc_csvfile("./data/freefall1_acc.csv") acc_norm = algo.compute_norm(acc) [state_freefall] = threshold_inf(acc_norm, 1.5) [state_freefall] = threshold_time(timea[:, 0], state_freefall, 0.1) [state_inactive] = search_state(timea[:, 0], acc_norm, 10.0, 5.0) [state_inactive] = threshold_time(timea[:, 0], state_inactive, 0.1) py.figure() py.plot(timea[:, 0], acc[:, 0:3]) py.title("FreeFall Accelerations") py.legend(('x', 'y', 'z'), bbox_to_anchor=(0, 1, 1, 0), ncol=2, loc=3, borderaxespad=0.) py.figure() py.title("FreeFall detection Results (Python)") py.plot(acc_norm) py.plot(state_freefall) py.plot(state_inactive * 5) return "OK"