Bioformats in Matlab - JAI Error

I am running into an issue with bioformats in MATLAB and keep getting the following message:

“Error using bfGetReader (line 85)
Java exception occurred:
loci.formats.MissingLibraryException: Java Advanced Imaging (JAI) is required to read some TIFF files. Please install JAI from https://jai.dev.java.net/

I found on the Bioformats for MATLAB website:
" Troubleshooting

If you encounter an error trying to open JPEG-2000 data in MATLAB but the file will open e.g. in Fiji using Bio-Formats, it may be due to conflicting versions of JAI ImageIO in different JARs. As discussed on the component page, JAI ImageIO is no longer maintained and you will likely need to remove the conflicting JAR(s) as a workaround."

I am not clear on how to proceed. Does anyone have any advice?

Thank you!

This sounds like it is likely due to conflicting versions of JAI. If you run the below command does that give you the location of a JAR?

info=jj2000.j2k.JJ2KInfo();
disp(info.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());

Hi David,

Thanks so much for your help. I abandoned this here but now have a new Mac and am still unable to open w MATLAB. The error is different, but the file type is the same. Do you have any suggestions? I am trying to open a Metamorph TIF using bioformats. Previously w Nikon ND2 files, it has been very simple to import!

I just tested out:
IM = ’ file address’
exist IM
1
bfopen(IM)
Error using bfGetReader (line 85)
Java exception occurred:
java.lang.IndexOutOfBoundsException: Index: 8, Size: 1
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at ome.xml.model.Instrument.getLightSource(Instrument.java:355)
at ome.xml.meta.OMEXMLMetadataImpl.setLaserID(OMEXMLMetadataImpl.java:8251)
at ome.xml.meta.FilterMetadata.setLaserID(FilterMetadata.java:1368)
at loci.formats.in.MetamorphReader.initFile(MetamorphReader.java:1018)
at loci.formats.FormatReader.setId(FormatReader.java:1392)
at loci.formats.ImageReader.setId(ImageReader.java:849)
at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
at loci.formats.ChannelFiller.setId(ChannelFiller.java:223)
at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
at loci.formats.ChannelSeparator.setId(ChannelSeparator.java:293)

Error in bfopen (line 114)
r = bfGetReader(id, stitchFiles);

Thank you for any hep!

That error looks more like a bug for that particular dataset or format. If you have a sample file showing the exception which we could test you can upload it to https://www.openmicroscopy.org/qa2/qa/upload/