Hi Dears 3DSlicer developers
After loading dicom files using DICOM module, how can I access the value of certain attribute (tag) in “DICOM Metadata” from Python Interactor?
For example, I want to access the value of IsocenterPosition with the tag number (300a,012c) from Python Interactor. How can I do that?
Please guide me,
Thanks a lot.
Here are some examples - let us know if this doesn’t cover your use case.
Thanks a lot for sending to me the link to ScriptRepository.
I can access to tags such as (0020,0010) to (300a,000c), but unfortunately I can not read tags that are located in item, such as (300a,012c), highlighted in the following figure.
The following figure is screenshot of DICOM File Browser and the tag that I want to access its value (300a,012c).
I enter the following commands:
As you see, the last command dose not give any output.
Please guide me to access tags that are loacted in Items.
Thanks a lot.
Hi Shahrokh -
Ah, sorry - you are right, the database doesn’t cache nested tags, only top level ones.
I added a new section to the script repository showing how to access nested tags using pydicom.
Hi Dear Steve
Thank you very much for the link you provided. I study it now.
But I accidentally solved my problem according to the description given on the site of Pydicom User Guide — pydicom 1.0a documentation.
In JupyterLab, I enter the following commands:
: import pydicom
: ds = dicom.read_file("112325-00000000.dcm")
(300a, 00b0) Beam Sequence 2 item(s) ----
(300a, 00b2) Treatment Machine Name SH: 'Compact'
(300a, 0111) Control Point Sequence 2 item(s) ----
(300a, 0112) Control Point Index IS: "0"
(300a, 012c) Isocenter Position DS: ['111.908', '-52.0623', '-1212.2']
['111.908', '-52.0623', '-1212.2']
But this method is difficult.
Yes, getting data out of nested dicom sequences is kind of awkward. The example I linked is abit easier to read, since it uses the dicom dictionary name instead of the hex tag.