Skip to content

Commit

Permalink
ENH: more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorov committed Mar 21, 2017
1 parent e43d3be commit 2c1aa3b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 20 deletions.
3 changes: 2 additions & 1 deletion include/dcmqi/MultiframeObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <dcmtk/dcmiod/modequipment.h>
#include <dcmtk/dcmiod/modenhequipment.h>
#include <dcmtk/dcmiod/modmultiframedimension.h>
#include <dcmtk/dcmiod/iodcontentitemmacro.h>

#include "dcmqi/Exceptions.h"
#include "dcmqi/ImageVolumeGeometry.h"
Expand Down Expand Up @@ -77,7 +78,7 @@ class MultiframeObject {
virtual int initializeCompositeContext();
virtual bool metaDataIsComplete();


ContentItemMacro* initializeContentItemMacro(CodeSequenceMacro, CodeSequenceMacro);

// List of tags, and FGs they belong to, for initializing dimensions module
int initializeDimensions(std::vector<std::pair<DcmTag, DcmTag> >);
Expand Down
18 changes: 18 additions & 0 deletions libsrc/MultiframeObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,21 @@ int MultiframeObject::initializePlaneOrientationFG() {
);
return EXIT_SUCCESS;
}

ContentItemMacro* MultiframeObject::initializeContentItemMacro(CodeSequenceMacro conceptName,
CodeSequenceMacro conceptCode){
ContentItemMacro* item = new ContentItemMacro();
CodeSequenceMacro* concept = new CodeSequenceMacro(conceptName);
CodeSequenceMacro* value = new CodeSequenceMacro(conceptCode);

if (!item || !concept || !value)
{
return NULL;
}

item->getEntireConceptNameCodeSequence().push_back(concept);
item->getEntireConceptCodeSequence().push_back(value);
item->setValueType(ContentItemMacro::VT_CODE);

return EXIT_SUCCESS;
}
1 change: 1 addition & 0 deletions libsrc/ParametricMapConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ namespace dcmqi {
// TODO: LutExplanation and LUTLabel should be added as Metainformation
realWorldValueMappingItem->setLUTExplanation(metaInfo.metaInfoRoot["MeasurementUnitsCode"]["CodeMeaning"].asCString());
realWorldValueMappingItem->setLUTLabel(metaInfo.metaInfoRoot["MeasurementUnitsCode"]["CodeValue"].asCString());

ContentItemMacro* quantity = new ContentItemMacro;
CodeSequenceMacro* qCodeName = new CodeSequenceMacro("G-C1C6", "SRT", "Quantity");
CodeSequenceMacro* qSpec = new CodeSequenceMacro(
Expand Down
57 changes: 38 additions & 19 deletions libsrc/ParametricMapObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,37 +154,56 @@ int ParametricMapObject::initializeRWVMFG() {

if(metaDataJson.isMember("MeasurementsUnitsCode")){
CodeSequenceMacro& unitsCodeDcmtk = realWorldValueMappingItem->getMeasurementUnitsCode();
unitsCodeDcmtk = dcmqi::Helper::jsonToCodeSequenceMacro(metaDataJson["MeasurementsUnitsCode"]);
unitsCodeDcmtk.set(metaDataJson["MeasurementsUnitsCode"]["CodeValue"].asCString(),
metaDataJson["MeasurementsUnitsCode"]["CodingSchemeDesignator"].asCString(),
metaDataJson["MeasurementsUnitsCode"]["CodeMeaning"].asCString());
cout << "Measurements units initialized to " <<
dcmqi::Helper::codeSequenceMacroToString(unitsCodeDcmtk);

realWorldValueMappingItem->setLUTExplanation(metaDataJson["MeasurementUnitsCode"]["CodeMeaning"].asCString());
realWorldValueMappingItem->setLUTLabel(metaDataJson["MeasurementUnitsCode"]["CodeValue"].asCString());
}

if(metaDataJson.isMember("QuantityValueCode")){
CodeSequenceMacro& unitsCodeDcmtk = realWorldValueMappingItem->getMeasurementUnitsCode();
unitsCodeDcmtk = dcmqi::Helper::jsonToCodeSequenceMacro(metaDataJson["QuantityValueCode"]);

ContentItemMacro* quantity = new ContentItemMacro;
CodeSequenceMacro* qCodeName = new CodeSequenceMacro("G-C1C6", "SRT", "Quantity");
CodeSequenceMacro* qSpec = new CodeSequenceMacro(
metaDataJson["QuantityValueCode"]["CodeValue"].asCString(),
metaDataJson["QuantityValueCode"]["CodingSchemeDesignator"].asCString(),
metaDataJson["QuantityValueCode"]["CodeMeaning"].asCString());

if (!quantity || !qSpec || !qCodeName)
{
return NULL;
}
ContentItemMacro* item = initializeContentItemMacro(CodeSequenceMacro("G-C1C6", "SRT", "Quantity"),
dcmqi::Helper::jsonToCodeSequenceMacro(metaDataJson["QuantityValueCode"]));
realWorldValueMappingItem->getEntireQuantityDefinitionSequence().push_back(item);
}

quantity->getEntireConceptNameCodeSequence().push_back(qCodeName);
quantity->getEntireConceptCodeSequence().push_back(qSpec);
realWorldValueMappingItem->getEntireQuantityDefinitionSequence().push_back(quantity);
quantity->setValueType(ContentItemMacro::VT_CODE);
// TODO: factor out defined CodeSequenceMacros into definitions as in dcmsr/include/dcmtk/dcmsr/codes
if(metaDataJson.isMember("MeasurementMethodCode")){
ContentItemMacro* item = initializeContentItemMacro(CodeSequenceMacro("G-C306", "SRT", "Measurement Method"),
dcmqi::Helper::jsonToCodeSequenceMacro(metaDataJson["MeasurementMethodCode"]));
realWorldValueMappingItem->getEntireQuantityDefinitionSequence().push_back(item);
}

if(metaDataJson.isMember("ModelFittingMethodCode")){
// TODO: update this once CP-1665 is integrated into the standard
ContentItemMacro* item = initializeContentItemMacro(CodeSequenceMacro("xxxxx2", "99DCMCP1665", "Model Fitting Method"),
dcmqi::Helper::jsonToCodeSequenceMacro(metaDataJson["ModelFittingMethodCode"]));
realWorldValueMappingItem->getEntireQuantityDefinitionSequence().push_back(item);
}

if(metaDataJson.isMember("SourceImageDiffusionBValues")){
for(int bvalId=0;bvalId<metaDataJson["SourceImageDiffusionBValues"].size();bvalId++){
ContentItemMacro* bval = new ContentItemMacro;
CodeSequenceMacro* bvalUnits = new CodeSequenceMacro("s/mm2", "UCUM", "s/mm2");
// TODO: update this once CP-1665 is integrated into the standard
CodeSequenceMacro* qCodeName = new CodeSequenceMacro("xxxxx1", "99DCMCP1665", "Source image diffusion b-value");

if (!bval || !bvalUnits || !qCodeName)
{
return NULL;
}

bval->setValueType(ContentItemMacro::VT_NUMERIC);
bval->getEntireConceptNameCodeSequence().push_back(qCodeName);
bval->getEntireMeasurementUnitsCodeSequence().push_back(bvalUnits);
if(bval->setNumericValue(metaDataJson["SourceImageDiffusionBValues"][bvalId].asCString()).bad())
cout << "Failed to insert the value!" << endl;;
realWorldValueMappingItem->getEntireQuantityDefinitionSequence().push_back(bval);
}
}
#if 0

// initialize optional RWVM items, if available
Expand Down

0 comments on commit 2c1aa3b

Please sign in to comment.