Skip to content

Commit 7f930ab

Browse files
Py3 scripts for LUNA16 eval (#1068)
Fixes # . ### Description Provide Py3 scripts for LUNA16 eval ### Checks <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [ ] Notebook runs automatically `./runner [-p <regex_pattern>]` Signed-off-by: Can Zhao <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 47033b5 commit 7f930ab

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

detection/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ python3 luna16_testing.py \
105105

106106
#### [3.4 LUNA16 Detection Evaluation](./run_luna16_offical_eval.sh)
107107
Please download the official LUNA16 evaluation scripts from https://luna16.grand-challenge.org/Evaluation/,
108-
and save it as ./evaluation_luna16. Note that the official LUNA16 evaluation scripts are based on Python2.
108+
and save it as ./evaluation_luna16. Note that the official LUNA16 evaluation scripts are based on python2.
109+
110+
To run it with python3, please 1) copy the files in ./evaluationScript_py3_update to replace the files in downloaded scripts in ./evaluation_luna16; 2) then run the following command to convert python2 code to python3 code: `python -m pip install future; futurize --stage1 -w evaluation_luna16/noduleCADEvaluationLUNA16.py; futurize --stage2 -w evaluation_luna16/noduleCADEvaluationLUNA16.py`;
111+
3) In ./evaluation_luna16/noduleCADEvaluationLUNA16.py, replace `plt.xscale('log', basex=2)` with `plt.xscale('log', base=2)`.
109112

110113
./evaluation_luna16/noduleCADEvaluationLUNA16.py will be the main python script to generate evaluation scores.
111114

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import csv
2+
3+
4+
def writeCSV(filename, lines):
5+
with open(filename, "wb") as f:
6+
csvwriter = csv.writer(f)
7+
csvwriter.writerows(lines)
8+
9+
10+
def readCSV(filename):
11+
lines = []
12+
try:
13+
with open(filename, "rb") as f:
14+
csvreader = csv.reader(f)
15+
for line in csvreader:
16+
lines.append(line)
17+
except:
18+
with open(filename, "r") as f:
19+
csvreader = csv.reader(f)
20+
for line in csvreader:
21+
lines.append(line)
22+
return lines
23+
24+
25+
def tryFloat(value):
26+
try:
27+
value = float(value)
28+
except:
29+
value = value
30+
31+
return value
32+
33+
34+
def getColumn(lines, columnid, elementType=""):
35+
column = []
36+
for line in lines:
37+
try:
38+
value = line[columnid]
39+
except:
40+
continue
41+
42+
if elementType == "float":
43+
value = tryFloat(value)
44+
45+
column.append(value)
46+
return column

detection/run_luna16_offical_eval.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ python ./luna16_post_combine_cross_fold_results.py \
2525
-o ./result/result_luna16_all.csv
2626

2727
mkdir -p ./result/eval_luna16_scores
28-
python2 ./evaluation_luna16/noduleCADEvaluationLUNA16.py \
28+
python ./evaluation_luna16/noduleCADEvaluationLUNA16.py \
2929
./evaluation_luna16/annotations/annotations.csv \
3030
./evaluation_luna16/annotations/annotations_excluded.csv \
3131
./evaluation_luna16/annotations/seriesuids.csv \

0 commit comments

Comments
 (0)