-
Notifications
You must be signed in to change notification settings - Fork 0
/
result_integrate_test1.py
128 lines (105 loc) · 4.58 KB
/
result_integrate_test1.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# *-* coding: UTF-8 *-*
import os, sys, re, time
import numpy as np
from file_script import log_result, new_fold
root_path = os.getcwd()
channel_pos_list = ['S0', # 中心位置
'U1', 'U2', 'D1', 'D2', 'L1', 'L2', 'R1', 'R2'] # 上 下 左 右
proportional_list = ['1.0', '0.9', '0.8', '0.7', '0.6', '0.8-0.9', '0.7-0.9', '0.6-0.9']
action_lists = [7, 9, 11]
# action_lists = [7]
def result_load(dir='250_100', feature_type='TD4', subject='subject_1', norm='_norm', action='7', training_type='intra'):
file_path = root_path + '/result_test1/' + dir + '/' +\
feature_type+'_data4_'+ subject + norm + '/' +\
'feat_'+feature_type+'_'+training_type+'_action_1-'+str(action)+'.npy'
data = np.load(file_path)
return data
def result_integrate_intra(time_now):
training_type = 'intra'
span = len(proportional_list)
fold_path = root_path + '/result_test1/proportional_integrate'
new_fold(fold_path)
feature_type = 'TD4'
norm = '_norm'
subject_list = ['subject_' + str(i) for i in range(1, 6)]
res_all = []
blank_line = ['' for i in range(len(channel_pos_list))]
res_all.append(blank_line)
for action in action_lists:
for subject in subject_list:
res = []
index = 2
res_ind = 1
data = result_load('250_100',feature_type, subject, norm, action, training_type)
title = feature_type+'_'+subject+'_action_1-'+str(action)
res_head = [title]
res_head.extend(proportional_list)
res.append(res_head)
for i in range(len(channel_pos_list)):
res_intra = [channel_pos_list[i]]
# print res_intra
res_intra.extend(map(float,data[index:index+span,4][:]))
index += span
res.append(res_intra)
res_np = np.array(res)
res_aver = ['average']
for i in range(len(proportional_list)):
res_aver.append(np.mean(map(float,res_np[res_ind:,i+1])))
res.append(res_aver)
# file_path = fold_path + '/prop_'+training_type+'_'+title+'_'+str(time_now)
# log_result(res, file_path, 2)
res_all.extend(res)
res_all.append(blank_line)
res_all.append(blank_line)
res_all.append(blank_line)
res_all.append(blank_line)
res_all.append(blank_line)
file_path = fold_path + '/prop_'+training_type+'_all_'+str(time_now)
log_result(res_all, file_path, 2)
def result_integrate_inter(time_now):
training_type = 'inter'
span = len(proportional_list)
fold_path = root_path + '/result_test1/proportional_integrate'
new_fold(fold_path)
feature_type = 'TD4'
norm = '_norm'
subject_list = ['subject_' + str(i) for i in range(1, 6)]
res_all = []
blank_line = ['' for i in range(len(channel_pos_list))]
res_all.append(blank_line)
for action in action_lists:
for subject in subject_list:
res = []
index = 2
res_ind = 1
data = result_load('250_100',feature_type, subject, norm, action, training_type)
title = feature_type+'_'+subject+'_action_1-'+str(action)
res_head = [title]
res_head.extend(proportional_list)
res.append(res_head)
for i in range(len(channel_pos_list)-1):
res_intra = [channel_pos_list[i+1]]
# print res_intra
res_intra.extend(map(float,data[index:index+span,4][:]))
index += span
res.append(res_intra)
res_np = np.array(res)
res_aver = ['average']
for i in range(len(proportional_list)):
res_aver.append(np.mean(map(float,res_np[res_ind:res_ind+8,i+1])))
res.append(res_aver)
# file_path = fold_path + '/prop_'+training_type+'_'+title+'_'+str(time_now)
# log_result(res, file_path, 2)
res_all.extend(res)
res_all.append(blank_line)
res_all.append(blank_line)
res_all.append(blank_line)
res_all.append(blank_line)
res_all.append(blank_line)
file_path = fold_path + '/prop_'+training_type+'_all_'+str(time_now)
log_result(res_all, file_path, 2)
if __name__ == '__main__':
time_now = time.strftime('%Y-%m-%d_%H-%M',time.localtime(time.time()))
# print time_now
result_integrate_intra(time_now)
result_integrate_inter(time_now)