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)
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}”")
Your syntax is not that of SimpleITK. Possibly this example does what you need.
Highly recommend going through the read-the-docs examples and possibly the toolkit’s Jupyter notebooks to get up to speed on syntax and available functionality.