Creating DICOM Directories

In order to identify a DICOM file-set, and to facilitate accessing the information stored in the DICOM files of the file-set, the DICOM standard has defined the Basic Directory IOD. A DICOM file-set contains one or more DICOM files. One of the files contained in the file-set is the DICOMDIR file. The DICOMDIR file contains Dicom Directory information, which makes it easier to access the information contained in the other DICOM files in the file set. The DICOM files in the file-set are assigned File IDs, so that they can be referenced by the DICOMDIR File, which itself, is identified by a File ID of DICOMDIR.

LEADTOOLS provides the LEADDicomDir COM object, which implements the ILEADDicomDir interface, to simplify the process of creating DICOM Directories for file-sets.

As a demonstration of a typical usage of the methods and properties of the ILEADDicomDir interface, let’s suppose that we need to build the DICOM Directory of the file-set defined by the files contained in the folder "C:\DICOM Images\" and in any subfolders. This folder is then the destination folder of the DICOMDIR File.

At the beginning of the application, the destination folder should be specified. This is done using the ResetDicomDir method.

Only the DICOM files within the destination folder (e.g., "C:\DICOM Images\Brain") or in a subfolder of this folder (e.g., "C:\DICOM Images\Patient1\Series1\Knee") can be added to the Dicom Directory. The File ID, which is used by the Dicom Directory to reference an added file, will be the relative path of the file. For instance, the File IDs of the two previous files would be "Brain" and "Patient1\Series1\Knee", respectively.

A DICOM file can be added to the Dicom Directory in one of two ways:

image\sqrblit.gif Directly, using the InsertDicomFile method. The DICOM files contained in the destination folder can be added individually or all at once using this method. Adding the files individually requires multiple calls to the InsertDicomFile method, with the name of the file to add passed in the bstrFileName parameter. All files in the destination folder can be added at once by calling the InsertDicomFile method with the bstrFileName parameter set to NULL. In this case, the DicomFileInsert event is fired for each file that is added so that the progress of adding the files can be monitored. The IncludeSubfolders property specifies whether the files in the subfolders of the destination folder should also be added.

image\sqrblit.gif Indirectly, using the InsertDicomDS method. In this way, the Data Set contained by the DICOM file to be added is first loaded using the LoadDS method of the LEADTOOLS DICOM COM object and the handle to the Data Set (specified by the hDicomDS property of the control) is then passed to the InsertDicomDS method.

The SetFileSetID method can be used to identify the file-set by providing a simple humanly readable identifier. Also, the SetDescriptorFile method can be used to specify a descriptor file (a "readme" file) for the file-set.

The InsertIconImageSequence property specifies whether to add an icon image that represents the image stored in the DICOM file or Data Set to be added to the Dicom Directory.

The ImplementationClassUID property and ImplementationVersionName property can be used to identify the implementation that writes the DICOMDIR File and its content.

The RejectInvalidFileID property specifies whether those methods of the ILEADDicomDir interface that take a filename as a parameter should reject invalid File IDs.

The handle to the Data Set of the DICOM Directory managed by the COM object is specified by the hDicomDirDS property. For further manipulation of this Data Set, the handle can be used with the LEADTOOLS DICOM COM object.

Once the DICOM Directory is ready, the SaveDicomDir method can be called to create the DICOMDIR File and store the directory information. The DICOMDIR File is named "DICOMDIR" and is saved in the destination folder ("C:\DICOM Images\DICOMDIR").

The LoadDicomDir method can be used to load the Dicom Directory stored in an existing DICOMDIR file. The loaded Dicom Directory can then be manipulated using the various properties and methods. For instance, additional DICOM files can be added to the Directory.

Most of the methods of the ILEADDicomDir interface return a value that indicates success or failure. If you need these methods to generate runtime exceptions in case of failure (in addition to the return value), set the EnableMethodErrors property to VARIANT_TRUE.