-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsupported datatype by Converter (ImagePlus) #60
Comments
What data type should we convert the int array into? Into float? |
I think so, |
Great! I will implement it! What about the other data types? |
Yes, cast each unsuported toward the closest supported. If that makes sense :) |
I am implementing this currently on a separate branch and i am wondering how to do it. For example: if the Also we have to note that java does not support unsigned datat types, so if the I would lean towards the second approach as it is what ImgLib2 does, but what do you think? @StRigaud |
@StRigaud @carlosuc3m Could you point to a concrete example where that
exception happens? I need a bit more context. I think, in general, it is best to let the user control what should happen:
I think it is a ok default approach. Other options would be: Yet another option: |
Hi @tpietzsch, just to clarify the issue: On the CLIJ3 repo, while playing around, I tested a small pipeline where the output is not provided and To my knowledge, the issue relys on the datatype supported by the ImageJ converter: clesperantoj_prototype/src/main/java/net/clesperanto/imagej/ImageJDataType.java Lines 11 to 14 in 53e944d
And how the function to convert from clesperanto Array to ImagePlus is doing: clesperantoj_prototype/src/main/java/net/clesperanto/imagej/ImageJConverters.java Lines 38 to 50 in 53e944d
From what I saw, @carlosuc3m already tried to work on this: But I haven't tested yet if this works or not.
I am usually in favor of forbidding, especially in the context of a developper library. But because this concern a piece of code specific to ImageJ, and this piece of code is in charge of making the communication between ImageJ and clesperanto, It should ensure that what ever returns clesperanto, it can convert it to into an ImagePlus. if that make sense? In general, clesperanto return the same type as you provide, with the exception of PS: my knowledge of Java and ImagePlus datastructure is quite limited, I don't know if what I am saying make sense 🙃 |
@tpietzsch @StRigaud ImagePlus can only display images as float32, uint16 or uint8. Clesperanto supports int8, uint8, int16, uint16, int32, uint32 and float32. This mismatch between data types is only problematic when pulling images from the GPU. In order to workarounf this problem, what is done in the ImageJDataType class is to pull:
The logic can be seen more clearly in the test class that checks if pulls are done correctly for ImagePlus: |
The array data type supported by ImagePlus is limited to
uchar
,ushort
, andfloat
. If, during some clesperanto pipeline, the return Array if of typeint
, the convertion back to ImagePlus will failWe need to update the
ImageJConverters.copyArrayJToImagePlus
to cast the buffer result into a supported datatype.@carlosuc3m This is important if we want to take advantage of the output management of clesperanto. I don't know if this can be an issue for the other converters
The text was updated successfully, but these errors were encountered: