dcmjs-org / dcmjs

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

The saved image file is inconsistent with the source file. #347

Closed suoc closed 1 year ago

suoc commented 1 year ago

http://23.94.212.216/download/dicoms/position-img.dcm

This picture has positioning lines, which disappear after reading and saving.

pieper commented 1 year ago

Thanks for posting this issue with a link to the data. Perhaps someone will be able to use this to help with this.

It would help if you provided the exact code to replicate the issue, along with screenshots before and after. If there are any diagnostic messages printed please include those too.

suoc commented 1 year ago

I used your nodejs sample code. Before After

pieper commented 1 year ago

Did you look at the object before and after? Probably there is a sequence that didn't get converted.

Note that this is not a paid project with guaranteed support. We'd like to make the software better but we need to share the work of investigating any issues. It would help if you posted the file before and after and also investigate specifically what's different.

suoc commented 1 year ago

Here is my code.

const filePath = 'a dcm file path';

let arrayBuffer = fs.readFileSync(filePath).buffer;

let DicomDict = dcmjs.data.DicomMessage.readFile(arrayBuffer);

const dataset = dcmjs.data.DicomMetaDictionary.naturalizeDataset(DicomDict.dict);

console.log(dataset);

DicomDict.dict = dcmjs.data.DicomMetaDictionary.denaturalizeDataset(dataset);

let new_file_WriterBuffer = DicomDict.write();

fs.writeFileSync('to local path', new Buffer(new_file_WriterBuffer));
suoc commented 1 year ago

Thank you for your reply, in addition, I also found that the data parsed by dcmjs will be partially missing. image

suoc commented 1 year ago

Sorry for my mistake, I found the reason and I will close this issue.

pieper commented 1 year ago

Okay, glad you sorted it out and thanks for looping back to report here 👍

suoc commented 1 year ago

The reason for this issue is that calling naturalizeDataset and then calling denaturalizeDataset will lose some tags.

pieper commented 1 year ago

Did you see anything odd about the data that would explain why it behaves this way?