MATLAB Bio-Formats (5.9.2) bfopen cannot open jp2 files made by Stereo Investigator of MBF

MATLAB Bio-Formats’ (5.9.2) bfopen() cannot open jp2 files made by Stereo Investigator of MBF. It was able to open the same files before updating to 5.9.2.

Here is the Java error message.

    .Error using bfGetPlane (line 78)
Java exception occurred:
java.lang.RuntimeException:
jj2000.j2k.fileformat.reader.FileFormatReader.<init>(Ljj2000/j2k/io/RandomAccessIO;Lcom/sun/media/imageioimpl/plugins/jpeg2000/J2KMetadata;)V

	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:729)

	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.<init>(J2KReadState.java:241)

	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.readRaster(J2KImageReader.java:551)

	at ome.codecs.services.JAIIIOServiceImpl.readRaster(JAIIIOServiceImpl.java:177)

	at ome.codecs.JPEG2000Codec.decompress(JPEG2000Codec.java:296)

	at ome.codecs.JPEG2000Codec.decompress(JPEG2000Codec.java:267)

	at loci.formats.codec.WrappedCodec.decompress(WrappedCodec.java:132)

	at loci.formats.codec.JPEG2000Codec.decompress(JPEG2000Codec.java:63)

	at loci.formats.in.JPEG2000Reader.openBytes(JPEG2000Reader.java:182)

	at loci.formats.ImageReader.openBytes(ImageReader.java:460)

	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:156)

	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:148)

	at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:198)

	at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:159)

Caused by: java.lang.NoSuchMethodError:
jj2000.j2k.fileformat.reader.FileFormatReader.<init>(Ljj2000/j2k/io/RandomAccessIO;Lcom/sun/media/imageioimpl/plugins/jpeg2000/J2KMetadata;)V

	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:450)

	... 13 more

Error in bfopen (line 150)
        arr = bfGetPlane(r, i, varargin{:}); 

Hi @kouichi-c-nakamura, what version of Bio-Formats had you been using previously?

It’s hard to know. Even though I have them in version control, there isn’t explicit version information in the toolbox itself.

I may try downgrading later.

My bad. It was NOT the new version of Bio-Formats. It was MATLAB R2019a pre-release that was causing this error. R2018b worked fine with Bio-Formats 5.9.2.

Full error message.

Error using bfGetPlane (line 78)
Java exception occurred:
java.lang.RuntimeException:
jj2000.j2k.fileformat.reader.FileFormatReader.<init>(Ljj2000/j2k/io/RandomAccessIO;Lcom/sun/media/imageioimpl/plugins/jpeg2000/J2KMetadata;)V

	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:729)

	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.<init>(J2KReadState.java:241)

	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.readRaster(J2KImageReader.java:551)

	at ome.codecs.services.JAIIIOServiceImpl.readRaster(JAIIIOServiceImpl.java:177)

	at ome.codecs.JPEG2000Codec.decompress(JPEG2000Codec.java:296)

	at ome.codecs.JPEG2000Codec.decompress(JPEG2000Codec.java:267)

	at loci.formats.codec.WrappedCodec.decompress(WrappedCodec.java:132)

	at loci.formats.codec.JPEG2000Codec.decompress(JPEG2000Codec.java:63)

	at loci.formats.in.JPEG2000Reader.openBytes(JPEG2000Reader.java:182)

	at loci.formats.ImageReader.openBytes(ImageReader.java:460)

	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:156)

	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:148)

	at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:198)

	at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:159)

Caused by: java.lang.NoSuchMethodError:
jj2000.j2k.fileformat.reader.FileFormatReader.<init>(Ljj2000/j2k/io/RandomAccessIO;Lcom/sun/media/imageioimpl/plugins/jpeg2000/J2KMetadata;)V

	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:450)

	... 13 more

Error in bfopen (line 150)
        arr = bfGetPlane(r, i, varargin{:}); 

The error occurs at line 78 of bfGetPlane.m, where r, which is loci.formats.ChannelSeparator object, uses the openBytes method and that issues the error.

plane = r.openBytes(...
    ip.Results.iPlane - 1, ip.Results.x - 1, ip.Results.y - 1, ...
    ip.Results.width, ip.Results.height);

Thank you for the report Kouichi, here at OME I am not aware that we had tried out a prerelease of MATLAB R2019a yet though I also hadn’t expected any J2K-related changes. We appreciate the heads-up about this breakage and I have taken a note for us to investigate it.

If you have anything particular that you want me to examine, let me know. eg. particular jar files or name conflicts.

Thanks @kouichi-c-nakamura, we have created a Trello card on the Bio-Formats inbox to track this issue: https://trello.com/c/Vooey1Qj/323-jp2-breaks-under-matlab-r2019a

I can also confirm now that when Fiji is launched from within MATLAB (R2019a prelease) using ImageJ-MATLAB linking, that instance of Fiji cannot open Strereo Investigator-generated jpeg 2000 files, even though it can open them when it is launched standalone in Windows 10 or from within MATLAB R2018b.

(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52i; Java 1.8.0_181 [64-bit]; Windows 10 10.0; 559MB of 30000MB (1%)
 
java.lang.RuntimeException: jj2000.j2k.fileformat.reader.FileFormatReader.<init>(Ljj2000/j2k/io/RandomAccessIO;Lcom/sun/media/imageioimpl/plugins/jpeg2000/J2KMetadata;)V
	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:729)
	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.<init>(J2KReadState.java:241)
	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReader.readRaster(J2KImageReader.java:551)
	at ome.codecs.services.JAIIIOServiceImpl.readRaster(JAIIIOServiceImpl.java:177)
	at ome.codecs.JPEG2000Codec.decompress(JPEG2000Codec.java:296)
	at ome.codecs.JPEG2000Codec.decompress(JPEG2000Codec.java:267)
	at loci.formats.codec.WrappedCodec.decompress(WrappedCodec.java:132)
	at loci.formats.codec.JPEG2000Codec.decompress(JPEG2000Codec.java:63)
	at loci.formats.in.JPEG2000Reader.openBytes(JPEG2000Reader.java:182)
	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:156)
	at loci.formats.ChannelFiller.openBytes(ChannelFiller.java:148)
	at loci.formats.ChannelSeparator.openBytes(ChannelSeparator.java:198)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.DimensionSwapper.openBytes(DimensionSwapper.java:249)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:348)
	at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:269)
	at loci.formats.MinMaxCalculator.openBytes(MinMaxCalculator.java:260)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:334)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:334)
	at loci.plugins.util.ImageProcessorReader.openProcessors(ImageProcessorReader.java:186)
	at loci.plugins.in.ImagePlusReader.readProcessors(ImagePlusReader.java:422)
	at loci.plugins.in.ImagePlusReader.readPlanes(ImagePlusReader.java:387)
	at loci.plugins.in.ImagePlusReader.readImage(ImagePlusReader.java:282)
	at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:243)
	at loci.plugins.in.ImagePlusReader.readImages(ImagePlusReader.java:221)
	at loci.plugins.in.ImagePlusReader.openImagePlus(ImagePlusReader.java:116)
	at loci.plugins.in.Importer.readPixels(Importer.java:149)
	at loci.plugins.in.Importer.run(Importer.java:86)
	at loci.plugins.LociImporter.run(LociImporter.java:78)
	at ij.IJ.runUserPlugIn(IJ.java:228)
	at ij.IJ.runPlugIn(IJ.java:192)
	at ij.IJ.runPlugIn(IJ.java:181)
	at HandleExtraFileTypes.openImage(HandleExtraFileTypes.java:499)
	at HandleExtraFileTypes.run(HandleExtraFileTypes.java:72)
	at ij.IJ.runUserPlugIn(IJ.java:228)
	at ij.IJ.runPlugIn(IJ.java:192)
	at ij.IJ.runPlugIn(IJ.java:181)
	at ij.io.Opener.openWithHandleExtraFileTypes(Opener.java:516)
	at ij.io.Opener.openImage(Opener.java:370)
	at ij.io.Opener.openImage(Opener.java:242)
	at ij.io.Opener.open(Opener.java:109)
	at ij.io.Opener.openAndAddToRecent(Opener.java:291)
	at ij.plugin.DragAndDrop.openFile(DragAndDrop.java:192)
	at ij.plugin.DragAndDrop.run(DragAndDrop.java:159)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: jj2000.j2k.fileformat.reader.FileFormatReader.<init>(Ljj2000/j2k/io/RandomAccessIO;Lcom/sun/media/imageioimpl/plugins/jpeg2000/J2KMetadata;)V
	at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:450)
	... 44 more

As far as I can see, there is no mention of jpeg 2000 or jp2 in the Release Note of R2019a prerelease.

Hi Kouichi,

this looks fairly similar to the issue we discussed on this ome-users thread in a previous release of MATLAB.

As previously, I suspect some incompatibility between JAI forks. Probably, the first step is to identify which JAR ships another implementation of the class. Can you give us the output of the following snippet

r = jj2000.j2k.fileformat.reader.FileFormatReader([], []);
disp(r.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());

Sebastien

@s.besson Thank you for spotting the previous issue. I thought that this was similar, but even I myself could not find where I reported.

How do I load jj2000?

>> r = jj2000.j2k.fileformat.reader.FileFormatReader([], []);
disp(r.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());

No constructor 'jj2000.j2k.fileformat.reader.FileFormatReader' with matching
signature found.

Arg. Of course, your initial error is about the signature of the constructor for this particular class being different from the one shipped in the ome-jai component.

Can you retry with another class of the package, e.g.

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

I figured out once I run bfopen, the path to jj2000 is added to MATLAB Java class path. So I can run the test code.

R2018b

>> info=jj2000.j2k.JJ2KInfo();
>> disp(info.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
/D:/Dropbox/Private_Dropbox/matlab_toolbox/bfmatlab/bioformats_package.jar

R2019a Prerelease

>> info=jj2000.j2k.JJ2KInfo();
>> disp(info.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
/C:/Program%20Files/MATLAB/R2019a/java/jarext/tika-app.jar

Again, your guess was just right, I think. Thanks.

Kouichi

I can confirm that this problem persists in R2019a (not pre-release).

hello,
I also have the same problem using bioformat with R2018b.
bfopen returns:

Reading series #1

  • .Error using bfGetPlane (line 78)*
    Java exception occurred:

test code above:

info=jj2000.j2k.JJ2KInfo();
disp(info.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
/C:/Program%20Files/MATLAB/R2018b/java/jarext/tika-app.jar

Please, how can I fix this problem?

Thank you,

Mounia

In my installtion of R2018b, bfopen works with Stereo Investigetor’s jpeg 2000.

The file tika-app.jar is not found in C:\Program Files\MATLAB\R2018b\java\jarext, while I can see it in C:\Program Files\MATLAB\R2019a\java\jarext.

>> info=jj2000.j2k.JJ2KInfo();
>> disp(info.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
% /D:/OneDrive%20-%20Nexus365/Private_Dropbox/matlab_toolbox/bfmatlab/bioformats_package.jar

Workaround

This isn’t a proper fix and will cause unexpected issues around handling of jpeg 2000 for sure, but you can get bfopen working by following (tested):

  1. Close MALTAB
  2. Go to C:\Program Files\MATLAB\R2019a\java\jarext
  3. Find tika-app.jar and rename it as tika-app.jar.bak temporarily.
  4. Launch MATLAB
  5. Execute bfopen

It works .
Thank you very much Kouichi.

1 Like