ahnlabb / BioformatsLoader.jl

A julia package to load images using bioformats
Other
17 stars 7 forks source link

crash with metadata #28

Open RainerHeintzmann opened 4 months ago

RainerHeintzmann commented 4 months ago

If metadata is present as a filed called "metadata.txt", it is somehow read and this seems to cause a crash preventing any data to read. Here is an example metadata.txt file causing such a crash: metadata.txt (just place it into a folder with a .tif file to load and load the .tif file) Not sure if the error is caused inside the Java part or, see below, only a wrong way to call a java method by "BioformatsLoader.jl":

Exception in thread "main" java.lang.IllegalArgumentException: 0 must be non-null and strictly positive.
        at ome.xml.model.primitives.PositiveInteger.<init>(PositiveInteger.java:48)
        at loci.formats.MetadataTools.populatePixelsOnly(MetadataTools.java:314)
        at loci.formats.MetadataTools.populateMetadata(MetadataTools.java:262)
        at loci.formats.MetadataTools.populatePixels(MetadataTools.java:151)
        at loci.formats.MetadataTools.populatePixels(MetadataTools.java:116)
        at loci.formats.in.MicromanagerReader.populateMetadata(MicromanagerReader.java:339)
        at loci.formats.in.MicromanagerReader.initFile(MicromanagerReader.java:334)
        at loci.formats.FormatReader.setId(FormatReader.java:1392)
        at loci.formats.ImageReader.setId(ImageReader.java:849)
ERROR: JavaCall.JavaCallError("Error calling Java: java.lang.IllegalArgumentException: 0 must be non-null and strictly positive.")
Stacktrace:
  [1] geterror()
 @ JavaCall C:\Users\pi96doc\.julia\packages\JavaCall\IAoV2\src\core.jl:544
  [2] _jcall(obj::JavaCall.JavaObject{…}, jmethodId::Ptr{…}, rettype::Type{…}, argtypes::Tuple{…}, args::String; callmethod::typeof(JavaCall.JNI.CallVoidMethodA))
ahnlabb commented 4 months ago

Thank you @RainerHeintzmann. Seems like it's due to bioformats but we could perhaps mitigate it from BioformatsLoader. The MicromanagerReader in bioformats matches whenever there is a metadata.txt file in the folder and then reads the image files based on the metadata in this file. Maybe those files are missing here. Either way this seems like strange behavior to me and I'll see if we can work around it in a sensible way.

RainerHeintzmann commented 4 months ago

That would be great. In the worst case a try catch statement may prevent a total crash. But it also looked from the error message like there is a wrong Javacall statement somewhere in which case it can possibly be fixed.