Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit dcd8cf7

Browse files
committed
Merge branch 'evaluation' into 'dev'
Debugged version of evaluation with scipy ndimage See merge request !43
2 parents 1e59278 + 7ca5217 commit dcd8cf7

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

niftynet/evaluation/compute_ROI_statistics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ def run(param, csv_dict):
6868
elif len(np.unique(seg_d)) == 2:
6969
type_str = "Binary"
7070
seg_d = MorphologyOps(seg_d, 24).foreground_component()
71-
threshold_steps = np.arange(1, np.max(seg_d))
71+
threshold_steps = np.arange(1, seg_d[1])
7272
else:
7373
pass
7474

7575
for n, i in enumerate(threshold_steps):
7676
print('{} of {} thresholding steps'.format(
7777
n, len(threshold_steps)))
7878
if type_str == "Labels" or type_str == "Binary":
79-
seg_d_binary = (seg_d == i)
79+
seg_d_binary = (seg_d[0] == i)
8080
else:
81-
seg_d_binary = np.copy(seg_d)
82-
seg_d_binary[seg_d < i] = 0 # threshold prob.
83-
if np.count_nonzero(seg_d) == 0:
81+
seg_d_binary = np.copy(seg_d[1])
82+
seg_d_binary[seg_d[0] < i] = 0 # threshold prob.
83+
if np.count_nonzero(seg_d_binary) == 0:
8484
print("Empty foreground in thresholded image")
8585
continue
8686
roi_stats = RegionProperties(seg_d_binary, img, MEASURES)

niftynet/evaluation/pairwise_measures.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ def _connected_components(self):
196196

197197
def connected_elements(self):
198198
blobs_ref, blobs_seg, init = self._connected_components()
199-
list_blobs_ref = np.unique(blobs_ref[blobs_ref > 0])
200-
list_blobs_seg = np.unique(blobs_seg[blobs_seg > 0])
201-
mul_blobs_ref = np.multiply(blobs_ref, init)
202-
mul_blobs_seg = np.multiply(blobs_seg, init)
199+
list_blobs_ref = range(1, blobs_ref[1])
200+
list_blobs_seg = range(1, blobs_seg[1])
201+
mul_blobs_ref = np.multiply(blobs_ref[0], init)
202+
mul_blobs_seg = np.multiply(blobs_seg[0], init)
203203
list_TP_ref = np.unique(mul_blobs_ref[mul_blobs_ref > 0])
204204
list_TP_seg = np.unique(mul_blobs_seg[mul_blobs_seg > 0])
205205

@@ -210,27 +210,27 @@ def connected_elements(self):
210210
@CacheFunctionOutput
211211
def connected_errormaps(self):
212212
blobs_ref, blobs_seg, init = self._connected_components()
213-
list_blobs_ref = np.unique(blobs_ref[blobs_ref > 0])
214-
list_blobs_seg = np.unique(blobs_seg[blobs_seg > 0])
215-
mul_blobs_ref = np.multiply(blobs_ref, init)
216-
mul_blobs_seg = np.multiply(blobs_seg, init)
213+
list_blobs_ref = range(1, blobs_ref[1])
214+
list_blobs_seg = range(1, blobs_seg[1])
215+
mul_blobs_ref = np.multiply(blobs_ref[0], init)
216+
mul_blobs_seg = np.multiply(blobs_seg[0], init)
217217
list_TP_ref = np.unique(mul_blobs_ref[mul_blobs_ref > 0])
218218
list_TP_seg = np.unique(mul_blobs_seg[mul_blobs_seg > 0])
219219

220220
list_FN = [x for x in list_blobs_ref if x not in list_TP_ref]
221221
list_FP = [x for x in list_blobs_seg if x not in list_TP_seg]
222222
# print(np.max(blobs_ref),np.max(blobs_seg))
223-
tpc_map = np.zeros_like(blobs_ref)
224-
fpc_map = np.zeros_like(blobs_ref)
225-
fnc_map = np.zeros_like(blobs_ref)
223+
tpc_map = np.zeros_like(blobs_ref[0])
224+
fpc_map = np.zeros_like(blobs_ref[0])
225+
fnc_map = np.zeros_like(blobs_ref[0])
226226
for i in list_TP_ref:
227-
tpc_map[blobs_ref == i] = 1
227+
tpc_map[blobs_ref[0] == i] = 1
228228
for i in list_TP_seg:
229-
tpc_map[blobs_seg == i] = 1
229+
tpc_map[blobs_seg[0] == i] = 1
230230
for i in list_FN:
231-
fnc_map[blobs_ref == i] = 1
231+
fnc_map[blobs_ref[0] == i] = 1
232232
for i in list_FP:
233-
fpc_map[blobs_seg == i] = 1
233+
fpc_map[blobs_seg[0] == i] = 1
234234
return tpc_map, fnc_map, fpc_map
235235

236236
def outline_error(self):

niftynet/utilities/misc_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def border_map(self):
109109
return border
110110

111111
def foreground_component(self):
112-
return ndimage.label(self.binary_map, background=0)
112+
return ndimage.label(self.binary_map)
113113

114114

115115
class CacheFunctionOutput(object):

0 commit comments

Comments
 (0)