From a8d6b2da977330bc696969e2ede9d91e2573e77c Mon Sep 17 00:00:00 2001 From: William Silversmith Date: Wed, 31 Jan 2024 18:21:00 -0500 Subject: [PATCH] fix: find_objects doesn't work with arbitrarily large IDs --- kimimaro/utility.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kimimaro/utility.py b/kimimaro/utility.py index 4da5ae5..723fa68 100644 --- a/kimimaro/utility.py +++ b/kimimaro/utility.py @@ -74,7 +74,9 @@ def cross_sectional_area( else: total = len(skeletons) - all_slices = find_objects(all_labels) + cc_labels, remapping = compute_cc_labels(all_labels) + all_slices = find_objects(cc_labels) + del all_labels for skel in tqdm(iterator, desc="Labels", disable=(not progress), total=total): label = skel.id @@ -82,6 +84,7 @@ def cross_sectional_area( if label == 0: continue + label = remapping[label] slices = all_slices[label - 1] if slices is None: continue @@ -90,7 +93,7 @@ def cross_sectional_area( if roi.volume() <= 1: continue - binimg = np.asfortranarray(all_labels[slices] == label) + binimg = np.asfortranarray(cc_labels[slices] == label) all_verts = (skel.vertices / anisotropy).round().astype(int) all_verts -= roi.minpt