-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute2.py
executable file
·193 lines (154 loc) · 6.19 KB
/
compute2.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import numpy as np
import os
# this computes the value of 2020 based on the best average value of 2019 for semi-supervised
def read(root, root2020):
iteration = list(range(0, 52, 2))
WT = []
ET = []
TC = []
for ind in iteration:
path = root + str(ind)
path = os.path.join(path, 'result.txt')
file1 = open(path, 'r')
Lines = file1.readlines()
WT_line = Lines[1]
ET_line = Lines[2]
TC_line = Lines[3]
wt_strs = WT_line.split(' ')
et_strs = ET_line.split(' ')
tc_strs = TC_line.split(' ')
for i, s in enumerate(wt_strs):
if s != 'DICE:':
print("s is ", s)
continue
WT.append(np.float(wt_strs[i + 1].split(',')[0]))
ET.append(np.float(et_strs[i + 1].split(',')[0]))
TC.append(np.float(tc_strs[i + 1].split(',')[0]))
print(len(ET))
print("WT is ", WT)
print("ET is ", ET)
print("TC is ", TC)
WT = np.array(WT)
ET = np.array(ET)
TC = np.array(TC)
avg = ET + TC + WT
print("avg")
print(len(avg))
avg = np.array(avg)
avg = avg / 3
print("avg is ", avg / 3)
mi = np.argmax(avg)
print('max is')
mv = avg[mi]
print(mv)
print("best val iter is")
print(iteration[mi])
print("each is")
print("WT ", WT[mi])
print("ET ", ET[mi])
print("TC ", TC[mi])
if iteration[mi] == 50:
r = 49
else:
r = iteration[mi]
path = root2020 + str(r)
path = os.path.join(path, 'result.txt')
file1 = open(path, 'r')
Lines = file1.readlines()
print("2020 is")
print(Lines)
WT_line = Lines[1]
ET_line = Lines[2]
TC_line = Lines[3]
testWT = None
testET = None
testTC = None
wt_strs = WT_line.split(' ')
et_strs = ET_line.split(' ')
tc_strs = TC_line.split(' ')
for i, s in enumerate(wt_strs):
if s != 'DICE:':
print("s is ", s)
continue
return np.float(wt_strs[i + 1].split(',')[0]), np.float(et_strs[i + 1].split(',')[0]), np.float(
tc_strs[i + 1].split(',')[0])
print("************** SEED 41 **************")
seed = 41
year2019 = 'test2019'
year2020 = 'test2020'
ratio = 5
date_time = '2022-02-17 10:24:29.947448'
root2019 = '/projects/sina/W-Net/miccai2022/semi_alternate/sup_ratio_{}/seed_{}/{}/'\
'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2019)
root2020 = '/projects/sina/W-Net/miccai2022/semi_alternate/sup_ratio_{}/seed_{}/{}/'\
'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2020)
# ratio = 3
# date_time = '2022-02-15 22:14:39.973107'
# root2019 = '/projects/sina/W-Net/cvpr2022/sup_ratio_{}/seed_{}/{}/' \
# 'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2019)
#
# root2020 = '/projects/sina/W-Net/cvpr2022/sup_ratio_{}/seed_{}/{}/' \
# 'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2020)
#
# root2020 = '/projects/sina/W-Net/cvpr2022/semi_alternate/sup_ratio_{}/seed_{}/{}/' \
# 'result_images/{}_new_results_iter'.format(ratio, seed, date_time,year2020)
#CVPR
# root2019 = '/projects/sina/W-Net/PGS_result/Brats/CVPR2022/semi_pgs_CE_all2018/sup_ratio_{}/seed_{}/result_images/{}_new_results_iter'.format(
# ratio, seed, year2019)
#
# root2020 = '/projects/sina/W-Net/PGS_result/Brats/CVPR2022/semi_pgs_CE_all2018/sup_ratio_{}/seed_{}/result_images/{}_new_results_iter'.format(
# ratio, seed, year2020)
w41, e41, t41 = read(root2019, root2020)
print("************** SEED 42 **************")
seed = 42
year2019 = 'test2019'
year2020 = 'test2020'
ratio = 5
date_time = '2022-02-17 13:22:13.958454'
root2019 = '/projects/sina/W-Net/miccai2022/semi_alternate/sup_ratio_{}/seed_{}/{}/'\
'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2019)
root2020 = '/projects/sina/W-Net/miccai2022/semi_alternate/sup_ratio_{}/seed_{}/{}/'\
'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2020)
#
# ratio=3
# date_time = '2022-02-16 10:28:39.015293'
# root2019 = '/projects/sina/W-Net/cvpr2022/sup_ratio_{}/seed_{}/{}/' \
# 'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2019)
#
# root2020 = '/projects/sina/W-Net/cvpr2022/sup_ratio_{}/seed_{}/{}/' \
# 'result_images/{}_new_results_iter'.format(ratio, seed, date_time,year2020)
# CVPR
# root2019 = '/projects/sina/W-Net/PGS_result/Brats/CVPR2022/semi_pgs_CE_all2018/sup_ratio_{}/seed_{}/result_images/{}_new_results_iter'.format(
# ratio, seed, year2019)
#
# root2020 = '/projects/sina/W-Net/PGS_result/Brats/CVPR2022/semi_pgs_CE_all2018/sup_ratio_{}/seed_{}/result_images/{}_new_results_iter'.format(
# ratio, seed, year2020)
w42, e42, t42 = read(root2019, root2020)
print("************** SEED 43 **************")
seed = 43
year2019 = 'test2019'
year2020 = 'test2020'
ratio = 5
date_time = '2022-02-17 16:12:50.231484'
root2019 = '/projects/sina/W-Net/miccai2022/semi_alternate/sup_ratio_{}/seed_{}/{}/'\
'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2019)
root2020 = '/projects/sina/W-Net/miccai2022/semi_alternate/sup_ratio_{}/seed_{}/{}/'\
'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2020)
# ratio=3
# date_time = '2022-02-16 07:48:53.989469'
# root2019 = '/projects/sina/W-Net/cvpr2022/sup_ratio_{}/seed_{}/{}/' \
# 'result_images/{}_new_results_iter'.format(ratio, seed,date_time, year2019)
#
# root2020 = '/projects/sina/W-Net/cvpr2022/sup_ratio_{}/seed_{}/{}/' \
# 'result_images/{}_new_results_iter'.format(ratio, seed, date_time, year2020)
#CVPR
# root2019 = '/projects/sina/W-Net/PGS_result/Brats/CVPR2022/semi_pgs_CE_all2018/sup_ratio_{}/seed_{}/result_images/{}_new_results_iter'.format(
# ratio, seed, year2019)
#
# root2020 = '/projects/sina/W-Net/PGS_result/Brats/CVPR2022/semi_pgs_CE_all2018/sup_ratio_{}/seed_{}/result_images/{}_new_results_iter'.format(
# ratio, seed, year2020)
w43, e43, t43 = read(root2019, root2020)
print("FINAL RESULT")
print("WT ", (w41 + w42 + w43) / 3)
print("ET ", (e41 + e42 + e43) / 3)
print("TC ", (t41 + t42 + t43) / 3)