diff --git a/apps/BioModelCalc/BioModelCalcApplicationData.cpp b/apps/BioModelCalc/BioModelCalcApplicationData.cpp index 5474684..cc9a343 100644 --- a/apps/BioModelCalc/BioModelCalcApplicationData.cpp +++ b/apps/BioModelCalc/BioModelCalcApplicationData.cpp @@ -1,72 +1,66 @@ // ----------------------------------------------------------------------- // 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 "BioModelCalcApplicationData.h" #include "BioModelCmdLineParser.h" namespace rttb { namespace apps { namespace bioModelCalc { ApplicationData:: ApplicationData() { this->reset(); } void ApplicationData:: reset() { _doseFileName = ""; _outputFileName = ""; _doseScaling = 1.0; _nFractions = 1; _modelParameters.clear(); _modelParameterMapsFilename.clear(); _modelParameterMaps.clear(); } void populateAppData(boost::shared_ptr<BioModelCmdLineParser> argParser, ApplicationData& appData) { appData._doseFileName = argParser->get<std::string>(argParser->OPTION_DOSE_FILE); - appData._doseLoadStyle = argParser->get<std::vector<std::string> >(argParser->OPTION_LOAD_STYLE); + appData._doseLoadStyle = argParser->get<std::string>(argParser->OPTION_LOAD_STYLE); appData._doseScaling = argParser->get<double>(argParser->OPTION_DOSE_SCALING); appData._outputFileName = argParser->get<std::string>(argParser->OPTION_OUTPUT_FILE); appData._model = argParser->get<std::string>(argParser->OPTION_MODEL); if (argParser->isSet(argParser->OPTION_MODEL_PARAMETERS)){ appData._modelParameters = argParser->get<std::vector<double> >(argParser->OPTION_MODEL_PARAMETERS); } else { appData._modelParameterMapsFilename = argParser->get<std::vector<std::string> >(argParser->OPTION_MODEL_PARAMETER_MAPS); - appData._parameterMapsLoadStyle = argParser->get<std::vector<std::string> >(argParser->OPTION_LOAD_STYLE_PARAMETER_MAPS); + appData._parameterMapsLoadStyle = argParser->get<std::string>(argParser->OPTION_LOAD_STYLE_PARAMETER_MAPS); } if (argParser->isSet(argParser->OPTION_N_FRACTIONS)){ appData._nFractions = argParser->get<unsigned int>(argParser->OPTION_N_FRACTIONS); } } } } } diff --git a/apps/BioModelCalc/BioModelCalcApplicationData.h b/apps/BioModelCalc/BioModelCalcApplicationData.h index 165e3e9..9a27136 100644 --- a/apps/BioModelCalc/BioModelCalcApplicationData.h +++ b/apps/BioModelCalc/BioModelCalcApplicationData.h @@ -1,74 +1,62 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ -/*! -// @file -// @version $Revision: 1210 $ (last changed revision) -// @date $Date: 2015-11-24 15:52:45 +0100 (Di, 24 Nov 2015) $ (last change date) -// @author $Author: hentsch $ (last changed by) -*/ - #ifndef __BIO_MODEL_CALC_APPLICATION_DATA_H #define __BIO_MODEL_CALC_APPLICATION_DATA_H #include <deque> #include <boost/shared_ptr.hpp> #include "rttbDoseAccessorInterface.h" namespace rttb { namespace apps { namespace bioModelCalc { class BioModelCmdLineParser; /*! @class ApplicationData @brief Class for storing all relevant variables needed in BioModelCalc */ class ApplicationData { public: - /**Vector of arguments used to specify the loading style (always the first argument) - * and, if needed, additional arguments for the specified loading style. - */ - typedef std::vector<std::string> LoadingStyleArgType; - core::DoseAccessorInterface::DoseAccessorPointer _dose; std::deque<core::AccessorInterface::AccessorPointer> _modelParameterMaps; std::string _doseFileName; - LoadingStyleArgType _doseLoadStyle; - LoadingStyleArgType _parameterMapsLoadStyle; + std::string _doseLoadStyle; + std::string _parameterMapsLoadStyle; double _doseScaling; unsigned int _nFractions; std::string _outputFileName; std::string _model; std::vector<double> _modelParameters; std::vector<std::string> _modelParameterMapsFilename; void reset(); ApplicationData(); }; /*! @brief Reads the necessary arguments from the BioModelCmdLineParser and writes them in the respective variables of ApplicationData */ void populateAppData(boost::shared_ptr<BioModelCmdLineParser> argParser, ApplicationData& appData); } } } #endif diff --git a/apps/BioModelCalc/BioModelCmdLineParser.cpp b/apps/BioModelCalc/BioModelCmdLineParser.cpp index 6738c9a..35d4fb8 100644 --- a/apps/BioModelCalc/BioModelCmdLineParser.cpp +++ b/apps/BioModelCalc/BioModelCmdLineParser.cpp @@ -1,125 +1,141 @@ +// ----------------------------------------------------------------------- +// 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. +// +//------------------------------------------------------------------------ + #include "BioModelCmdLineParser.h" namespace rttb { namespace apps { namespace bioModelCalc { BioModelCmdLineParser::BioModelCmdLineParser(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) : CmdLineParserBase(name, version, description, contributor, category) { //REQUIRED addOption<std::string>(OPTION_DOSE_FILE, OPTION_GROUP_REQUIRED, "The name of the dose file. Can be omitted if used as " "positional argument (see above).", 'd', true); addInformationForXML(OPTION_DOSE_FILE, cmdlineparsing::XMLGenerator::paramType::INPUT, { "*" }); addOption<std::string>(OPTION_OUTPUT_FILE, OPTION_GROUP_REQUIRED, "The name of the output file. Can be omitted if used as " "positional argument (see above).", 'o', true); addInformationForXML(OPTION_OUTPUT_FILE, cmdlineparsing::XMLGenerator::paramType::OUTPUT, { "*" }); addPositionalOption(OPTION_DOSE_FILE, 1); addPositionalOption(OPTION_OUTPUT_FILE, 1); addOptionWithDefaultValue<std::string>(OPTION_MODEL, OPTION_GROUP_REQUIRED, "The used radiobiological model the dose should be analyzed with. Available models are:\n \"LQ\", Formula: exp(-(alpha * D + beta * D^2/n))", "LQ", "LQ", 'm'); addInformationForXML(OPTION_MODEL, cmdlineparsing::XMLGenerator::paramType::STRINGENUMERATION, { "LQ" }); addOptionWithDefaultValue<double>(OPTION_DOSE_SCALING, OPTION_GROUP_REQUIRED, "Dose scaling that should be applied.", 1.0, "1.0", 'e'); addInformationForXML(OPTION_DOSE_SCALING, cmdlineparsing::XMLGenerator::paramType::DOUBLE); - std::vector<std::string> defaultLoadingStyle; - defaultLoadingStyle.push_back("itk"); + std::string defaultLoadingStyle; + defaultLoadingStyle = "itk"; - std::string doseLoadStyleDescription = "The loading style for the dose. Available styles are:\n" - "\"dicom\": normal dicom dose\n" - "\"itk\": use itk image loading\n" - "\"helax\": load a helax dose (choosing this style, the dose path should only be a directory)."; + std::string doseLoadStyleDescription = "The loading style for the dose. Available styles are:" + "\ndicom: normal dicom dose" + "\nitk: use itk image loading" + "\nitkDicom: use itk dicom image loading" + "\nhelax: load a helax dose (choosing this style, the dose path should only be a directory)."; - addOptionWithDefaultValue<std::vector<std::string> >(OPTION_LOAD_STYLE, OPTION_GROUP_REQUIRED, doseLoadStyleDescription, - defaultLoadingStyle, defaultLoadingStyle.at(0), + addOptionWithDefaultValue<std::string>(OPTION_LOAD_STYLE, OPTION_GROUP_REQUIRED, doseLoadStyleDescription, + defaultLoadingStyle, defaultLoadingStyle, 't', true, true); - addInformationForXML(OPTION_LOAD_STYLE, cmdlineparsing::XMLGenerator::paramType::STRINGENUMERATION, { "itk", "dicom", "helax" }); + addInformationForXML(OPTION_LOAD_STYLE, cmdlineparsing::XMLGenerator::paramType::STRING); //OPTIONAL addOption<std::vector<double> >(OPTION_MODEL_PARAMETERS, OPTION_GROUP_OPTIONAL, "The parameters for the radiobiological model.", 'p', false, true); addInformationForXML(OPTION_MODEL_PARAMETERS, cmdlineparsing::XMLGenerator::paramType::STRING); addOption<std::vector<std::string> >(OPTION_MODEL_PARAMETER_MAPS, OPTION_GROUP_OPTIONAL, "The parameters maps as itk readable image files for the radiobiological model.", 'a', false, true); addInformationForXML(OPTION_MODEL_PARAMETER_MAPS, cmdlineparsing::XMLGenerator::paramType::INPUT, { "*" }); addOption<unsigned int>(OPTION_N_FRACTIONS, OPTION_GROUP_OPTIONAL, "The number of fractions (n in the formula).", 'f'); addInformationForXML(OPTION_N_FRACTIONS, cmdlineparsing::XMLGenerator::paramType::INTEGER); - addOptionWithDefaultValue<std::vector<std::string> >(OPTION_LOAD_STYLE_PARAMETER_MAPS, OPTION_GROUP_OPTIONAL, doseLoadStyleDescription, - defaultLoadingStyle, defaultLoadingStyle.at(0), + addOptionWithDefaultValue<std::string>(OPTION_LOAD_STYLE_PARAMETER_MAPS, OPTION_GROUP_OPTIONAL, doseLoadStyleDescription, + defaultLoadingStyle, defaultLoadingStyle, 'u', true, true); - addInformationForXML(OPTION_LOAD_STYLE_PARAMETER_MAPS, cmdlineparsing::XMLGenerator::paramType::STRINGENUMERATION, { "itk", "dicom", "helax" }); + addInformationForXML(OPTION_LOAD_STYLE_PARAMETER_MAPS, cmdlineparsing::XMLGenerator::paramType::STRING); parse(argc, argv); } void BioModelCmdLineParser::validateInput() const { std::string model = get<std::string>(OPTION_MODEL); if (model != "LQ") { throw cmdlineparsing::InvalidConstraintException("Unknown model: " + model + ".\nPlease refer to the help for valid models."); } else { if (!isSet(OPTION_MODEL_PARAMETERS) && !isSet(OPTION_MODEL_PARAMETER_MAPS)){ throw cmdlineparsing::InvalidConstraintException("Either the model parameters or model parameter maps must be specified!"); } if ((isSet(OPTION_MODEL_PARAMETERS) && get<std::vector<double> >(OPTION_MODEL_PARAMETERS).size() != 2) || (isSet(OPTION_MODEL_PARAMETER_MAPS) && get<std::vector<std::string> >(OPTION_MODEL_PARAMETER_MAPS).size() != 2)) { throw cmdlineparsing::InvalidConstraintException("The LQ Model requires two parameters or parameter maps!"); } } - std::vector<std::string> loadStyle = get<std::vector<std::string> >(OPTION_LOAD_STYLE); - std::string loadStyleAbbreviation = loadStyle.at(0); + std::string loadStyle = get<std::string>(OPTION_LOAD_STYLE); - if (loadStyleAbbreviation != "dicom" - && loadStyleAbbreviation != "itk" - && loadStyleAbbreviation != "helax") + if (loadStyle != "dicom" + && loadStyle != "itk" + && loadStyle != "itkDicom" + && loadStyle != "helax") { - throw cmdlineparsing::InvalidConstraintException("Unknown load style: " + loadStyleAbbreviation + + throw cmdlineparsing::InvalidConstraintException("Unknown load style: " + loadStyle + ".\nPlease refer to the help for valid loading style settings."); } double doseScaling = get<double>(OPTION_DOSE_SCALING); if (doseScaling <= 0) { throw cmdlineparsing::InvalidConstraintException("Negative dose scaling is not allowed. Dose scaling has to be >0."); } } void BioModelCmdLineParser::printHelp() const { cmdlineparsing::CmdLineParserBase::printHelp(); std::cout << "Example:" << std::endl << std::endl; std::cout << m_programName << " dose.mhd result.mhd -m LQ -p 0.2 0.02" << std::endl << std::endl; std::cout << "This will calculate the Linear quadratic (LQ) BioModel from \"dose.mhd\" and will write the result to \"result.mhd\". " "The alpha and beta parameters for the LQ model are 0.2 and 0.02, respectively." << std::endl; } } } }