-
Notifications
You must be signed in to change notification settings - Fork 0
/
summary_of_results.py
41 lines (32 loc) · 1.64 KB
/
summary_of_results.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
import pandas as pd
if __name__=='__main__':
output_txt = True
output_tex = True
output_csv = True
results_filenames = ['Benchmark_Bundle_Segmentation/results_streamlines_1NN_train_10.csv',
'Benchmark_Minor_Bundle_Segmentation/results_streamlines_1NN_train_10.csv']
for results_filename in results_filenames:
results = pd.read_csv(results_filename)
# print(results)
summary = results.groupby(['bundle_string']).agg({'DSC_voxels':['mean', 'std']})
pd.set_option('display.max_rows', None)
print(summary.sort_values(ascending=False, by=('DSC_voxels', 'mean')))
if output_txt:
report_filename = results_filename.replace(".csv", ".txt").replace("results", "report")
print(f"Saving report in {report_filename}")
f = open(report_filename, 'w')
print(summary.sort_values(ascending=False, by=('DSC_voxels', 'mean')), file=f)
f.close()
if output_tex:
report_filename = results_filename.replace(".csv", ".tex").replace("results", "report")
print(f"Saving report in {report_filename}")
f = open(report_filename, 'w')
print(summary.sort_values(ascending=False, by=('DSC_voxels', 'mean')).round(2).to_latex(), file=f)
f.close()
if output_csv:
report_filename = results_filename.replace("results", "report")
print(f"Saving report in {report_filename}")
f = open(report_filename, 'w')
print(summary.sort_values(ascending=False, by=('DSC_voxels', 'mean')).to_csv(), file=f)
f.close()
print("")