diff --git a/apps/seg/Testing/CMakeLists.txt b/apps/seg/Testing/CMakeLists.txt index 1ead4de9..f31124db 100644 --- a/apps/seg/Testing/CMakeLists.txt +++ b/apps/seg/Testing/CMakeLists.txt @@ -50,6 +50,7 @@ dcmqi_add_test( --outputDICOM ${MODULE_TEMP_DIR}/liver_heart_seg_reordered.dcm ) + find_program(DCIODVFY_EXECUTABLE dciodvfy) if(EXISTS ${DCIODVFY_EXECUTABLE}) @@ -139,6 +140,22 @@ dcmqi_add_test( ${itk2dcm}_makeSEG_multiple_segment_files_reordered ) + dcmqi_add_test( + NAME ${dcm2itk}_makeNRRD_merged_segment_file + MODULE_NAME ${MODULE_NAME} + COMMAND ${SEM_LAUNCH_COMMAND} $ + --compare ${BASELINE}/liver_seg.nrrd ${MODULE_TEMP_DIR}/makeNRRD_multiple_segments-1.nrrd + --compare ${BASELINE}/spine_seg.nrrd ${MODULE_TEMP_DIR}/makeNRRD_multiple_segments-2.nrrd + --compare ${BASELINE}/heart_seg.nrrd ${MODULE_TEMP_DIR}/makeNRRD_multiple_segments-3.nrrd + ${dcm2itk}Test + --inputDICOM ${MODULE_TEMP_DIR}/liver_heart_seg.dcm + --outputDirectory ${MODULE_TEMP_DIR} + --prefix makeNRRD_merged_segment_file + --mergeSegments + TEST_DEPENDS + ${itk2dcm}_makeSEG_multiple_segment_files + ) + dcmqi_add_test( NAME seg_meta_roundtrip MODULE_NAME ${MODULE_NAME} @@ -160,8 +177,6 @@ dcmqi_add_test( ${dcm2itk}_makeNRRD_multiple_segment_files ) - - set(TEST_SEG_SIZES 24x38x3 23x38x3) foreach(seg_size ${TEST_SEG_SIZES}) diff --git a/include/dcmqi/JSONSegmentationMetaInformationHandler.h b/include/dcmqi/JSONSegmentationMetaInformationHandler.h index 1b087a98..c7d312a6 100644 --- a/include/dcmqi/JSONSegmentationMetaInformationHandler.h +++ b/include/dcmqi/JSONSegmentationMetaInformationHandler.h @@ -38,7 +38,7 @@ namespace dcmqi { // segGroupNumber starts with 0 and refers to the item in segmentsAttributesMappingList. // if segGroupNumber is invalid, create segment within a newly created segmentation group // otherwise add segment to the existing segmentation group identified by segGroupNumber - SegmentAttributes* createOrGetSegment(const int segGroupNumber, unsigned labelID); + SegmentAttributes* createOrGetSegment(const unsigned int segGroupNumber, unsigned labelID); protected: diff --git a/libsrc/JSONSegmentationMetaInformationHandler.cpp b/libsrc/JSONSegmentationMetaInformationHandler.cpp index 5f6a4d46..8780e7ad 100644 --- a/libsrc/JSONSegmentationMetaInformationHandler.cpp +++ b/libsrc/JSONSegmentationMetaInformationHandler.cpp @@ -151,25 +151,21 @@ namespace dcmqi { return values; } - SegmentAttributes *JSONSegmentationMetaInformationHandler::createOrGetSegment(const int segGroupNumber, const unsigned labelID) { - //std::cout << "DEBUG: num segmentations: " << this->segmentsAttributesMappingList.size() << std::endl; - /* - for (vector >::const_iterator vIt = this->segmentsAttributesMappingList.begin(); - vIt != this->segmentsAttributesMappingList.end(); ++vIt) { - for(map::const_iterator mIt = vIt->begin();mIt!=vIt->end();++mIt){ - SegmentAttributes *segmentAttributes = mIt->second; - if (segmentAttributes->getLabelID() == labelID) - return NULL; - } - }*/ + SegmentAttributes *JSONSegmentationMetaInformationHandler::createOrGetSegment(const unsigned int segGroupNumber, const unsigned labelID) { + if (segGroupNumber < 1) + { + std::cerr << "ERROR: Segment group number must be >= 1" << std::endl; + return NULL; + } SegmentAttributes *segment = new SegmentAttributes(labelID); - if (this->segmentsAttributesMappingList.size() < segGroupNumber+1) { + if (this->segmentsAttributesMappingList.size() < segGroupNumber) { map tempMap; tempMap[labelID] = segment; this->segmentsAttributesMappingList.push_back(tempMap); - } else - this->segmentsAttributesMappingList[segGroupNumber][labelID] = segment; + } else { + this->segmentsAttributesMappingList[segGroupNumber-1][labelID] = segment; + } return segment; } diff --git a/libsrc/OverlapUtil.cpp b/libsrc/OverlapUtil.cpp index 6e96ceff..a5b77f6c 100644 --- a/libsrc/OverlapUtil.cpp +++ b/libsrc/OverlapUtil.cpp @@ -324,7 +324,6 @@ OFCondition OverlapUtil::getSegmentsByPosition(SegmentsByPosition& result) DCMSEG_DEBUG(ss.str()); } DCMSEG_DEBUG("groupFramesByPosition(): Grouping segments by position took " << tm.getDiff() << " s"); - return cond; }