def findsync(dataMatrix): datamatrix = Init.getData(dataMatrix,sensors=["STE"],datas=[ "acc"]) signal= dataMatrix[:,2] maxAbsValue, maxAbsFreq = FourierTransformation.maxAbsFreq(signal) Filtered = FeatureKonstruktion.filter(datamatrix,[2,3,4],maxAbsFreq) plt.plot(Filtered[:,2:]) plt.show()
def getminimas(dataMatrix, Sensor=[290]): signal = dataMatrix[:,Sensor[0]] maxAbsValue, maxAbsFreq = FourierTransformation.maxAbsFreq(signal[0:13000]) Filtered = FeatureKonstruktion.filter(dataMatrix,Sensor,maxAbsFreq) print maxAbsFreq,maxAbsValue plt.plot(signal) plt.show() return argrelmin(Filtered[:,Sensor],order=25)
def getmaximas(dataMatrix, Sensor=[290]): signal = dataMatrix[:,Sensor[0]] maxAbsValue, maxAbsFreq = FourierTransformation.maxAbsFreq(signal[0:13000]) Filtered = FeatureKonstruktion.filter(dataMatrix,Sensor,maxAbsFreq) plt.plot(Filtered[:,Sensor],label="z-Acceleration Foot") plt.title("Filtered acceleration") plt.legend() plt.xlabel("Samples") plt.ylabel("m/s^2") plt.show() return argrelmax(Filtered[:,Sensor],order=25)
def MatrixforAndroid(datamatrix, elan): modifiedmatrix ,steps = StepExtraction.videosteps(datamatrix,elan) print steps print elan e,f = FeatureKonstruktion.handverkrampft(modifiedmatrix,steps[:,[0,1]]) g,h,k = FeatureKonstruktion.aufrechtgehen(modifiedmatrix,steps[:,[0,1]]) i,j =FeatureKonstruktion.Fussabrollen(modifiedmatrix,steps[:,[0,1]]) passgang = FeatureKonstruktion.Passgang(modifiedmatrix,steps[:,[0,1]]) rightpeak,leftpeak = FeatureKonstruktion.Stockaufsatz(modifiedmatrix,steps[:,[0,1]]) a,b = FeatureKonstruktion.schulterbewegung(modifiedmatrix,steps[:,[0,1]]) c,d = FeatureKonstruktion.armstreckung(modifiedmatrix,steps[:,[0,1]]) elan = pd.DataFrame(elan[:,1:],index=elan[:,0]) elanpass = np.array(elan.ix['1Passgang'])[:,3] elanstock = np.array(elan.ix['1Stockeinsatz'])[:,3] elanarm = np.array(elan.ix['1Armeinsatz'])[:,3] elanschritt = np.array(elan.ix['2Schrittlaenge'])[:,3] elanschub = np.array(elan.ix['2Schub'])[:,3] elanverkrampfung = np.array(elan.ix['2Verkrampfung'])[:,3] elanober = np.array(elan.ix['2Oberkoerper'])[:,3] elanfuss = np.array(elan.ix['2Fussaufsatz'])[:,3] elantiming = np.array(elan.ix['2Timing'])[:,3] elanshwingen = np.array(elan.ix['3Vorschwingen'])[:,3] elanblick = np.array(elan.ix['3Blick'])[:,3] print len(steps) print len(elanpass) print len(elanstock) print len(elanarm) print len(elanschritt) print len(elanschub) print len(elanfuss) print len(elanverkrampfung) print len(elanober) print len(elantiming) print len(elanshwingen) print len(elanblick) new = np.c_[steps,elanpass] new = np.c_[new,elanstock] new = np.c_[new,elanarm] new = np.c_[new,elanschritt] new = np.c_[new,elanschub] new = np.c_[new,elanfuss] new = np.c_[new,elanverkrampfung] new = np.c_[new,elanober] new = np.c_[new,elantiming] new = np.c_[new,elanshwingen] new = np.c_[new,elanblick] plt.subplot(4,1,1) plt.title("passgang") plt.plot(passgang) plt.subplot(4,1,2) plt.title("Stockaufsatz") plt.plot(rightpeak) plt.plot(leftpeak) plt.subplot(4,1,3) plt.title("schulter") plt.plot(a) plt.plot(b, label= "Rechteschulter") plt.subplot(4,1,4) plt.title("Arm") plt.plot(c) plt.plot(d) #plt.plot(d, label= "Rechter Arm") plt.show() file = [] label= [] FeatureFile= np.c_[steps,passgang,rightpeak,leftpeak,a,b,c,d,e,f,g,h,i,j,k] for k in range(4,len(new[1,:])): for t in range(0,len(new)): if new[t,k]==3 or new[t,k]==2 or new[t,k]==1: temp = new[t,k] else: new[t,k]= temp for i in range(0,len(new)): temp = new[i,4] if temp==3: new[i,4:]=3 for i in range(0,len(new)): if new[i,4]==2 or new[i,4]==1: print new[i,4] file.append(FeatureFile[i,:]) label.append(new[i,:]) labelpass = [] filepass = [] for i in range(0,len(new)): if new[i,4]==2 or new[i,4]==1 or new[i,4]== 3: filepass.append(FeatureFile[i,:]) labelpass.append(new[i,:5]) print(label) print(file) np.savetxt("20151127ID005features.csv",file,delimiter="\t") np.savetxt("20151127ID005labels.csv",label,delimiter="\t",fmt="%s") np.savetxt("20151127ID005featurespass.csv",filepass,delimiter="\t") np.savetxt("20151127ID005labelspass.csv",labelpass,delimiter="\t",fmt="%s") print "finished"