-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modifying dicom tags #64
Comments
I'd suggest something more like this: 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)); |
Man, I am over the moon! 👍 Thank you so much @pieper for quick & accurate response! Just one last question, is it possible to add new Tag with Array as value? With pydicom we used to do this:
how can achieve something similar like this one? |
No problem - hope you find this useful. After years of working with various dicom toolkits I tried to make dcmjs as painless as possible, so for most purposes you just assign a member to the dataset named based on the data dictionary, so there's no hex codes needed and the values are simple javascript types wherever possible (numbers, strings, lists, objects, etc).
|
Indeed! dcmjs helped me to develop things very smoothly. I have been searching for JS tools available for DICOM, and those efforts ended on dcmjs. I saw your work from dcmio to dcmjs. Amazing job.. Once we have documentation in-place, it will take no time for developers to understand the APIs, even for newcomers to DICOM world. kudos to you and dcmjs team! 🥇 👍 |
Thanks! By the way if you're interested in such things you might want to join us for a Project Week (there's one next week at MIT, then another in Canada in July and one in Spain in January). |
Sounds great, very appreciative of your offer. Looking forward to meet you in London, Canada! |
Oooo, too bad that's the one I'll miss, but you'll meet lots of great folks there! |
Hi Piper, after I used your code, i got the wrong image like this. As you can see, the image become red flag. How to fix it ? thanks |
IMG022911.zip |
I want to confirm whether this will work for all the .dcm files as I'm getting an error (First argument to DataView constructor must be an ArrayBuffer) |
There are so many different flavors of DICOM in the wild (some valid and some not) so it's hard to say for sure.
If this is happening on data that used to work there could be a regression. If so please file a new issue. Or if you have example data that doesn't work consider making it available, filing an issue, and making a PR with a test case. |
Thank you for your prompt reply. I have submitted an issue and attached the file for reference. |
For future reference: #370 |
I am completely newbie to DICOM and was assigned to modify DICOM tags ;) so please bear with me.
My question is very simple, how do we modify DICOM tags and save it as file?
We will be using this module in Electron App so will have access to Node's fs module. I tried it on my own, something like:
With this, file get saved correctly but when I read the DICOM again, it has added new tag like:
x00000010 length=16; VR=PN; "JAYKUMAR THAKER"
rather than modifying"x00100010"
I am sure this might not be the correct way. However any level of guidance would be really appreciated.
The text was updated successfully, but these errors were encountered: