Replies: 4 comments
-
Please attach a dataset that demonstrates the issue, or a minimally reproducible code sample. |
Beta Was this translation helpful? Give feedback.
-
When a dicom file with GroupTagLengh is read, then the dataset hosts this tag. E.g. Is there a method to enforce writing the group length tag? My script's primary task is to pseudonymize a DICOM file, and as a sanity check, the original file must be reconstructed from the pseudonymized version using the stored information about what was removed during pseudonymization. Sorry for the mixup |
Beta Was this translation helpful? Give feedback.
-
So you are saying that the group length tag is removed, not added? I'm confused about the actual issue. |
Beta Was this translation helpful? Give feedback.
-
There's no method to keep the group length tags, they're removed here. If you want to track which group length elements are removed you can do: from pydicom.dataset import Dataset
from pydicom.dataelem import DataElement
def find_group_length_elements(ds):
results = {}
for elem in ds:
if elem.tag.element == 0x0000:
results[elem.tag] = elem
continue
if elem.VR == "SQ":
for item in elem.value:
result = find_group_length_elements(item)
if result:
sq_results = results.get(elem.tag, [])
sq_results.append(result)
results[elem.tag] = sq_results
return results
ds = Dataset()
ds[0x00090000] = DataElement(0x00090000, "UL", 4)
ds.BeamSequence = [Dataset()]
item = ds.BeamSequence[0]
item[0x00090000] = DataElement(0x00090000, "UL", 42)
for leaf, branch in find_group_length_elements(ds).items():
print(f"{leaf}: {branch}")
|
Beta Was this translation helpful? Give feedback.
-
Similar behaviour as desribed in this issue but for function
safe_as()
. Although no Group Length Tags and Elements are present in theds
, when writing the DICOM file usingsave_as(ds)
, those unwanted and deprecated group-length-tags are written to the stored file.Beta Was this translation helpful? Give feedback.
All reactions