Skip to content

Commit 656dbb9

Browse files
committed
fix tests
1 parent 54a6447 commit 656dbb9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tiatoolbox/models/engine/nucleus_detector.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -525,15 +525,17 @@ def _extract_detection_arrays_from_block(
525525
"""
526526
# block: (h, w, C) NumPy chunk (post-stitching, no halos)
527527
if block_info is not None:
528-
info = block_info[0]
529-
(r0, _), (c0, _), _ = info["array-location"] # global interior start/stop
528+
info = block_info[0] # block_info[0] is input block info
529+
(global_y_start, _), (global_x_start, _), _ = info[
530+
"array-location"
531+
] # global interior start/stop
530532
else:
531-
r0, c0 = 0, 0
533+
global_y_start, global_x_start = 0, 0
532534

533535
# find the coordinates and channel indices of nonzeros
534-
ys, xs, cs = np.nonzero(block)
536+
ys_local, xs_local, classes = np.nonzero(block)
535537

536-
if ys.size == 0:
538+
if ys_local.size == 0:
537539
# return empty arrays
538540
return (
539541
np.empty(0, dtype=np.uint32),
@@ -542,13 +544,13 @@ def _extract_detection_arrays_from_block(
542544
np.empty(0, dtype=np.float32),
543545
)
544546

545-
x = xs.astype(np.uint32, copy=False) + int(c0)
546-
y = ys.astype(np.uint32, copy=False) + int(r0)
547-
t = cs.astype(np.uint32, copy=False)
547+
xs_global = xs_local.astype(np.uint32, copy=False) + int(global_x_start)
548+
ys_global = ys_local.astype(np.uint32, copy=False) + int(global_y_start)
549+
classes = classes.astype(np.uint32, copy=False)
548550

549551
# read detection probabilities
550-
p = block[ys, xs, cs].astype(np.float32, copy=False)
551-
return x, y, t, p
552+
probs = block[ys_local, xs_local, classes].astype(np.float32, copy=False)
553+
return xs_global, ys_global, classes, probs
552554

553555
@staticmethod
554556
def _centroid_maps_to_detection_arrays(

0 commit comments

Comments
 (0)