dcmjs-org / dcmjs

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

modifying dicom meta-data #370

Open satyam-qure opened 1 year ago

satyam-qure commented 1 year ago

While using the below code, it works in most cases. However, for abnormal x-rays, it produces an error. (First argument to DataView constructor must be an ArrayBuffer).

const dcmjs = require("dcmjs"); const fs = require("fs");

const filePath = "/Users/pieper/data/public-dicom/MRHead-multiframe+seg/MRHead-multiframe.dcm"

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

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

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

dataset.PatientName = "Name^Somebody's"

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

let new_file_WriterBuffer = DicomDict.write();

fs.writeFileSync("/tmp/file.dcm", new Buffer(new_file_WriterBuffer));

Attaching the DICOM file for reference: https://drive.google.com/file/d/1kS_MQVVA6BJkMwhjh-dbz3fZINIAKi7r/view?usp=drive_link

pieper commented 1 year ago

Thanks for the report and the file. Did you figure out what's different about this data? Will you be able to look into a fix?

satyam-qure commented 1 year ago

Thanks for the report and the file. Did you figure out what's different about this data? Will you be able to look into a fix?

Not yet, I'm currently looking into this.