diff --git a/demoapps/CMakeLists.txt b/demoapps/CMakeLists.txt index 22ca34d..f9a355e 100644 --- a/demoapps/CMakeLists.txt +++ b/demoapps/CMakeLists.txt @@ -1,6 +1,11 @@ MESSAGE(STATUS "processing RTToolbox demo apps") OPTION(BUILD_DemoApp_DoseAcc "Determine if the demo application DoseAcc will be generated." OFF) IF(BUILD_DemoApp_DoseAcc) ADD_SUBDIRECTORY(DoseAcc) ENDIF(BUILD_DemoApp_DoseAcc) + +OPTION(BUILD_DemoApp_DoseMap "Determine if the demo application DoseMap will be generated." OFF) +IF(BUILD_DemoApp_DoseMap) +ADD_SUBDIRECTORY(DoseMap) +ENDIF(BUILD_DemoApp_DoseMap) diff --git a/demoapps/DoseMap/CMakeLists.txt b/demoapps/DoseMap/CMakeLists.txt new file mode 100644 index 0000000..89153d6 --- /dev/null +++ b/demoapps/DoseMap/CMakeLists.txt @@ -0,0 +1,3 @@ +MESSAGE (STATUS "generating demo app: DoseMap - simple dose mapping tool example") + +RTTB_CREATE_APPLICATION(DoseMap DEPENDS RTTBCore RTTBAlgorithms RTTBInterpolation RTTBMatchPointBinding RTTBITKIO RTTBVirtuosIO RTTBDicomIO RTTBHelaxIO PACKAGE_DEPENDS MatchPoint ITK) \ No newline at end of file diff --git a/demoapps/DoseMap/DoseMap.cpp b/demoapps/DoseMap/DoseMap.cpp new file mode 100644 index 0000000..7f790fa --- /dev/null +++ b/demoapps/DoseMap/DoseMap.cpp @@ -0,0 +1,201 @@ +// ----------------------------------------------------------------------- +// 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: 741 $ (last changed revision) +// @date $Date: 2014-09-16 16:34:22 +0200 (Di, 16 Sep 2014) $ (last change date) +// @author $Author: hentsch $ (last changed by) +*/ + +#include "DoseMapApplicationData.h" +#include "DoseMapHelper.h" + +#include "mapDummyRegistrationAlgorithm.h" + +rttb::apps::doseMap::ApplicationData appData; + +/** + Main function of dose mapper. + @retval 0 normal program execution + @retval 1 showed help or version (flag was set). + @retval 2 not enough required input files. + @retval 3 Argument parsing error + @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, char** argv) +{ + int result = 0; + + std::cout << "DoseMap - RTTB demo app for simple dose mapping." << std::endl; + + switch (rttb::apps::doseMap::ParseArgumentsForAppData(argc, argv, appData)) + { + case 1: + { + //showed version or help info. Done. + return 1; + } + + case 2: + { + std::cerr << "Missing Parameters. Use one of the following flags for more information:" << + std::endl; + std::cerr << "-? or --help" << std::endl; + return 2; + } + + case 3: + { + //wrong option usage. + return 3; + } + } + + if (appData._fileCount < 2) + { + std::cerr << "Missing Parameters. Use one of the following flags for more information:" << + std::endl; + std::cerr << "-? or --help" << std::endl; + return 1; + } + + std::cout << std::endl << "*******************************************" << std::endl; + std::cout << "Input dose file: " << appData._inputDoseFileName << 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; + } + + 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._inputDose = 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/demoapps/DoseMap/DoseMapApplicationData.cpp b/demoapps/DoseMap/DoseMapApplicationData.cpp new file mode 100644 index 0000000..4e4f189 --- /dev/null +++ b/demoapps/DoseMap/DoseMapApplicationData.cpp @@ -0,0 +1,175 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notices for more information. +// +//------------------------------------------------------------------------ +/*! +// @file +// @version $Revision: 741 $ (last changed revision) +// @date $Date: 2014-09-16 16:34:22 +0200 (Di, 16 Sep 2014) $ (last change date) +// @author $Author: hentsch $ (last changed by) +*/ + +#include "DoseMapApplicationData.h" + +#include "itksys/SystemTools.hxx" +#include "itksys/CommandLineArguments.hxx" + +#include "RTToolboxConfigure.h" + +namespace rttb +{ + namespace apps + { + namespace doseMap + { + + int unknown_argument(const char* argument, void* call_data) + { + std::cout << "Got unknown argument: \"" << argument << "\"" << std::endl; + return 0; + } + + ApplicationData:: + ApplicationData() + { + this->Reset(); + } + + void + ApplicationData:: + Reset() + { + _inputDoseFileName = ""; + _refDoseFileName = ""; + _outputFileName = ""; + _regFileName = ""; + + _interpolatorName = "linear"; + + _showVersion = false; + _showHelp = false; + + _fileCount = 0; + } + + unsigned int + ParseArgumentsForAppData(int argc, char** argv, ApplicationData& appData) + { + itksys::CommandLineArguments cmdParser; + + appData.Reset(); + + if (argc > 2) + { + appData._inputDoseFileName = argv[1]; + ++appData._fileCount; + --argc; + ++argv; + + appData._outputFileName = argv[1]; + ++appData._fileCount; + --argc; + ++argv; + } + + cmdParser.Initialize(argc, argv); + + cmdParser.SetUnknownArgumentCallback(unknown_argument); + + cmdParser.AddArgument("--interpolator", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._interpolatorName), + "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\"."); + cmdParser.AddArgument("-i", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._interpolatorName), + "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\"."); + + cmdParser.AddArgument("--registration", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._regFileName), + "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."); + cmdParser.AddArgument("-r", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._regFileName), + "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."); + + cmdParser.AddArgument("--template", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._refDoseFileName), + "Specifies name and location of the dose file that should be the reference/template for the grid to mapp into. If flag is not specified, the input dose is the reference."); + cmdParser.AddArgument("-t", itksys::CommandLineArguments::SPACE_ARGUMENT, + &(appData._refDoseFileName), + "Specifies name and location of the dose file that should be the reference/template for the grid to mapp into. If flag is not specified, the input dose is the reference."); + + cmdParser.AddArgument("--loadStyleInput", itksys::CommandLineArguments::MULTI_ARGUMENT, + &(appData._inputDoseLoadStyle), + "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)."); + + cmdParser.AddArgument("--loadStyleReference", itksys::CommandLineArguments::MULTI_ARGUMENT, + &(appData._refDoseLoadStyle), + "Indicates the load style that should be used for the reference 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. : \"--loadStyle2 virtuos myFavorite.pln\"); \"itk\": use itk image loading; \"helax\": load a helax dose (choosing this style, the dose path should only be a directory)."); + + cmdParser.AddArgument("-v", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showVersion), + "Shows the version of the program."); + + cmdParser.AddArgument("-h", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + cmdParser.AddArgument("--help", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + cmdParser.AddArgument("-?", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + cmdParser.AddArgument("/h", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + cmdParser.AddArgument("/?", itksys::CommandLineArguments::NO_ARGUMENT, &(appData._showHelp), + "Shows this help information for the program."); + + if (!cmdParser.Parse()) + { + std::cerr << "Wrong command line option or insufficient number of arguments." << std::endl; + std::cerr << "The last correct argument was: " << argv[cmdParser.GetLastArgument()] << std::endl << + "Use one of the following flags for more information:" << std::endl; + std::cerr << "-? or --help" << std::endl; + return 3; + }; + + if (appData._showHelp) + { + std::cout << std::endl << "Usage: " << std::endl << std::endl; + std::cout << " DoseMap [options]" << std::endl << std::endl; + std::cout << " Dose1: File path to the input dose." << std::endl; + std::cout << " DoseOutput: File path where the output should be stored." << std::endl << + std::endl; + std::cout << "Command-Line Options:" << std::endl << std::endl; + std::cout << cmdParser.GetHelp() << std::endl << std::endl; + std::cout << " Example:" << std::endl << std::endl; + std::cout << + " DoseMap dose1.mhd result.mhd -r reg.mapr --loadStyleInput itk --loadStyleReference 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; + return 1; + } + + if (appData._showVersion) + { + std::cout << std::endl << "Version: " << RTT_FULL_VERSION_STRING; + return 1; + } + + if (appData._fileCount < 2) + { + return 2; + } + + return 0; + }; + + } + } +} diff --git a/demoapps/DoseMap/DoseMapApplicationData.h b/demoapps/DoseMap/DoseMapApplicationData.h new file mode 100644 index 0000000..344aff0 --- /dev/null +++ b/demoapps/DoseMap/DoseMapApplicationData.h @@ -0,0 +1,87 @@ +// ----------------------------------------------------------------------- +// 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: 741 $ (last changed revision) +// @date $Date: 2014-09-16 16:34:22 +0200 (Di, 16 Sep 2014) $ (last change date) +// @author $Author: hentsch $ (last changed by) +*/ + + +#ifndef __DOSE_MAP_APPLICATION_DATA_H +#define __DOSE_MAP_APPLICATION_DATA_H + +#include "mapRegistration.h" + +#include "rttbBaseType.h" +#include "rttbDoseAccessorInterface.h" + +namespace rttb +{ + namespace apps + { + namespace 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). + */ + 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; + + bool _showVersion; + bool _showHelp; + + int _fileCount; + + void Reset(); + + ApplicationData(); + }; + + /** Parse the application argument passed when starting the application. + * If no error or special request occurred the return is 0. Otherwise the return values + * have the following meaning: \n + * 0: Normal parsing.\n + * 1: showed help or version (flag was set).\n + * 2: not enough required input files.\n + * 3: Parsing error.\n + * @param argc Number of parameter arguments + * @param argv Pointer to the passed arguments + * @return Result code of the parsing (see above).**/ + unsigned int ParseArgumentsForAppData(int argc, char** argv, ApplicationData& appData); + + } + } +} +#endif diff --git a/demoapps/DoseMap/DoseMapHelper.cpp b/demoapps/DoseMap/DoseMapHelper.cpp new file mode 100644 index 0000000..51bb0f0 --- /dev/null +++ b/demoapps/DoseMap/DoseMapHelper.cpp @@ -0,0 +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: 741 $ (last changed revision) +// @date $Date: 2014-09-16 16:34:22 +0200 (Di, 16 Sep 2014) $ (last change date) +// @author $Author: hentsch $ (last changed by) +*/ + + +#include "DoseMapHelper.h" + +#include "mapRegistrationFileReader.h" +#include "itkImageFileWriter.h" + +#include "rttbVirtuosPlanFileDoseAccessorGenerator.h" +#include "rttbDicomFileDoseAccessorGenerator.h" +#include "rttbDicomHelaxFileDoseAccessorGenerator.h" + +#include "rttbITKImageFileDoseAccessorGenerator.h" +#include "rttbDicomFileDoseAccessorGenerator.h" +#include "rttbSimpleMappableDoseAccessor.h" +#include "rttbMatchPointTransformation.h" +#include "rttbLinearInterpolation.h" +#include "rttbNearestNeighborInterpolation.h" +#include "rttbRosuMappableDoseAccessor.h" +#include "rttbITKImageDoseAccessorConverter.h" +#include "rttbArithmetic.h" +#include "rttbBinaryFunctorDoseAccessor.h" +#include "rttbExceptionMacros.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::ITKImageFileDoseAccessorGenerator 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::ITKImageDoseAccessorConverter converter(outputAccessor); + converter.setFailOnInvalidIDs(true); + converter.process(); + io::itk::ITKDoseImageType::Pointer itkImage = converter.getITKImage(); + std::cout << "done." << std::endl; + + typedef ::itk::ImageFileWriter WriterType; + + std::cout << std::endl << "write output image... "; + WriterType::Pointer writer = WriterType::New(); + writer->SetInput(itkImage); + writer->SetFileName(appData._outputFileName); + writer->Write(); + std::cout << "done." << std::endl; +}; diff --git a/demoapps/DoseMap/DoseMapHelper.h b/demoapps/DoseMap/DoseMapHelper.h new file mode 100644 index 0000000..b12ce94 --- /dev/null +++ b/demoapps/DoseMap/DoseMapHelper.h @@ -0,0 +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: 741 $ (last changed revision) +// @date $Date: 2014-09-16 16:34:22 +0200 (Di, 16 Sep 2014) $ (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); + + /**Containes 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/demoapps/DoseMap/files.cmake b/demoapps/DoseMap/files.cmake new file mode 100644 index 0000000..69e97c4 --- /dev/null +++ b/demoapps/DoseMap/files.cmake @@ -0,0 +1,13 @@ +SET(CPP_FILES +DoseMap.cpp +DoseMapHelper.cpp +DoseMapApplicationData.cpp +) + +SET(H_FILES +DoseMapHelper.h +DoseMapApplicationData.h +) + +SET(TPP_FILES +)