Parse DICOMDIR to get image filepaths

1.2k Views Asked by At

I'm trying to locate DICOM filepaths by parsing a DICOMDIR.

But can't seem to figure out how to locate them. I parse through the DICOMDIR as follows:

DicomDirectory dir = new DicomDirectory("AE_TITLE");
dir.Load(dirPath);
foreach(DirectoryRecordSequenceItem elem in dir.RootDirectoryRecordCollection){//study
    foreach(DirectoryRecordSequenceItem innerElem in elem.LowerLevelDirectoryRecordCollection){//sequence
        foreach(DirectoryRecordSequenceItem inner2Elem in innerElem.LowerLevelDirectoryRecordCollection){//series
            foreach (DirectoryRecordSequenceItem inner3Elem in lastElem.LowerLevelDirectoryRecordCollection) // img
            {

            } 
        }
    }
}

this loops through the each study/sequence/series/image but non of these seem to contain a filepath to a .dcm file.

P.S. I use the ClearCanvas library to create the DicomDirectory object

1

There are 1 best solutions below

1
On BEST ANSWER

It appears that if you go to the lowest level (image level) the dicomfile has an attribute ReferencedFileId which holds the relative path so all that was needed is:

Console.inner3Elem.GetAttribute(DicomTags.ReferencedFileId).ToString();

This returns the path to the dicom file relative to where the DICOMDIR is located