forked from Chanlaw/pointer-networks
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstats.py
61 lines (40 loc) · 1.28 KB
/
stats.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
from pandas import read_csv
from numpy import mean
from numpy import std
from numpy import delete
from numpy import savetxt
import numpy as np
from sklearn.preprocessing import normalize
data = read_csv('./EEGEYE.csv', header=None)
values = data.values
is_CP = []
boundaries = []
gap = []
values_down = np.zeros((values.shape[0]/10 + 1,16))
print(values_down.shape[0])
def is_toggle(x):
if (x==1):
return True
return False
for i in range(0,values.shape[0]-1,1):
if (is_toggle(values[i][0])==1):
is_CP.append(i)
for i in range(len(is_CP)-1):
if(i%2==0):
tup = (is_CP[i],is_CP[i+1],is_CP[i+1]-is_CP[i])
boundaries.append(tup)
gap.append(is_CP[i+1]-is_CP[i])
print("Mean " + str(mean(gap))) #610
print("Max " + str(max(gap))) #2401
print("Min " + str(min(gap))) #27
#Down Sampling of data, 15000 data points for 117 seconds.
# Down sample 10 data points
for i in range(0,values.shape[0],10):
if 1 in values[i:i+10,0]:
values_down[i//10][0]=1
else:
values_down[i//10][0]=0
values_down[i//10][1] = 0 #Leaving this column as random, no need of it
for j in range(2,16):
values_down[i//10][j] = mean(values[i:i+10,j])
savetxt('EEG_down.csv', values_down, delimiter=',',fmt='%0.3f')