-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_data.py
76 lines (33 loc) · 1.51 KB
/
load_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
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
72
73
74
75
76
import numpy as np
import pickle
import os
load_path = './DATA/SEED_V/EEG_DE_features/'
save_path = './DATA/SEED_V/EEG/'
data_npz = np.load(os.path.join(load_path, '1_123.npz'))
# data = pickle.loads(data_npz['data'])
# data = list(data.values())
data = pickle.loads(data_npz['label'])
data = list(data.values())
# an_array = np.array(data)
# print(an_array[0])
# exit(0)
for subject_num in range(1, 17):
for fold_num in range(1, 4):
data_npz = np.load(os.path.join(load_path, '{}_123.npz').format(subject_num))
data = pickle.loads(data_npz['data'])
label = pickle.loads(data_npz['label'])
data = np.array(list(data.values()))
label = np.array(list(label.values()))
temp_data = np.zeros((0, 310))
temp_label = np.zeros((0, 1))
for session_num in range(0, 3):
start_trial_num, end_trial_num = 5*(fold_num-1), 5*fold_num
start_trial_num = start_trial_num + 15*session_num
end_trial_num = end_trial_num + 15*session_num
for trials_num in range(start_trial_num, end_trial_num):
print(session_num, trials_num)
temp_data = np.vstack((temp_data, data[trials_num]))
temp_label = np.vstack((temp_label, np.expand_dims(label[trials_num], 1)))
np.save(os.path.join(save_path, 'de_{}_{}').format(subject_num, fold_num), temp_data)
np.save(os.path.join(save_path, 'label_{}_{}').format(subject_num, fold_num), temp_label)
#