matchYZ[i] = (None, 0) for j in sZ: cd = cover_distance(i,j) if matchYZ[i][1] < cd: matchYZ[i] = (j, cd) return matchXY, matchXZ, matchYZ if __name__ == '__main__': # 'NOGA', 'FSL' p = Pacientes() e = Exercises() p.from_db(pilot='NOGA') e.from_db(pilot='NOGA') for ex in e.iterator(): t = Trajectory(ex.get_coordinates()) if t.straightness()[0] < 0.95: e.delete_exercises([ex.id]) for ex in e.iterator(): print (ex.uid + '-' + str(ex.id)) trajec = Trajectory(np.array(ex.frame.loc[:, ['epx', 'epy']]), exer=ex.uid + ' ' + str(ex.id)) beg, nd, vdis = trajec.find_begginning_end() print(beg, nd) ltuplesX = segment_signal(ex.frame['rhfx'] - ex.frame['lhfx'], beg, nd)
prevw = word(sdisc[0]) lvoc = [prevw] for i in range(1, sdisc.shape[0]): nword = word(sdisc[i]) if nword != prevw: lvoc.append(nword) self.codes[c] = Counter(lvoc) # print(c, self.codes[c]) if __name__ == '__main__': from iWalker.Data import User, Exercise, Exercises, Pacientes, Trajectory from iWalker.Util.Misc import show_list_signals p = Pacientes() e = Exercises() p.from_db(pilot='NOGA') e.from_db(pilot='NOGA') e.delete_patients(['FSL30']) wlen = 64 voclen = 3 ncoefs = 3 dseries = {} for ex in e.iterator(): forces = ex.get_forces() if forces.shape[0] > wlen: dseries[ex.id] = forces[:, 0] boss = Boss(dseries, 10) boss.discretization_intervals(ncoefs, wlen, voclen)
""" __author__ = 'bejar' from iWalker.Data import User, Exercise, Exercises, Pacientes, Trajectory from iWalker.Util.Misc import show_list_signals from iWalker.Util import Boss, boss_distance, euclidean_distance, bin_hamming_distance, hamming_distance,\ cosine_similarity from sklearn.manifold import MDS, Isomap, TSNE, SpectralEmbedding import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D if __name__ == '__main__': p = Pacientes() e = Exercises() p2 = Pacientes() e2 = Exercises() p.from_db(pilot='NOGALES') e.from_db(pilot='NOGALES') # p2.from_db(pilot='FSL') # e2.from_db(pilot='FSL') # e2.delete_patients(['FSL30']) # # e.merge(e2) e.delete_exercises([1425290750]) # e.delete_exercises([1416241920, 1416241871, 1416409354, 1416391685, 1416933676, 1416918342, 1416391884, 1416391948]) wlen = 128 voclen = 3
# coef = np.zeros((nwindows, ncoef), dtype=np.complex) # # for w in range(nwindows): # y = np.fft.rfft(series[w:w+wsize]) # for l in range(ncoef): # coef[w, l] = y[l] # # # return coef if __name__ == '__main__': from iWalker.Data import User, Exercise, Exercises, Pacientes, Trajectory from iWalker.Util.Misc import show_list_signals p = Pacientes() e = Exercises() p.from_db(pilot='NOGA') e.from_db(pilot='NOGA') e.delete_patients(['FSL30']) ex = e.iterator().__next__() signal = ex.get_forces()[:, 0] # show_list_signals([signal]) print(signal.shape) itime = time.time() coef1 = mft(signal, sampling=10, ncoef=15, wsize=32) ftime = time.time() print(ftime - itime) # itime = time.time()
from sklearn.manifold import MDS, Isomap, TSNE, SpectralEmbedding import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from sklearn.mixture import BayesianGaussianMixture as Dirichlet import matplotlib.colors as colors from sklearn.metrics import silhouette_score from itertools import product __author__ = 'bejar' # colors = "rgbymcykrgbymcyk" if __name__ == '__main__': p = Pacientes() e = Exercises() p.from_db(pilot='NOGALES') e.from_db(pilot='NOGALES') e.delete_exercises([1424971539, 1424968950]) e.delete_exercises([1425290750, 1425376956, 1425486861, 1425484520]) # e.delete_exercises([1425290750]) for wlen in [128]: # wlen = 128 print('*' * 20) print('WLEN=', wlen) for ex in e.iterator(): t = Trajectory(ex.get_coordinates()) if t.straightness()[0] < 0.95:
ncoefs = 7 data=[wlen, voclen, ncoefs] with open("ranscore_l0.csv", "a") as f: writer = csv.writer(f) writer.writerow(data) writer.writerow(" ") x=10 lol=[] for u in range(0, x): p = Pacientes() e = Exercises() p.from_db(pilot='NOGALES') e.from_db(pilot='NOGALES') e.delete_exercises([1425638547]) e.delete_exercises([1425638507]) e.delete_exercises([1425638379]) e.delete_exercises([1425638343]) e.delete_exercises([1425637677]) e.delete_exercises([1425637642]) e.delete_exercises([1425637526]) e.delete_exercises([1425637492]) e.delete_exercises([1425637369]) e.delete_exercises([1425637335]) e.delete_exercises([1425577862])