I’m developing an extension that has to add to the series Metadata a tag that indicates a URL and also update some other tags, like actual Date or Time.
My issue is that I can read without any problem the metadata with a extract of code like the following:
But it doesn’t modify. I know that there is a ‘setTag’ method in pydicom but I dont know with which object can I use it. I have checked the Script repository but I haven’t seen anything that I can use. If anyone can help me it would be great.
DICOM standard does not let you modify an instance that was made available outside your software. No modification of an existing instance is allowed, because an instance UID must uniquely identify the entire content. Therefore, if you received a DICOM file from somewhere and want to make changes then you must create a new instance (with new instance UIDs), preferably add references to the original UIDs, and then hide or delete the original version.
The DICOM patcher in Slicer can modify an instance without regenerating UIDs, but this is for cases when the input data has already violated the DICOM standard.
Ok, I haven’t been working on it lately but I have started again. I searched and i didn’t find anything about creating a new instance from the DICOM file I originally had. Is it possible? Being able to create a duplicate with a different UID and some other different parameters would solve my problem.
Creating valid dicom files is a complex topic, and everything depend on what you are really trying to accomplish. Have a look at the export methods in some of the plugins for examples.