dcmjs-org / dcmjs

Javascript implementation of DICOM manipulation
https://dcmjs.netlify.com/
MIT License
287 stars 108 forks source link

Write issue for JPEG2000Loseless images #375

Open syedkibrahim opened 6 months ago

syedkibrahim commented 6 months ago

We are trying to anonymize a DICOM file which is a JPEG2000Loseless type (Transfer Syntax ID - 1.2.840.10008.1.2.4.90) But when we try to perform the .write() operation, we are getting an error: First argument to DataView constructor must be an ArrayBuffer

But it's working fine for other DICOM file types.

We tried opening this file in MicroDicom Viewer and it's loading up fine.

Can anyone help understand why we might be getting this error ?

The steps we are using are as follows:

We are generating the buffer for the file and storing it in a variable named buffer.

const dicomDict = dcmjs.data.DicomMessage.readFile(buffer);

dicomDict.dict['00204000'].Value = 'DE-IDENTIFIED';
const deIdentifiedBuffer = dicomDict.write();

Which also brings me to the next question, is this the proper way to anonymize or should we be using the dicomDict.upsertTag() function ?

pieper commented 6 months ago

Probably only a few transfer syntaxes were tested originally. I'm sure it would be possible to add support for that, but historically codecs haven't been easily dealt with. This is probably changing and it would be great if someone could investigate using dicom-codecs-wasmjs with dcmjs.

For anonymizing did you look at the existing code?

https://github.com/dcmjs-org/dcmjs/blob/master/src/anonymizer.js

https://github.com/dcmjs-org/dcmjs/blob/master/test/anonymizer.test.js

syedkibrahim commented 6 months ago

Sure will take a look into that, thanks. My follow up question is - Where can I find the list of transfer syntaxes supported by dcmjs and if that contains any compressed array buffer as well. That might help us get a better understanding of how to handle this.

pieper commented 6 months ago

I'm not sure but I believe only uncompressed pixel data is currently supported.