Skip to content
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

EOFException on PixelData missing 1 byte #1236

Open
damien-vdb opened this issue Jul 27, 2022 · 1 comment
Open

EOFException on PixelData missing 1 byte #1236

damien-vdb opened this issue Jul 27, 2022 · 1 comment

Comments

@damien-vdb
Copy link

Description
I'm receiving Native DICOMs from a modality with apparently a missing byte.
You'll find a dump here
With the following parameters

(0028,0002) US 3                                            #   2, 1 SamplesPerPixel
(0028,0004) CS [RGB]                                    #   4, 1 PhotometricInterpretation
(0028,0006) US 0                                        #   2, 1 PlanarConfiguration
(0028,0010) US 735                                      #   2, 1 Rows
(0028,0011) US 975                                      #   2, 1 Columns
(0028,0100) US 8                                        #   2, 1 BitsAllocated
(0028,0101) US 8                                        #   2, 1 BitsStored
(0028,0102) US 7                                        #   2, 1 HighBit
(0028,0103) US 0                                        #   2, 1 PixelRepresentation

we could expect a Pixel Data length of 2149875, but we have

(7fe0,0010) OW 0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000... # 2149874, 1 PixelData

Actual behavior

Using a DicomImageReaderor Transcoder results in an EOFException

./dcm2dcm --version                                                                                                                                                                      
Native OpenCV library has been found in /opt/dcm4che/lib/linux-x86-64/libopencv_java.so
dcm2dcm: 5.27.0

./dcm2dcm --jlsl <input> <output>
Native OpenCV library has been found in /opt/dcm4che/lib/linux-x86-64/libopencv_java.so
Jul 27, 2022 1:46:35 PM org.opencv.osgi.OpenCVNativeLoader init
INFO: Successfully loaded OpenCV native library.
13:46:35.677 DEBUG - Compressor: org.dcm4che3.opencv.NativeJLSImageWriter
Failed to transcode <path_to_file.dcm>: null
java.io.EOFException
	at org.dcm4che3.util.StreamUtils.readFully(StreamUtils.java:69)
	at org.dcm4che3.io.DicomInputStream.readFully(DicomInputStream.java:477)
	at org.dcm4che3.io.DicomInputStream.readFully(DicomInputStream.java:473)
	at org.dcm4che3.imageio.codec.Transcoder.readFully(Transcoder.java:784)
	at org.dcm4che3.imageio.codec.Transcoder.readFrame(Transcoder.java:777)
	at org.dcm4che3.imageio.codec.Transcoder.compressPixelData(Transcoder.java:575)
	at org.dcm4che3.imageio.codec.Transcoder.processPixelData(Transcoder.java:513)
	at org.dcm4che3.imageio.codec.Transcoder.access$800(Transcoder.java:71)
	at org.dcm4che3.imageio.codec.Transcoder$1.readValue(Transcoder.java:466)
	at org.dcm4che3.io.DicomInputStream.readAttributes(DicomInputStream.java:681)
	at org.dcm4che3.io.DicomInputStream.readAllAttributes(DicomInputStream.java:568)
	at org.dcm4che3.imageio.codec.Transcoder.transcode(Transcoder.java:440)
	at org.dcm4che3.tool.dcm2dcm.Dcm2Dcm.transcodeWithTranscoder(Dcm2Dcm.java:405)
	at org.dcm4che3.tool.dcm2dcm.Dcm2Dcm.transcode(Dcm2Dcm.java:345)
	at org.dcm4che3.tool.dcm2dcm.Dcm2Dcm.mtranscode(Dcm2Dcm.java:336)
	at org.dcm4che3.tool.dcm2dcm.Dcm2Dcm.mtranscode(Dcm2Dcm.java:318)
	at org.dcm4che3.tool.dcm2dcm.Dcm2Dcm.main(Dcm2Dcm.java:290)

The weasis-dicom-tools library successfully reads the image.

This could be similar to #1199.

Could we make this work ?

Workaround

Using a

new DicomInputStream(input) {
            @Override
            public void readFully(byte[] s, int off, int len) throws IOException {
                try {
                    super.readFully(s, off, len);
                } catch (EOFException e) {
                    // Ignore
                }
            }
        }

does the job in this specific case, but I don't think it could be a permanent solution.

Additional context

I could privately provide you with a DICOM for tests purposes.

@gunterze
Copy link
Member

gunterze commented Aug 5, 2022

Compression of such faulty images is not supported - but you may receive/parse/store them uncompressed as received

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants