diff --git a/code/io/mask/files.cmake b/code/io/mask/files.cmake index a0cc7d6..cc37d20 100644 --- a/code/io/mask/files.cmake +++ b/code/io/mask/files.cmake @@ -1,16 +1,18 @@ SET(CPP_FILES rttbITKImageFileMaskAccessorGenerator.cpp rttbITKImageMaskAccessor.cpp rttbITKImageMaskAccessorGenerator.cpp rttbITKImageMaskAccessorConverter.cpp ) SET(H_FILES rttbITKImageFileMaskAccessorGenerator.h rttbITKImageFileMaskAccessorGenerator.tpp rttbITKImageMaskAccessor.h rttbITKImageMaskAccessorGenerator.h rttbITKImageMaskAccessorConverter.h + rttbMaskAccessorProcessorBase.h + rttbMaskAccessorProcessorInterface.h ../itk/rttbImageReader.h ../itk/rttbImageReader.tpp ) diff --git a/code/io/mask/rttbITKImageMaskAccessor.cpp b/code/io/mask/rttbITKImageMaskAccessor.cpp index 400a465..cf56a61 100644 --- a/code/io/mask/rttbITKImageMaskAccessor.cpp +++ b/code/io/mask/rttbITKImageMaskAccessor.cpp @@ -1,177 +1,175 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include #include #include #include "rttbITKImageMaskAccessor.h" #include "rttbException.h" #include "rttbInvalidDoseException.h" namespace rttb { namespace io { namespace mask { ITKImageMaskAccessor::ITKImageMaskAccessor(ITKMaskImageType::ConstPointer aMaskImage) : _mask(aMaskImage) { if (_mask.IsNull()) { throw core::InvalidDoseException("Mask image = 0!") ; } assembleGeometricInfo(); } ITKImageMaskAccessor::~ITKImageMaskAccessor() { }; bool ITKImageMaskAccessor::assembleGeometricInfo() { _geoInfo = boost::make_shared(); _geoInfo->setSpacing(SpacingVectorType3D(_mask->GetSpacing()[0], _mask->GetSpacing()[1], _mask->GetSpacing()[2])); if (_geoInfo->getSpacing()[0] == 0 || _geoInfo->getSpacing()[1] == 0 || _geoInfo->getSpacing()[2] == 0) { throw core::InvalidDoseException("Pixel spacing = 0!"); } _geoInfo->setImagePositionPatient(WorldCoordinate3D(_mask->GetOrigin()[0], _mask->GetOrigin()[1], _mask->GetOrigin()[2])); OrientationMatrix OM(0); for (int col = 0; col < 3; ++col) { for (int row = 0; row < 3; ++row) { OM(col, row) = _mask->GetDirection()(col, row); } } _geoInfo->setOrientationMatrix(OM); _geoInfo->setNumColumns(_mask->GetLargestPossibleRegion().GetSize()[0]); _geoInfo->setNumRows(_mask->GetLargestPossibleRegion().GetSize()[1]); _geoInfo->setNumSlices(_mask->GetLargestPossibleRegion().GetSize()[2]); if (_geoInfo->getNumColumns() == 0 || _geoInfo->getNumRows() == 0 || _geoInfo->getNumSlices() == 0) { throw core::InvalidDoseException("Empty mask!") ; } return true; } void ITKImageMaskAccessor::updateMask() { return; } ITKImageMaskAccessor::MaskVoxelListPointer ITKImageMaskAccessor::getRelevantVoxelVector() { // if not already generated start voxelization here updateMask(); + _spRelevantVoxelVector = boost::make_shared(); + for(int gridIndex =0 ; gridIndex < _geoInfo->getNumColumns()*_geoInfo->getNumRows()*_geoInfo->getNumSlices(); gridIndex++){ core::MaskVoxel currentVoxel = core::MaskVoxel(gridIndex); if(getMaskAt(gridIndex, currentVoxel)){ if(currentVoxel.getRelevantVolumeFraction() > 0){ _spRelevantVoxelVector->push_back(currentVoxel); } } } return _spRelevantVoxelVector; } ITKImageMaskAccessor::MaskVoxelListPointer ITKImageMaskAccessor::getRelevantVoxelVector(float lowerThreshold) { MaskVoxelListPointer filteredVoxelVectorPointer(new MaskVoxelList); updateMask(); - // filter relevant voxels - ITKImageMaskAccessor::MaskVoxelList::iterator it = _spRelevantVoxelVector->begin(); - - while (it != _spRelevantVoxelVector->end()) - { - if ((*it).getRelevantVolumeFraction() > lowerThreshold) - { - filteredVoxelVectorPointer->push_back(*it); + for(int gridIndex =0 ; gridIndex < _geoInfo->getNumColumns()*_geoInfo->getNumRows()*_geoInfo->getNumSlices(); gridIndex++){ + core::MaskVoxel currentVoxel = core::MaskVoxel(gridIndex); + if(getMaskAt(gridIndex, currentVoxel)){ + if(currentVoxel.getRelevantVolumeFraction() > lowerThreshold){ + filteredVoxelVectorPointer->push_back(currentVoxel); + } } - - ++it; } - // if mask calculation was not successful this is empty! return filteredVoxelVectorPointer; } bool ITKImageMaskAccessor::getMaskAt(VoxelGridID aID, core::MaskVoxel& voxel) const { VoxelGridIndex3D aVoxelGridIndex; if (_geoInfo->convert(aID, aVoxelGridIndex)) { return getMaskAt(aVoxelGridIndex, voxel); } else { return false; } } bool ITKImageMaskAccessor::getMaskAt(const VoxelGridIndex3D& aIndex, core::MaskVoxel& voxel) const { voxel.setRelevantVolumeFraction(0); if (_geoInfo->validIndex(aIndex)) { const ITKMaskImageType::IndexType pixelIndex = {{aIndex[0], aIndex[1], aIndex[2]}}; double value = _mask->GetPixel(pixelIndex); VoxelGridID gridId; _geoInfo->convert(aIndex, gridId); if(value >= 0 && value <=1 ){ voxel.setRelevantVolumeFraction(value); } else{ + std::cerr << "The pixel value of the mask should be >=0 and <=1!"< #include #include "rttbITKImageMaskAccessorConverter.h" #include "rttbException.h" #include "rttbInvalidDoseException.h" #include "rttbGeometricInfo.h" +#include "itkImageRegionIterator.h" +#include "rttbITKImageMaskAccessor.h" namespace rttb { namespace io { namespace mask { + ITKImageMaskAccessorConverter::ITKImageMaskAccessorConverter(MaskAccessorPointer accessor) + { + setMaskAccessor(accessor); + } + bool ITKImageMaskAccessorConverter::process() + { + //Transfer GeometricInfo to ITK Properties + core::GeometricInfo geoInfo = _maskAccessor->getGeometricInfo(); + + ITKImageMaskAccessor::ITKMaskImageType::RegionType region; + ITKImageMaskAccessor::ITKMaskImageType::IndexType start; + + for (unsigned int i = 0; i < 3; ++i) + { + start[i] = 0; + } + + ITKImageMaskAccessor::ITKMaskImageType::SizeType size; + size[0] = geoInfo.getNumColumns(); + size[1] = geoInfo.getNumRows(); + size[2] = geoInfo.getNumSlices(); + + ITKImageMaskAccessor::ITKMaskImageType::SpacingType spacing; + + for (unsigned int i = 0; i < 3; ++i) + { + spacing[i] = geoInfo.getSpacing()[i]; + } + + ITKImageMaskAccessor::ITKMaskImageType::PointType origin; + + for (unsigned int i = 0; i < 3; ++i) + { + origin[i] = geoInfo.getImagePositionPatient()[i]; + } + + ITKImageMaskAccessor::ITKMaskImageType::DirectionType direction; + OrientationMatrix OM = geoInfo.getOrientationMatrix(); + + for (int col = 0; col < 3; ++col) + { + for (int row = 0; row < 3; ++row) + { + direction(col, row) = OM(col, row); + } + } + + //Create image, assign properties + region.SetSize(size); + region.SetIndex(start); + + _itkImage = ITKImageMaskAccessor::ITKMaskImageType::New(); + _itkImage->SetRegions(region); + _itkImage->SetSpacing(spacing); + _itkImage->SetDirection(direction); + _itkImage->SetOrigin(origin); + _itkImage->Allocate(); + + ::itk::ImageRegionIterator imageIterator(_itkImage, region); + VoxelGridID id = 0; + + //Transfer Mask values to itk image + //Large advantage: rttbVoxelGridId ordering is the same as itk ordering + while (!imageIterator.IsAtEnd()) + { + VoxelGridIndex3D aIndex; + + if (_maskAccessor->getGeometricInfo().validID(id)) + { + rttb::core::MaskVoxel maskVoxel = core::MaskVoxel(id);; + _maskAccessor->getMaskAt(id, maskVoxel); + // Set the current pixel + imageIterator.Set(maskVoxel.getRelevantVolumeFraction()); + } + else + { + if (failsOnInvalidIDs()) + { + throw core::InvalidDoseException("invalid Mask id!"); + return false; + } + else + { + imageIterator.Set(_invalidDoseValue); + } + } + + ++imageIterator; + ++id; + } + + return true; + } }//end namespace mask }//end namespace io }//end namespace rttb diff --git a/code/io/mask/rttbITKImageMaskAccessorConverter.h b/code/io/mask/rttbITKImageMaskAccessorConverter.h index f4986ef..41374ab 100644 --- a/code/io/mask/rttbITKImageMaskAccessorConverter.h +++ b/code/io/mask/rttbITKImageMaskAccessorConverter.h @@ -1,42 +1,70 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #ifndef __ITK_IMAGE_MASK_ACCESSOR_CONVERTER_H #define __ITK_IMAGE_MASK_ACCESSOR_CONVERTER_H #include #include "rttbITKImageMaskAccessor.h" +#include "rttbMaskAccessorProcessorBase.h" +#include "../itk/rttbDoseAccessorConversionSettingInterface.h" namespace rttb { namespace io { namespace mask { - class ITKImageMaskAccessorConverter + /*! @class ITKImageMaskAccessorConverter + @brief Class converts/dumps the processed accessor into an itk image + @remark MaskAccessorConversionInterface defines how the converter should react on non valid Mask values. + */ + class ITKImageMaskAccessorConverter: public core::MaskAccessorProcessorBase, + public rttb::core::DoseAccessorConversionSettingInterface + { - + public: + typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; + + bool process(); + + ITKImageMaskAccessor::ITKMaskImageType::Pointer getITKImage() + { + return _itkImage; + } + + ITKImageMaskAccessorConverter(MaskAccessorPointer accessor); + virtual ~ITKImageMaskAccessorConverter() {}; + + private: + ITKImageMaskAccessorConverter(const + ITKImageMaskAccessorConverter&); //not implemented on purpose -> non-copyable + ITKImageMaskAccessorConverter& operator=(const + ITKImageMaskAccessorConverter&);//not implemented on purpose -> non-copyable + + ITKImageMaskAccessor::ITKMaskImageType::Pointer _itkImage; + }; } } } #endif diff --git a/code/io/mask/rttbMaskAccessorProcessorBase.h b/code/io/mask/rttbMaskAccessorProcessorBase.h new file mode 100644 index 0000000..d225190 --- /dev/null +++ b/code/io/mask/rttbMaskAccessorProcessorBase.h @@ -0,0 +1,61 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ +/*! +// @file +// @version $Revision: 793 $ (last changed revision) +// @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) +// @author $Author: hentsch $ (last changed by) +*/ +#ifndef __MASK_ACCESSOR_PROCESSOR_BASE_H +#define __MASK_ACCESSOR_PROCESSOR_BASE_H + +#include + +#include "rttbMaskAccessorProcessorInterface.h" + +namespace rttb +{ + namespace core + { + /*! @class MaskAccessorProcessorBase + @brief Abstract class for all MaskAccessor converter classes + */ + class MaskAccessorProcessorBase: public MaskAccessorProcessorInterface + { + public: + typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; + + virtual void setMaskAccessor(MaskAccessorPointer accessor) + { + _maskAccessor = accessor; + }; + + private: + MaskAccessorProcessorBase(const + MaskAccessorProcessorBase&); //not implemented on purpose -> non-copyable + MaskAccessorProcessorBase& operator=(const + MaskAccessorProcessorBase&);//not implemented on purpose -> non-copyable + + protected: + MaskAccessorProcessorBase() {}; + virtual ~MaskAccessorProcessorBase() {}; + + /*! @brief Mask accessor which should be generated */ + MaskAccessorPointer _maskAccessor; + }; + } +} + +#endif diff --git a/code/io/mask/rttbMaskAccessorProcessorInterface.h b/code/io/mask/rttbMaskAccessorProcessorInterface.h new file mode 100644 index 0000000..acfd3fe --- /dev/null +++ b/code/io/mask/rttbMaskAccessorProcessorInterface.h @@ -0,0 +1,62 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ +/*! +// @file +// @version $Revision: 793 $ (last changed revision) +// @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) +// @author $Author: hentsch $ (last changed by) +*/ +#ifndef __MASK_ACCESSOR_PROCESSOR_INTERFACE_H +#define __MASK_ACCESSOR_PROCESSOR_INTERFACE_H + +#include "rttbMaskAccessorInterface.h" + +namespace rttb{ + namespace core + { + /*! @class MaskAccessorProcessorInterface + @brief Interface for all MaskAccessor converter classes + */ + class MaskAccessorProcessorInterface + { + public: + typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; + + + private: + MaskAccessorProcessorInterface(const MaskAccessorProcessorInterface&); //not implemented on purpose -> non-copyable + MaskAccessorProcessorInterface& operator=(const MaskAccessorProcessorInterface&);//not implemented on purpose -> non-copyable + + + protected: + MaskAccessorProcessorInterface() {}; + virtual ~MaskAccessorProcessorInterface(){}; + + public: + + /*! @brief Sets the MaskAccessor that should be processed + @pre passed accessor must point to a valid instance. + */ + virtual void setMaskAccessor(MaskAccessorPointer accessor) = 0; + + /*! @brief Process the passed MaskAccessor + @return if the processing was successful. + */ + virtual bool process() = 0; + }; + } + } + +#endif diff --git a/testing/io/mask/CMakeLists.txt b/testing/io/mask/CMakeLists.txt index feff2ba..beb72cc 100644 --- a/testing/io/mask/CMakeLists.txt +++ b/testing/io/mask/CMakeLists.txt @@ -1,26 +1,27 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- SET(MaskIO_TEST ${EXECUTABLE_OUTPUT_PATH}/rttbMaskIOTests) SET(TEST_DATA_ROOT ${RTTBTesting_SOURCE_DIR}/data) SET(TEMP ${RTTBTesting_BINARY_DIR}/temporary) #----------------------------------------------------------------------------- ADD_TEST(MaskAccessorGeneratorTest ${MaskIO_TEST} MaskAccessorGeneratorTest "${TEST_DATA_ROOT}/MatchPointLogo.mhd") ADD_TEST(MaskIOTest ${MaskIO_TEST} MaskIOTest "${TEST_DATA_ROOT}/MatchPointLogo.mhd") ADD_TEST(MaskAccessorConverterTest ${MaskIO_TEST} MaskAccessorConverterTest - "${TEST_DATA_ROOT}/DICOM/TestDose/ConstantTwo.dcm" "${TEST_DATA_ROOT}/MatchPointLogo.mhd" ) + "${TEST_DATA_ROOT}/DICOM/StructureSet/RS1.3.6.1.4.1.2452.6.841242143.1311652612.1170940299.4217870819.dcm" "${TEST_DATA_ROOT}/DICOM/TestDose/ConstantTwo.dcm" + "${TEST_DATA_ROOT}/MatchPointLogo.mhd") -RTTB_CREATE_TEST_MODULE(rttbMaskIO DEPENDS RTTBMaskIO RTTBDicomIO RTTBITKIO PACKAGE_DEPENDS Boost Litmus MatchPoint ITK DCMTK) +RTTB_CREATE_TEST_MODULE(rttbMaskIO DEPENDS RTTBMaskIO RTTBDicomIO RTTBITKIO RTTBMasks PACKAGE_DEPENDS Boost Litmus MatchPoint ITK DCMTK) diff --git a/testing/io/mask/MaskAccessorConverterTest.cpp b/testing/io/mask/MaskAccessorConverterTest.cpp index 6857f59..9dac894 100644 --- a/testing/io/mask/MaskAccessorConverterTest.cpp +++ b/testing/io/mask/MaskAccessorConverterTest.cpp @@ -1,82 +1,131 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html [^] // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ // this file defines the rttbCoreTests for the test driver // and all it expects is that you have a function called RegisterTests #include #include #include "litCheckMacros.h" #include "litImageTester.h" #include "litTestImageIO.h" #include "itkImage.h" #include "itkImageFileReader.h" #include "rttbBaseType.h" #include "rttbDoseIteratorInterface.h" #include "rttbDicomFileDoseAccessorGenerator.h" #include "rttbDicomDoseAccessor.h" #include "rttbInvalidDoseException.h" +#include "rttbDicomFileStructureSetGenerator.h" +#include "rttbOTBMaskAccessor.h" +#include "rttbITKImageMaskAccessorConverter.h" +#include "rttbITKImageFileMaskAccessorGenerator.h" + namespace rttb { namespace testing { /*!@brief MaskAccessorConverterTest - test the conversion rttb dose accessor ->itk 1) test with dicom file (DicomDoseAccessorGenerator) 2) test with mhd file (ITKImageFileDoseAccessorGenerator) */ int MaskAccessorConverterTest(int argc, char* argv[]) { typedef core::DoseIteratorInterface::DoseAccessorPointer DoseAccessorPointer; + typedef core::StructureSetGeneratorInterface::StructureSetPointer StructureSetPointer; + typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; + typedef io::mask::ITKImageMaskAccessor::ITKMaskImageType::Pointer ITKImageTypePointer; PREPARE_DEFAULT_TEST_REPORTING; //ARGUMENTS: - // 1: dose1 file name - // 2: dose2 file name + //ARGUMENTS: 1: structure file name + // 2: dose1 file name - std::string RTDOSE_FILENAME; - std::string RTDOSE2_FILENAME; + std::string RTStr_FILENAME; + std::string RTDose_FILENAME; + std::string Mask_FILENAME; if (argc > 1) { - RTDOSE_FILENAME = argv[1]; + RTStr_FILENAME = argv[1]; } if (argc > 2) { - RTDOSE2_FILENAME = argv[2]; + RTDose_FILENAME = argv[2]; } + if (argc > 3) + { + Mask_FILENAME = argv[3]; + } //1) Read dicomFile and test getITKImage() + io::dicom::DicomFileDoseAccessorGenerator doseAccessorGenerator1(RTDose_FILENAME.c_str()); + DoseAccessorPointer doseAccessor1(doseAccessorGenerator1.generateDoseAccessor()); + + StructureSetPointer rtStructureSet = io::dicom::DicomFileStructureSetGenerator( + RTStr_FILENAME.c_str()).generateStructureSet(); + + + MaskAccessorPointer maskAccessorPtr = boost::make_shared(rtStructureSet->getStructure(0), doseAccessor1->getGeometricInfo()); + + io::mask::ITKImageMaskAccessorConverter maskAccessorConverter(maskAccessorPtr); + + CHECK_NO_THROW(maskAccessorConverter.process()); + CHECK_NO_THROW(maskAccessorConverter.getITKImage()); + + //2) Read itk image, generate mask and convert it back to itk image, check equal + MaskAccessorPointer maskAccessorPtr2 = io::mask::ITKImageFileMaskAccessorGenerator(Mask_FILENAME.c_str()).generateMaskAccessor(); + io::mask::ITKImageMaskAccessorConverter maskAccessorConverter2(maskAccessorPtr2); + maskAccessorConverter2.process(); + + typedef itk::Image< DoseTypeGy, 3 > MaskImageType; + typedef itk::ImageFileReader ReaderType; + + ITKImageTypePointer convertedImagePtr = maskAccessorConverter2.getITKImage(); + + io::mask::ITKImageMaskAccessor::ITKMaskImageType::ConstPointer expectedImage = + lit::TestImageIO::readImage( + Mask_FILENAME); + + CHECK_EQUAL(convertedImagePtr->GetOrigin()[0], expectedImage->GetOrigin()[0]); + CHECK_EQUAL(convertedImagePtr->GetOrigin()[1], expectedImage->GetOrigin()[1]); + CHECK_EQUAL(convertedImagePtr->GetOrigin()[2], expectedImage->GetOrigin()[2]); + + CHECK_EQUAL(convertedImagePtr->GetSpacing()[0], expectedImage->GetSpacing()[0]); + CHECK_EQUAL(convertedImagePtr->GetSpacing()[1], expectedImage->GetSpacing()[1]); + CHECK_EQUAL(convertedImagePtr->GetSpacing()[2], expectedImage->GetSpacing()[2]); + RETURN_AND_REPORT_TEST_SUCCESS; } }//testing }//rttb diff --git a/testing/io/mask/MaskAccessorGeneratorTest.cpp b/testing/io/mask/MaskAccessorGeneratorTest.cpp index e4d953e..bd249a8 100644 --- a/testing/io/mask/MaskAccessorGeneratorTest.cpp +++ b/testing/io/mask/MaskAccessorGeneratorTest.cpp @@ -1,94 +1,97 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html [^] // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ /*! // @file // @version $Revision: 793 $ (last changed revision) // @date $Date: 2014-10-10 10:24:45 +0200 (Fr, 10 Okt 2014) $ (last change date) // @author $Author: hentsch $ (last changed by) */ // this file defines the rttbCoreTests for the test driver // and all it expects is that you have a function called RegisterTests #include #include #include "litCheckMacros.h" #include "itkImage.h" #include "itkImageFileReader.h" #include "rttbBaseType.h" #include "rttbInvalidDoseException.h" #include "rttbITKImageFileMaskAccessorGenerator.h" #include "rttbITKImageMaskAccessorGenerator.h" namespace rttb { namespace testing { /*!@brief MaskAccessorGeneratorTest - test the generators for dicom data 1) test itk file generator generateDoseAccessor() 2) test itk generator generateDoseAccessor() */ int MaskAccessorGeneratorTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; //ARGUMENTS: // 1: mhd/raw file name std::string Mask_FILENAME; if (argc > 1) { Mask_FILENAME = argv[1]; } - /* test ITKFileDoseAccessorGenerator generateDoseAccessor()*/ + /* test ITKImageFileMaskAccessorGenerator generateDoseAccessor()*/ CHECK_THROW_EXPLICIT(io::mask::ITKImageFileMaskAccessorGenerator("test.test").generateMaskAccessor(), core::InvalidDoseException); CHECK_NO_THROW(io::mask::ITKImageFileMaskAccessorGenerator( Mask_FILENAME.c_str()).generateMaskAccessor()); - /* test ITKDoseAccessorGenerator generateDoseAccessor()*/ + /* test ITKImageMaskAccessorGenerator generateDoseAccessor()*/ typedef itk::Image< DoseTypeGy, 3 > MaskImageType; typedef itk::ImageFileReader ReaderType; MaskImageType::ConstPointer invalidDose = MaskImageType::New(); ReaderType::Pointer reader = ReaderType::New(); CHECK_THROW_EXPLICIT(io::mask::ITKImageMaskAccessorGenerator( invalidDose.GetPointer()).generateMaskAccessor(), core::InvalidDoseException); reader->SetFileName(Mask_FILENAME); //important to update the reader (won't work without) reader->Update(); CHECK_NO_THROW(io::mask::ITKImageMaskAccessorGenerator(reader->GetOutput()).generateMaskAccessor()); + io::mask::ITKImageMaskAccessorGenerator::MaskAccessorPointer maskAcc = io::mask::ITKImageMaskAccessorGenerator(reader->GetOutput()).generateMaskAccessor(); + + rttb::core::MaskAccessorInterface::MaskVoxelListPointer maskVoxelListPtr = maskAcc->getRelevantVoxelVector(); RETURN_AND_REPORT_TEST_SUCCESS; } }//testing }//rttb