Skip to content

Commit a8d6b2d

Browse files
fix: find_objects doesn't work with arbitrarily large IDs
1 parent 55ecb93 commit a8d6b2d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kimimaro/utility.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,17 @@ def cross_sectional_area(
7474
else:
7575
total = len(skeletons)
7676

77-
all_slices = find_objects(all_labels)
77+
cc_labels, remapping = compute_cc_labels(all_labels)
78+
all_slices = find_objects(cc_labels)
79+
del all_labels
7880

7981
for skel in tqdm(iterator, desc="Labels", disable=(not progress), total=total):
8082
label = skel.id
8183

8284
if label == 0:
8385
continue
8486

87+
label = remapping[label]
8588
slices = all_slices[label - 1]
8689
if slices is None:
8790
continue
@@ -90,7 +93,7 @@ def cross_sectional_area(
9093
if roi.volume() <= 1:
9194
continue
9295

93-
binimg = np.asfortranarray(all_labels[slices] == label)
96+
binimg = np.asfortranarray(cc_labels[slices] == label)
9497

9598
all_verts = (skel.vertices / anisotropy).round().astype(int)
9699
all_verts -= roi.minpt

0 commit comments

Comments
 (0)