The Structure of DICOMDIR
DICOMDIR acts as a "Directory" for DICOM file sets and holds a full 4 level hierarchy (PATIENT --> STUDY --> SERIES --> IMAGE) as shown below:
DICOMDIR files can be read using DicomDataSets.ReadDirectory method in DicomObjects and the complex structure of linked lists with offsets is held in a single DicomDataSet object.
When accessing the DICOMDIR, you may bear in mind that different DICOM attributes (or Tags) belong to different levels, for example PatientName is a Patient Level attribute, StudyUID is a Study Level attribute, Modality is Series Level and Image Number is Image Level.
The following VB.NET sample code demonstrates how to loop through the entire structure and extract some attributes of each level.
Dim d As New DicomObjects.DicomDataSet Dim ds As New DicomObjects.DicomDataSets Dim patient As DicomObjects.DicomDataSet Dim study As DicomObjects.DicomDataSet Dim series As DicomObjects.DicomDataSet Dim image As DicomObjects.DicomDataSet Dim PatientName, StudyUID, Modality, ImageNo As String d = ds.ReadDirectory("Your DICOMDIR") ' Read in the DicomDIR file into DicomDataSet Object For Each patient in d.Children ' For each Patient in the DICOMDIR PatientName = patient.Name For Each study in patient.Children ' For each study in patient StudyUID = study.StudyUID For Each series in study.Children ' For each series in study Modality = series.Attributes(&H8, &H60).Value For Each image in series.Children ' For each image in series ImageNo= image.Attributes(&H20,&H13).Value Next Next Next Next
Private attributes are allowed to be added at each level in DICOMDIR but they should be ignored when reading the DICOMDIR.
Images can be added to DICOMDIR by using DicomDataSet.AddToDirectory method.
Sample programs in VB.NET and C# can be downloaded from the samples page.