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

Not writing JPEG encoded pixel data correctly #31

Open
davidssmith opened this issue Apr 11, 2019 · 4 comments
Open

Not writing JPEG encoded pixel data correctly #31

davidssmith opened this issue Apr 11, 2019 · 4 comments

Comments

@davidssmith
Copy link
Contributor

When I try to use DCMTK to dump a lossless-JPEG encoded DICOM that I wrote with this package, I get this error:

E: Found explicit length Pixel Data in top level dataset with transfer syntax JPEG Lossless, Non-hierarchical, 1st Order
Prediction: Only undefined length permitted
E: dcmdump: Pixel data in top level dataset in compressed Transfer Syntax uses explicit length: reading file: out.dcm

I think it is referring to the fact that this particular Transfer Syntax (1.2.840.10008.1.2.4.70) is encoded with sequence start/end elements instead of an explicit length value. So the pixel data is written with an explicit length (derived from the Julia arrays?), but also encoded with sequence start/end values, making DCMTK complain.

Is there an easy way to fix this?

@notZaki
Copy link
Member

notZaki commented Apr 11, 2019

As far as I'm aware, this package doesn't support JPEG encoding.
I'd be surprised if it even reads JPEG encoded files correctly.

The fix would be to add in that support. Not sure how difficult that would be.
One way could be to rely on an external library, similar to how pydicom does it.

@davidssmith
Copy link
Contributor Author

How hard would it be to fix so that it could read and write the raw bytes correctly without bothering to decode?

@notZaki
Copy link
Member

notZaki commented Apr 12, 2019

I don't know---JPEG encoded DICOM files are foreign to me. Maybe someone else can chime in.

An alternative could be to use something like gdcm which might be able to convert an uncompressed out.dcm into a properly encoded file.

@davidssmith
Copy link
Contributor Author

When the pixel data is encoded as a sequence instead of a fixed-length field, this package concatenates the sequence into a single, typed, pixel data array, so the fact that it was originally sequence encoded is lost. I guess the only clue to that after the read is complete is indirectly found by way of the Transfer Syntax.

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