Parsing a DICOMDIR with pydicom

1,192 views
Skip to first unread message

swundra

unread,
Jun 19, 2013, 7:06:30 AM6/19/13
to pyd...@googlegroups.com
Hello,

I just started playing with pydicom and I am having some trouble reading a DICOMDIR file.

I studied the pydicom myprint() example and wrote code to parse the DICOMDIR hierarchy recursively.
The DICOMDIR is structured as usual in a PATIENT->STUDY->SERIES->IMAGE hierarchy


To my suprise, the following code prints out all IMAGE, STUDY, PATIENT, and SERIES tags, even thought it is NOT going

into recursion. It seems like the hierarchy is somehow flattened.


def Test(ds):
   for element in ds:

if element.VR == "SQ":

test = element.value;

for item in test:

print(item[0x0004, 0x1430].value)


ds = dicom.read_file("DICOMDIR')
Test(ds)

What is the reason for this. Is pydicom able to handle DICOMDIR at all?
Reading the hierarchy with dcmtk for example is no problem.

I am using python-xy with pydicom 0.9.8-2

Best Regards,
Stefan

Darcy Mason

unread,
Jun 19, 2013, 9:17:14 AM6/19/13
to pyd...@googlegroups.com
I don't have time at the moment for a more detailed response, but I will point you to the repository -- there is a new read_dicomdir function not in any pydicom releases yet, and some example code, in several revisions since the beginning of 2013: https://code.google.com/p/pydicom/source/list

The dicomdir file structure is a little strange -- it is based on record offsets, so it is not so easy to interpret when read as a normal dicom file.

Darcy
Reply all
Reply to author
Forward
0 new messages