To create and load a Data Set from an existing DICOM file, you begin by creating an instance of the Leadtools.Dicom.DicomDataSet class. You can then use DicomDataSet.Load to load the Data Set.
At this point, you are ready to get information about the Data Set, traverse the Data Set, search for specific Modules or elements, get/set data values, add Modules or elements or delete Modules or elements.
As a short example, the code shown below does the following:
By comparing the displayed values for the Module number, Data Element Tag, and Value Representation to their respective default tables, you can determine which Module, element and Value Representation are present.
// Make sure you add references to: // Leadtools.Dicom.dll // Leadtools.Dicom.Tables.dll DicomDataSet dataSet; int Count = 0; DicomModule Module = null; DicomElement Element = null; string cs = string.Empty; DicomEngine.Startup(); // Create new DicomDataSet dataSet = new DicomDataSet(); // Load Dicom Data Set dataSet.Load(ImagesPath.Path + "IMAGE1.dcm", 0); // Determine the number of modules in this dataset Count = dataSet.ModuleCount; // Find the first module on Level 0 of the Data Set tree Module = dataSet.FindModuleByIndex(0); if (Module != null) { Element = Module.Elements[0]; // Print the information string csFormat = "" + "This data set has {0:D} modules. \n" + " First Module Type: {1}\n" + " First Module Element Count: {2:D} \n " + " The first element of the first module: \n" + " Length: {3:D}\n" + " Tag: {4:X} \n" + " VR: {5:X}"; cs = string.Format(csFormat, Count, Module.Type.ToString(), Module.Elements.Length, Element.Length, Element.Tag, Element.VR.ToString()); MessageBox.Show(cs, "Notice"); } else MessageBox.Show( "Module is NULL", "Notice"); // Release all resources used by the DICOM DataSet dataSet.Dispose();