# access meta dictionary using simpleitk

**URL:** https://discourse.itk.org/t/access-meta-dictionary-using-simpleitk/4939
**Category:** Beginner Questions
**Tags:** dicom, simpleitk, python
**Created:** [April 25, 2022, 8:51pm UTC](https://discourse.itk.org/t/access-meta-dictionary-using-simpleitk/4939 "2022-04-25T20:51:15Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![sehreen](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/838e76/32.png) [@sehreen](https://discourse.itk.org/u/sehreen)
#### Post date: [April 25, 2022, 8:51pm UTC](https://discourse.itk.org/t/access-meta-dictionary-using-simpleitk/4939/1 "2022-04-25T20:51:15Z")

</div>

how can I change the following code to read image in Simpleitk set meta data and save as simpleitk

dicom = dcmread(dcm\_path) #load it from simplitk and read it in simplitk instead dcmread  
for key,value in meta\_dict.items():  
dicom[key].value = value  
dicom.save\_as(dcm\_path)

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [April 25, 2022, 9:07pm UTC](https://discourse.itk.org/t/access-meta-dictionary-using-simpleitk/4939/2 "2022-04-25T21:07:07Z")

</div>

You could combine [tag modification example in C++](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/IO/DicomImageReadChangeHeaderWrite.cxx) with Python syntax from [tag print example](https://itk.org/ITKExamples/src/IO/GDCM/ReadAndPrintDICOMTags/Documentation.html). This uses Python ITK, not SimpleITK.

---

<div class="post-metadata">

### Author: ![sehreen](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/838e76/32.png) [@sehreen](https://discourse.itk.org/u/sehreen)
#### Post date: [April 25, 2022, 9:10pm UTC](https://discourse.itk.org/t/access-meta-dictionary-using-simpleitk/4939/3 "2022-04-25T21:10:54Z")

</div>

i used:  
dicom=sitk.ReadImage(dcm\_path)  
#dicom = dcmread(dcm\_path) #load it from simplitk and read it in simplitk instead dcmread  
for a in dicom.GetMetaDataKeys():  
b = dicom.GetMetaData(a)  
print(f"({a}) = = “{b}”")

it is just printinh “AAAAAA…” and

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [April 25, 2022, 11:57pm UTC](https://discourse.itk.org/t/access-meta-dictionary-using-simpleitk/4939/4 "2022-04-25T23:57:53Z")

</div>

Hello @sehreen,

Your syntax is not that of SimpleITK. Possibly [this example](https://simpleitk.readthedocs.io/en/master/link_DicomSeriesReadModifyWrite_docs.html) does what you need.

Highly recommend going through the [read-the-docs examples](https://simpleitk.readthedocs.io/en/master/link_examples.html) and possibly the toolkit’s [Jupyter notebooks](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks) to get up to speed on syntax and available functionality.
