forked from tiilt-lab/MYO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_data.py
40 lines (32 loc) · 1.02 KB
/
process_data.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
import csv
import numpy as np
initial_data = np.load("train_set.npz")
x=initial_data['x']
y=initial_data['y']
#x = np.ndarray.tolist(initial_data['x'])
#y = np.ndarray.tolist(initial_data['y'])
for val in y:
val = np.append(val, 0)
gesture = np.array([[0, 0, 0, 0, 0, 1]])
with open('myo_emg.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
i = 0
data_group = np.array([])
for row in csv_reader:
i = i + 1
row = row[1:]
if i == 1:
data_group = list(map(int, row))
elif i == 5:
for j in range(len(data_group)):
data_group[j] = round(data_group[j]/5)
x = np.vstack((x, np.array([data_group])))
y = np.vstack((y, gesture))
data_group = np.array([])
i = 0
else:
for j in range(len(data_group)):
data_group[j] = data_group[j] + int(row[j])
print(np.asarray(x))
print(np.asarray(y))
np.savez("train_set2.npz", x=np.asarray(x), y=np.asarray(y))