wondering how to change a dicom tag value inside a file

1,318 views
Skip to first unread message

Dicom Asker

unread,
Jul 5, 2017, 11:18:59 AM7/5/17
to dcm4che
Hi everyone. This is what I need to do
  1. I need to retrieve some dicom files from a pacs, for which I am using the movescu+storescp command line tool. This part works OK.
  2. Then I need to change some values from the dicom header. My doubt is about this step.
  3. And finally I need to send the modified file to another pacs. I will use the storescu command line tool. This part works OK.
I am trying to do all this steps usying the command line tools inside a linux shell script. I do not have a very good knowledge of the library so I am not considering writing a java tools to achieve this. I am using dcm command line tools version 3.3.8

I am wondering if there is a dcm4che tool which allows me to do this change.

I have been trying the json2dcm/dcm2json tool. And this is my first test

There is one dicom file called original.dcm

[]$ ls
original.dcm

Then I extract all its headers into a json file called original.json

[]$ /opt/dcm4che/bin/dcm2json original.dcm > original.json

And finally I use the reverse tool hoping the resulting file will be exacly the same as I have not change anything into the dicom/headers/json

[]$ /opt/dcm4che/bin/json2dcm -i original.dcm -j original.json -o result.dcm

But the checksum says they are not the same. Almost the same in size though.

[]$ sha1sum original.dcm
b21468feaa74153a2c07dfefb4e765418f633e02  original.dcm

[]$ sha1sum result.dcm
bc2093cc967c829ac79ca23f6f01ab9907ef890a  result.dcm

[]$ ls -l
8357 jul  5 16:37 origina.json
4384 jul  5 16:20 original.dcm
4378 jul  5 16:38 result.dcm

My idea is changing the intermediate json file into the correct values using shell script as I need to retrieve the new values from a database. And the merging the modified json file with the original dicom file.


dcmdumping the original and resulting dicom file, I can see little differences. dots (...) stands for headers with the same value in the original and in the result file

---------------------------------original --------------------
...
1274: (0010,4000) LT #12 [Insurance=] PatientComments
...
3640: (0032,1032) PN #14 [DESCONOCIDO^^^] RequestingPhysician


---------------------------------original --------------------
...
1274: (0010,4000) LT #10 [Insurance=] PatientComments
...
3638: (0032,1032) PN #12 [DESCONOCIDO] RequestingPhysician


The dcm2jpg output for both original.dcm and result.dcm is exactly the same

With all this information, can I asume this process will not lose or change any header/information other than the ones I will replace in the json file

Am I doing something wrong with the parameters of the tools, is there a better/simple way to achieve this using the dcm4che command line tools ?

Thank you very much in advance.

Juan Miguel Camarasaltas Moreno

unread,
Jul 12, 2017, 1:30:33 PM7/12/17
to dcm4che

Hi,

I have made change in Dicom tags using Mirth Connect. I think it's relatively easy. If you want, I can help you with Mirth Connect example


Regards

Marius Gudas

unread,
Nov 29, 2017, 5:06:33 AM11/29/17
to dcm4che
Can you upload mirth example?

Darius Seiffert

unread,
May 16, 2018, 6:15:16 AM5/16/18
to dcm4che
Hi Juan, can you please upload your Mirth example?

Is it possible to change the value of an attribute of a DCM and write it back into a DCM?

Thanks in advance and best regards

Dicom Asker

unread,
May 16, 2018, 6:50:00 AM5/16/18
to dcm4che
When in Mirth Connect, 

if you need to get the value of a Dicom Tag, you can use

an = msg['tag00080050'].toString();



If you need to change the value of a tag inside the dicom objet, you can use

msg['tag00100020'].setChildren( '11111111A' );


It is important to note that when changing dicom messages we need to use the msg, not the tmp variable (I do not why, but that is the way. I can not find right now where I read it, sorry).
If you want to write the output dicom file in a directory for example you can use the ${DICOMMESSAGE} mirth variable as a template.

I hope this will help. Feel free to ask anything which is not clear. 

Darius Seiffert

unread,
May 16, 2018, 12:38:19 PM5/16/18
to dcm4che
Many thanks, seems like a good solution, will try that
Reply all
Reply to author
Forward
0 new messages