From 3baebf7bb1201713a444963126195737bce9c10b Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Thu, 22 Jun 2017 16:54:59 -0400 Subject: [PATCH] ENH: fixing issues identified by tests --- apps/paramaps/itkimage2paramap.cxx | 2 +- include/dcmqi/DICOMFrame.h | 13 ++++++++----- include/dcmqi/MultiframeObject.h | 6 +++++- include/dcmqi/ParametricMapObject.h | 4 ++++ libsrc/DICOMFrame.cpp | 1 + libsrc/MultiframeObject.cpp | 12 ++++++++++++ libsrc/ParametricMapConverter.cpp | 12 ++++++++---- libsrc/ParametricMapObject.cpp | 6 +++++- 8 files changed, 44 insertions(+), 12 deletions(-) diff --git a/apps/paramaps/itkimage2paramap.cxx b/apps/paramaps/itkimage2paramap.cxx index da712122..38163f69 100644 --- a/apps/paramaps/itkimage2paramap.cxx +++ b/apps/paramaps/itkimage2paramap.cxx @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) std::string metadata( (std::istreambuf_iterator(metainfoStream) ), (std::istreambuf_iterator())); - DcmDataset* result = dcmqi::ParametricMapConverter::itkimage2paramap(parametricMapImage, dcmDatasets, metadata); + DcmDataset* result = dcmqi::itkimage2paramapReplacement(parametricMapImage, dcmDatasets, metadata); if (result == NULL) { return EXIT_FAILURE; diff --git a/include/dcmqi/DICOMFrame.h b/include/dcmqi/DICOMFrame.h index c0e61833..586c6e9c 100644 --- a/include/dcmqi/DICOMFrame.h +++ b/include/dcmqi/DICOMFrame.h @@ -47,23 +47,26 @@ namespace dcmqi { if(dataset->findAndGetOFString(DCM_SOPClassUID, classUIDOF).good()){ classUID = classUIDOF.c_str(); } + + }; + + int getFrameNumber() const { + return frameNumber; // 0 for legacy datasets, 1 or above for enhanced objects }; - int getFrameNumber() const; // 0 for legacy datasets, 1 or above for enhanced objects - OFString getInstanceUID() const; vnl_vector getFrameIPP(){ return frameIPP; }; - string getSeriesUID(){ + string getSeriesUID() const { return seriesUID; } - string getInstanceUID(){ + string getInstanceUID() const{ return instanceUID; } - string getClassUID(){ + string getClassUID() const { return classUID; } diff --git a/include/dcmqi/MultiframeObject.h b/include/dcmqi/MultiframeObject.h index 838df9e6..e882a1f9 100644 --- a/include/dcmqi/MultiframeObject.h +++ b/include/dcmqi/MultiframeObject.h @@ -78,7 +78,7 @@ class MultiframeObject { int initializeVolumeGeometryFromITK(DummyImageType::Pointer); // initialize attributes of the composite context that are common for all multiframe objects - virtual int initializeCompositeContext(); + //virtual int initializeCompositeContext(); // check whether all of the attributes required for initialization of the object are present in the // input metadata virtual bool metaDataIsComplete(); @@ -113,8 +113,12 @@ class MultiframeObject { Json::Value metaDataJson; // Multiframe DICOM object representation + // probably not needed, since need object-specific DCMTK class in + // derived classes DcmDataset* dcmRepresentation; + // probably not needed at this level, since for SEG each segment will + // have separate geometry definition ImageVolumeGeometry volumeGeometry; // DcmDataset(s) that hold the original representation of the diff --git a/include/dcmqi/ParametricMapObject.h b/include/dcmqi/ParametricMapObject.h index e5c9b83a..4f6c59cd 100644 --- a/include/dcmqi/ParametricMapObject.h +++ b/include/dcmqi/ParametricMapObject.h @@ -33,6 +33,10 @@ class ParametricMapObject : public MultiframeObject { int updateMetaDataFromDICOM(std::vector); + DPMParametricMapIOD* getDICOMRepresentation(){ + return parametricMap; + }; + protected: typedef itk::CastImageFilter Float32ToDummyCasterType; diff --git a/libsrc/DICOMFrame.cpp b/libsrc/DICOMFrame.cpp index bfbff419..f652f26a 100644 --- a/libsrc/DICOMFrame.cpp +++ b/libsrc/DICOMFrame.cpp @@ -7,6 +7,7 @@ namespace dcmqi { int DICOMFrame::initializeFrameGeometryFromLegacyInstance() { OFString ippStr; + frameIPP.set_size(3); for(int j=0;j<3;j++){ CHECK_COND(frameDataset->findAndGetOFString(DCM_ImagePositionPatient, ippStr, j)); frameIPP[j] = atof(ippStr.c_str()); diff --git a/libsrc/MultiframeObject.cpp b/libsrc/MultiframeObject.cpp index 389df8e0..fd60697b 100644 --- a/libsrc/MultiframeObject.cpp +++ b/libsrc/MultiframeObject.cpp @@ -18,16 +18,22 @@ int MultiframeObject::initializeMetaDataFromString(const std::string &metaDataSt int MultiframeObject::initializeEquipmentInfo() { if(sourceRepresentationType == ITK_REPR){ + equipmentInfoModule = IODEnhGeneralEquipmentModule::EquipmentInfo(QIICR_MANUFACTURER, QIICR_DEVICE_SERIAL_NUMBER, + QIICR_MANUFACTURER_MODEL_NAME, QIICR_SOFTWARE_VERSIONS); + /* equipmentInfoModule.m_Manufacturer = QIICR_MANUFACTURER; equipmentInfoModule.m_DeviceSerialNumber = QIICR_DEVICE_SERIAL_NUMBER; equipmentInfoModule.m_ManufacturerModelName = QIICR_MANUFACTURER_MODEL_NAME; equipmentInfoModule.m_SoftwareVersions = QIICR_SOFTWARE_VERSIONS; + */ + } else { // DICOM_REPR } return EXIT_SUCCESS; } int MultiframeObject::initializeContentIdentification() { + if(sourceRepresentationType == ITK_REPR){ CHECK_COND(contentIdentificationMacro.setContentCreatorName("dcmqi")); if(metaDataJson.isMember("ContentDescription")){ @@ -40,6 +46,12 @@ int MultiframeObject::initializeContentIdentification() { } else { CHECK_COND(contentIdentificationMacro.setContentLabel("DCMQI")); } + if(metaDataJson.isMember("InstanceNumber")){ + CHECK_COND(contentIdentificationMacro.setInstanceNumber(metaDataJson["InstanceNumber"].asCString())); + } else { + CHECK_COND(contentIdentificationMacro.setInstanceNumber("1")); + } + CHECK_COND(contentIdentificationMacro.check()) return EXIT_SUCCESS; } else { // DICOM_REPR } diff --git a/libsrc/ParametricMapConverter.cpp b/libsrc/ParametricMapConverter.cpp index 71344f48..9375c3ca 100644 --- a/libsrc/ParametricMapConverter.cpp +++ b/libsrc/ParametricMapConverter.cpp @@ -6,6 +6,7 @@ // DCMQI includes #include "dcmqi/ParametricMapConverter.h" #include "dcmqi/SegmentationImageConverter.h" +#include "dcmqi/ParametricMapObject.h" using namespace std; @@ -13,11 +14,14 @@ namespace dcmqi { DcmDataset* itkimage2paramapReplacement(const FloatImageType::Pointer ¶metricMapImage, vector dcmDatasets, const string &metaData) { - /* - ParametricMapConverter pmConverter(parametricMapImage, dcmDatasets, metaData); - pmConverter.convert(); + ParametricMapObject pm; + pm.initializeFromITK(parametricMapImage, metaData, dcmDatasets); + + DPMParametricMapIOD* pmap = pm.getDICOMRepresentation(); + + DcmDataset* output = new DcmDataset(); + CHECK_COND(pmap->writeDataset(*output)); - return convert.getDataset(); */ return NULL; } diff --git a/libsrc/ParametricMapObject.cpp b/libsrc/ParametricMapObject.cpp index 5de1250b..cb5f91e5 100644 --- a/libsrc/ParametricMapObject.cpp +++ b/libsrc/ParametricMapObject.cpp @@ -26,6 +26,8 @@ int ParametricMapObject::initializeFromITK(Float32ITKImageType::Pointer inputIma // NB: the sequence of steps initializing different components of the object parallels that // in the original converter function. It probably makes sense to revisit the sequence // of these steps. It does not necessarily need to happen in this order. + initializeEquipmentInfo(); + initializeContentIdentification(); // TODO: consider creating parametric map object after all FGs are initialized instead createParametricMap(); @@ -101,8 +103,10 @@ int ParametricMapObject::createParametricMap() { DPMTypes::CQ_RESEARCH); // TODO: look into the following, check with @che85 on the purpose of this line! - if (OFCondition* pCondition = OFget(&obj)) + if (OFCondition* pCondition = OFget(&obj)) { + std::cerr << "Failed to create parametric map object!" << std::endl; return EXIT_FAILURE; + } parametricMap = OFget(&obj);