Package com.pixelmed.dicom

## Class ImageLibrary

- java.lang.Object
- - com.pixelmed.dicom.ImageLibrary

- Direct Known Subclasses:
    `CrossSectionalImageLibrary`, `ProjectionXRayImageLibrary`

      public class ImageLibrary
      extends java.lang.Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `ImageLibrary.ImageLibraryEntry` |

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected CompositeInstanceContext` | `compositeInstanceContext` |
    `protected java.util.Map<java.lang.String,​ImageLibrary.ImageLibraryEntry>` | `entriesIndexedBySOPInstanceUID` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ImageLibrary()` | Construct an empty Image Library.
    `ImageLibrary​(AttributeList list)` | Construct an Image Library by extracting it from an existing DICOM SR instance.
    `ImageLibrary​(ContentItem imageLibraryContainer, AttributeList list)` | Construct an Image Library by extracting it from an existing DICOM SR instance.
    `ImageLibrary​(java.util.Set<java.io.File> files)` | Create an SR Image Library from a bunch of DICOM image instances.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `addContributingEquipmentSequence​(AttributeList list)` |
    `ImageLibrary.ImageLibraryEntry` | `addImage​(AttributeList list)` | Create and add an SR Image Library entry derived from a DICOM image instance.
    `protected void` | `constructImageLibrary​(ContentItem imageLibraryContainer, AttributeList list)` | Construct an Image Library by extracting it from an existing DICOM SR instance.
    `static ContentItem` | `findImageLibraryContainer​(ContentItem node)` | Find the Image Library contained within an SR content tree.
    `AttributeList` | `getAttributeList()` |
    `SequenceAttribute` | `getCommonInstanceReferenceModuleReferencedSeriesSequence​(java.lang.String studyInstanceUID)` |
    `SequenceAttribute` | `getHierarchicalEvidenceSequence()` | Build a hierarchical evidence sequence for the current Image Library content.
    `protected java.util.Map<java.lang.String,​HierarchicalSOPInstanceReference>` | `getHierarchicalSOPInstanceReferencesIndexedBySOPInstanceUID​(AttributeList list)` |
    `StructuredReport` | `getStructuredReport()` |
    `ContentItem` | `getStructuredReportFragment​(ContentItem parent)` | Get the Image Library as an SR fragment.
    `static void` | `main​(java.lang.String[] arg)` | Create an SR Image Library from a bunch of DICOM image instances.
    `ImageLibrary.ImageLibraryEntry` | `makeImageLibraryEntry​(AttributeList list)` |
    `ImageLibrary.ImageLibraryEntry` | `makeImageLibraryEntry​(ContentItemFactory.ImageContentItem imageContentItem, java.util.Map<java.lang.String,​HierarchicalSOPInstanceReference> hierarchicalSOPInstanceReferencesIndexedBySOPInstanceUID)` |
    `static ImageLibrary` | `read​(java.lang.String filename)` | Extract the Image Library from a DICOM SR instance.
    `java.lang.String` | `toString()` |
    `void` | `write​(java.io.File file)` |
    `void` | `write​(java.lang.String filename)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### entriesIndexedBySOPInstanceUID

          protected java.util.Map<java.lang.String,​ImageLibrary.ImageLibraryEntry> entriesIndexedBySOPInstanceUID

    - #### compositeInstanceContext

          protected CompositeInstanceContext compositeInstanceContext

  - ### Constructor Detail

    - #### ImageLibrary

          public ImageLibrary()

      Construct an empty Image Library.

    - #### ImageLibrary

          public ImageLibrary​(AttributeList list)
                       throws DicomException

      Construct an Image Library by extracting it from an existing DICOM SR instance.

      Searches the content tree for the Image Library CONTAINER content item.

      Parameters:
        `list` - the attributes comprising the DICOM SR instance containing the Image Library
      Throws:
        `DicomException` - if error in DICOM encoding

    - #### ImageLibrary

          public ImageLibrary​(ContentItem imageLibraryContainer,
                              AttributeList list)

      Construct an Image Library by extracting it from an existing DICOM SR instance.

      Parameters:
        `imageLibraryContainer` - the content item that is the Image Library CONTAINER
        `list` - the attributes comprising the DICOM SR instance containing the Image Library

    - #### ImageLibrary

          public ImageLibrary​(java.util.Set<java.io.File> files)
                       throws java.io.IOException,
                              DicomException

      Create an SR Image Library from a bunch of DICOM image instances.

      Adds a new series (instance UID) to the existing study (instance UID).

      Parameters:
        `files` - the filenames and/or folder names of files containing the input image files
      Throws:
        `DicomException` - if error in DICOM encoding
        `java.io.IOException` - if error reading a file

  - ### Method Detail

    - #### makeImageLibraryEntry

          public ImageLibrary.ImageLibraryEntry makeImageLibraryEntry​(ContentItemFactory.ImageContentItem imageContentItem,
                                                                      java.util.Map<java.lang.String,​HierarchicalSOPInstanceReference> hierarchicalSOPInstanceReferencesIndexedBySOPInstanceUID)

    - #### makeImageLibraryEntry

          public ImageLibrary.ImageLibraryEntry makeImageLibraryEntry​(AttributeList list)
                                                               throws DicomException

      Throws:
        `DicomException`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getCommonInstanceReferenceModuleReferencedSeriesSequence

          public SequenceAttribute getCommonInstanceReferenceModuleReferencedSeriesSequence​(java.lang.String studyInstanceUID)
                                                                                     throws DicomException

      Throws:
        `DicomException`

    - #### getHierarchicalEvidenceSequence

          public SequenceAttribute getHierarchicalEvidenceSequence()
                                                            throws DicomException

      Build a hierarchical evidence sequence for the current Image Library content.

      This contains the Study and Series Instance UIDs and is required for most SR IODs.

      Returns:
        a CurrentRequestedProcedureEvidenceSequence listing all the referenced instances
      Throws:
        `DicomException` - if error in DICOM encoding

    - #### findImageLibraryContainer

          public static ContentItem findImageLibraryContainer​(ContentItem node)

      Find the Image Library contained within an SR content tree.

      The Image Library is identified by the ("111028","DCM","Image Library") concept name for the content item.

      Parameters:
        `node` - the content item to being the search at (e.g., the root node)
      Returns:
        the content item that is the Image Library CONTAINER

    - #### getHierarchicalSOPInstanceReferencesIndexedBySOPInstanceUID

          protected java.util.Map<java.lang.String,​HierarchicalSOPInstanceReference> getHierarchicalSOPInstanceReferencesIndexedBySOPInstanceUID​(AttributeList list)

    - #### constructImageLibrary

          protected void constructImageLibrary​(ContentItem imageLibraryContainer,
                                               AttributeList list)

      Construct an Image Library by extracting it from an existing DICOM SR instance.

      Parameters:
        `imageLibraryContainer` - the content item that is the Image Library CONTAINER
        `list` - the attributes comprising the DICOM SR instance containing the Image Library

    - #### getStructuredReportFragment

          public ContentItem getStructuredReportFragment​(ContentItem parent)
                                                  throws DicomException

      Get the Image Library as an SR fragment.

      Has side effect of adding the fragment to the parent if the parent is not null.

      Parameters:
        `parent` - the parent CONTAINER content item (usually the root content item)
      Returns:
        a new ContainerContentItem with ImageContentItem children
      Throws:
        `DicomException` - if error in DICOM encoding

    - #### getStructuredReport

          public StructuredReport getStructuredReport()
                                               throws DicomException

      Throws:
        `DicomException`

    - #### getAttributeList

          public AttributeList getAttributeList()
                                         throws DicomException

      Throws:
        `DicomException`

    - #### addContributingEquipmentSequence

          protected void addContributingEquipmentSequence​(AttributeList list)
                                                   throws DicomException

      Throws:
        `DicomException`

    - #### write

          public void write​(java.lang.String filename)
                     throws DicomException,
                            java.io.IOException

      Throws:
        `DicomException`
        `java.io.IOException`

    - #### write

          public void write​(java.io.File file)
                     throws DicomException,
                            java.io.IOException

      Throws:
        `DicomException`
        `java.io.IOException`

    - #### read

          public static ImageLibrary read​(java.lang.String filename)
                                   throws DicomException,
                                          java.io.IOException

      Extract the Image Library from a DICOM SR instance.

      Parameters:
        `filename` - the DICOM SR instance containing the Image Library
      Returns:
        an instance of the ImageLibrary class representing the Image Library content encoded in the DICOM SR file
      Throws:
        `DicomException` - if error in DICOM encoding
        `java.io.IOException` - if error reading the file

    - #### addImage

          public ImageLibrary.ImageLibraryEntry addImage​(AttributeList list)
                                                  throws DicomException

      Create and add an SR Image Library entry derived from a DICOM image instance.

      Requires that a SOP Instance UID be present in the supplied image instance, to be used to index the entries.

      Parameters:
        `list` - the list of attributes of the image instance
      Returns:
        the new ImageLibraryEntry added to this ImageLibrary, or null if no SOP Instance UID is present in the supplied image instance
      Throws:
        `DicomException` - if error in DICOM encoding

    - #### main

          public static void main​(java.lang.String[] arg)

      Create an SR Image Library from a bunch of DICOM image instances.

      Adds a new series (instance UID) to the existing study (instance UID).

      Parameters:
        `arg` - the path for the SR Image Library output, then the filenames and/or folder names of files containing the input image files