Hi
I am trying to edit nested DICOM tags in an RDSR file in python using pydicom. I have a Treeview of the RDSR file from which I can select the tag. I can get the path to the tag as a string by traversing the parents of the tree nodes. I can get the value of the tag by doing something like
path_to_tag = ''ds.ReferencedRequestSequence[0].RequestedProcedureDescription'
tag_value = eval(path_to_tag)
but apart from the security concerns of using eval it doesn't work the other way around to set the tag value.
I have tried using getattr and setattr iteratively on the string as below
def get_dot_attr(obj, att_name)->str:
path = att_name.split('.')
for part in path:
obj = getattr(obj, part)
return obj
but it fails on the sequence lists. I can probably programmatically handle the list in the above function but it feels like a bit of a kludge.
Have I missed something and is there an easier way of changing these nested tags?
Regards
Alan