-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfile5.py
39 lines (29 loc) · 909 Bytes
/
file5.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
import cPickle
import numpy as np
from matplotlib import pyplot as plt
import butterworthFilter as bwf
import functions as func
import peakDetection as pd
import pca
lowcut = 0.1
highcut = 0.5
samplingFreq = 128.0 #Hz
fpulse = 1.3333
thres = 0.48 #for s01_trial05 testdata[4,38] BPM = 71.4
x = cPickle.load(open('s01.dat', 'rb'))
testdata = x['data']
testarray = testdata[04,38]
print ('testarray.shape',testarray.shape)
data = np.array(testarray)
plt.plot(data)
plt.show()
T = len(data)
nsamples = len(data)
#func.fft_plot2(data)
cnt=0
y = bwf.butterworthHighPass(T,nsamples,samplingFreq,lowcut,data)
#fpulse = pca.getfpulse(np.array(y),samplingFreq)
#func.fft_plot2(y)
#np.savetxt('ppg_signal.out', y, delimiter=',')
bpm,hrv,SDNN = pd.plotFinalBPM(y,T,nsamples,samplingFreq,fpulse,thres,cnt)
print ("Final BPM = %f, fpulse = %f" %(bpm,fpulse)) #BPM = 49.6