-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplots.py
71 lines (59 loc) · 1.83 KB
/
plots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import matplotlib.pyplot as plt
import numpy as np
import itertools
from scipy import interpolate, signal
import sklearn.decomposition
import signals
import facetracking
import threading
import Queue
import time
import pickle
t = 6
data = pickle.load(open('all.pkl', 'r'))
fft = pickle.load(open('fft.pkl', 'r'))
print data['transformed'].T.shape
print data['filtered'].T.shape
plt.figure()
plt.plot(data['points'][0:(t * 30)])
plt.title('Facetracked points (one second, 30Hz)')
plt.xlabel('Frame number')
plt.ylabel('Position offset')
plt.savefig('graph1.png', bbox_inches='tight')
plt.figure()
plt.plot(data['interpolated'].T[0:(t * 250)])
plt.title('Interpolated points (one second, 250Hz)')
plt.xlabel('Interpolated frame number')
plt.ylabel('Position Offset')
plt.savefig('graph2.png', bbox_inches='tight')
plt.show()
plt.figure()
plt.plot(data['filtered'][0:(t * 250)])
plt.title('Butterworth filtered points')
plt.xlabel('Interpolated frame number')
plt.ylabel('Filtered point position')
plt.savefig('graph3.png', bbox_inches='tight')
plt.show()
plt.figure()
plt.plot(data['transformed'][0:(t * 250)])
plt.title('Princple Components of movements')
plt.xlabel('Interpolated frame number')
plt.ylabel('Waveform value')
plt.savefig('graph4.png', bbox_inches='tight')
plt.show()
plt.figure()
plt.plot(fft['frequencies'][:50] * 60.0, fft['power'][:50])
plt.title('Frequencies of principle components')
plt.xlabel('Frequency (BPM)')
plt.ylabel('Power')
plt.savefig('graph5.png', bbox_inches='tight')
plt.show()
plt.figure()
most_periodic = np.argmax(data['periodicities'])
for i, p in enumerate(data['transformed'].T):
plt.plot(p[0:t * 250], linewidth=5 if i == most_periodic else 1)
plt.title('Princple Components of movements')
plt.xlabel('Interpolated frame number')
plt.ylabel('Waveform value')
plt.savefig('graph6.png', bbox_inches='tight')
plt.show()