Open esmadau opened 1 year ago
Thanks for reporting this. That's definitely a use case we want to make sure works.
From what I can see the DICM
marker is missing (maybe the whole preamble is missing).
But it should have been written out by DicomDict.write()
so something must be going on.
Could you look at, for example, this test and see what's different from your case? If needed could you make a PR for this use case in the form of a test that could be used to document this use case and confirm that it's (ultimately) fixed.
Thanks for the quick reply. I'll work on a test. Also, I noticed that when overriding the UID given the example provided, PixelData is lost. Is there a way for me to change the UID and retain PixelData?
PixelData should not be lost. Did you make a simple test case to illustrate what you are doing?
hi friends! I have a similar problem...
I'm trying to insert a dicom tag. A tag is inserted in the final dicom file. but, an error occurs when opening the saved dicom file. So I thought about my problem. After checking that the Pixeldata is changed after saving, I looked for the problem.
let arrayBuffer = fs.readFileSync(filePath).buffer;
let DicomDict = dcmjs.data.DicomMessage.readFile(arrayBuffer);
console.log(DicomDict.dict['7FE00010']);
DicomDict.upsertTag('00080005', 'CS', 'ISO_IR 192');
console.log(DicomDict.dict['7FE00010']);
let new_file_WriterBuffer = DicomDict.write();
fs.writeFileSync(filePath, new Buffer.from(new_file_WriterBuffer));
If you print the log before and after modifying the dicom file, you can get the following result.
Since the file is a 512*512 image, byteLength 524288 should appear, but you can see that it is loaded as byteLength 519511.
Some another files are loaded so perfect
I think that when loading the dicom file, the PixelArray cannot be loaded correctly.... The "dcmjs.data.DicomMessage.readFile" function doesn't seem to load the file correctly.
Please... help me...
@EastLight0 Thanks for reporting. Please make a test that demonstrates the issue following the example of the other tests in the repo.
A lot of this was taken from this example: https://github.com/dcmjs-org/dcmjs/blob/add-commander/examples/nodejs/readwrite.js
I just need to be able to set the UID and generate new binary data. Code below is making sure data held in memory has changed.
To reproduce:
What I would expect:
What I see: