How to read a tag from a subheader #2042
Replies: 2 comments
-
I'm assuming you figured it out, but for anyone else the required element is nested inside at least one sequence with tag (0021,11FE). To access elements in a sequence you need to do: seq = ds[0x0021, 0x11FE] # A sequence item, which is basically list[Dataset]
item = seq[0] # The first Dataset item in the sequence, there may be 0 or more items
elem = item[0x0021, 0x1106] # The required element
# elem = ds[0x0021, 0x11FE][0][0x0021, 0x1106] # Alternatively
value = elem.value # The value of the required element All the above is for private elements (those with an odd group number), for public elements you can also access via the more human friendly keywords: value = ds.BeamSequence[0].BeamName # The value of the Beam Name element |
Beta Was this translation helpful? Give feedback.
-
Yes, thanks, I indeed figured it out. I printed the ds but because the new enhanced DICOM from Siemens (XA-30) is so long and repetitive, which made that the root element was scrolled out of my screen completely (so I missed it when I did what you described here, and got an error). |
Beta Was this translation helpful? Give feedback.
-
If I read a DICOM dataset and display it I see a field that I want to read, i.e. I want to read
(0021, 1106)
from this dataset:I get a key error if I try:
The only way I manage to read the tag is by using
iterall()
, but isn't there a better way?Beta Was this translation helpful? Give feedback.
All reactions