Class SetCharacteristicsFromSummary


  • public class SetCharacteristicsFromSummary
    extends java.lang.Object

    A class containing an application for adding or replacing top level and shared multi-frame functional group attributes from a JSON summary description.

    The JSON file used to describe the changes is not encoded in the same format as the standard PS3.18 Annex F DICOM JSON Model, since (a) it allows the data elements to be changed by keyword in addition to the data element tag, and (b) it compactly specifies whether the changes are to the top level dataset ("top") or the keyword of the sequence corresponding to the functional group to be changed, and (c) lists attributes in the top level data set to be removed ("remove") or those to be removed recursively from within sequences ("removeall"), and (d) lists options that control the process of modification.

    The required format of the JSON file is a single enclosing object containing a list of objects named by "remove", "options", a functional group sequence keyword or "top".

    The functional group sequence keyword or "top" entries each contains either a single string value, an array of string values (possibly empty) (for multi-valued attributes), or an array of objects (possibly empty) each of which is a sequence item consisting of a list of attributes, an object that contained a list of code sequence item attributes (named as cv for CodeValue, csd for CodingSchemeDesignator and cm for CodeMeaning) or null for an empty (type 2) attribute or sequence.

    The "remove" object contains a list of keywords and null values.

    The "options" object contains a list of options and boolean values. Current options are ReplaceCodingSchemeIdentificationSequence (default is true) and AppendToContributingEquipmentSequence (default is true)

    E.g.:

     {
            "options" : {
                    "AppendToContributingEquipmentSequence" : false
            },
            "remove" : {
                    "ContributingEquipmentSequence" : null
            },
            "removeall" : {
                    "FrameType" : null
            },
            "top" : {
                    "00204000" : "new value of ImageComments",
                    "InstitutionalDepartmentName" : "Radiology",
                    "ImageType" : [ "DERIVED", "PRIMARY", "DIXON", "WATER" ],
                    "PatientBreedCodeSequence" : null,
                    "BreedRegistrationSequence" : [
                            {
                                    "BreedRegistrationNumber" : "1234",
                                    "BreedRegistryCodeSequence" : { "cv" : "109200", "csd" : "DCM", "cm" : "America Kennel Club" }
                            },
                            {
                                    "BreedRegistrationNumber" : \"5678\",
                                    "BreedRegistryCodeSequence" : { "cv" : "109202", "csd" : "DCM", "cm" : "American Canine Association" }
                            }
                    ],
                    "StudyID" : null,
                    "AccessionNumber" : [],
                    "ReferencedStudySequence" : [],
                    "ContentCreatorName" : "Smith^John"
            },
            "FrameAnatomySequence" : {
                    "AnatomicRegionSequence" : { "cv" : "T-A0100", "csd" : "SRT", "cm" : "Brain" },
                    "FrameLaterality" : "B"
            },
            "ParametricMapFrameTypeSequence" : {
                    "FrameType" : [ "DERIVED", "PRIMARY", "DIXON", "WATER" ]
            },
            "FrameVOILUTSequence" : {
                    "WindowCenter" : "0.7",
                    "WindowWidth" : "0.7",
                    "VOILUTFunction" : "LINEAR_EXACT"
            }
     }
     

    Attributes are "merged" with the existing content of a functional group sequence, if any, otherwise a new functional group sequence is created.

    Currently only the shared functional group sequence can be updated, since non-programmatic use cases for replacing the content of the per-frame functional group sequence items have not yet been identified.

    • Field Detail

      • ourAETitle

        protected java.lang.String ourAETitle
      • dstFolderName

        protected java.lang.String dstFolderName
      • options

        protected java.util.Map<java.lang.String,​java.lang.Boolean> options
      • topLevelRemovalList

        protected java.util.Set<AttributeTag> topLevelRemovalList
      • recursiveRemovalList

        protected java.util.Set<AttributeTag> recursiveRemovalList
      • topLevelReplacementsList

        protected AttributeList topLevelReplacementsList
    • Constructor Detail

      • SetCharacteristicsFromSummary

        public SetCharacteristicsFromSummary​(java.lang.String jsonfile,
                                             java.lang.String src,
                                             java.lang.String dstFolderName,
                                             MessageLogger logger)
                                      throws java.io.IOException,
                                             DicomException

        Update top level and shared multi-frame functional group attributes from a JSON summary description.

        Updates SpecificCharacterSet before writing new file.

        Parameters:
        jsonfile - JSON file describing the functional groups and attributes and values to be added or replaced
        src - source folder or DICOMDIR
        dstFolderName - destination folder
        logger - logger to send progress, warnings and errors
        Throws:
        java.io.IOException
        DicomException
      • SetCharacteristicsFromSummary

        public SetCharacteristicsFromSummary​(java.lang.String jsonfile,
                                             java.lang.String[] srcs,
                                             java.lang.String dstFolderName,
                                             MessageLogger logger)
                                      throws java.io.IOException,
                                             DicomException

        Update top level and shared multi-frame functional group attributes from a JSON summary description.

        Updates SpecificCharacterSet before writing new file.

        Parameters:
        jsonfile - JSON file describing the functional groups and attributes and values to be added or replaced
        srcs - source folders or DICOMDIRs
        dstFolderName - destination folder
        logger - logger to send progress, warnings and errors
        Throws:
        java.io.IOException
        DicomException
      • SetCharacteristicsFromSummary

        public SetCharacteristicsFromSummary​(java.lang.String jsonfile,
                                             AttributeList list)
                                      throws java.io.IOException,
                                             DicomException

        Update top level and shared multi-frame functional group attributes from a JSON summary description.

        Does not update SpecificCharacterSet in AttributeList.

        Parameters:
        jsonfile - JSON file describing the functional groups and attributes and values to be added or replaced
        list - the list to update
        Throws:
        java.io.IOException
        DicomException
    • Method Detail

      • parseOptionsFromJSON

        protected void parseOptionsFromJSON​(javax.json.JsonObject entries)
                                     throws DicomException
        Throws:
        DicomException
      • parseSummaryFile

        protected void parseSummaryFile​(java.lang.String jsonfile)
                                 throws DicomException,
                                        java.io.FileNotFoundException
        Throws:
        DicomException
        java.io.FileNotFoundException
      • main

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

        Update top level and shared multi-frame functional group attributes from a JSON summary description.

        Parameters:
        arg - array of three or more strings - a JSON file describing the functional groups and attributes and values to be added or replaced, followed by one or more source folders or DICOMDIR, and a destination folder