|
a |
|
b/evaluate_luna_seg_scan.py |
|
|
1 |
import glob |
|
|
2 |
import os |
|
|
3 |
import sys |
|
|
4 |
import numpy as np |
|
|
5 |
import blobs_detection |
|
|
6 |
import pathfinder |
|
|
7 |
import utils |
|
|
8 |
import utils_lung |
|
|
9 |
from configuration import set_configuration |
|
|
10 |
import data_transforms |
|
|
11 |
|
|
|
12 |
if len(sys.argv) < 2: |
|
|
13 |
sys.exit("Usage: evaluate_luna_scan.py <configuration_name>") |
|
|
14 |
|
|
|
15 |
config_name = sys.argv[1] |
|
|
16 |
set_configuration('configs_seg_scan', config_name) |
|
|
17 |
|
|
|
18 |
predictions_dir = utils.get_dir_path('model-predictions', pathfinder.METADATA_PATH) |
|
|
19 |
outputs_path = predictions_dir + '/%s' % config_name |
|
|
20 |
|
|
|
21 |
blob_files = sorted(glob.glob(outputs_path + '/*.pkl')) |
|
|
22 |
# print blob_files |
|
|
23 |
|
|
|
24 |
pid2annotations = utils_lung.read_luna_annotations(pathfinder.LUNA_LABELS_PATH) |
|
|
25 |
|
|
|
26 |
tp = 0 |
|
|
27 |
n_pos = 0 |
|
|
28 |
n_blobs = 0 |
|
|
29 |
for p in blob_files: |
|
|
30 |
pid = utils_lung.extract_pid_filename(p, '.pkl') |
|
|
31 |
blobs = utils.load_pkl(p) |
|
|
32 |
n_blobs += len(blobs) |
|
|
33 |
print pid |
|
|
34 |
print 'n_blobs', len(blobs) |
|
|
35 |
print 'tp / n pos ', int(np.sum(blobs[:, -1])), len(pid2annotations[pid]) |
|
|
36 |
if int(np.sum(blobs[:, -1])) < len(pid2annotations[pid]): |
|
|
37 |
print '-------- HERE!!!!!! ------------' |
|
|
38 |
tp += np.sum(blobs[:, -1]) |
|
|
39 |
print '=====================================' |
|
|
40 |
|
|
|
41 |
print 'n patients', len(blob_files) |
|
|
42 |
print 'TP', tp |
|
|
43 |
print 'n blobs', n_blobs |
|
|
44 |
print n_pos |