diff --git a/apps/DoseAcc/DoseAcc.cpp b/apps/DoseAcc/DoseAcc.cpp index d068d6f..7f60cd5 100644 --- a/apps/DoseAcc/DoseAcc.cpp +++ b/apps/DoseAcc/DoseAcc.cpp @@ -1,179 +1,173 @@ // ----------------------------------------------------------------------- // 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: 1107 $ (last changed revision) -// @date $Date: 2015-09-17 12:47:41 +0200 (Do, 17 Sep 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include "DoseAccApplicationData.h" #include "DoseAccHelper.h" #include "DoseAccCmdLineParser.h" #include "boost/shared_ptr.hpp" #include "boost/make_shared.hpp" #include "RTToolboxConfigure.h" #include "rttbDoseLoader.cpp" int main(int argc, const char** argv) { int result = 0; rttb::apps::doseAcc::ApplicationData appData; boost::shared_ptr argParser; const std::string appCategory = "RT-Toolbox App"; const std::string appName = "DoseAcc"; const std::string appDesc = "An App to accumulate two doses. The GUI for this app is currently under development and in an experimental state."; const std::string appContributor = "SIDT@DKFZ"; const std::string appVersion = RTTB_FULL_VERSION_STRING; try { argParser = boost::make_shared(argc, argv, appName, appVersion, appDesc, appContributor, appCategory); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; return 5; } // This is vital. The application needs to exit if the "help" or "version" parameter is set // because this means the other parameters won't be parsed. if (argParser->isSet(argParser->OPTION_HELP) || argParser->isSet(argParser->OPTION_VERSION) || argParser->isSet(argParser->OPTION_XML)) { return 0; } rttb::apps::doseAcc::populateAppData(argParser, appData); std::cout << std::endl << "*******************************************" << std::endl; std::cout << "Dose 1 file: " << appData._dose1FileName << std::endl; std::cout << "Dose 2 file: " << appData._dose2FileName << std::endl; std::cout << "Dose output file: " << appData._outputFileName << std::endl; if (!(appData._regFileName.empty())) { std::cout << "Registration file: " << appData._regFileName << std::endl; } std::cout << "Dose 1 weight: " << appData._weightDose1 << std::endl; std::cout << "Dose 2 weight: " << appData._weightDose2 << std::endl; std::cout << "Operator: " << appData._operator << std::endl; std::cout << std::endl << "read dose file... "; try { appData._dose1 = rttb::io::utils::loadDose(appData._dose1FileName, appData._dose1LoadStyle); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 4; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 4; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 4; } try { appData._dose2 = rttb::io::utils::loadDose(appData._dose2FileName, appData._dose2LoadStyle); std::cout << "done." << std::endl; } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 4; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 4; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 4; } if (!(appData._regFileName.empty())) { try { appData._spReg = rttb::apps::doseAcc::loadRegistration(appData._regFileName); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 5; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 5; } catch (...) { std::cerr << "Error!!! unknown error while reading registration file." << std::endl; return 5; } } try { rttb::apps::doseAcc::processData(appData); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 9; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 9; } catch (...) { std::cerr << "Error!!! unknown error while mapping and writing image." << std::endl; return 9; } std::cout << std::endl; return result; } diff --git a/apps/DoseAcc/DoseAccCmdLineParser.h b/apps/DoseAcc/DoseAccCmdLineParser.h index 237e204..70b1c1d 100644 --- a/apps/DoseAcc/DoseAccCmdLineParser.h +++ b/apps/DoseAcc/DoseAccCmdLineParser.h @@ -1,65 +1,60 @@ // ----------------------------------------------------------------------- // 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: 1374 $ (last changed revision) -// @date $Date: 2016-05-30 14:15:42 +0200 (Mo, 30 Mai 2016) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #ifndef __DOSEACC_CMD_LINE_PARSER #define __DOSEACC_CMD_LINE_PARSER #include "CmdLineParserBase.h" + namespace rttb { namespace apps { namespace doseAcc { /*! @class DoseAccCmdLineParser @brief Argument parsing is parametrized here based on ArgParserLib @see cmdlineparsing::CmdLineParserBase */ class DoseAccCmdLineParser : public cmdlineparsing::CmdLineParserBase { public: DoseAccCmdLineParser(int argc, const char** argv, const std::string& name, const std::string& version, const std::string& description, const std::string& contributor, const std::string& category); void validateInput() const override; void printHelp() const override; // Option groups const std::string OPTION_GROUP_REQUIRED = "Required Arguments"; const std::string OPTION_GROUP_OPTIONAL = "Optional Arguments"; // Parameters const std::string OPTION_DOSE1_FILENAME = "dose1"; const std::string OPTION_DOSE2_FILENAME = "dose2"; const std::string OPTION_OUTPUT_FILENAME = "output"; const std::string OPTION_INTERPOLATOR = "interpolator"; const std::string OPTION_WEIGHT1 = "weight1"; const std::string OPTION_WEIGHT2 = "weight2"; const std::string OPTION_REGISTRATION_FILENAME = "registration"; const std::string OPTION_LOAD_STYLE_DOSE1 = "loadStyle1"; const std::string OPTION_LOAD_STYLE_DOSE2 = "loadStyle2"; const std::string OPTION_OPERATOR = "operator"; }; } } } #endif \ No newline at end of file diff --git a/apps/DoseAcc/DoseAccHelper.cpp b/apps/DoseAcc/DoseAccHelper.cpp index 0a5eac7..20dfecd 100644 --- a/apps/DoseAcc/DoseAccHelper.cpp +++ b/apps/DoseAcc/DoseAccHelper.cpp @@ -1,172 +1,165 @@ // ----------------------------------------------------------------------- // 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: 1132 $ (last changed revision) -// @date $Date: 2015-10-06 14:48:56 +0200 (Di, 06 Okt 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ - #include "DoseAccHelper.h" #include "boost/make_shared.hpp" #include "mapRegistrationFileReader.h" #include "rttbExceptionMacros.h" #include "rttbITKImageAccessorConverter.h" #include "rttbSimpleMappableDoseAccessor.h" #include "rttbMatchPointTransformation.h" #include "rttbLinearInterpolation.h" #include "rttbNearestNeighborInterpolation.h" #include "rttbRosuMappableDoseAccessor.h" #include "rttbArithmetic.h" #include "rttbBinaryFunctorAccessor.h" #include "rttbImageWriter.h" rttb::apps::doseAcc::ApplicationData::RegistrationType::Pointer rttb::apps::doseAcc::loadRegistration(const std::string& fileName) { map::io::RegistrationFileReader::Pointer spRegReader = map::io::RegistrationFileReader::New(); map::io::RegistrationFileReader::LoadedRegistrationPointer spReg; std::cout << std::endl << "read registration file... "; spReg = spRegReader->read(fileName); std::cout << "done." << std::endl; ApplicationData::RegistrationType::Pointer resultPtr = dynamic_cast(spReg.GetPointer()); if (resultPtr.IsNull()) { rttbDefaultExceptionStaticMacro( << "Loaded registration cannot be used. Only 3D 3D registrations are allowed."); } return resultPtr; }; rttb::core::DoseAccessorInterface::Pointer generateNNMappableAccessor( const rttb::core::GeometricInfo& geoInfoTargetImage, const rttb::core::DoseAccessorInterface::Pointer doseMovingImage, const rttb::interpolation::TransformationInterface::Pointer aTransformation) { auto interpolate = boost::make_shared(); return boost::make_shared(geoInfoTargetImage, doseMovingImage, aTransformation, interpolate); } rttb::core::DoseAccessorInterface::Pointer generateLinearMappableAccessor( const rttb::core::GeometricInfo& geoInfoTargetImage, const rttb::core::DoseAccessorInterface::Pointer doseMovingImage, const rttb::interpolation::TransformationInterface::Pointer aTransformation) { auto interpolate = boost::make_shared(); return boost::make_shared(geoInfoTargetImage, doseMovingImage, aTransformation, interpolate); } rttb::core::DoseAccessorInterface::Pointer generateRosuMappableAccessor( const rttb::core::GeometricInfo& geoInfoTargetImage, const rttb::core::DoseAccessorInterface::Pointer doseMovingImage, const rttb::interpolation::TransformationInterface::Pointer aTransformation) { return boost::make_shared(geoInfoTargetImage, doseMovingImage, aTransformation); } /**Private helper function for processData(). Generates a suitable output accessor * (depending on the configuration in appData a suitable accessor pipeline is established) * which performs the accumulation of the doses and returns the output.to */ rttb::core::DoseAccessorInterface::Pointer assembleOutputAccessor(rttb::apps::doseAcc::ApplicationData& appData) { rttb::core::DoseAccessorInterface::Pointer dose2Accessor = appData._dose2; if (appData._spReg.IsNotNull()) { auto transform = boost::make_shared(appData._spReg); if (appData._interpolatorName == "rosu") { dose2Accessor = generateRosuMappableAccessor(appData._dose1->getGeometricInfo(), appData._dose2, transform); } else if (appData._interpolatorName == "nn") { dose2Accessor = generateNNMappableAccessor(appData._dose1->getGeometricInfo(), appData._dose2, transform); } else if (appData._interpolatorName == "linear") { dose2Accessor = generateLinearMappableAccessor(appData._dose1->getGeometricInfo(), appData._dose2, transform); } else { rttbDefaultExceptionStaticMacro( << "Unkown interpolation type selected. Cannot map dose. Interpolation type: " << appData._interpolatorName); } } rttb::core::DoseAccessorInterface::Pointer outputAccessor; if (appData._operator == "+") { rttb::algorithms::arithmetic::doseOp::AddWeighted addOp(appData._weightDose1, appData._weightDose2); outputAccessor = boost::make_shared >(appData._dose1, dose2Accessor, addOp); } else if (appData._operator == "*") { outputAccessor = boost::make_shared > (appData._dose1, dose2Accessor, rttb::algorithms::arithmetic::doseOp::Multiply()); } else { rttbDefaultExceptionStaticMacro( << "Unkown operator selected. Cannot map dose. Operator: " << appData._interpolatorName); } return outputAccessor; } void rttb::apps::doseAcc::processData(rttb::apps::doseAcc::ApplicationData& appData) { rttb::core::DoseAccessorInterface::Pointer outputAccessor = assembleOutputAccessor( appData); std::cout << std::endl << "generate output image... "; io::itk::ITKImageAccessorConverter converter(outputAccessor); converter.setFailOnInvalidIDs(true); converter.process(); io::itk::ITKImageAccessorConverter::ITKImageType::Pointer itkImage = converter.getITKImage(); std::cout << "done." << std::endl; std::cout << std::endl << "write output image... "; io::itk::ImageWriter writer(appData._outputFileName, itkImage.GetPointer()); writer.writeFile(); std::cout << "done." << std::endl; }; diff --git a/apps/DoseAcc/DoseAccHelper.h b/apps/DoseAcc/DoseAccHelper.h index 8fb43be..9ecb548 100644 --- a/apps/DoseAcc/DoseAccHelper.h +++ b/apps/DoseAcc/DoseAccHelper.h @@ -1,49 +1,43 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #ifndef __DOSE_ACC_HELPER_H #define __DOSE_ACC_HELPER_H #include #include #include "rttbDoseAccessorInterface.h" #include "DoseAccApplicationData.h" namespace rttb { namespace apps { namespace doseAcc { ApplicationData::RegistrationType::Pointer loadRegistration(const std::string& fileName); /**Contains the business logic for the accumulation of the doses and the storing of the result. Uses appData for the input data and the correct configuration.*/ void processData(ApplicationData& appData); } } } #endif diff --git a/apps/DoseMap/DoseMap.cpp b/apps/DoseMap/DoseMap.cpp index d46d82c..3cd9386 100644 --- a/apps/DoseMap/DoseMap.cpp +++ b/apps/DoseMap/DoseMap.cpp @@ -1,214 +1,208 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include "DoseMapApplicationData.h" #include "DoseMapHelper.h" #include "DoseMapCmdLineParser.h" #include "boost/shared_ptr.hpp" #include "boost/make_shared.hpp" #include "RTToolboxConfigure.h" #include "rttbException.h" #include "mapDummyRegistrationAlgorithm.h" #include "rttbDoseLoader.cpp" /** Main function of dose mapper. @retval 0 normal program execution @retval 2 not enough required input files. @retval 4 Error loading input dose file @retval 5 Error loading reference dose file @retval 6 Error loading registration @retval 9 Error while mapping or storing result. */ int main(int argc, const char** argv) { int result = 0; rttb::apps::doseMap::ApplicationData appData; boost::shared_ptr argParser; try { std::string appName = "DoseMap"; std::string appVersion = RTTB_FULL_VERSION_STRING; argParser = boost::make_shared(argc, argv, appName, appVersion); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; return 2; } // This is vital. The application needs to exit if the "help" or "version" parameter is set // because this means the other parameters won't be parsed. if (argParser->isSet(argParser->OPTION_HELP) || argParser->isSet(argParser->OPTION_VERSION)) { return 0; } try{ rttb::apps::doseMap::populateAppData(argParser, appData); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; } std::cout << std::endl << "*******************************************" << std::endl; std::cout << "Input dose file: " << appData._inputDoseFileName << std::endl; std::cout << "Input dose file load style: " << appData._inputDoseLoadStyle.at(0) << std::endl; std::cout << "Output file: " << appData._outputFileName << std::endl; if (!(appData._regFileName.empty())) { std::cout << "Registration file: " << appData._regFileName << std::endl; } if (!(appData._refDoseFileName.empty())) { std::cout << "Reference dose file: " << appData._refDoseFileName << std::endl; std::cout << "Reference dose style: " << appData._refDoseLoadStyle.at(0) << std::endl; } std::cout << std::endl << "read dose file... "; try { appData._inputDose = rttb::io::utils::loadDose(appData._inputDoseFileName, appData._inputDoseLoadStyle); std::cout << "done." << std::endl; } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 4; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 4; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 4; } if (!(appData._refDoseFileName.empty())) { try { appData._refDose = rttb::io::utils::loadDose(appData._refDoseFileName, appData._refDoseLoadStyle); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 5; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 5; } catch (...) { std::cerr << "Error!!! unknown error while reading reference image." << std::endl; return 5; } } else { appData._refDose = appData._inputDose; } if (!(appData._regFileName.empty())) { try { appData._spReg = rttb::apps::doseMap::loadRegistration(appData._regFileName); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 6; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 6; } catch (...) { std::cerr << "Error!!! unknown error while reading registration file." << std::endl; return 6; } } else { //generate dummy identity registration using DummyRegType = map::algorithm::DummyRegistrationAlgorithm<3>; DummyRegType::Pointer regAlg = DummyRegType::New(); appData._spReg = regAlg->getRegistration(); } try { rttb::apps::doseMap::processData(appData); } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; return 9; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 9; } catch (...) { std::cerr << "Error!!! unknown error while mapping and writing image." << std::endl; return 9; } std::cout << std::endl; return result; } diff --git a/apps/DoseMap/DoseMapApplicationData.h b/apps/DoseMap/DoseMapApplicationData.h index 550b9bf..f7d426e 100644 --- a/apps/DoseMap/DoseMapApplicationData.h +++ b/apps/DoseMap/DoseMapApplicationData.h @@ -1,66 +1,65 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ #ifndef __DOSEMAP_APPLICATION_DATA_H #define __DOSEMAP_APPLICATION_DATA_H #include "mapRegistration.h" #include "rttbDoseAccessorInterface.h" - namespace rttb { namespace apps { namespace doseMap { class DoseMapCmdLineParser; /*! @class ApplicationData @brief Class for storing all relevant variables needed in DoseMap */ class ApplicationData { public: typedef map::core::Registration<3, 3> RegistrationType; /** Loaded Dose.*/ core::DoseAccessorInterface::Pointer _inputDose; std::string _inputDoseFileName; std::string _inputDoseLoadStyle; core::DoseAccessorInterface::Pointer _refDose; std::string _refDoseFileName; std::string _refDoseLoadStyle; RegistrationType::Pointer _spReg; std::string _regFileName; std::string _outputFileName; std::string _interpolatorName; void reset(); ApplicationData(); }; /*! @brief Reads the necessary arguments from the DoseToolCmdLineParser and writes them in the respective variables of ApplicationData. */ void populateAppData(boost::shared_ptr argParser, ApplicationData& appData); } } } #endif diff --git a/apps/DoseMap/DoseMapCmdLineParser.h b/apps/DoseMap/DoseMapCmdLineParser.h index d956900..677478c 100644 --- a/apps/DoseMap/DoseMapCmdLineParser.h +++ b/apps/DoseMap/DoseMapCmdLineParser.h @@ -1,63 +1,56 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ - #ifndef __DOSEMAP_CMD_LINE_PARSER #define __DOSEMAP_CMD_LINE_PARSER #include "CmdLineParserBase.h" namespace rttb { namespace apps { namespace doseMap { /*! @class DoseMapCmdLineParser @brief Argument parsing is parametrized here based on ArgParserLib @see cmdlineparsing::CmdLineParserBase */ class DoseMapCmdLineParser : public cmdlineparsing::CmdLineParserBase { public: DoseMapCmdLineParser(int argc, const char** argv, const std::string& name, const std::string& version); void validateInput() const; void printHelp() const; // Option groups const std::string OPTION_GROUP_REQUIRED = "Required Arguments"; const std::string OPTION_GROUP_OPTIONAL = "Optional Arguments"; // Parameters const std::string OPTION_INPUT_DOSE_FILE_NAME = "inputDoseFileName"; const std::string OPTION_OUTPUT_FILE_NAME = "outputFileName"; const std::string OPTION_INTERPOLATOR = "interpolator"; const std::string OPTION_REG_FILE_NAME = "regFileName"; const std::string OPTION_REF_DOSE_FILE = "refDoseFile"; const std::string OPTION_REF_DOSE_LOAD_STYLE = "refDoseLoadStyle"; const std::string OPTION_INPUT_DOSE_LOAD_STYLE = "inputDoseLoadStyle"; }; } } } #endif \ No newline at end of file diff --git a/apps/DoseMap/DoseMapHelper.cpp b/apps/DoseMap/DoseMapHelper.cpp index 6d833d9..db54354 100644 --- a/apps/DoseMap/DoseMapHelper.cpp +++ b/apps/DoseMap/DoseMapHelper.cpp @@ -1,120 +1,113 @@ // ----------------------------------------------------------------------- // 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: 1127 $ (last changed revision) -// @date $Date: 2015-10-01 13:33:33 +0200 (Do, 01 Okt 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ - #include "DoseMapHelper.h" #include #include "mapRegistrationFileReader.h" #include "rttbITKImageAccessorConverter.h" #include "rttbSimpleMappableDoseAccessor.h" #include "rttbMatchPointTransformation.h" #include "rttbLinearInterpolation.h" #include "rttbNearestNeighborInterpolation.h" #include "rttbRosuMappableDoseAccessor.h" #include "rttbArithmetic.h" #include "rttbBinaryFunctorAccessor.h" #include "rttbExceptionMacros.h" #include "rttbImageWriter.h" rttb::apps::doseMap::ApplicationData::RegistrationType::Pointer rttb::apps::doseMap::loadRegistration(const std::string& fileName) { map::io::RegistrationFileReader::Pointer spRegReader = map::io::RegistrationFileReader::New(); map::io::RegistrationFileReader::LoadedRegistrationPointer spReg; std::cout << std::endl << "read registration file... "; spReg = spRegReader->read(fileName); std::cout << "done." << std::endl; ApplicationData::RegistrationType::Pointer resultPtr = dynamic_cast(spReg.GetPointer()); if (resultPtr.IsNull()) { mapDefaultExceptionStaticMacro( << "Loaded registration cannot be used. Only 3D 3D registrations are allowed."); } return resultPtr; }; /**Private helper function for processData(). Generates a suitable output accessor * (depending on the configuration in appData a suitable accessor pipeline is established) * which performs the accumulation of the doses and returns the output.to */ rttb::core::DoseAccessorInterface::Pointer assembleOutputAccessor(rttb::apps::doseMap::ApplicationData& appData) { rttb::core::DoseAccessorInterface::Pointer outputAccessor = appData._inputDose; auto transform = boost::make_shared(appData._spReg); if (appData._interpolatorName == "rosu") { outputAccessor = boost::make_shared(appData._refDose->getGeometricInfo(), appData._inputDose, transform); } else { rttb::interpolation::InterpolationBase::Pointer interpolate = boost::make_shared(); if (appData._interpolatorName == "nn") { interpolate = boost::make_shared(); } else if (appData._interpolatorName != "linear") { mapDefaultExceptionStaticMacro( << "Unkown interpolation type selected. Cannot map dose. Interpolation type: " << appData._interpolatorName); } outputAccessor = boost::make_shared(appData._refDose->getGeometricInfo(), appData._inputDose, transform, interpolate); } return outputAccessor; } void rttb::apps::doseMap::processData(rttb::apps::doseMap::ApplicationData& appData) { rttb::core::DoseAccessorInterface::Pointer outputAccessor = assembleOutputAccessor( appData); std::cout << std::endl << "generate output image... "; io::itk::ITKImageAccessorConverter converter(outputAccessor); converter.setFailOnInvalidIDs(true); converter.process(); io::itk::ITKImageAccessorConverter::ITKImageType::Pointer itkImage = converter.getITKImage(); std::cout << "done." << std::endl; std::cout << std::endl << "write output image... "; io::itk::ImageWriter writer(appData._outputFileName, itkImage.GetPointer()); writer.writeFile(); std::cout << "done." << std::endl; }; diff --git a/apps/DoseMap/DoseMapHelper.h b/apps/DoseMap/DoseMapHelper.h index 047e577..00ed90c 100644 --- a/apps/DoseMap/DoseMapHelper.h +++ b/apps/DoseMap/DoseMapHelper.h @@ -1,44 +1,38 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #ifndef __DOSE_MAP_HELPER_H #define __DOSE_MAP_HELPER_H #include "DoseMapApplicationData.h" namespace rttb { namespace apps { namespace doseMap { ApplicationData::RegistrationType::Pointer loadRegistration(const std::string& fileName); /**Contains the business logic for the accumulation of the doses and the storing of the result. Uses appData for the input data and the correct configuration.*/ void processData(ApplicationData& appData); } } } #endif diff --git a/apps/DoseTool/DoseToolCmdLineParser.h b/apps/DoseTool/DoseToolCmdLineParser.h index 685c955..d720e18 100644 --- a/apps/DoseTool/DoseToolCmdLineParser.h +++ b/apps/DoseTool/DoseToolCmdLineParser.h @@ -1,66 +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: 1374 $ (last changed revision) -// @date $Date: 2016-05-30 14:15:42 +0200 (Mo, 30 Mai 2016) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #ifndef __DOSETOOL_CMD_LINE_PARSER #define __DOSETOOL_CMD_LINE_PARSER #include "CmdLineParserBase.h" + namespace rttb { namespace apps { namespace doseTool { /*! @class DoseToolCmdLineParser @brief Argument parsing is parametrized here based on ArgParserLib @see cmdlineparsing::CmdLineParserBase */ class DoseToolCmdLineParser : public cmdlineparsing::CmdLineParserBase { public: DoseToolCmdLineParser(int argc, const char** argv, const std::string& name, const std::string& version, const std::string& description, const std::string& contributor, const std::string& category); void validateInput() const; void printHelp() const; // Option groups const std::string OPTION_GROUP_REQUIRED = "Required Arguments"; const std::string OPTION_GROUP_OPTIONAL = "Optional Arguments"; // Parameters const std::string OPTION_DOSE_FILE = "doseFile"; const std::string OPTION_STRUCT_FILE = "structFile"; const std::string OPTION_STRUCT_NAME = "structName"; const std::string OPTION_DOSE_STATISTICS = "doseStatistics"; const std::string OPTION_DVH = "DVH"; const std::string OPTION_DOSE_LOAD_STYLE = "doseLoadStyle"; const std::string OPTION_STRUCT_LOAD_STYLE = "structLoadStyle"; const std::string OPTION_COMPLEX_STATISTICS = "complexStatistics"; const std::string OPTION_PRESCRIBED_DOSE = "prescribedDose"; const std::string OPTION_ALLOW_SELF_INTERSECTION_STRUCT = "allowSelfIntersection"; const std::string OPTION_MULTIPLE_STRUCTS_MODE = "multipleStructsMode"; }; } } } #endif \ No newline at end of file diff --git a/apps/DoseTool/DoseToolHelper.h b/apps/DoseTool/DoseToolHelper.h index 54f2da1..02a2840 100644 --- a/apps/DoseTool/DoseToolHelper.h +++ b/apps/DoseTool/DoseToolHelper.h @@ -1,60 +1,53 @@ // ----------------------------------------------------------------------- // 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: 1374 $ (last changed revision) -// @date $Date: 2016-05-30 14:15:42 +0200 (Mo, 30 Mai 2016) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #ifndef __DOSETOOL_HELPER_H #define __DOSETOOL_HELPER_H - #include "rttbDoseAccessorInterface.h" #include "rttbStructureSetGeneratorInterface.h" #include "rttbDoseIteratorInterface.h" #include "rttbMaskAccessorInterface.h" namespace rttb { namespace apps { namespace doseTool { class ApplicationData; /*! @brief Contains the business logic of processing all information to calculate the dose statistics and writing them to an xml file. @details Uses appData for the input data and the correct configuration. */ void processData(ApplicationData& appData); /*! @brief Generates a mask from the struct file by using the boostAccessor. In case of itk image, it directly loads the voxelized image. */ std::vector generateMasks( ApplicationData& appData); core::DoseIteratorInterface::Pointer generateMaskedDoseIterator( core::MaskAccessorInterface::Pointer maskAccessorPtr, core::DoseAccessorInterface::Pointer doseAccessorPtr); std::string assembleFilenameWithStruct(const std::string& originalFilename, const std::string& structName); } } } #endif diff --git a/testing/apps/DoseAcc/DoseAccInvalidParametersTest.cpp b/testing/apps/DoseAcc/DoseAccInvalidParametersTest.cpp index b6bd47f..d67f07f 100644 --- a/testing/apps/DoseAcc/DoseAccInvalidParametersTest.cpp +++ b/testing/apps/DoseAcc/DoseAccInvalidParametersTest.cpp @@ -1,103 +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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include #include "litCheckMacros.h" #include "boost/filesystem.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseAccInvalidParametersTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseAccExecutable; if (argc > 1) { doseAccExecutable = argv[1]; } boost::filesystem::path callingPath(_callingAppPath); std::string doseAccExeWithPath = callingPath.parent_path().string() + "/" + doseAccExecutable; //call with too few parameters std::string toofewParametersCommand = doseAccExeWithPath; toofewParametersCommand += " test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); toofewParametersCommand = doseAccExeWithPath; toofewParametersCommand += " test test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); toofewParametersCommand = doseAccExeWithPath; toofewParametersCommand += " -d test"; toofewParametersCommand += " -e test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); std::string minimalCLI = doseAccExeWithPath + " test test test "; //call with invalid interpolator std::string invalidInterpolatorOption = minimalCLI; invalidInterpolatorOption += "-i wrongInterpolator"; std::cout << "Command line call: " + invalidInterpolatorOption << std::endl; CHECK_EQUAL(system(invalidInterpolatorOption.c_str()) != 0, true); //call with invalid operator std::string invalidOperatorOption = minimalCLI; invalidOperatorOption += "-p -"; std::cout << "Command line call: " + invalidOperatorOption << std::endl; CHECK_EQUAL(system(invalidOperatorOption.c_str()) != 0, true); //call with operator* and weight std::string invalidOperatorMultWithWeightOption = minimalCLI; invalidOperatorMultWithWeightOption += "-p * --weight1 2.0"; std::cout << "Command line call: " + invalidOperatorMultWithWeightOption << std::endl; CHECK_EQUAL(system(invalidOperatorMultWithWeightOption.c_str()) != 0, true); //call with invalid dose1 load option std::string invalidDose1LoadOption = minimalCLI; invalidDose1LoadOption += "-t invalidLoadStyleOption"; std::cout << "Command line call: " + invalidDose1LoadOption << std::endl; CHECK_EQUAL(system(invalidDose1LoadOption.c_str()) != 0, true); //call with invalid dose2 load option std::string invalidDose2LoadOption = minimalCLI; invalidDose2LoadOption += "-u invalidLoadStyleOption"; std::cout << "Command line call: " + invalidDose2LoadOption << std::endl; CHECK_EQUAL(system(invalidDose2LoadOption.c_str()) != 0, true); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseAcc/DoseAccNeutralWeightTest.cpp b/testing/apps/DoseAcc/DoseAccNeutralWeightTest.cpp index 6774bf0..b08592d 100644 --- a/testing/apps/DoseAcc/DoseAccNeutralWeightTest.cpp +++ b/testing/apps/DoseAcc/DoseAccNeutralWeightTest.cpp @@ -1,108 +1,102 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include "litCheckMacros.h" #include "litImageTester.h" #include "boost/filesystem.hpp" #include "itkImage.h" #include "rttbITKIOHelper.h" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseAccNeutralWeightTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseAccExecutable; std::string doseFilename; std::string referenceFilename; std::string reference2Filename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 4) { doseAccExecutable = argv[1]; doseFilename = argv[2]; referenceFilename = argv[3]; reference2Filename = argv[4]; } std::string doseAccExeWithPath = callingPath.parent_path().string() + "/" + doseAccExecutable; const std::string defaultOutputAddFilename = "doseAccAddOutput.nrrd"; const std::string defaultOutputMultFilename = "doseAccMultOutput.nrrd"; std::string baseCommand = doseAccExeWithPath; baseCommand += " -d \"" + doseFilename + "\""; baseCommand += " -e \"" + doseFilename + "\""; std::string defaultDoseAccAddCommand = baseCommand + " -o " + defaultOutputAddFilename + " --weight1 0.0"; std::cout << "Command line call: " + defaultDoseAccAddCommand << std::endl; CHECK_EQUAL(system(defaultDoseAccAddCommand.c_str()), 0); CHECK_EQUAL(boost::filesystem::exists(defaultOutputAddFilename), true); std::string defaultDoseAccMultCommand = baseCommand + " -o " + defaultOutputMultFilename + " --operator \"*\""; std::cout << "Command line call: " + defaultDoseAccMultCommand << std::endl; CHECK_EQUAL(system(defaultDoseAccMultCommand.c_str()), 0); CHECK_EQUAL(boost::filesystem::exists(defaultOutputMultFilename), true); // Check result against reference typedef ::itk::Image TestImageType; TestImageType::Pointer referenceAddImage = io::itk::readITKDoubleImage(referenceFilename); TestImageType::Pointer outputAddImage = io::itk::readITKDoubleImage(defaultOutputAddFilename); lit::ImageTester tester; tester.setExpectedImage(referenceAddImage); tester.setActualImage(outputAddImage); tester.setCheckThreshold(1e-5); CHECK_TESTER(tester); TestImageType::Pointer referenceMultImage = io::itk::readITKDoubleImage(reference2Filename); TestImageType::Pointer outputMultImage = io::itk::readITKDoubleImage(defaultOutputMultFilename); tester.setExpectedImage(referenceMultImage); tester.setActualImage(outputMultImage); tester.setCheckThreshold(1e-5); CHECK_TESTER(tester); CHECK_EQUAL(std::remove(defaultOutputAddFilename.c_str()), 0); CHECK_EQUAL(std::remove(defaultOutputMultFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseAcc/DoseAccSimpleTest.cpp b/testing/apps/DoseAcc/DoseAccSimpleTest.cpp index 8107f00..6fb8af3 100644 --- a/testing/apps/DoseAcc/DoseAccSimpleTest.cpp +++ b/testing/apps/DoseAcc/DoseAccSimpleTest.cpp @@ -1,92 +1,86 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include "litCheckMacros.h" #include "litImageTester.h" #include "boost/filesystem.hpp" #include "itkImage.h" #include "rttbITKIOHelper.h" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseAccSimpleTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseAccExecutable; std::string dose1Filename; std::string dose2Filename; std::string referenceFilename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 4) { doseAccExecutable = argv[1]; dose1Filename = argv[2]; dose2Filename = argv[3]; referenceFilename = argv[4]; } std::string doseAccExeWithPath = callingPath.parent_path().string() + "/" + doseAccExecutable; std::string defaultOutputFilename = "doseAccOutput.nrrd"; std::string baseCommand = doseAccExeWithPath; baseCommand += " -d \"" + dose1Filename + "\""; baseCommand += " -e \"" + dose2Filename + "\""; baseCommand += " -o " + defaultOutputFilename; std::string defaultDoseAccCommand = baseCommand + " --weight1 2.0"; std::cout << "Command line call: " + defaultDoseAccCommand << std::endl; CHECK_EQUAL(system(defaultDoseAccCommand.c_str()), 0); CHECK_EQUAL(boost::filesystem::exists(defaultOutputFilename), true); // Check result against reference typedef ::itk::Image TestImageType; TestImageType::Pointer referenceImage = io::itk::readITKDoubleImage(referenceFilename); TestImageType::Pointer outputImage = io::itk::readITKDoubleImage(defaultOutputFilename); lit::ImageTester tester; tester.setExpectedImage(referenceImage); tester.setActualImage(outputImage); tester.setCheckThreshold(0.0); CHECK_TESTER(tester); CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseAcc/DoseAccTests.cpp b/testing/apps/DoseAcc/DoseAccTests.cpp index 51d1b8b..8b6e2cc 100644 --- a/testing/apps/DoseAcc/DoseAccTests.cpp +++ b/testing/apps/DoseAcc/DoseAccTests.cpp @@ -1,71 +1,65 @@ // ----------------------------------------------------------------------- // 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: 1374 $ (last changed revision) -// @date $Date: 2016-05-30 14:15:42 +0200 (Mo, 30 Mai 2016) $ (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() #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "litMultiTestsMain.h" #include "RTToolboxConfigure.h" namespace rttb { namespace testing { const char* _callingAppPath = nullptr; void registerTests() { LIT_REGISTER_TEST(DoseAccInvalidParametersTest); LIT_REGISTER_TEST(DoseAccSimpleTest); LIT_REGISTER_TEST(DoseAccNeutralWeightTest); } } //namespace testing } //namespace map int main(int argc, char* argv[]) { int result = 0; rttb::testing::registerTests(); if (argc > 0) { rttb::testing::_callingAppPath = argv[0]; } try { result = lit::multiTestsMain(argc, argv); } catch (...) { result = -1; } return result; } diff --git a/testing/apps/DoseTool/DoseToolDVHTest.cpp b/testing/apps/DoseTool/DoseToolDVHTest.cpp index d2a1ac8..b4f72ce 100644 --- a/testing/apps/DoseTool/DoseToolDVHTest.cpp +++ b/testing/apps/DoseTool/DoseToolDVHTest.cpp @@ -1,96 +1,90 @@ // ----------------------------------------------------------------------- // 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: 1233 $ (last changed revision) -// @date $Date: 2016-01-20 15:47:47 +0100 (Mi, 20 Jan 2016) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include "litCheckMacros.h" #include "../../io/other/CompareDVH.h" #include "rttbDVHXMLFileReader.h" #include "boost/filesystem.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseToolDVHTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseToolExecutable; std::string doseFilename; std::string structFilename; std::string structName; std::string referenceXMLFilename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 5) { doseToolExecutable = argv[1]; doseFilename = argv[2]; structFilename = argv[3]; structName = argv[4]; referenceXMLFilename = argv[5]; } std::string doseToolExeWithPath = callingPath.parent_path().string() + "/" + doseToolExecutable; std::string defaultOutputFilename = "dicomDVHOutput2.xml"; std::string baseCommand = doseToolExeWithPath; baseCommand += " -d \"" + doseFilename + "\""; baseCommand += " -s \"" + structFilename + "\""; if (structName != "") { baseCommand += " -n " + structName; } else { baseCommand += " -u itk "; } std::string defaultDVHCommand = baseCommand + " -z " + defaultOutputFilename; std::cout << "Command line call: " + defaultDVHCommand << std::endl; CHECK_EQUAL(system(defaultDVHCommand.c_str()), 0); //check if file exists CHECK_EQUAL(boost::filesystem::exists(defaultOutputFilename), true); io::other::DVHXMLFileReader xmlDVHDefaultReaderActual(defaultOutputFilename); DVHPointer defaultDVHActual = xmlDVHDefaultReaderActual.generateDVH(); io::other::DVHXMLFileReader xmlDVHDefaultReaderExpected(referenceXMLFilename); DVHPointer defaultDVHExpected = xmlDVHDefaultReaderExpected.generateDVH(); CHECK(checkEqualDVH(defaultDVHActual, defaultDVHExpected)); //delete file again CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseTool/DoseToolDicomDoseTest.cpp b/testing/apps/DoseTool/DoseToolDicomDoseTest.cpp index 1ec561d..12a7f45 100644 --- a/testing/apps/DoseTool/DoseToolDicomDoseTest.cpp +++ b/testing/apps/DoseTool/DoseToolDicomDoseTest.cpp @@ -1,137 +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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include "rttbDoseStatisticsXMLReader.h" #include "rttbDVHXMLFileReader.h" #include "../../io/other/CompareDoseStatistic.h" #include "../../io/other/CompareDVH.h" #include "litCheckMacros.h" #include "boost/filesystem.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseToolDicomDoseTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseToolExecutable; std::string doseFilename; std::string structFilename; std::string structName; std::string referenceXMLFilename; std::string referenceDVHXMLFilename; std::string referenceXMLComplexFilename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 7) { doseToolExecutable = argv[1]; doseFilename = argv[2]; structFilename = argv[3]; structName = argv[4]; referenceXMLFilename = argv[5]; referenceDVHXMLFilename = argv[6]; referenceXMLComplexFilename = argv[7]; } std::string doseToolExeWithPath = callingPath.parent_path().string() + "/" + doseToolExecutable; std::string defaultOutputFilename = "dicomDoseOutput.xml"; std::string defaultDVHOutputFilename = "dicomDoseDVHOutput.xml"; std::string complexOutputFilename = "dicomDoseOutputComplex.xml"; std::string baseCommand = doseToolExeWithPath; baseCommand += " -d \"" + doseFilename + "\""; baseCommand += " -s \"" + structFilename + "\""; if (structName != "") { baseCommand += " -n " + structName; } else { baseCommand += " -u itk "; } std::string defaultDoseStatisticsCommand = baseCommand + " -y " + defaultOutputFilename; std::cout << "Command line call: " + defaultDoseStatisticsCommand << std::endl; CHECK_EQUAL(system(defaultDoseStatisticsCommand.c_str()), 0); std::string defaultDoseStatisticsAndDVHCommand = defaultDoseStatisticsCommand + " -z " + defaultDVHOutputFilename; std::cout << "Command line call: " + defaultDoseStatisticsAndDVHCommand << std::endl; CHECK_EQUAL(system(defaultDoseStatisticsAndDVHCommand.c_str()), 0); std::string complexDoseStatisticsCommand = baseCommand + " -y " + complexOutputFilename; //prescribed dose is 14 Gy complexDoseStatisticsCommand += " -f -p 14"; std::cout << "Command line call: " + complexDoseStatisticsCommand << std::endl; CHECK_EQUAL(system(complexDoseStatisticsCommand.c_str()), 0); //check if file exists CHECK_EQUAL(boost::filesystem::exists(defaultOutputFilename), true); CHECK_EQUAL(boost::filesystem::exists(complexOutputFilename), true); CHECK_EQUAL(boost::filesystem::exists(defaultDVHOutputFilename), true); //check if file has dose statistics that are same than these in than reference file io::other::DoseStatisticsXMLReader readerDefaultExpected(referenceXMLFilename); auto doseStatisticsDefaultExpected = readerDefaultExpected.generateDoseStatistic(); io::other::DoseStatisticsXMLReader readerDefaultActual(defaultOutputFilename); auto doseStatisticsDefaultActual = readerDefaultActual.generateDoseStatistic(); CHECK(checkEqualDoseStatistic(doseStatisticsDefaultExpected, doseStatisticsDefaultActual)); io::other::DoseStatisticsXMLReader readerComplexExpected(complexOutputFilename); auto doseStatisticsComplexExpected = readerComplexExpected.generateDoseStatistic(); io::other::DoseStatisticsXMLReader readerComplexActual(referenceXMLComplexFilename); auto doseStatisticsComplexActual = readerComplexActual.generateDoseStatistic(); CHECK(checkEqualDoseStatistic(doseStatisticsComplexExpected, doseStatisticsComplexActual)); //check DVH files io::other::DVHXMLFileReader xmlDVHDefaultReaderActual(defaultDVHOutputFilename); core::DVH::Pointer defaultDVHActual = xmlDVHDefaultReaderActual.generateDVH(); io::other::DVHXMLFileReader xmlDVHDefaultReaderExpected(referenceDVHXMLFilename); core::DVH::Pointer defaultDVHExpected = xmlDVHDefaultReaderExpected.generateDVH(); CHECK(checkEqualDVH(defaultDVHActual, defaultDVHExpected)); //delete file again CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); CHECK_EQUAL(std::remove(defaultDVHOutputFilename.c_str()), 0); CHECK_EQUAL(std::remove(complexOutputFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseTool/DoseToolITKDoseTest.cpp b/testing/apps/DoseTool/DoseToolITKDoseTest.cpp index cd2ec21..77c7dd8 100644 --- a/testing/apps/DoseTool/DoseToolITKDoseTest.cpp +++ b/testing/apps/DoseTool/DoseToolITKDoseTest.cpp @@ -1,115 +1,109 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include "litCheckMacros.h" #include "rttbDoseStatisticsXMLReader.h" #include "../../io/other/CompareDoseStatistic.h" #include "boost/filesystem.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseToolITKDoseTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseToolExecutable; std::string doseFilename; std::string structFilename; std::string structName; std::string referenceXMLFilename; std::string referenceXMLComplexFilename; std::string defaultOutputFilename; std::string complexOutputFilename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 8) { doseToolExecutable = argv[1]; doseFilename = argv[2]; structFilename = argv[3]; structName = argv[4]; referenceXMLFilename = argv[5]; referenceXMLComplexFilename = argv[6]; defaultOutputFilename = argv[7]; complexOutputFilename = argv[8]; } std::string doseToolExeWithPath = callingPath.parent_path().string() + "/" + doseToolExecutable; std::string baseCommand = doseToolExeWithPath; baseCommand += " -d \"" + doseFilename + "\""; baseCommand += " -s \"" + structFilename + "\""; baseCommand += " -t itk "; if (structName != "") { baseCommand += " -n " + structName; } if (boost::filesystem::extension(structFilename).compare(".nrrd") == 0) { baseCommand += " -u itk"; } std::string defaultDoseStatisticsCommand = baseCommand + " -y " + defaultOutputFilename; std::cout << "Command line call: " + defaultDoseStatisticsCommand << std::endl; CHECK_EQUAL(system(defaultDoseStatisticsCommand.c_str()), 0); std::string complexDoseStatisticsCommand = baseCommand + " -y " + complexOutputFilename; //prescribed dose is 14 Gy complexDoseStatisticsCommand += " -f -p 14"; std::cout << "Command line call: " + complexDoseStatisticsCommand << std::endl; CHECK_EQUAL(system(complexDoseStatisticsCommand.c_str()), 0); //check if file exists CHECK_EQUAL(boost::filesystem::exists(defaultOutputFilename), true); CHECK_EQUAL(boost::filesystem::exists(complexOutputFilename), true); //check if file has dose statistics that are same than these in than reference file io::other::DoseStatisticsXMLReader readerDefaultExpected(referenceXMLFilename); auto doseStatisticsDefaultExpected = readerDefaultExpected.generateDoseStatistic(); io::other::DoseStatisticsXMLReader readerDefaultActual(defaultOutputFilename); auto doseStatisticsDefaultActual = readerDefaultActual.generateDoseStatistic(); CHECK(checkEqualDoseStatistic(doseStatisticsDefaultExpected, doseStatisticsDefaultActual)); io::other::DoseStatisticsXMLReader readerComplexExpected(referenceXMLComplexFilename); auto doseStatisticsComplexExpected = readerComplexExpected.generateDoseStatistic(); io::other::DoseStatisticsXMLReader readerComplexActual(complexOutputFilename); auto doseStatisticsComplexActual = readerComplexActual.generateDoseStatistic(); CHECK(checkEqualDoseStatistic(doseStatisticsComplexExpected, doseStatisticsComplexActual)); //delete file again CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); CHECK_EQUAL(std::remove(complexOutputFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseTool/DoseToolInvalidParametersTest.cpp b/testing/apps/DoseTool/DoseToolInvalidParametersTest.cpp index 22d1dba..b28d7c6 100644 --- a/testing/apps/DoseTool/DoseToolInvalidParametersTest.cpp +++ b/testing/apps/DoseTool/DoseToolInvalidParametersTest.cpp @@ -1,98 +1,92 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include #include "litCheckMacros.h" #include "boost/filesystem.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseToolInvalidParametersTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseToolExecutable; if (argc > 1) { doseToolExecutable = argv[1]; } boost::filesystem::path callingPath(_callingAppPath); std::string doseToolExeWithPath = callingPath.parent_path().string() + "/" + doseToolExecutable; //call with too few parameters std::string toofewParametersCommand = doseToolExeWithPath; toofewParametersCommand += " -d test"; toofewParametersCommand += " -s test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); toofewParametersCommand = doseToolExeWithPath; toofewParametersCommand += " -s test"; toofewParametersCommand += " -n test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); toofewParametersCommand = doseToolExeWithPath; toofewParametersCommand += " test"; toofewParametersCommand += " test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); toofewParametersCommand = doseToolExeWithPath; toofewParametersCommand += " -d test"; toofewParametersCommand += " -s test"; toofewParametersCommand += " -n test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); //call with invalid dose load option std::string minimalCLI = doseToolExeWithPath + " test test test "; std::string invalidDoseLoadOption = minimalCLI; invalidDoseLoadOption += "-t wrongOption"; std::cout << "Command line call: " + invalidDoseLoadOption << std::endl; CHECK_EQUAL(system(invalidDoseLoadOption.c_str()) != 0, true); //call with invalid struct load option std::string invalidStructLoadOption = minimalCLI; invalidStructLoadOption += "-u wrongOption"; std::cout << "Command line call: " + invalidStructLoadOption << std::endl; CHECK_EQUAL(system(invalidStructLoadOption.c_str()) != 0, true); //call with complex dose statistics, but without prescribed dose std::string complexDoseWithoutPrescribedDoseCommand = minimalCLI; complexDoseWithoutPrescribedDoseCommand += "-f"; std::cout << "Command line call: " + complexDoseWithoutPrescribedDoseCommand << std::endl; CHECK_EQUAL(system(complexDoseWithoutPrescribedDoseCommand.c_str()) != 0, true); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseTool/DoseToolRegexTest.cpp b/testing/apps/DoseTool/DoseToolRegexTest.cpp index 7f3487f..6981dc0 100644 --- a/testing/apps/DoseTool/DoseToolRegexTest.cpp +++ b/testing/apps/DoseTool/DoseToolRegexTest.cpp @@ -1,119 +1,113 @@ // ----------------------------------------------------------------------- // 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: 1221 $ (last changed revision) -// @date $Date: 2015-12-01 13:43:31 +0100 (Di, 01 Dez 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ #include "rttbDoseStatisticsXMLReader.h" #include "../../io/other/CompareDoseStatistic.h" #include "litCheckMacros.h" #include "boost/filesystem.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseToolRegexTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseToolExecutable; std::string doseFilename; std::string doseLoadStyle; std::string structFilename; std::string structLoadStyle; std::string structName; std::string referenceXMLFilename; std::string referenceXMLFilename2; boost::filesystem::path callingPath(_callingAppPath); if (argc > 8) { doseToolExecutable = argv[1]; doseFilename = argv[2]; doseLoadStyle = argv[3]; structFilename = argv[4]; structLoadStyle = argv[5]; structName = argv[6]; referenceXMLFilename = argv[7]; referenceXMLFilename2 = argv[8]; } std::string doseToolExeWithPath = callingPath.parent_path().string() + "/" + doseToolExecutable; std::string defaultOutputFilename = "regexOutput.xml"; std::string defaultExpectedOutputFilename = "regexOutput_Nodes.xml"; std::string defaultExpectedOutputFilename2 = "regexOutput_Heart.xml"; std::string baseCommand = doseToolExeWithPath; baseCommand += " -d \"" + doseFilename + "\""; baseCommand += " -t " + doseLoadStyle; baseCommand += " -s \"" + structFilename + "\""; baseCommand += " -u " + structLoadStyle; baseCommand += " -n \"" + structName + "\""; baseCommand += " -y " + defaultOutputFilename; std::cout << "Command line call: " + baseCommand << std::endl; CHECK_EQUAL(system(baseCommand.c_str()), 0); CHECK_EQUAL(boost::filesystem::exists(defaultOutputFilename), true); CHECK_EQUAL(boost::filesystem::exists(defaultExpectedOutputFilename), false); CHECK_EQUAL(boost::filesystem::exists(defaultExpectedOutputFilename2), false); CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); std::string defaultDoseStatisticsCommand = baseCommand + " -m"; std::cout << "Command line call: " + defaultDoseStatisticsCommand << std::endl; CHECK_EQUAL(system(defaultDoseStatisticsCommand.c_str()), 0); //check if two file were written CHECK_EQUAL(boost::filesystem::exists(defaultExpectedOutputFilename), true); CHECK_EQUAL(boost::filesystem::exists(defaultExpectedOutputFilename2), true); //check if file has dose statistics that are same than these in than reference file io::other::DoseStatisticsXMLReader readerDefaultExpected(referenceXMLFilename); auto doseStatisticsDefaultExpected = readerDefaultExpected.generateDoseStatistic(); io::other::DoseStatisticsXMLReader readerDefaultActual(defaultExpectedOutputFilename); auto doseStatisticsDefaultActual = readerDefaultActual.generateDoseStatistic(); CHECK(checkEqualDoseStatistic(doseStatisticsDefaultExpected, doseStatisticsDefaultActual)); io::other::DoseStatisticsXMLReader readerDefaultExpected2(referenceXMLFilename2); auto doseStatisticsDefaultExpected2 = readerDefaultExpected2.generateDoseStatistic(); io::other::DoseStatisticsXMLReader readerDefaultActual2(defaultExpectedOutputFilename2); auto doseStatisticsDefaultActual2 = readerDefaultActual2.generateDoseStatistic(); CHECK(checkEqualDoseStatistic(doseStatisticsDefaultExpected2, doseStatisticsDefaultActual2)); //delete file again CHECK_EQUAL(std::remove(defaultExpectedOutputFilename.c_str()), 0); CHECK_EQUAL(std::remove(defaultExpectedOutputFilename2.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseTool/DoseToolTests.cpp b/testing/apps/DoseTool/DoseToolTests.cpp index 123c347..c3dc74a 100644 --- a/testing/apps/DoseTool/DoseToolTests.cpp +++ b/testing/apps/DoseTool/DoseToolTests.cpp @@ -1,73 +1,67 @@ // ----------------------------------------------------------------------- // 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: 1374 $ (last changed revision) -// @date $Date: 2016-05-30 14:15:42 +0200 (Mo, 30 Mai 2016) $ (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() #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "litMultiTestsMain.h" #include "RTToolboxConfigure.h" namespace rttb { namespace testing { const char* _callingAppPath = nullptr; void registerTests() { LIT_REGISTER_TEST(DoseToolInvalidParametersTest); LIT_REGISTER_TEST(DoseToolDicomDoseTest); LIT_REGISTER_TEST(DoseToolITKDoseTest); LIT_REGISTER_TEST(DoseToolRegexTest); LIT_REGISTER_TEST(DoseToolDVHTest); } } //namespace testing } //namespace map int main(int argc, char* argv[]) { int result = 0; rttb::testing::registerTests(); if (argc > 0) { rttb::testing::_callingAppPath = argv[0]; } try { result = lit::multiTestsMain(argc, argv); } catch (...) { result = -1; } return result; } diff --git a/testing/io/other/CompareDVH.cpp b/testing/io/other/CompareDVH.cpp index 8911b52..b092916 100644 --- a/testing/io/other/CompareDVH.cpp +++ b/testing/io/other/CompareDVH.cpp @@ -1,86 +1,79 @@ // ----------------------------------------------------------------------- // 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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) -*/ - #include "CompareDVH.h" #include namespace rttb { namespace testing { bool checkEqualDVH(DVHPointer aDVH1, DVHPointer aDVH2) { bool result; const double errorConstantDVH = 1e-4; result = lit::AreClose(aDVH1->getDeltaD(), aDVH2->getDeltaD(), errorConstantDVH); result = result && lit::AreClose(aDVH1->getDeltaV(), aDVH2->getDeltaV(), errorConstantDVH); result = result && (aDVH1->getDoseID() == aDVH2->getDoseID()); result = result && (aDVH1->getStructureID() == aDVH2->getStructureID()); result = result && lit::AreClose(aDVH1->getMaximum(), aDVH2->getMaximum(), errorConstantDVH); result = result && lit::AreClose(aDVH1->getMinimum(), aDVH2->getMinimum(), errorConstantDVH); result = result && lit::AreClose(aDVH1->getMean(), aDVH2->getMean(), errorConstantDVH); result = result && (aDVH1->getDataDifferential().size() == aDVH2->getDataDifferential().size()); for (size_t i = 0; i < aDVH1->getDataDifferential().size(); i++) { result = result && lit::AreClose(aDVH1->getDataDifferential().at(i), aDVH2->getDataDifferential().at(i), errorConstantDVH); } return result; } rttb::testing::DVHPointer computeDiffDVH(DVHPointer aDVH1, DVHPointer aDVH2) { if (aDVH1->getDeltaD() == aDVH2->getDeltaD() && aDVH1->getDeltaV() == aDVH2->getDeltaV()){ rttb::core::DVH::DataDifferentialType dvhData1 = aDVH1->getDataDifferential(); rttb::core::DVH::DataDifferentialType dvhData2 = aDVH2->getDataDifferential(); rttb::core::DVH::DataDifferentialType dvhDataDifference; auto it1 = dvhData1.cbegin(); auto it2 = dvhData2.cbegin(); while (it1 != dvhData1.cend() && it2 != dvhData2.cend()) { dvhDataDifference.push_back(*it1-*it2); ++it1; ++it2; } auto differenceDVH = ::boost::make_shared(dvhDataDifference, aDVH1->getDeltaD(), aDVH1->getDeltaV(), aDVH1->getStructureID(), aDVH1->getDoseID()); return differenceDVH; } else { return aDVH1; } } }//testing }//rttb diff --git a/testing/io/other/CompareDVH.h b/testing/io/other/CompareDVH.h index bd5ce71..86329cc 100644 --- a/testing/io/other/CompareDVH.h +++ b/testing/io/other/CompareDVH.h @@ -1,46 +1,39 @@ // ----------------------------------------------------------------------- // 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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) -*/ - #include "litCheckMacros.h" #include "rttbDVH.h" #ifndef __DVH_COMPARER_H #define __DVH_COMPARER_H namespace rttb { namespace testing { typedef core::DVH::Pointer DVHPointer; /*! Compare 2 DVHs and return the results. @result Indicates if the test was successful (true) or if it failed (false) */ bool checkEqualDVH(DVHPointer aDVH1, DVHPointer aDVH2); DVHPointer computeDiffDVH(DVHPointer aDVH1, DVHPointer aDVH2); }//testing }//rttb #endif