bioformats icon indicating copy to clipboard operation
bioformats copied to clipboard

Dicom: SkipBytes Exception

Open dgault opened this issue 5 years ago • 1 comments

Issue was discovered in submitted QA files: QA-29062 QA-29063 QA-29064 QA-29065

Files were tested using Bio-Formats 6.3.1 and the following exception was seen when attempting to read the files:

java.lang.IllegalArgumentException
	at java.nio.Buffer.position(Buffer.java:244)
	at loci.common.NIOFileHandle.buffer(NIOFileHandle.java:650)
	at loci.common.NIOFileHandle.skipBytes(NIOFileHandle.java:494)
	at loci.common.NIOFileHandle.skipBytes(NIOFileHandle.java:482)
	at loci.common.RandomAccessInputStream.skipBytes(RandomAccessInputStream.java:670)
	at loci.formats.in.DicomReader.addFileToList(DicomReader.java:1411)
	at loci.formats.in.DicomReader.scanDirectory(DicomReader.java:1354)
	at loci.formats.in.DicomReader.makeFileList(DicomReader.java:1303)
	at loci.formats.in.DicomReader.initFile(DicomReader.java:799)
	at loci.formats.FormatReader.setId(FormatReader.java:1389)

The line it is failing on is stream.skipBytes(elementLength); for tag 0

dgault avatar Feb 11 '20 19:02 dgault

Confirmed that these datasets still have problems with 6.8.0. Files in the same directory are not grouped together, and pixel data is unreadable (possibly due to 12-bit JPEG?):

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 1024 out of bounds for byte[0]
	at java.base/java.lang.System.arraycopy(Native Method)
	at loci.formats.in.DicomReader.getTile(DicomReader.java:1594)
	at loci.formats.in.DicomReader.openBytes(DicomReader.java:300)
	at loci.formats.FormatReader.openBytes(FormatReader.java:919)
	at loci.formats.ImageReader.openBytes(ImageReader.java:449)
	at loci.formats.ReaderWrapper.openBytes(ReaderWrapper.java:334)
	at loci.formats.gui.BufferedImageReader.openImage(BufferedImageReader.java:86)
	at loci.formats.tools.ImageInfo.readPixels(ImageInfo.java:821)
	at loci.formats.tools.ImageInfo.testRead(ImageInfo.java:1055)
	at loci.formats.tools.ImageInfo.main(ImageInfo.java:1121)

melissalinkert avatar Dec 22 '21 17:12 melissalinkert