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

Add a better error for type support. #121

Closed aymuos15 closed 3 months ago

aymuos15 commented 3 months ago
  File "cc3d.pyx", line 336, in cc3d.connected_components
  File "cc3d.pyx", line 225, in cc3d.estimate_provisional_labels
TypeError: Type float16 not currently supported.

Listing what all are the available options would be nice.

william-silversmith commented 3 months ago

Thanks for the feedback! Here's what's supported iirc:

bool, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64

float16 is more difficult to support because it's not a native type in C++ though there are some libraries to help with that. What you can do though (though it might not always work) is:

data.view(np.uint16) which will view the same data as uint16 and may allow it to be processed. Since the particularities of the actual value don't matter, only whether the values are equal, this can be okay.

aymuos15 commented 3 months ago

Sorry, you may have misunderstood me. I mean to say that, just while presenting the error, you could just list out what the available options are so one does not need to come here to check. Like, within the TypeError itself.

I do not (personally) think it is required to add float16 because of what you said about the absence of the native typing.

william-silversmith commented 3 months ago

Ah I already did both! Check out the latest release. The supported types are printed out and float16 is supported for labeled images (but not continuous images).

aymuos15 commented 3 months ago

That sounds great! Thank you so much :)