I am currently encountering difficulties with my coding-project related to specifying the desired encoding when using dcmodify. I have developed a simple Python script that updates values in specific DICOM tags. However, I am facing an issue when attempting to execute this modification with dcmodify:
1) the pre-existing DICOM file (dicomfile.dcm) is stored with special character set 'ISO_IR 100' (equal to 'latin-1' in python) with an outdated patientname (Maxi^MußtermannOld), please not the special character 'ß'
2) in python, the new patient name is stored in unicode in the string newPatientName="Maxi^MußtermannNew"
3) I want to update the dicomfile.dcm with the newPatientName value
4) when executing python code
Code: Select all
newPatientName="Maxi^MußtermannNew"
command = ['dcmodify', '-nb', '-m', f'(0010,0010)={newPatientName}', dicomfile.dcm]
subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
output of original dicomfile:
Code: Select all
dcmdump +P 0010,0010 original_dicomfile.dcm
# output: Maxi^Mu?termannOld
dcmdump +U8 +P 0010,0010 original_dicomfile.dcm
# output: Maxi^MußtermannOld
dcmdump +P 0008,0005 original_dicomfile.dcm
# output ISO_IR 100
Code: Select all
dcmdump +P 0010,0010 dicomfile.dcm
# output: Maxi^MußtermannOld --> this should be Maxi^Mu?termannOld
dcmdump +U8 +P 0010,0010 dicomfile.dcm
# output: Maxi^MuÃtermannNew --> this should be Maxi^MußtermannOld
dcmdump +P 0008,0005 dicomfile.dcm
# output ISO_IR 100
Any hits are appreciated
![Smile :-)](./images/smilies/icon_e_smile.gif)