dcmjs-org / dcmjs

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

storing pixel data locally #252

Closed muhammedmokbel closed 2 years ago

muhammedmokbel commented 2 years ago

I am trying to get pixel data from dicom store in google healthcare and storing this pixel data in dicom file locally using node js not browser environment

const buffer = Buffer.from(respond.data) const pixel = new Uint8Array(buffer, offset, length) just I have to remove mime type from the headers to get the pixel data only because google healthcare using multipart/related

const dicomDict = dcmjs.data.datasetToDict(dicomObj) const buffer = Buffer.from(dicomDict.write()) then I convert dicom object after storing pixel data in to dictionary then buffering this dictionary

BUT unfortunately the pixel data appear in that way ?

sotring pixels

can anyone explain to me why that was happen ?

pieper commented 2 years ago

It depends on what api endpoint you use to get the data via dicomweb. If you get the instance you will get a binary "part10" data that needs to be parsed, which you can do with dcmjs just like you would from a file. This will let you access the PixelData directly and reshape it to match the Rows and Columns. If you use a frame level DICOMweb api call you can get the pixel data directly as binary and would need the Rows and Columns from a separate metadata endpoint.

muhammedmokbel commented 2 years ago

@pieper thank you for respond

actually I am working on frame level .. and already I get pixel data from endpoint based on frame and decode multipart to extract pixel data without headers mime type const buffer = Buffer.from(respond.data) const data = decode.multipartDecode(buffer)

multipartDecode is function that implemented in dicomweb-client so i think it is tested well

and I already get metadata then fill dicomobject with meta and pixel data also I should share with you mime type is octet-stream

I will be grateful for any tips 👍

pieper commented 2 years ago

Are you sure the image is not compressed? (check the transfer syntax in the metadata and the http headers).

muhammedmokbel commented 2 years ago

thank you so much @pieper the problem is fixed