cornerstonejs / cornerstoneWADOImageLoader

[DEPRECATED] DICOM WADO Image Loader for the cornerstone library
MIT License
283 stars 266 forks source link

JPX Error: Unsupported COD options (selectiveArithmeticCodingBypass) #251

Open Neuroforge opened 5 years ago

Neuroforge commented 5 years ago

Hello,

I am receiving the follow error when loading images. This is one particular set of dicom images work in RadiAnt and with the online demo.(https://rawgit.com/cornerstonejs/cornerstoneWADOImageLoader/master/examples/dicomfile/index.html)

Uncaught Error: JPX Error: Unsupported COD options (selectiveArithmeticCodingBypass)
    at a.parseCodestream (wado-image-loader-codecs.min.js:3)
    at a.parse (wado-image-loader-codecs.min.js:3)
    at wado-image-loader-web-worker.min.js:2
    at t.default (wado-image-loader-web-worker.min.js:2)
    at t.default (wado-image-loader-web-worker.min.js:2)
    at Object.handler (wado-image-loader-web-worker.min.js:2)
    at self.onmessage (wado-image-loader-web-worker.min.js:2)
let webWorkerUrl = "/assets/js/wado-image-loader-web-worker.min.js"
let codecsUrl = "/assets/js/wado-image-loader-codecs.min.js"

let webWorkerConfig = {
  maxWebWorkers: Math.max(navigator.hardwareConcurrency||1, 4),
  startWebWorkersOnDemand: false,
  webWorkerPath: webWorkerUrl,
  webWorkerTaskPaths: [],
  taskConfiguration: {
    decodeTask: {
      loadCodecsOnStartup: true,
      initializeCodecsOnStartup: false,
      codecsPath: codecsUrl,
      usePDFJS: true,
      strict: true
    }
  }
}

cornerstoneWADOImageLoader.webWorkerManager.initialize(webWorkerConfig);

Most images work fine, but this set seems to be causing an uncaught exception.

It appears to occur with the image-JPEG2000 codec.

Any thoughts or advice would be appreciated.

This google group conversation seems similar, but not identical. https://groups.google.com/forum/#!topic/cornerstone-platform/nLebuvcZxuA

malaterre commented 5 years ago

Can you share one such DICOM instance ?

Neuroforge commented 5 years ago

Hello @malaterre ,

Unfortunately, they have patient information attached to them. If i use DicomCleaner to remove patient information, then something strange happens. There are 50 images in total, but the loader is able to process 30 of them after being processed with DicomCleaner.

Do you have an email address where i could send one image to you in confidence? I do not wish to post them publicly on Github. Or can you recommend another method to remove the data without changing the image format.

Regards,

Daniel

malaterre commented 5 years ago

@Neuroforge Two things:

  1. Can you try harder and reduce the issue to a single file.
  2. Download gdcm and use gdcmraw + gdcmimg to craft an example without PHI meta data.

Typical steps:

$ gdcmraw input_j2k.dcm output.j2k
$ gdcmimg output.j2k output_nophi.dcm

WARNING: Do not post publicly if name of patient can be found somewhere on the image itself (pixel data element).

Neuroforge commented 5 years ago

The patient data is in the image itself. :/

Johns-MBP:Dicom johnbell$ gdcmimg xxxxxxxxx.dcm output.j2k Johns-MBP:Dicom johnbell$ gdcmimg output.j2k output_nophi.dcm Expected a SOC marker Could not read: output.j2k

I have tried DicomCleaner again, but with the same result.

malaterre commented 5 years ago

The patient data is in the image itself. :/

Johns-MBP:Dicom johnbell$ gdcmimg xxxxxxxxx.dcm output.j2k Johns-MBP:Dicom johnbell$ gdcmimg output.j2k output_nophi.dcm Expected a SOC marker Could not read: output.j2k

I have tried DicomCleaner again, but with the same result.

Just for later reference gdcmimg != gdcmraw.

evanzombie commented 5 years ago

Any update?

dannyrb commented 5 years ago

This appears to be a decoding issue? I'm going to move this to cornerstoneWADOImageLoader's repo.

Without a minimal reproduction, this is incredibly hard to troubleshoot or provide guidance on.

cylien commented 4 years ago

I have the same problem. I solved this problem by converting the JPEG2000 to uncompressed image, and then converting the uncompressed image into JPEG2000 by using gdcm as following:

gdcmconv -w B:\90.dcm B:\UN.dcm
gdcmconv -k  B:\UN.dcm B:\New90.dcm
Neuroforge commented 4 years ago

@cylien Can you do this inside of the web app?

cylien commented 4 years ago

Can you do this inside of the web app

It can be done by creating a web API to allow the user to upload the DICOM file to convert at the server-side by executing shell commands to generate the new DICOM file which returns to the client. For example, using the Node.js to implement it is a good method.