diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 5322d2c..01d1e21 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -1,64 +1,64 @@ MESSAGE(STATUS "processing RTToolbox apps") #extract and build ArgumentParsingLib include(ExternalProject) message(STATUS "ArgumentParsingLib will be automatically downloaded and built.") set(ArgumentParsingLib_SOURCE_DIR "${CMAKE_BINARY_DIR}/external/ArgumentParsingLib-src") set(ArgumentParsingLib_BUILD_DIR "${CMAKE_BINARY_DIR}/external/ArgumentParsingLib-build") set(ArgumentParsingLib_CMAKE_DIR "${CMAKE_BINARY_DIR}/external/ArgumentParsingLib-cmake") IF(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) SET(ARG_BUILD_SHARED_LIBS ON) ELSE(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) SET(ARG_BUILD_SHARED_LIBS OFF) ENDIF(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) ExternalProject_Add( ArgumentParsingLib URL ${RTToolbox_SOURCE_DIR}/utilities/ArgumentParsingLib/ArgumentParsingLib.tar.gz SOURCE_DIR ${ArgumentParsingLib_SOURCE_DIR} BINARY_DIR ${ArgumentParsingLib_BUILD_DIR} PREFIX ${ArgumentParsingLib_CMAKE_DIR} INSTALL_COMMAND "" UPDATE_COMMAND "" CMAKE_ARGS -DBUILD_TESTS:BOOL=OFF -DBoost_INCLUDE_DIR:STRING=${Boost_INCLUDE_DIR} -DBUILD_SHARED_LIBS:BOOL=${ARG_BUILD_SHARED_LIBS} ) OPTION(BUILD_App_DoseAcc "Determine if the demo application DoseAcc will be generated." ON) IF(BUILD_App_DoseAcc) ADD_SUBDIRECTORY(DoseAcc) IF(RTTB_VIRTUOS_SUPPORT AND BUILD_IO_Virtuos) ADD_SUBDIRECTORY(DoseAcc4V) ENDIF() ENDIF() OPTION(BUILD_App_DoseMap "Determine if the application DoseMap will be generated." ON) -IF(BUILD_App_DoseMap AND BUILD_IO_Virtuos) +IF(BUILD_App_DoseMap) ADD_SUBDIRECTORY(DoseMap) ENDIF() OPTION(BUILD_App_DoseTool "Determine if the application DoseTool will be generated." ON) IF(BUILD_App_DoseTool) ADD_SUBDIRECTORY(DoseTool) IF(RTTB_VIRTUOS_SUPPORT AND BUILD_IO_Virtuos) ADD_SUBDIRECTORY(DoseTool4V) ENDIF() ENDIF() OPTION(BUILD_App_VoxelizerTool "Determine if the application VoxelizerTool will be generated." ON) IF(BUILD_App_VoxelizerTool) ADD_SUBDIRECTORY(VoxelizerTool) ENDIF() OPTION(BUILD_App_BioModelCalc "Determine if the demo application BioModelCalc will be generated." ON) IF(BUILD_App_BioModelCalc) ADD_SUBDIRECTORY(BioModelCalc) IF(RTTB_VIRTUOS_SUPPORT AND BUILD_IO_Virtuos) ADD_SUBDIRECTORY(BioModelCalc4V) ENDIF() ENDIF() \ No newline at end of file diff --git a/apps/DoseMap/CMakeLists.txt b/apps/DoseMap/CMakeLists.txt index 9170efb..9c77f73 100644 --- a/apps/DoseMap/CMakeLists.txt +++ b/apps/DoseMap/CMakeLists.txt @@ -1,8 +1,3 @@ MESSAGE (STATUS "generating app: DoseMap - simple dose mapping tool") SET(RTTB_Boost_ADDITIONAL_COMPONENT program_options) -RTTB_CREATE_APPLICATION(DoseMap DEPENDS RTTBCore RTTBAlgorithms RTTBInterpolation RTTBInterpolationMatchPointTransformation RTTBITKIO RTTBVirtuosIO RTTBDicomIO RTTBHelaxIO PACKAGE_DEPENDS MatchPoint ITK ArgumentParsingLib BoostBinaries) - -IF (NOT WIN32) -# target_compile_features(DoseMap PRIVATE cxx_auto_type cxx_nullptr cxx_override) -# set(CMAKE_CXX_FLAGS "-fpermissive") -ENDIF() +RTTB_CREATE_APPLICATION(DoseMap DEPENDS RTTBCore RTTBAlgorithms RTTBInterpolation RTTBInterpolationMatchPointTransformation RTTBITKIO RTTBDicomIO RTTBHelaxIO PACKAGE_DEPENDS MatchPoint ITK ArgumentParsingLib BoostBinaries) diff --git a/apps/DoseMap/DoseMap.cpp b/apps/DoseMap/DoseMap.cpp index d95d966..3a43014 100644 --- a/apps/DoseMap/DoseMap.cpp +++ b/apps/DoseMap/DoseMap.cpp @@ -1,209 +1,209 @@ // ----------------------------------------------------------------------- // 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" /** 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,true); + 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; } try { appData._inputDose = rttb::apps::doseMap::loadDose(appData._inputDoseFileName, appData._inputDoseLoadStyle); } 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::apps::doseMap::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 typedef map::algorithm::DummyRegistrationAlgorithm<3> DummyRegType; 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 d4a422e..3cebc22 100644 --- a/apps/DoseMap/DoseMapApplicationData.h +++ b/apps/DoseMap/DoseMapApplicationData.h @@ -1,78 +1,77 @@ // ----------------------------------------------------------------------- // 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_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; /**Vector of arguments used to specify the loading style (always the first argument) - * and, if needed, additional arguments for the specified loading style (e.g. location of the - * Virtuos plan file for the Virtuos IO style). + * and, if needed, additional arguments for the specified loading style. */ typedef std::vector LoadingStyleArgType; /** Loaded Dose.*/ core::DoseAccessorInterface::DoseAccessorPointer _inputDose; std::string _inputDoseFileName; LoadingStyleArgType _inputDoseLoadStyle; core::DoseAccessorInterface::DoseAccessorPointer _refDose; std::string _refDoseFileName; LoadingStyleArgType _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.cpp b/apps/DoseMap/DoseMapCmdLineParser.cpp index f4a8326..747af67 100644 --- a/apps/DoseMap/DoseMapCmdLineParser.cpp +++ b/apps/DoseMap/DoseMapCmdLineParser.cpp @@ -1,118 +1,115 @@ // ----------------------------------------------------------------------- // 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: 1145 $ (last changed revision) // @date $Date: 2015-10-12 17:06:10 +0200 (Mo, 12 Okt 2015) $ (last change date) // @author $Author: hentsch $ (last changed by) */ #include "DoseMapCmdLineParser.h" namespace rttb { namespace apps { namespace doseMap { DoseMapCmdLineParser::DoseMapCmdLineParser(int argc, const char** argv, const std::string& name, - const std::string& version, bool virtuosSupport) : - CmdLineParserBase(name, version), _virtuosSupport(virtuosSupport) + const std::string& version) : + CmdLineParserBase(name, version) { std::vector defaultLoadingStyle; defaultLoadingStyle.push_back("dicom"); std::string doseLoadStyleDescription = "Indicates the load style that should be used for the input dose. Available styles: \"dicom\": normal dicom dose (default);" - "\"virtuos\": load of a virtuos dose (This style is a multi argument. The second argument specifies the virtuos plan file, e.g. : \"--loadStyle1 virtuos myFavorite.pln\");" "\"itk\": use itk image loading; \"helax\": load a helax dose (choosing this style, the dose path should only be a directory)."; addOption(OPTION_INPUT_DOSE_FILE_NAME, OPTION_GROUP_REQUIRED, "The name of the input dose file. Can be omitted if used as positional argument (see above).", 'd', true); addOption(OPTION_OUTPUT_FILE_NAME, OPTION_GROUP_REQUIRED, "The name of the output file. Can be omitted if used as positional argument (see above).", 'o', true); addOptionWithDefaultValue(OPTION_INTERPOLATOR, OPTION_GROUP_REQUIRED, "Specifies the interpolator that should be used for mapping." - "Available options are: \"nn\": nearest neighbour,\"linear\": linear interpolation, \"rosu\" interpolation based on the concept of Rosu et al.. Default interpolator is \"linear\".", + "Available options are: \"nn\": nearest neighbor,\"linear\": linear interpolation, \"rosu\" interpolation based on the concept of Rosu et al..", "linear", "linear", 'i', true); addOptionWithDefaultValue(OPTION_REG_FILE_NAME, OPTION_GROUP_REQUIRED, "Specifies name and location of the registration file that should be used to map the input dose. " "Default is no mapping, thus an identity transform is used. The registration should be stored as MatchPoint registration.", "", "no mapping", 'r',true); - addOption(OPTION_REF_DOSE_FILE, OPTION_GROUP_OPTIONAL, "Specifies name and location of the dose file that should be the reference/template for the grid to mapp into. " + addOption(OPTION_REF_DOSE_FILE, OPTION_GROUP_OPTIONAL, "Specifies name and location of the dose file that should be the reference/template for the grid to map into. " "If flag is not specified, the input dose is the reference.", 't'); addOptionWithDefaultValue >(OPTION_INPUT_DOSE_LOAD_STYLE, OPTION_GROUP_REQUIRED, doseLoadStyleDescription, defaultLoadingStyle, defaultLoadingStyle.at(0),'l',true); addOptionWithDefaultValue >(OPTION_REF_DOSE_LOAD_STYLE, OPTION_GROUP_OPTIONAL, doseLoadStyleDescription, defaultLoadingStyle, defaultLoadingStyle.at(0), 's', true); addPositionalOption(OPTION_INPUT_DOSE_FILE_NAME, 1); addPositionalOption(OPTION_OUTPUT_FILE_NAME, 1); parse(argc, argv); } void DoseMapCmdLineParser::validateInput() const { auto interpolator = get(OPTION_INTERPOLATOR); if (interpolator != "nn" && interpolator != "linear" && interpolator != "rosu") { throw cmdlineparsing::InvalidConstraintException("Unknown interpolator: " + interpolator + ".\nPlease refer to the help for valid interpolator settings."); } std::vector inputDoseLoadStyle = get >(OPTION_INPUT_DOSE_LOAD_STYLE); std::string indoseLoadStyleAbbreviation = inputDoseLoadStyle.at(0); - if (indoseLoadStyleAbbreviation != "dicom" && indoseLoadStyleAbbreviation != "virtuos" - && indoseLoadStyleAbbreviation != "itk" && indoseLoadStyleAbbreviation != "helax") + if (indoseLoadStyleAbbreviation != "dicom" && indoseLoadStyleAbbreviation != "itk" && indoseLoadStyleAbbreviation != "helax") { throw cmdlineparsing::InvalidConstraintException("Unknown load style for input dose file: " + indoseLoadStyleAbbreviation + ".\nPlease refer to the help for valid loading style settings."); } if (isSet(OPTION_REF_DOSE_FILE)){ std::vector refDoseLoadStyle = get >(OPTION_REF_DOSE_LOAD_STYLE); std::string refDoseLoadStyleAbbreviation = refDoseLoadStyle.at(0); - if (refDoseLoadStyleAbbreviation != "dicom" && refDoseLoadStyleAbbreviation != "virtuos" - && refDoseLoadStyleAbbreviation != "itk" && refDoseLoadStyleAbbreviation != "helax") + if (refDoseLoadStyleAbbreviation != "dicom" && refDoseLoadStyleAbbreviation != "itk" && refDoseLoadStyleAbbreviation != "helax") { throw cmdlineparsing::InvalidConstraintException("Unknown load style for reference dose file: " + refDoseLoadStyleAbbreviation + ".\nPlease refer to the help for valid loading style settings."); } } } void DoseMapCmdLineParser::printHelp() const { cmdlineparsing::CmdLineParserBase::printHelp(); std::cout << "Example:" << std::endl << std::endl; std::cout << m_programName << " dose1.mhd result.mhd -r reg.mapr --" << OPTION_INPUT_DOSE_LOAD_STYLE << " itk --" << OPTION_REF_DOSE_LOAD_STYLE+ " itk" << std::endl << std::endl; std::cout << "This will map \"dose1.mhd\" by using \"reg.mapr\" into the grid geometry of the input dose. The resulting dose will be stored in \"result.mhd\"." << std::endl; } } } } diff --git a/apps/DoseMap/DoseMapCmdLineParser.h b/apps/DoseMap/DoseMapCmdLineParser.h index 113f3cc..d956900 100644 --- a/apps/DoseMap/DoseMapCmdLineParser.h +++ b/apps/DoseMap/DoseMapCmdLineParser.h @@ -1,66 +1,63 @@ // ----------------------------------------------------------------------- // 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, bool virtuosSupport = false); + 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"; - - - bool _virtuosSupport; }; } } } #endif \ No newline at end of file diff --git a/apps/DoseMap/DoseMapHelper.cpp b/apps/DoseMap/DoseMapHelper.cpp index 07ce813..69d9260 100644 --- a/apps/DoseMap/DoseMapHelper.cpp +++ b/apps/DoseMap/DoseMapHelper.cpp @@ -1,204 +1,184 @@ // ----------------------------------------------------------------------- // 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 "mapRegistrationFileReader.h" -#include "rttbVirtuosPlanFileDoseAccessorGenerator.h" #include "rttbDicomFileDoseAccessorGenerator.h" #include "rttbDicomHelaxFileDoseAccessorGenerator.h" #include "rttbITKImageAccessorConverter.h" #include "rttbSimpleMappableDoseAccessor.h" #include "rttbMatchPointTransformation.h" #include "rttbLinearInterpolation.h" #include "rttbNearestNeighborInterpolation.h" #include "rttbRosuMappableDoseAccessor.h" #include "rttbITKImageFileAccessorGenerator.h" #include "rttbArithmetic.h" #include "rttbBinaryFunctorAccessor.h" #include "rttbExceptionMacros.h" #include "rttbImageWriter.h" rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseMap::loadDose(const std::string& fileName, const rttb::apps::doseMap::ApplicationData::LoadingStyleArgType& args) { rttb::core::DoseAccessorInterface::DoseAccessorPointer result; std::cout << std::endl << "read dose file... "; if (args.empty() || args[0] == "dicom") { std::cout << "use RTTB dicom IO... "; result = loadDicomDose(fileName); } else if (args[0] == "helax") { std::cout << "use RTTB Helax IO... "; result = loadHelaxDose(fileName); } else if (args[0] == "itk") { std::cout << "use RTTB itk IO... "; result = loadITKDose(fileName); } - else if (args[0] == "virtuos") - { - if (args.size() < 2) - { - rttbDefaultExceptionStaticMacro( << - "Cannot load virtuos dose. Plan file is missing. Specify plan file as 2nd io stlye argument."); - } - - std::cout << "use RTTB virtuos IO... " << std::endl; - std::cout << " virtuos plan file: " << args[1] << " ... "; - result = loadVirtuosDose(fileName, args[1]); - } else { rttbDefaultExceptionStaticMacro( << "Unknown io style selected. Cannot load data. Selected style: " << args[0]); } std::cout << "done." << std::endl; return result; }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseMap::loadDicomDose(const std::string& fileName) { rttb::io::dicom::DicomFileDoseAccessorGenerator generator(fileName); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseMap::loadHelaxDose(const std::string& path) { rttb::io::helax::DicomHelaxFileDoseAccessorGenerator generator(path); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseMap::loadITKDose(const std::string& fileName) { rttb::io::itk::ITKImageFileAccessorGenerator generator(fileName); return generator.generateDoseAccessor(); }; -rttb::core::DoseAccessorInterface::DoseAccessorPointer -rttb::apps::doseMap::loadVirtuosDose(const std::string& fileName, const std::string& planFileName) -{ - rttb::io::virtuos::VirtuosPlanFileDoseAccessorGenerator generator(fileName, planFileName); - return generator.generateDoseAccessor(); -}; - 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::DoseAccessorPointer assembleOutputAccessor(rttb::apps::doseMap::ApplicationData& appData) { rttb::core::DoseAccessorInterface::DoseAccessorPointer outputAccessor = appData._inputDose; rttb::interpolation::TransformationInterface::Pointer transform = rttb::interpolation::TransformationInterface::Pointer(new rttb::interpolation::MatchPointTransformation(appData._spReg)); if (appData._interpolatorName == "rosu") { outputAccessor = rttb::core::DoseAccessorInterface::DoseAccessorPointer( new rttb::interpolation::RosuMappableDoseAccessor(appData._refDose->getGeometricInfo(), appData._inputDose, transform)); } else { rttb::interpolation::InterpolationBase::Pointer interpolate = rttb::interpolation::LinearInterpolation::Pointer(new rttb::interpolation::LinearInterpolation()); if (appData._interpolatorName == "nn") { interpolate = rttb::interpolation::NearestNeighborInterpolation::Pointer(new rttb::interpolation::NearestNeighborInterpolation()); } else if (appData._interpolatorName != "linear") { mapDefaultExceptionStaticMacro( << "Unkown interpolation type selected. Cannot map dose. Interpolation type: " << appData._interpolatorName); } outputAccessor = rttb::core::DoseAccessorInterface::DoseAccessorPointer( new rttb::interpolation::SimpleMappableDoseAccessor(appData._refDose->getGeometricInfo(), appData._inputDose, transform, interpolate)); } return outputAccessor; } void rttb::apps::doseMap::processData(rttb::apps::doseMap::ApplicationData& appData) { rttb::core::DoseAccessorInterface::DoseAccessorPointer 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 7d5d397..3d737b7 100644 --- a/apps/DoseMap/DoseMapHelper.h +++ b/apps/DoseMap/DoseMapHelper.h @@ -1,62 +1,58 @@ // ----------------------------------------------------------------------- // 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 { /**loads the dose from a file. Throws exception if loading fails*/ core::DoseAccessorInterface::DoseAccessorPointer loadDose(const std::string& fileName, const rttb::apps::doseMap::ApplicationData::LoadingStyleArgType& args); /**loads the dose from a file using the dicom dose generator. Throws exception if loading fails*/ core::DoseAccessorInterface::DoseAccessorPointer loadDicomDose(const std::string& fileName); /**loads the dose from a path using the helax io dose generator. Throws exception if loading fails*/ core::DoseAccessorInterface::DoseAccessorPointer loadHelaxDose(const std::string& path); /**loads the dose from a file stored in an ITK supported data format. Throws exception if loading fails*/ core::DoseAccessorInterface::DoseAccessorPointer loadITKDose(const std::string& fileName); - /**loads the dose from a file stored in Virtuos data format. Throws exception if loading fails*/ - core::DoseAccessorInterface::DoseAccessorPointer loadVirtuosDose(const std::string& fileName, - const std::string& planFileName); - 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