Skip to content
Advertisement

Access DICOM files via DICOMDIR using pydicom

I am new to this file type. I want to access files in the folder S65279_1148582599_LIVER__QIU__SHIFU__M_53 by accessing the DICOMDIR located besides that folder. Inside the folder, I want to access the “IMG” files in a folder that looks like:

JavaScript

After reading the DICOMDIR file using dcmread, I get something like this:

JavaScript

How should I proceed to get ‘IMG00000739’? I have tried tried to access ReferenceFileID using ds[0x0004,0x1500], but this is not working.

Advertisement

Answer

A DICOMDIR file contains a linked list of directory records for patients, studies, series and images with some of their attributes. If all you need is a list of the DICOM files referenced in the DICOMDIR, you can just find all ReferencedFileID tags, which contain the path components to the path as a list. ReferencedFileID is only present in the image level directory records, so if you search for these entries, you will get the path to all contained DICOM images.

In pydicom, a DICOMDIR is represented by a FileSet that handles the specifics of that file type and allows you to search the directory records.
So, if you want to get all DICOM file paths referenced in the DICOMDIR, you can do something like this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement