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)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IndexError is generated when using cc3d.connected_components

julesberman opened this issue · comments

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.

Hi! For some reason, I am not able to reproduce this bug. It has something to do with this PR #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!

I think I fixed it in the last release:

2da2547

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

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