-
Notifications
You must be signed in to change notification settings - Fork 0
/
showData.py
60 lines (54 loc) · 1.86 KB
/
showData.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
import matplotlib.pyplot as plt
import csv, os, sys, copy, pywt
import numpy as np
from loadData import load
from sklearn import preprocessing
def indices(mylist, value):
return [i for i,x in enumerate(mylist) if x==value]
def showAveragepower():
path = './bci2003/'
subject = 'trainData'.split(' ')
loadData = load(subNames=subject, path=path,isRand=True)
(x_train, y_train) = loadData.loadTrainDataFromTxt()
d_avg = dict()
for tp in range(2):
tmp_index = indices(y_train, tp)
#print(len(tmp_index)) #show class quantity
tempList = x_train[tmp_index]
fixList = np.sum(tempList,axis=0)
resultList = np.divide(fixList,tempList.shape[0])
d_avg[tp] = resultList
LH = np.array(d_avg[0])
RH = np.array(d_avg[1])
time = np.arange(LH[:,0].size) / 128
plt.subplot(211)
plt.plot(time,LH)
plt.legend(['c3','cZ','c4'], loc='upper left')
plt.subplot(212)
plt.plot(time,RH)
plt.legend(['c3','cZ','c4'], loc='upper left')
plt.show()
def showDWT():
path = './bci2003'
subject = 'trainData_DWT'.split(' ')
loadData = load(subNames=subject, path=path)
(x_train, y_train) = loadData.loadTrainDataFromTxt()
d_avg = dict()
for tp in range(2):
tmp_index = indices(y_train, tp)
#print(len(tmp_index)) #show class quantity
tempList = x_train[tmp_index]
fixList = np.sum(tempList, axis=0)
resultList = np.divide(fixList, tempList.shape[0])
d_avg[tp] = resultList
plt.subplot(211)
plt.plot(d_avg[0])
plt.legend(['c3','cZ','c4'], loc='upper left')
plt.subplot(212)
plt.plot(d_avg[1])
plt.legend(['c3','cZ','c4'], loc='upper left')
plt.show()
print("end")
if __name__ == "__main__":
showAveragepower()
showDWT()