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.
Modifier and Type | Class and Description |
---|---|
protected class |
SetCharacteristicsFromSummary.OurMediaImporter |
Modifier and Type | Field and Description |
---|---|
protected DicomDictionary |
dictionary |
protected java.lang.String |
dstFolderName |
protected java.util.Map<AttributeTag,AttributeList> |
functionalGroupsReplacementsList |
protected java.util.Map<java.lang.String,java.lang.Boolean> |
options |
protected java.lang.String |
ourAETitle |
protected java.util.Set<AttributeTag> |
recursiveRemovalList |
protected java.util.Set<AttributeTag> |
topLevelRemovalList |
protected AttributeList |
topLevelReplacementsList |
Constructor and Description |
---|
SetCharacteristicsFromSummary(java.lang.String jsonfile,
AttributeList list)
Update top level and shared multi-frame functional group attributes from a JSON summary description.
|
SetCharacteristicsFromSummary(java.lang.String jsonfile,
java.lang.String[] srcs,
java.lang.String dstFolderName,
MessageLogger logger)
Update top level and shared multi-frame functional group attributes from a JSON summary description.
|
SetCharacteristicsFromSummary(java.lang.String jsonfile,
java.lang.String src,
java.lang.String dstFolderName,
MessageLogger logger)
Update top level and shared multi-frame functional group attributes from a JSON summary description.
|
Modifier and Type | Method and Description |
---|---|
protected AttributeTag |
getAttributeTagFromKeywordOrGroupAndElement(java.lang.String name) |
static void |
main(java.lang.String[] arg)
Update top level and shared multi-frame functional group attributes from a JSON summary description.
|
protected Attribute |
makeNewAttribute(AttributeTag tag) |
protected Attribute |
makeNewSequenceAttribute(AttributeTag tag) |
protected Attribute |
makeNewStringAttribute(AttributeTag tag) |
protected Attribute |
parseAttributeFromJSON(javax.json.JsonObject obj,
java.lang.String name) |
protected void |
parseAttributesFromJSON(javax.json.JsonObject functionalGroupEntries,
AttributeList list) |
protected void |
parseAttributeTagsFromJSON(javax.json.JsonObject entries,
java.util.Set<AttributeTag> tags) |
protected void |
parseOptionsFromJSON(javax.json.JsonObject entries) |
protected void |
parseSummaryFile(java.lang.String jsonfile) |
protected void |
performReplacements(AttributeList list) |
protected void |
processAttributeListAfterReplacements(AttributeList list) |
protected DicomDictionary dictionary
protected java.lang.String dstFolderName
protected java.util.Map<AttributeTag,AttributeList> functionalGroupsReplacementsList
protected java.util.Map<java.lang.String,java.lang.Boolean> options
protected java.lang.String ourAETitle
protected java.util.Set<AttributeTag> recursiveRemovalList
protected java.util.Set<AttributeTag> topLevelRemovalList
protected AttributeList topLevelReplacementsList
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.
jsonfile
- JSON file describing the functional groups and attributes and values to be added or replacedlist
- the list to updatejava.io.IOException
DicomException
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.
jsonfile
- JSON file describing the functional groups and attributes and values to be added or replacedsrcs
- source folders or DICOMDIRsdstFolderName
- destination folderlogger
- logger to send progress, warnings and errorsjava.io.IOException
DicomException
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.
jsonfile
- JSON file describing the functional groups and attributes and values to be added or replacedsrc
- source folder or DICOMDIRdstFolderName
- destination folderlogger
- logger to send progress, warnings and errorsjava.io.IOException
DicomException
protected AttributeTag getAttributeTagFromKeywordOrGroupAndElement(java.lang.String name) throws DicomException
DicomException
public static void main(java.lang.String[] arg)
Update top level and shared multi-frame functional group attributes from a JSON summary description.
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 folderprotected Attribute makeNewAttribute(AttributeTag tag) throws DicomException
DicomException
protected Attribute makeNewSequenceAttribute(AttributeTag tag) throws DicomException
DicomException
protected Attribute makeNewStringAttribute(AttributeTag tag) throws DicomException
DicomException
protected Attribute parseAttributeFromJSON(javax.json.JsonObject obj, java.lang.String name) throws DicomException
DicomException
protected void parseAttributesFromJSON(javax.json.JsonObject functionalGroupEntries, AttributeList list) throws DicomException
DicomException
protected void parseAttributeTagsFromJSON(javax.json.JsonObject entries, java.util.Set<AttributeTag> tags) throws DicomException
DicomException
protected void parseOptionsFromJSON(javax.json.JsonObject entries) throws DicomException
DicomException
protected void parseSummaryFile(java.lang.String jsonfile) throws DicomException, java.io.FileNotFoundException
DicomException
java.io.FileNotFoundException
protected void performReplacements(AttributeList list) throws DicomException
DicomException
protected void processAttributeListAfterReplacements(AttributeList list) throws DicomException
DicomException