Hierarchical SOP Instance

While DicomObjects can not create a Dicom Hierarchical SOP Instance dataset collection directly, however it can do much of the work for you. A Hierarchical SOP Instance Dataset collection are similar in structure to a DicomDir which DicomObjects can create automatically. Hierarchical SOP Instances are primarily used in the creation of Key Note Objects. The Structure of the Hierarchical SOP Instance is Study - Series - Instance (NO PATIENT)

The first Step is to organise all the objects of interest into a DicomDir by adding them to a DicomDataSet by using the AddToDirectory method.

    DicomDataSet PseudoDicomDir = new DicomDataSet();
    // Add all the Objects to the DicomDir
    PseudoDicomDir.AddToDirectory(ThisObject, "", "");

We Should now check that only a references to a single patient have been made, the top level of a DicomDir is patient level therefore

    // if more than one member to the Top Level, then we have more than one patient 
    if (PseudoDicomDir.Children.Count > 1)
      MessageBox.Show("ERROR - more than one patient ID");

We can now extract the information required from the DicomDir into DicomDataSetCollection that represents a Hierarchical SOP Instances and can be added to(0040,A375).

 DicomDataSetCollection StudySequence = new DicomDataSetCollection();
 // for each Study in the dicomdir (only one patient allowed)
 foreach (DicomDataSet study in PseudoDicomDir.Children[0].Children)
    DicomDataSet StudySequenceItem = new DicomDataSet();
    StudySequenceItem.StudyUID = study.StudyUID; // Unique identifier of a Series that is part of this Study 
    DicomDataSetCollection SeriesSequence = new DicomDataSetCollection();
    foreach (DicomDataSet series in study.Children) // for each series in each study
        DicomDataSet SeriesSequenceItem = new DicomDataSet();
        SeriesSequenceItem.SeriesUID = series.SeriesUID; // Referenced Series Instance UID
        DicomDataSetCollection InstanceSequence = new DicomDataSetCollection();
        foreach (DicomDataSet Instance in series.Children) // for each instance in each series
            DicomDataSet InstanceSequenceItem = new DicomDataSet();
            // Referenced SOP Class UID
            // Referenced SOP Instance UID
        // add all the instance collection to the series
        SeriesSequenceItem.Add(Keyword.ReferencedSOPSequence, InstanceSequence);
    // add the series collection to the study
    StudySequenceItem.Add(Keyword.ReferencedSeriesSequence, SeriesSequence);

We use cookies to give you the best possible experience on our website. By continuing to use this website, you agree with our use of cookies. for more information please click HERE