seung-lab / connected-components-3d

Connected components on discrete and continuous multilabel 3D & 2D images. Handles 26, 18, and 6 connected variants; periodic boundaries (4, 8, & 6)
GNU Lesser General Public License v3.0
356 stars 42 forks source link

IndexError is generated when using cc3d.connected_components #74

Closed julesberman closed 2 years ago

julesberman commented 2 years ago

The follow index error is generated when using connected components:

IndexError: index 3 is out of bounds for axis 0 with size 3 Exception ignored in: 'cc3d.epl_special_row' Traceback (most recent call last): File "****", line 9, in new = cc3d.connected_components(test) IndexError: index 3 is out of bounds for axis 0 with size 3

This can be reproduced with the following code:

import cc3d
import numpy as np

c = 5

test = np.zeros((3, 4, 4,), dtype='int')
test[0, 0, 1] = c
test[0, 0, 2] = c
new = cc3d.connected_components(test)
print(np.count_nonzero(new) == 0)

In addition the array returned is all zeros, which I don't think should be the case. Surprisingly if we init to ones all runs as expected as in:

test = np.ones((3, 4, 4,), dtype='int')

I may be missing something, but I don't think this expected behavior.

william-silversmith commented 2 years ago

Hi! For some reason, I am not able to reproduce this bug. It has something to do with this PR https://github.com/seung-lab/connected-components-3d/pull/67. I did find a bug in that function a while back and fixed it. Can you let me know what version of cc3d you're using?

Thank you!

william-silversmith commented 2 years ago

I think I fixed it in the last release:

https://github.com/seung-lab/connected-components-3d/commit/2da2547570ba5dc83fda9b17e68ea34b9fdc01d1

julesberman commented 2 years ago

Yes the update seems to have fix the issue for me. Thanks for the quick response.

william-silversmith commented 2 years ago

Fantastic! Let me know if you run into any other issues.