diff --git a/CMakeLists.txt b/CMakeLists.txt index d1fb6c6..b12d92b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,294 +1,292 @@ #----------------------------------------------------------------------------- # This is the root RTToolbox CMakeList file. #----------------------------------------------------------------------------- PROJECT(RTToolbox) -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11.2) -IF(CMAKE_BACKWARDS_COMPATIBILITY GREATER 2.8.11.2) - SET(CMAKE_BACKWARDS_COMPATIBILITY 2.8.11.2 CACHE STRING "Latest version of CMake when this project was released." FORCE) -ENDIF(CMAKE_BACKWARDS_COMPATIBILITY GREATER 2.8.11.2) +CMAKE_MINIMUM_REQUIRED(VERSION 3.1) # RTToolbox version number. SET(RTToolbox_VERSION_MAJOR "4") SET(RTToolbox_VERSION_MINOR "1") SET(RTToolbox_VERSION_PATCH "1") # Version string should not include patch level. The major.minor is # enough to distinguish available features of the toolbox. SET(RTToolbox_VERSION_STRING "${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}") SET(RTToolbox_FULL_VERSION_STRING "${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}.${RTToolbox_VERSION_PATCH}") # default build type SET(CMAKE_BUILD_TYPE Release) MARK_AS_ADVANCED(BUILD_SHARED_LIBS) IF (WIN32) IF (MSVC_VERSION LESS 1600) MESSAGE(FATAL_ERROR "RTToolbox requires at least Visual Studio 2010.") ENDIF(MSVC_VERSION LESS 1600) add_definitions(-D_SCL_SECURE_NO_WARNINGS) ELSE (WIN32) IF (CMAKE_COMPILER_IS_GNUCC) IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 5.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0) MESSAGE(AUTHOR_WARNING "RTToolbox was only tested with GCC 4.6 and GCC 4.9. You are using GCC " ${CMAKE_CXX_COMPILER_VERSION} ". This compiler version might not work.") ENDIF() ENDIF() ENDIF(WIN32) -IF (NOT (CMAKE_MAJOR_VERSION LESS 3)) - IF(COMMAND CMAKE_POLICY) - # Enable old CMake behaviour when dealing with export_library_dependencies(). - # This is necessary to avoid warnings in CMake versions - # greater than 3.0 - # See http://www.cmake.org/cmake/help/v3.0/policy/CMP0033.html - CMAKE_POLICY(SET CMP0033 OLD) - ENDIF(COMMAND CMAKE_POLICY) -ENDIF() +IF(COMMAND CMAKE_POLICY) + # Enable old CMake behaviour when dealing with export_library_dependencies(). + # This is necessary to avoid warnings in CMake versions + # greater than 3.0 + # See http://www.cmake.org/cmake/help/v3.0/policy/CMP0033.html + CMAKE_POLICY(SET CMP0033 OLD) +ENDIF(COMMAND CMAKE_POLICY) #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(cmake/MacroParseArguments.cmake) include(cmake/rttbMacroCreateModuleConf.cmake) include(cmake/rttbMacroCreateModule.cmake) include(cmake/rttbMacroCreateApplication.cmake) include(cmake/rttbMacroCheckModule.cmake) include(cmake/rttbMacroUseModule.cmake) include(cmake/rttbMacroCreateTestModule.cmake) include(cmake/rttbFunctionOrganizeSources.cmake) include(cmake/rttbMacroCreateApplicationTests.cmake) #----------------------------------------------------------------------------- # Basis config RTTB module infrastructure #----------------------------------------------------------------------------- set(RTTB_MODULES_CONF_DIR ${RTToolbox_BINARY_DIR}/modulesConf CACHE INTERNAL "Modules Conf") set(RTTB_MODULES_PACKAGE_DEPENDS_DIR ${RTToolbox_SOURCE_DIR}/cmake/PackageDepends) set(MODULES_PACKAGE_DEPENDS_DIRS ${RTTB_MODULES_PACKAGE_DEPENDS_DIR}) #----------------------------------------------------------------------------- # Testing setup # Configure Dart testing support. This should be done before any # MESSAGE(FATAL_ERROR ...) commands are invoked. #----------------------------------------------------------------------------- SET(CTEST_NEW_FORMAT 1) INCLUDE(CTest) ENABLE_TESTING() IF(BUILD_TESTING) CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/RemoveTemporaryFiles.cmake.in ${RTToolbox_BINARY_DIR}/cmake/RemoveTemporaryFiles.cmake @ONLY IMMEDIATE) CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/rttbSampleBuildTest.cmake.in ${RTToolbox_BINARY_DIR}/cmake/rttbSampleBuildTest.cmake @ONLY) CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/CTestCustom.ctest.in ${RTToolbox_BINARY_DIR}/cmake/CTestCustom.ctest @ONLY) FILE(WRITE ${RTToolbox_BINARY_DIR}/CTestCustom.cmake "INCLUDE(\"${RTToolbox_BINARY_DIR}/cmake/CTestCustom.ctest\")\n") SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard") MARK_AS_ADVANCED(BUILDNAME) ENDIF(BUILD_TESTING) #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- IF(NOT LIBRARY_OUTPUT_PATH) SET (LIBRARY_OUTPUT_PATH ${RTToolbox_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.") ENDIF(NOT LIBRARY_OUTPUT_PATH) IF(NOT EXECUTABLE_OUTPUT_PATH) SET (EXECUTABLE_OUTPUT_PATH ${RTToolbox_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.") ENDIF(NOT EXECUTABLE_OUTPUT_PATH) MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH) SET(RTToolbox_LIBRARY_PATH "${LIBRARY_OUTPUT_PATH}") SET(RTToolbox_EXECUTABLE_PATH "${EXECUTABLE_OUTPUT_PATH}") #----------------------------------------------------------------------------- # Find Doxygen. #----------------------------------------------------------------------------- FIND_PROGRAM(DOXYGEN_EXECUTABLE "doxygen") #----------------------------------------------------------------------------- # Installation vars. # RTToolbox_INSTALL_BIN_DIR - binary dir (executables) # RTToolbox_INSTALL_LIB_DIR - library dir (libs) # RTToolbox_INSTALL_INCLUDE_DIR - include dir (headers) # RTToolbox_INSTALL_NO_DEVELOPMENT - do not install development files # RTToolbox_INSTALL_NO_RUNTIME - do not install runtime files # RTToolbox_INSTALL_NO_DOCUMENTATION - do not install documentation files # Remark: needs directory are stored with no leading slash (CMake 2.4 and newer) #----------------------------------------------------------------------------- IF(NOT RTTOOLBOX_INSTALL_BIN_DIR) SET(RTTOOLBOX_INSTALL_BIN_DIR "bin") ENDIF(NOT RTTOOLBOX_INSTALL_BIN_DIR) IF(NOT RTTOOLBOX_INSTALL_LIB_DIR) SET(RTTOOLBOX_INSTALL_LIB_DIR "lib") ENDIF(NOT RTTOOLBOX_INSTALL_LIB_DIR) IF(NOT RTTOOLBOX_INSTALL_PACKAGE_DIR) SET(RTTOOLBOX_INSTALL_PACKAGE_DIR "lib") ENDIF(NOT RTTOOLBOX_INSTALL_PACKAGE_DIR) IF(NOT RTTOOLBOX_INSTALL_INCLUDE_DIR) SET(RTTOOLBOX_INSTALL_INCLUDE_DIR "include") ENDIF(NOT RTTOOLBOX_INSTALL_INCLUDE_DIR) IF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) SET(RTTOOLBOX_INSTALL_NO_DEVELOPMENT 0) ENDIF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) IF(NOT RTTOOLBOX_INSTALL_NO_RUNTIME) SET(RTTOOLBOX_INSTALL_NO_RUNTIME 0) ENDIF(NOT RTTOOLBOX_INSTALL_NO_RUNTIME) IF(NOT RTTOOLBOX_INSTALL_NO_DOCUMENTATION) SET(RTTOOLBOX_INSTALL_NO_DOCUMENTATION 0) ENDIF(NOT RTTOOLBOX_INSTALL_NO_DOCUMENTATION) SET(RTTOOLBOX_INSTALL_NO_LIBRARIES) IF(RTTOOLBOX_BUILD_SHARED_LIBS) IF(RTTOOLBOX_INSTALL_NO_RUNTIME AND RTTOOLBOX_INSTALL_NO_DEVELOPMENT) SET(RTTOOLBOX_INSTALL_NO_LIBRARIES 1) ENDIF(RTTOOLBOX_INSTALL_NO_RUNTIME AND RTTOOLBOX_INSTALL_NO_DEVELOPMENT) ELSE(RTTOOLBOX_BUILD_SHARED_LIBS) IF(RTTOOLBOX_INSTALL_NO_DEVELOPMENT) SET(RTTOOLBOX_INSTALL_NO_LIBRARIES 1) ENDIF(RTTOOLBOX_INSTALL_NO_DEVELOPMENT) ENDIF(RTTOOLBOX_BUILD_SHARED_LIBS) # set RTToolbox_DIR so it can be used by subprojects SET(RTToolbox_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "RTToolbox dir to be used by subprojects") #----------------------------------------------------------------------------- # DCMTK MT-Flag treat #----------------------------------------------------------------------------- option(RTTB_DCMTK_COMPLIANCE_ENFORCE_MT "This enforces the whole RTToolbox to be compiled with /MT,/MTd to be compliant with DCMTK" OFF) string(FIND ${CMAKE_GENERATOR} "Visual Studio" RTTB_VS_USED) if(RTTB_DCMTK_COMPLIANCE_ENFORCE_MT AND RTTB_VS_USED EQUAL 0) message(STATUS "Enforce DCMTK compliance: /MT and /MTd flags are used") string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) message(STATUS "CMAKE_C_FLAGS_DEBUG set to: ${CMAKE_C_FLAGS_DEBUG}") string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) message(STATUS "CMAKE_C_FLAGS_RELEASE set to: ${CMAKE_C_FLAGS_RELEASE}") string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) message(STATUS "CMAKE_C_FLAGS_MINSIZEREL set to: ${CMAKE_C_FLAGS_MINSIZEREL}") string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) message(STATUS "CMAKE_C_FLAGS_RELWITHDEBINFO set to: ${CMAKE_C_FLAGS_RELWITHDEBINFO}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) message(STATUS "CMAKE_CXX_FLAGS_DEBUG set to: ${CMAKE_CXX_FLAGS_DEBUG}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) message(STATUS "CMAKE_CXX_FLAGS_RELEASE set to: ${CMAKE_CXX_FLAGS_RELEASE}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL set to: ${CMAKE_CXX_FLAGS_MINSIZEREL}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO set to: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") endif() #----------------------------------------------------------------------------- # Advanced RTToolbox configuration #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # RTToolbox build configuration options. IF (WIN32) OPTION(BUILD_SHARED_LIBS "Build RTToolbox with shared libraries." OFF) ELSE (WIN32) OPTION(BUILD_SHARED_LIBS "Build RTToolbox with shared libraries." ON) ENDIF (WIN32) IF(NOT BUILD_SHARED_LIBS) IF(UNIX) MESSAGE(FATAL_ERROR "RTToolbox currently does not support a static build on unix like systems. We are working on that...") ENDIF(UNIX) ENDIF(NOT BUILD_SHARED_LIBS) SET(RTTB_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) IF(NOT RTToolbox_NO_LIBRARY_VERSION) # This setting of SOVERSION assumes that any API change # will increment either the minor or major version number of RTToolbox. SET(RTToolbox_LIBRARY_PROPERTIES VERSION "${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}.${RTToolbox_VERSION_PATCH}" SOVERSION "${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}" ) ENDIF(NOT RTToolbox_NO_LIBRARY_VERSION) #----------------------------------------------------------------------------- # Configure files with settings for use by the build. # #----------------------------------------------------------------------------- CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/RTToolboxConfigure.h.in ${RTToolbox_BINARY_DIR}/RTToolboxConfigure.h) IF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${RTToolbox_BINARY_DIR}/RTToolboxConfigure.h DESTINATION ${RTTOOLBOX_INSTALL_INCLUDE_DIR} COMPONENT Development) ENDIF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) #----------------------------------------------------------------------------- # The entire RTToolbox tree should use the same include path #----------------------------------------------------------------------------- #Default include dir. Others dirs will be defined by activated subprojects INCLUDE_DIRECTORIES(${RTToolbox_BINARY_DIR}) LINK_DIRECTORIES(${LIBARY_OUTPUT_PATH}) #Prepare the correct target information export by the subprojects SET(RTToolbox_TARGETS_FILE "${RTToolbox_BINARY_DIR}/RTToolboxTargets.cmake") FILE(WRITE ${RTToolbox_TARGETS_FILE} "# Generated by CMake, do not edit!") #----------------------------------------------------------------------------- # Dispatch the build into the proper subdirectories. #----------------------------------------------------------------------------- +OPTION(BUILD_Apps "Determine if the CLI applications will be generated." ON) MESSAGE (STATUS "generating Project RTToolbox") ADD_SUBDIRECTORY (code) -ADD_SUBDIRECTORY (demoapps) +IF (BUILD_Apps) + ADD_SUBDIRECTORY (apps) +ENDIF() IF (BUILD_TESTING) ADD_SUBDIRECTORY (testing) ENDIF (BUILD_TESTING) ADD_SUBDIRECTORY (documentation) #----------------------------------------------------------------------------- # Help other projects use RTToolbox. #----------------------------------------------------------------------------- EXPORT(PACKAGE RTToolbox) # Copy the UseRTToolbox.cmake file to the binary tree for backward compatability. CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/UseRTToolbox.cmake.in ${RTToolbox_BINARY_DIR}/UseRTToolbox.cmake COPYONLY IMMEDIATE) # Save library dependencies. EXPORT_LIBRARY_DEPENDENCIES(${RTToolbox_BINARY_DIR}/RTToolboxLibraryDepends.cmake) # Create the RTToolboxConfig.cmake file containing the RTToolbox configuration. INCLUDE (${RTToolbox_SOURCE_DIR}/rttbGenerateRTToolboxConfig.cmake) IF(NOT RTToolbox_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${RTToolbox_BINARY_DIR}/RTToolboxConfig.cmake ${RTToolbox_BINARY_DIR}/RTToolboxTargets.cmake ${RTToolbox_BINARY_DIR}/RTToolboxLibraryDepends.cmake ${RTToolbox_BINARY_DIR}/UseRTToolbox.cmake DESTINATION ${RTTOOLBOX_INSTALL_PACKAGE_DIR} COMPONENT Development ) ENDIF(NOT RTToolbox_INSTALL_NO_DEVELOPMENT) diff --git a/ReadMe.txt b/ReadMe.txt index c42645a..22f292a 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,174 +1,173 @@ RTToolbox - Read Me ---------------------------- ---------------------------- Compiler tests ---------------------------- RTToolbox is currently tested with the following compilers (only x64): -- Visual Studio 2010 - Visual Studio 2013 - GCC 4.6 - GCC 4.9 Needed Third Party Libraries ---------------------------- Please load and compile the following third party libraries/tools: Required: -1. CMake (version 2.8.11.2 or higher) +1. CMake (version 3.1 or higher) 2. boost (version 1.56.0 or higher) Optional: [3. Litmus (in this distribution; see \utilities\Litmus; if you want tests)] [4. dcmtk (with RT support - 3.6.1 or newer; if you want DICOM support)] [5. ITK (version 4.4 or higher; if you want DoseInterpolation support with itk::Transform or ITK File IO support)] [6. MatchPoint (version 0.11 or higher, see http://sourceforge.net/projects/matchpoint/; if you want DoseInterpolation support with MatchPoint Registration objects)] [7. doxygen (if you want to generate a source code documentation)] Installation Instruction ------------------------ Remark: To make sure everything runs smoothly, please make sure that all libraries and the RTToolbox are either compiled with \MD or \MT flags. If third party library packages cannot be found automatically, cmake will ask for them. Please give the location of the root folder, where the libraries where built for dcmtk, and Litmus. [A. If you build tests - Litmus] A.1. Configure Litmus with CMake (separated binary folder recommended) A.2. Build Litmus A.3. Enable BUILD_TESTING A.4. Press Configure A.5. Enable tests of interest A.6. Enable BUILD_RTToolbox_Test_examples if you want examples [B. If you build Helax or DICOM support - Boost] B.1. Build (using the same compiler options as RTToolbox, usually STATIC LINKING and x64 architecture). The component "filesystem" needs compilation. For all other modules, only the headers are required. [C. If you want DICOM support - DCMTK] For Windows: To compile DCMTK with \MD flags (standard for all other libs), you need to patch the CMAKE options of DCMTK (\\DCMTK\CMake\dcmtkPrepare.cmake), either by replacing "/MT" with "/MD" or by explicitly replacing lines 135 to 171 with the following lines: IF(DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS AND NOT BUILD_SHARED_LIBS) # settings for Microsoft Visual Studio IF(CMAKE_GENERATOR MATCHES "Visual Studio .*") # get Visual Studio Version STRING(REGEX REPLACE "Visual Studio ([0-9]+).*" "\\1" VS_VERSION "${CMAKE_GENERATOR}") # these settings never change even for C or C++ SET(CMAKE_C_FLAGS_DEBUG "/MDd /Z7 /Od") SET(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /MD /O2") SET(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /MD /O2") SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /MDd /Z7 /Od") SET(CMAKE_CXX_FLAGS_DEBUG "/MDd /Z7 /Od") SET(CMAKE_CXX_FLAGS_RELEASE "/DNDEBUG /MD /O2") SET(CMAKE_CXX_FLAGS_MINSIZEREL "/DNDEBUG /MD /O2") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/DNDEBUG /MDd /Z7 /Od") # specific settings for the various Visual Studio versions IF(VS_VERSION EQUAL 6) SET(CMAKE_C_FLAGS "/nologo /W3 /GX /Gy /YX") SET(CMAKE_CXX_FLAGS "/nologo /W3 /GX /Gy /YX /Zm500") # /Zm500 increments heap size which is needed on some system to compile templates in dcmimgle ENDIF(VS_VERSION EQUAL 6) IF(VS_VERSION EQUAL 7) SET(CMAKE_C_FLAGS "/nologo /W3 /Gy") SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy") ENDIF(VS_VERSION EQUAL 7) IF(VS_VERSION GREATER 7) SET(CMAKE_C_FLAGS "/nologo /W3 /Gy /EHsc") SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy /EHsc") ENDIF(VS_VERSION GREATER 7) ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio .*") ENDIF(DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS AND NOT BUILD_SHARED_LIBS) C.1. Configure DCMTK with CMake For unix-like systems: Set the CMake parameter DCMTK_FORCE_FPIC_ON_UNIX to true (It is an advanced parameter) C.2. Build DCMTK [D. If you want ITKIO or DoseInterpolation support with itk::Transform - ITK] D.1. Build ITK. [E. If you want support of DoseInterpolation with MatchPoint Registration objects - MatchPoint] E.1. Build MatchPoint. [F. Configure/Build RTToolbox] F.1. Configure with CMake F.1.1. Set BOOST_INCLUDE_DIR to the main boost directory (where "boost_build.jam" is located) REMARK: For the current version of the RTToolbox you do need to build boost only if you want to use the provided Helax-Dicom or DICOM data support. Otherwise you can use headers only. F.2. Select all packages you like to build (Parameters "BUILD_*"; e.g. BUILD_IO_Dicom) F.2.1. If you select BUILD_IO_DICOM the configuration will ask you for the DCMTK main directory (parameter DCMTK_DIR; where you have built DCMTK). REMARK: If you have built DCMTK as out source build you have to also set the CMake parameter DCMTK_SOURCE_DIR to the root directory of the DCMTK source. F.2.3. If you select BUILD_ITKBinding or BUILD_IO_ITK, set ITK_DIR to the binary directory of ITK F.2.3. If you select BUILD_MatchPointBinding, set MatchPoint_DIR to the binary directory of MatchPoint F.3. Generate CMake configuration F.4. Build RTToolbox and have fun! [G. Documentation] G.1. Generate the documentation using doxygen and the configuration found in "RTTB_binary_dir/documentation/doxygen.config". [H. Tests] H.1. Run tests (build RUN_TESTS project or ctest) to ensure that everything is correct. [I. Examples] I.1. Run tests (build RUN_TESTS project) to also build the examples. Be sure to have switched it on before (see A.6). These examples are a good starting point for own projects and show basic functionality of RTToolbox like DVH generation. Remarks ------- R.1. Virtuos Support: Virtuos is a proprietary data format and therefore not included in the RTToolbox. R.2. ITK Version: Only use one ITK version consistently throughout all libraries and RTToolbox! Otherwise, this will lead to linker errors. diff --git a/demoapps/BioModelCalc/BioModelCalc.cpp b/apps/BioModelCalc/BioModelCalc.cpp similarity index 91% rename from demoapps/BioModelCalc/BioModelCalc.cpp rename to apps/BioModelCalc/BioModelCalc.cpp index a51e823..3bf0fc6 100644 --- a/demoapps/BioModelCalc/BioModelCalc.cpp +++ b/apps/BioModelCalc/BioModelCalc.cpp @@ -1,133 +1,133 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1334 $ (last changed revision) +// @date $Date: 2016-04-22 11:13:22 +0200 (Fr, 22 Apr 2016) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #include "BioModelCalcApplicationData.h" #include "BioModelCalcHelper.h" #include "BioModelCmdLineParser.h" #include "boost/shared_ptr.hpp" #include "boost/make_shared.hpp" #include "RTToolboxConfigure.h" #include "rttbException.h" rttb::apps::bioModelCalc::ApplicationData appData; int main(int argc, const char** argv) { int result = 0; boost::shared_ptr argParser; try { std::string appName = "BioModelCalc"; 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 -1; } // 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; } rttb::apps::bioModelCalc::populateAppData(argParser, appData); std::cout << std::endl << "*******************************************" << std::endl; std::cout << "Dose file: " << appData._doseFileName << std::endl; std::cout << "Bio model output file: " << appData._outputFileName << std::endl; std::cout << "Model: " << appData._model << std::endl; std::cout << "Model parameters: "; for (size_t i = 0; i < appData._modelParameters.size(); i++) { if (i != 0) { std::cout << ", "; } std::cout << appData._modelParameters.at(i); } std::cout << std::endl; std::cout << "Dose scaling: " << appData._doseScaling << std::endl; std::cout << std::endl; try { appData._dose = rttb::apps::bioModelCalc::loadDose(appData._doseFileName, appData._doseLoadStyle); } catch (rttb::core::Exception& e) { std::cerr << "RTTB Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 1; } catch (const std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 1; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 1; } try { rttb::apps::bioModelCalc::processData(appData); } catch (rttb::core::Exception& e) { std::cerr << "RTTB Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 2; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 2; } catch (...) { std::cerr << "Error!!! unknown error while calculating the bioModel or writing the image." << std::endl; return 2; } return result; } diff --git a/demoapps/BioModelCalc/BioModelCalcApplicationData.cpp b/apps/BioModelCalc/BioModelCalcApplicationData.cpp similarity index 87% rename from demoapps/BioModelCalc/BioModelCalcApplicationData.cpp rename to apps/BioModelCalc/BioModelCalcApplicationData.cpp index ea35a91..0854fd8 100644 --- a/demoapps/BioModelCalc/BioModelCalcApplicationData.cpp +++ b/apps/BioModelCalc/BioModelCalcApplicationData.cpp @@ -1,57 +1,57 @@ // ----------------------------------------------------------------------- // 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) +// @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" namespace rttb { namespace apps { namespace bioModelCalc { ApplicationData:: ApplicationData() { this->Reset(); } void ApplicationData:: Reset() { _doseFileName = ""; _outputFileName = ""; _doseScaling = 1.0; } void populateAppData(boost::shared_ptr argParser, ApplicationData& appData) { appData._doseFileName = argParser->get(argParser->OPTION_DOSE_FILE); appData._doseLoadStyle = argParser->get >(argParser->OPTION_LOAD_STYLE); appData._doseScaling = argParser->get(argParser->OPTION_DOSE_SCALING); appData._outputFileName = argParser->get(argParser->OPTION_OUTPUT_FILE); appData._model = argParser->get(argParser->OPTION_MODEL); appData._modelParameters = argParser->get >(argParser->OPTION_MODEL_PARAMETERS); } } } } diff --git a/demoapps/BioModelCalc/BioModelCalcApplicationData.h b/apps/BioModelCalc/BioModelCalcApplicationData.h similarity index 88% rename from demoapps/BioModelCalc/BioModelCalcApplicationData.h rename to apps/BioModelCalc/BioModelCalcApplicationData.h index 43c7235..3804a41 100644 --- a/demoapps/BioModelCalc/BioModelCalcApplicationData.h +++ b/apps/BioModelCalc/BioModelCalcApplicationData.h @@ -1,69 +1,69 @@ // ----------------------------------------------------------------------- // 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) +// @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 #include "rttbDoseAccessorInterface.h" #include "BioModelCmdLineParser.h" namespace rttb { namespace apps { namespace bioModelCalc { /*! @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 (e.g. location of the * Virtuos plan file for the Virtuos IO style). */ typedef std::vector LoadingStyleArgType; core::DoseAccessorInterface::DoseAccessorPointer _dose; std::string _doseFileName; LoadingStyleArgType _doseLoadStyle; double _doseScaling; std::string _outputFileName; std::string _model; std::vector _modelParameters; 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 argParser, ApplicationData& appData); } } } #endif diff --git a/demoapps/BioModelCalc/BioModelCalcHelper.cpp b/apps/BioModelCalc/BioModelCalcHelper.cpp similarity index 93% rename from demoapps/BioModelCalc/BioModelCalcHelper.cpp rename to apps/BioModelCalc/BioModelCalcHelper.cpp index 990e9be..b833eaf 100644 --- a/demoapps/BioModelCalc/BioModelCalcHelper.cpp +++ b/apps/BioModelCalc/BioModelCalcHelper.cpp @@ -1,152 +1,152 @@ // ----------------------------------------------------------------------- // 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) +// @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 "BioModelCalcHelper.h" #include "boost/make_shared.hpp" #include "boost/shared_ptr.hpp" #include "rttbExceptionMacros.h" #include "rttbVirtuosPlanFileDoseAccessorGenerator.h" #include "rttbDicomFileDoseAccessorGenerator.h" #include "rttbDicomHelaxFileDoseAccessorGenerator.h" #include "rttbITKImageFileAccessorGenerator.h" #include "rttbITKImageAccessorConverter.h" #include "rttbImageWriter.h" #include "rttbLQModelAccessor.h" rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::bioModelCalc::loadDose(const std::string& fileName, const rttb::apps::bioModelCalc::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::bioModelCalc::loadDicomDose(const std::string& fileName) { rttb::io::dicom::DicomFileDoseAccessorGenerator generator(fileName); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::bioModelCalc::loadHelaxDose(const std::string& path) { rttb::io::helax::DicomHelaxFileDoseAccessorGenerator generator(path); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::bioModelCalc::loadITKDose(const std::string& fileName) { rttb::io::itk::ITKImageFileAccessorGenerator generator(fileName); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::bioModelCalc::loadVirtuosDose(const std::string& fileName, const std::string& planFileName) { rttb::io::virtuos::VirtuosPlanFileDoseAccessorGenerator generator(fileName, planFileName); return generator.generateDoseAccessor(); }; void rttb::apps::bioModelCalc::processData(rttb::apps::bioModelCalc::ApplicationData& appData) { rttb::core::DoseAccessorInterface::DoseAccessorPointer outputAccessor; std::cout << std::endl << "generate biomodel... "; auto bioModelAccessor = generateBioModel(appData._dose, appData._model, appData._modelParameters, appData._doseScaling); std::cout << "done." << std::endl; std::cout << std::endl << "generate output image... "; io::itk::ITKImageAccessorConverter converter(bioModelAccessor); 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); writer.writeFile(); std::cout << "done." << std::endl; }; rttb::core::AccessorInterface::AccessorPointer rttb::apps::bioModelCalc::generateBioModel( rttb::core::DoseAccessorInterface::DoseAccessorPointer dose, const std::string& model, const std::vector& modelParameters, double doseScaling) { if (model == "LQ") { return boost::make_shared(dose, modelParameters.at(0), modelParameters.at(1), doseScaling); } else { rttbDefaultExceptionStaticMacro( << "Unknown model selected. Cannot load data. Selected model: " << model); } } diff --git a/demoapps/BioModelCalc/BioModelCalcHelper.h b/apps/BioModelCalc/BioModelCalcHelper.h similarity index 91% rename from demoapps/BioModelCalc/BioModelCalcHelper.h rename to apps/BioModelCalc/BioModelCalcHelper.h index 28878aa..0d7300a 100644 --- a/demoapps/BioModelCalc/BioModelCalcHelper.h +++ b/apps/BioModelCalc/BioModelCalcHelper.h @@ -1,75 +1,75 @@ // ----------------------------------------------------------------------- // 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) +// @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_HELPER_H #define __BIO_MODEL_CALC_HELPER_H #include "BioModelCalcApplicationData.h" #include "rttbAccessorInterface.h" namespace rttb { namespace apps { namespace bioModelCalc { /*! @brief loads a dose from a file based on the loadingStyle. @details Throws an rttb::Exception if loading fails */ core::DoseAccessorInterface::DoseAccessorPointer loadDose(const std::string& fileName, const rttb::apps::bioModelCalc::ApplicationData::LoadingStyleArgType& args); /*! @brief loads a dicom dose from a file. @details Throws an rttb::Exception if loading fails @sa DicomFileDoseAccessorGenerator */ core::DoseAccessorInterface::DoseAccessorPointer loadDicomDose(const std::string& fileName); /*! @brief loads a helax dose from a file. @details Throws an rttb::Exception if loading fails @sa DicomHelaxFileDoseAccessorGenerator */ core::DoseAccessorInterface::DoseAccessorPointer loadHelaxDose(const std::string& path); /*! @brief loads an itk dose from a file. @details Throws an rttb::Exception if loading fails. Might be of all formats that ITK know (*.mhd, *.nrrd, ...). The absolute image values are taken as dose. @sa ITKImageFileAccessorGenerator */ core::DoseAccessorInterface::DoseAccessorPointer loadITKDose(const std::string& fileName); /*! @brief loads a virtuos dose from a file. @details Throws an rttb::Exception if loading fails @sa VirtuosPlanFileDoseAccessorGenerator */ core::DoseAccessorInterface::DoseAccessorPointer loadVirtuosDose(const std::string& fileName, const std::string& planFileName); /*! @brief Contains the business logic of processing all information to calculate a bioModel from the dose and writing it back to an image. @details Uses appData for the input data and the correct configuration. */ void processData(ApplicationData& appData); core::AccessorInterface::AccessorPointer generateBioModel( core::DoseAccessorInterface::DoseAccessorPointer dose, const std::string& model, const std::vector& modelParameters, double doseScaling = 1.0); } } } #endif diff --git a/demoapps/BioModelCalc/BioModelCmdLineParser.cpp b/apps/BioModelCalc/BioModelCmdLineParser.cpp similarity index 100% rename from demoapps/BioModelCalc/BioModelCmdLineParser.cpp rename to apps/BioModelCalc/BioModelCmdLineParser.cpp diff --git a/demoapps/BioModelCalc/BioModelCmdLineParser.h b/apps/BioModelCalc/BioModelCmdLineParser.h similarity index 100% rename from demoapps/BioModelCalc/BioModelCmdLineParser.h rename to apps/BioModelCalc/BioModelCmdLineParser.h diff --git a/demoapps/BioModelCalc/CMakeLists.txt b/apps/BioModelCalc/CMakeLists.txt similarity index 100% rename from demoapps/BioModelCalc/CMakeLists.txt rename to apps/BioModelCalc/CMakeLists.txt diff --git a/demoapps/BioModelCalc/files.cmake b/apps/BioModelCalc/files.cmake similarity index 100% rename from demoapps/BioModelCalc/files.cmake rename to apps/BioModelCalc/files.cmake diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt new file mode 100644 index 0000000..85f474d --- /dev/null +++ b/apps/CMakeLists.txt @@ -0,0 +1,55 @@ +MESSAGE(STATUS "processing RTToolbox apps") + +IF (BUILD_App_DoseTool OR BUILD_App_VoxelizerTool OR BUILD_App_BioModelCalc) + IF (WIN32) + IF (MSVC_VERSION LESS 1800) + MESSAGE(FATAL_ERROR "Some features of RTToolbox requires C++11 features that require Visual Studio 2013 or higher.") + ENDIF(MSVC_VERSION LESS 1800) + ENDIF(WIN32) + + #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") + + 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} + -DBoost_DIR:STRING=${Boost_DIR} + ) +ENDIF() + +OPTION(BUILD_App_DoseAcc "Determine if the application DoseAcc will be generated." OFF) +IF(BUILD_App_DoseAcc) + ADD_SUBDIRECTORY(DoseAcc) +ENDIF(BUILD_App_DoseAcc) + +OPTION(BUILD_App_DoseMap "Determine if the application DoseMap will be generated." OFF) +IF(BUILD_App_DoseMap) + ADD_SUBDIRECTORY(DoseMap) +ENDIF(BUILD_App_DoseMap) + +OPTION(BUILD_App_DoseTool "Determine if the application DoseTool will be generated." OFF) +IF(BUILD_App_DoseTool) + ADD_SUBDIRECTORY(DoseTool) +ENDIF(BUILD_App_DoseTool) + +OPTION(BUILD_App_VoxelizerTool "Determine if the application VoxelizerTool will be generated." OFF) +IF(BUILD_App_VoxelizerTool) + ADD_SUBDIRECTORY(VoxelizerTool) +ENDIF(BUILD_App_VoxelizerTool) + +OPTION(BUILD_App_BioModelCalc "Determine if the application BioModelCalc will be generated." OFF) +IF(BUILD_App_BioModelCalc) + ADD_SUBDIRECTORY(BioModelCalc) +ENDIF(BUILD_App_BioModelCalc) \ No newline at end of file diff --git a/demoapps/DoseAcc/CMakeLists.txt b/apps/DoseAcc/CMakeLists.txt similarity index 100% rename from demoapps/DoseAcc/CMakeLists.txt rename to apps/DoseAcc/CMakeLists.txt diff --git a/demoapps/DoseAcc/DoseAcc.cpp b/apps/DoseAcc/DoseAcc.cpp similarity index 92% rename from demoapps/DoseAcc/DoseAcc.cpp rename to apps/DoseAcc/DoseAcc.cpp index f7f3cf0..e62339d 100644 --- a/demoapps/DoseAcc/DoseAcc.cpp +++ b/apps/DoseAcc/DoseAcc.cpp @@ -1,172 +1,172 @@ // ----------------------------------------------------------------------- // 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) +// @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" rttb::apps::doseAcc::ApplicationData appData; int main(int argc, char** argv) { int result = 0; std::cout << "DoseAcc - RTTB demo app for simple dose accumulation." << std::endl; switch (rttb::apps::doseAcc::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 < 3) { 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 << "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; try { appData._Dose1 = rttb::apps::doseAcc::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::apps::doseAcc::loadDose(appData._dose2FileName, appData._dose2LoadStyle); } 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/demoapps/DoseAcc/DoseAccApplicationData.cpp b/apps/DoseAcc/DoseAccApplicationData.cpp similarity index 96% rename from demoapps/DoseAcc/DoseAccApplicationData.cpp rename to apps/DoseAcc/DoseAccApplicationData.cpp index 50524fa..dbbf9e4 100644 --- a/demoapps/DoseAcc/DoseAccApplicationData.cpp +++ b/apps/DoseAcc/DoseAccApplicationData.cpp @@ -1,202 +1,202 @@ // ----------------------------------------------------------------------- // 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) +// @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 "DoseAccApplicationData.h" #include "itksys/SystemTools.hxx" #include "itksys/CommandLineArguments.hxx" #include "RTToolboxConfigure.h" namespace rttb { namespace apps { namespace doseAcc { 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() { _dose1FileName = ""; _dose2FileName = ""; _outputFileName = ""; _regFileName = ""; _interpolatorName = "linear"; _showVersion = false; _showHelp = false; _weightDose1 = 1.0; _weightDose2 = 1.0; _fileCount = 0; _operator = "+"; } unsigned int ParseArgumentsForAppData(int argc, char** argv, ApplicationData& appData) { itksys::CommandLineArguments cmdParser; appData.Reset(); if (argc > 3) { appData._dose1FileName = argv[1]; ++appData._fileCount; --argc; ++argv; appData._dose2FileName = 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 neighbor, \"linear\": linear interpolation, \"rosu\" interpolation based on the concept of Rosu et al.. Default interpolator is \"linear\"."); cmdParser.AddArgument("--weight1", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose1), "Specifies the weight for dose 1. If not specified the weight is 1.0."); cmdParser.AddArgument("-w1", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose1), "Specifies the weight for dose 1. If not specified the weight is 1.0."); cmdParser.AddArgument("--weight2", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose2), "Specifies the weight for dose 2. If not specified the weight is 1.0."); cmdParser.AddArgument("-w2", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._weightDose2), "Specifies the weight for dose 2. If not specified the weight is 1.0."); cmdParser.AddArgument("--registration", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._regFileName), "Specifies name and location of the registration file that should be used to map dose 2 before accumulating it with dose 1. Default is no mapping, thus direct accumulation. 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 dose 2 before accumulating it with dose 1. Default is no mapping, thus direct accumulation. The registration should be stored as MatchPoint registration."); cmdParser.AddArgument("--loadStyle1", itksys::CommandLineArguments::MULTI_ARGUMENT, &(appData._dose1LoadStyle), "Indicates the load style that should be used for dose 1. 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("--loadStyle2", itksys::CommandLineArguments::MULTI_ARGUMENT, &(appData._dose2LoadStyle), "Indicates the load style that should be used for dose 2. 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("--operator", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._operator), "Specifies the operator used. Available operators are '+' and '*'. If not specified the operator is '+'."); cmdParser.AddArgument("-o", itksys::CommandLineArguments::SPACE_ARGUMENT, &(appData._operator), "Specifies the operator used. Available operators are '+' and '*'. If not specified the operator is '+'."); 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 << " DoseAcc [options]" << std::endl << std::endl; std::cout << " Dose1: File path to the 1st dose." << std::endl; std::cout << " Dose2: File path to the 2nd 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 << " DoseAcc dose1.mhd dose2.mhd result.mhd --loadStyle1 itk --loadStyle2 itk -w1 2 -r reg.mapr" << std::endl << std::endl; std::cout << " This will accumulate \"dose1.mhd\" and \"dose2.mhd\" by using \"reg.mapr\" to map dose 2. For the accumulation, dose 1 will be multiplied by 2. The resulting dose will be stored in \"result.mhd\"." << std::endl << std::endl; std::cout << " DoseAcc dose1.dcm dose2.dos.gz result.mhd --loadStyle2 virtuos dose2.pln -r reg.mapr" << std::endl << std::endl; std::cout << " This will accumulate \"dose1.dcm\" (using default dicom io) and \"dose2.dos.gz\" (using virtuos io and plan file dose2.pln) by using \"reg.mapr\" to map dose 2. The resulting dose will be stored in \"result.mhd\"." << std::endl; return 1; } if (appData._showVersion) { std::cout << std::endl << "Version: " << RTTB_FULL_VERSION_STRING; return 1; } if (appData._fileCount < 3) { return 2; } return 0; }; } } } diff --git a/demoapps/DoseAcc/DoseAccApplicationData.h b/apps/DoseAcc/DoseAccApplicationData.h similarity index 90% rename from demoapps/DoseAcc/DoseAccApplicationData.h rename to apps/DoseAcc/DoseAccApplicationData.h index df820ce..eb0e838 100644 --- a/demoapps/DoseAcc/DoseAccApplicationData.h +++ b/apps/DoseAcc/DoseAccApplicationData.h @@ -1,90 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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) */ #ifndef __DOSE_ACCAPPLICATION_DATA_H #define __DOSE_ACCAPPLICATION_DATA_H #include "mapRegistration.h" #include "rttbBaseType.h" #include "rttbDoseAccessorInterface.h" namespace rttb { namespace apps { namespace doseAcc { 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 _Dose1; std::string _dose1FileName; LoadingStyleArgType _dose1LoadStyle; core::DoseAccessorInterface::DoseAccessorPointer _Dose2; std::string _dose2FileName; LoadingStyleArgType _dose2LoadStyle; RegistrationType::Pointer _spReg; std::string _regFileName; std::string _operator; std::string _outputFileName; double _weightDose1; double _weightDose2; 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/DoseAcc/DoseAccHelper.cpp b/apps/DoseAcc/DoseAccHelper.cpp similarity index 95% rename from demoapps/DoseAcc/DoseAccHelper.cpp rename to apps/DoseAcc/DoseAccHelper.cpp index 6e06468..2172467 100644 --- a/demoapps/DoseAcc/DoseAccHelper.cpp +++ b/apps/DoseAcc/DoseAccHelper.cpp @@ -1,266 +1,266 @@ // ----------------------------------------------------------------------- // 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) +// @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 "mapRegistrationFileReader.h" #include "itkImageFileWriter.h" #include "rttbExceptionMacros.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" rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseAcc::loadDose(const std::string& fileName, const rttb::apps::doseAcc::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::doseAcc::loadDicomDose(const std::string& fileName) { rttb::io::dicom::DicomFileDoseAccessorGenerator generator(fileName); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseAcc::loadHelaxDose(const std::string& path) { rttb::io::helax::DicomHelaxFileDoseAccessorGenerator generator(path); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseAcc::loadITKDose(const std::string& fileName) { rttb::io::itk::ITKImageFileAccessorGenerator generator(fileName); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseAcc::loadVirtuosDose(const std::string& fileName, const std::string& planFileName) { rttb::io::virtuos::VirtuosPlanFileDoseAccessorGenerator generator(fileName, planFileName); return generator.generateDoseAccessor(); }; 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::DoseAccessorPointer generateNNMappableAccessor( const rttb::core::GeometricInfo& geoInfoTargetImage, const rttb::core::DoseAccessorInterface::DoseAccessorPointer doseMovingImage, const rttb::interpolation::TransformationInterface::Pointer aTransformation) { rttb::interpolation::InterpolationBase::Pointer interpolate = rttb::interpolation::NearestNeighborInterpolation::Pointer(new rttb::interpolation::NearestNeighborInterpolation()); return rttb::core::DoseAccessorInterface::DoseAccessorPointer( new rttb::interpolation::SimpleMappableDoseAccessor(geoInfoTargetImage, doseMovingImage, aTransformation, interpolate)); } rttb::core::DoseAccessorInterface::DoseAccessorPointer generateLinearMappableAccessor( const rttb::core::GeometricInfo& geoInfoTargetImage, const rttb::core::DoseAccessorInterface::DoseAccessorPointer doseMovingImage, const rttb::interpolation::TransformationInterface::Pointer aTransformation) { rttb::interpolation::InterpolationBase::Pointer interpolate = rttb::interpolation::LinearInterpolation::Pointer(new rttb::interpolation::LinearInterpolation()); return rttb::core::DoseAccessorInterface::DoseAccessorPointer( new rttb::interpolation::SimpleMappableDoseAccessor(geoInfoTargetImage, doseMovingImage, aTransformation, interpolate)); } rttb::core::DoseAccessorInterface::DoseAccessorPointer generateRosuMappableAccessor( const rttb::core::GeometricInfo& geoInfoTargetImage, const rttb::core::DoseAccessorInterface::DoseAccessorPointer doseMovingImage, const rttb::interpolation::TransformationInterface::Pointer aTransformation) { return rttb::core::DoseAccessorInterface::DoseAccessorPointer( new rttb::interpolation::RosuMappableDoseAccessor(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::DoseAccessorPointer assembleOutputAccessor(rttb::apps::doseAcc::ApplicationData& appData) { rttb::core::DoseAccessorInterface::DoseAccessorPointer dose2Accessor = appData._Dose2; if (appData._spReg.IsNotNull()) { rttb::interpolation::TransformationInterface::Pointer transform = rttb::interpolation::TransformationInterface::Pointer(new rttb::interpolation::MatchPointTransformation(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::DoseAccessorPointer outputAccessor; if (appData._operator == "+") { rttb::algorithms::arithmetic::doseOp::AddWeighted addOp(appData._weightDose1, appData._weightDose2); outputAccessor = rttb::core::DoseAccessorInterface::DoseAccessorPointer(new rttb::algorithms::BinaryFunctorAccessor (appData._Dose1, dose2Accessor, addOp)); } else if (appData._operator == "*") { outputAccessor = rttb::core::DoseAccessorInterface::DoseAccessorPointer(new rttb::algorithms::BinaryFunctorAccessor (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::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; typedef ::itk::ImageFileWriter WriterType; std::cout << std::endl << "write output image... "; WriterType::Pointer writer = WriterType::New(); writer->SetInput(itkImage); writer->SetFileName(appData._outputFileName); writer->SetUseCompression(true); writer->Write(); std::cout << "done." << std::endl; }; diff --git a/demoapps/DoseAcc/DoseAccHelper.h b/apps/DoseAcc/DoseAccHelper.h similarity index 90% rename from demoapps/DoseAcc/DoseAccHelper.h rename to apps/DoseAcc/DoseAccHelper.h index 75e83b5..0d0ce43 100644 --- a/demoapps/DoseAcc/DoseAccHelper.h +++ b/apps/DoseAcc/DoseAccHelper.h @@ -1,58 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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 "DoseAccApplicationData.h" namespace rttb { namespace apps { namespace doseAcc { /**loads the dose from a file. Throws exception if loading fails*/ core::DoseAccessorInterface::DoseAccessorPointer loadDose(const std::string& fileName, const rttb::apps::doseAcc::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/DoseAcc/files.cmake b/apps/DoseAcc/files.cmake similarity index 100% rename from demoapps/DoseAcc/files.cmake rename to apps/DoseAcc/files.cmake diff --git a/demoapps/DoseMap/CMakeLists.txt b/apps/DoseMap/CMakeLists.txt similarity index 100% rename from demoapps/DoseMap/CMakeLists.txt rename to apps/DoseMap/CMakeLists.txt diff --git a/demoapps/DoseMap/DoseMap.cpp b/apps/DoseMap/DoseMap.cpp similarity index 92% rename from demoapps/DoseMap/DoseMap.cpp rename to apps/DoseMap/DoseMap.cpp index ec0218b..5380149 100644 --- a/demoapps/DoseMap/DoseMap.cpp +++ b/apps/DoseMap/DoseMap.cpp @@ -1,201 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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 "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._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/demoapps/DoseMap/DoseMapApplicationData.cpp b/apps/DoseMap/DoseMapApplicationData.cpp similarity index 95% rename from demoapps/DoseMap/DoseMapApplicationData.cpp rename to apps/DoseMap/DoseMapApplicationData.cpp index b893065..b3cf506 100644 --- a/demoapps/DoseMap/DoseMapApplicationData.cpp +++ b/apps/DoseMap/DoseMapApplicationData.cpp @@ -1,175 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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 "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: " << RTTB_FULL_VERSION_STRING; return 1; } if (appData._fileCount < 2) { return 2; } return 0; }; } } } diff --git a/demoapps/DoseMap/DoseMapApplicationData.h b/apps/DoseMap/DoseMapApplicationData.h similarity index 90% rename from demoapps/DoseMap/DoseMapApplicationData.h rename to apps/DoseMap/DoseMapApplicationData.h index 20116be..737b0c6 100644 --- a/demoapps/DoseMap/DoseMapApplicationData.h +++ b/apps/DoseMap/DoseMapApplicationData.h @@ -1,87 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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_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/apps/DoseMap/DoseMapHelper.cpp similarity index 94% rename from demoapps/DoseMap/DoseMapHelper.cpp rename to apps/DoseMap/DoseMapHelper.cpp index 18f23c9..97d58c4 100644 --- a/demoapps/DoseMap/DoseMapHelper.cpp +++ b/apps/DoseMap/DoseMapHelper.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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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 "itkImageFileWriter.h" #include "rttbVirtuosPlanFileDoseAccessorGenerator.h" #include "rttbDicomFileDoseAccessorGenerator.h" #include "rttbDicomHelaxFileDoseAccessorGenerator.h" #include "rttbITKImageAccessorConverter.h" #include "rttbDicomFileDoseAccessorGenerator.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" 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; 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/apps/DoseMap/DoseMapHelper.h similarity index 90% rename from demoapps/DoseMap/DoseMapHelper.h rename to apps/DoseMap/DoseMapHelper.h index 9ba6942..1704090 100644 --- a/demoapps/DoseMap/DoseMapHelper.h +++ b/apps/DoseMap/DoseMapHelper.h @@ -1,58 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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); /**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/apps/DoseMap/files.cmake similarity index 100% rename from demoapps/DoseMap/files.cmake rename to apps/DoseMap/files.cmake diff --git a/demoapps/DoseTool/CMakeLists.txt b/apps/DoseTool/CMakeLists.txt similarity index 100% rename from demoapps/DoseTool/CMakeLists.txt rename to apps/DoseTool/CMakeLists.txt diff --git a/demoapps/DoseTool/DoseTool.cpp b/apps/DoseTool/DoseTool.cpp similarity index 92% rename from demoapps/DoseTool/DoseTool.cpp rename to apps/DoseTool/DoseTool.cpp index 6ef4227..a39352d 100644 --- a/demoapps/DoseTool/DoseTool.cpp +++ b/apps/DoseTool/DoseTool.cpp @@ -1,160 +1,160 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1315 $ (last changed revision) +// @date $Date: 2016-04-12 14:18:24 +0200 (Di, 12 Apr 2016) $ (last change date) +// @author $Author: floca $ (last changed by) */ #include "DoseToolApplicationData.h" #include "DoseToolHelper.h" #include "DoseToolCmdLineParser.h" #include "boost/shared_ptr.hpp" #include "boost/make_shared.hpp" #include "RTToolboxConfigure.h" #include "rttbException.h" rttb::apps::doseTool::ApplicationData appData; int main(int argc, const char** argv) { int result = 0; boost::shared_ptr argParser; try { std::string appName = "DoseTool"; 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 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)) { return 0; } rttb::apps::doseTool::populateAppData(argParser, appData); std::cout << std::endl << "*******************************************" << std::endl; std::cout << "Dose file: " << appData._doseFileName << std::endl; std::cout << "Struct file: " << appData._structFileName << std::endl; std::cout << "Struct name: " << appData._structNameRegex << std::endl; if (appData._computeDoseStatistics) { std::cout << "Dose statistic output file: " << appData._doseStatisticOutputFileName << std::endl; std::cout << "Compute complex statistics: " << appData._computeComplexDoseStatistics << std::endl; if (appData._computeComplexDoseStatistics) { std::cout << "Prescribed dose: " << appData._prescribedDose << std::endl; } std::cout << "Allow self intersections: " << appData._allowSelfIntersection << std::endl; } if (appData._computeDVH) { std::cout << "DVH output file: " << appData._dvhOutputFilename << std::endl; } try { appData._dose = rttb::apps::doseTool::loadDose(appData._doseFileName, appData._doseLoadStyle); } catch (rttb::core::Exception& e) { std::cerr << "RTTB Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 1; } catch (const std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 1; } catch (...) { std::cerr << "Error!!! unknown error while reading dose image." << std::endl; return 1; } //loading of structure file not necessary in ITK case as it can be used directly as mask input. if (appData._structLoadStyle.front() != "itk") { try { appData._struct = rttb::apps::doseTool::loadStruct(appData._structFileName, appData._structLoadStyle, appData._structNameRegex); } catch (rttb::core::Exception& e) { std::cerr << "RTTB Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 2; } catch (const std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 2; } catch (...) { std::cerr << "Error!!! unknown error while reading struct image." << std::endl; return 2; } } try { rttb::apps::doseTool::processData(appData); } catch (rttb::core::Exception& e) { std::cerr << "RTTB Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 3; } catch (std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 3; } catch (...) { std::cerr << "Error!!! unknown error while processing the data or writing the image." << std::endl; return 3; } return result; } diff --git a/demoapps/DoseTool/DoseToolApplicationData.cpp b/apps/DoseTool/DoseToolApplicationData.cpp similarity index 91% rename from demoapps/DoseTool/DoseToolApplicationData.cpp rename to apps/DoseTool/DoseToolApplicationData.cpp index 4e6b40f..f961c92 100644 --- a/demoapps/DoseTool/DoseToolApplicationData.cpp +++ b/apps/DoseTool/DoseToolApplicationData.cpp @@ -1,91 +1,91 @@ // ----------------------------------------------------------------------- // 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) +// @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 "DoseToolApplicationData.h" namespace rttb { namespace apps { namespace doseTool { ApplicationData:: ApplicationData() { this->reset(); } void ApplicationData:: reset() { _doseFileName = ""; _structFileName = ""; _structNameRegex = ""; _doseStatisticOutputFileName = ""; _computeComplexDoseStatistics = false; _allowSelfIntersection = false; _structIndices.clear(); _structNames.clear(); _prescribedDose = 1.0; _multipleStructsMode = false; _computeDVH = false; _computeDoseStatistics = false; } void populateAppData(boost::shared_ptr argParser, ApplicationData& appData) { appData._doseFileName = argParser->get(argParser->OPTION_DOSE_FILE); appData._doseLoadStyle = argParser->get > (argParser->OPTION_DOSE_LOAD_STYLE); appData._structFileName = argParser->get(argParser->OPTION_STRUCT_FILE); appData._structLoadStyle = argParser->get > (argParser->OPTION_STRUCT_LOAD_STYLE); appData._structNameRegex = argParser->get(argParser->OPTION_STRUCT_NAME); appData._multipleStructsMode = argParser->isSet(argParser->OPTION_MULTIPLE_STRUCTS_MODE); if (argParser->isSet(argParser->OPTION_DOSE_STATISTICS)) { appData._computeDoseStatistics = true; appData._doseStatisticOutputFileName = argParser->get (argParser->OPTION_DOSE_STATISTICS); appData._computeComplexDoseStatistics = argParser->isSet(argParser->OPTION_COMPLEX_STATISTICS); appData._allowSelfIntersection = argParser->isSet(argParser->OPTION_ALLOW_SELF_INTERSECTION_STRUCT); } if (argParser->isSet(argParser->OPTION_DVH)) { appData._computeDVH = true; appData._dvhOutputFilename = argParser->get(argParser->OPTION_DVH); } if (argParser->isSet(argParser->OPTION_DOSE_STATISTICS) && argParser->isSet(argParser->OPTION_PRESCRIBED_DOSE)) { appData._prescribedDose = argParser->get(argParser->OPTION_PRESCRIBED_DOSE); } } } } } diff --git a/demoapps/DoseTool/DoseToolApplicationData.h b/apps/DoseTool/DoseToolApplicationData.h similarity index 90% rename from demoapps/DoseTool/DoseToolApplicationData.h rename to apps/DoseTool/DoseToolApplicationData.h index 6e44258..bc79970 100644 --- a/demoapps/DoseTool/DoseToolApplicationData.h +++ b/apps/DoseTool/DoseToolApplicationData.h @@ -1,79 +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) +// @version $Revision: 1070 $ (last changed revision) +// @date $Date: 2015-08-19 14:50:28 +0200 (Mi, 19 Aug 2015) $ (last change date) +// @author $Author: floca $ (last changed by) */ #ifndef __DOSETOOL_APPLICATION_DATA_H #define __DOSETOOL_APPLICATION_DATA_H #include #include "rttbDoseAccessorInterface.h" #include "rttbStructureSetGeneratorInterface.h" #include "DoseToolCmdLineParser.h" namespace rttb { namespace apps { namespace doseTool { /*! @class ApplicationData @brief Class for storing all relevant variables needed in DoseTool */ 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 (e.g. location of the * Virtuos plan file for the Virtuos IO style). */ typedef std::vector LoadingStyleArgType; core::DoseAccessorInterface::DoseAccessorPointer _dose; core::StructureSetGeneratorInterface::StructureSetPointer _struct; std::string _structNameRegex; std::vector _structIndices; std::vector _structNames; std::string _doseFileName; std::string _structFileName; LoadingStyleArgType _doseLoadStyle; LoadingStyleArgType _structLoadStyle; bool _computeComplexDoseStatistics; DoseTypeGy _prescribedDose; std::string _doseStatisticOutputFileName; bool _allowSelfIntersection; bool _multipleStructsMode; bool _computeDVH; bool _computeDoseStatistics; std::string _dvhOutputFilename; /*! @brief Resets the variables. _prescribedDose is set to 1.0 because it produces no exception then (as it is not needed). Consistency checks are done in DoseToolCmdLineParser::validateInput() */ 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/demoapps/DoseTool/DoseToolCmdLineParser.cpp b/apps/DoseTool/DoseToolCmdLineParser.cpp similarity index 95% rename from demoapps/DoseTool/DoseToolCmdLineParser.cpp rename to apps/DoseTool/DoseToolCmdLineParser.cpp index 291301e..4cf4342 100644 --- a/demoapps/DoseTool/DoseToolCmdLineParser.cpp +++ b/apps/DoseTool/DoseToolCmdLineParser.cpp @@ -1,184 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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 "DoseToolCmdLineParser.h" namespace rttb { namespace apps { namespace doseTool { DoseToolCmdLineParser::DoseToolCmdLineParser(int argc, const char** argv, const std::string& name, const std::string& version) : CmdLineParserBase(name, version) { typedef double DoseTypeGy; addOption(OPTION_DOSE_FILE, OPTION_GROUP_REQUIRED, "The name of the dose file. Can be omitted if used as " "positional argument (see above).", 'd', true); addOption(OPTION_STRUCT_FILE, OPTION_GROUP_REQUIRED, "The name of the struct file. Can be omitted if used as " "positional argument (see above).", 's', true); addOptionWithDefaultValue(OPTION_STRUCT_NAME, OPTION_GROUP_REQUIRED, "The name of the struct as regular expression. Can be omitted if used as " "positional argument or with itk struct loadingStyle (see above).", "", "", 'n', true); addPositionalOption(OPTION_DOSE_FILE, 1); addPositionalOption(OPTION_STRUCT_FILE, 1); addPositionalOption(OPTION_STRUCT_NAME, 1); addPositionalOption(OPTION_DOSE_STATISTICS, 1); std::vector defaultLoadingStyle; defaultLoadingStyle.push_back("dicom"); addOptionWithDefaultValue >(OPTION_DOSE_LOAD_STYLE, OPTION_GROUP_REQUIRED, "The loading style for the dose. Available styles are:\n" "\"dicom\": normal dicom dose\n" "\"virtuos\": load of a virtuos dose (This style is a multi argument. The second argument specifies the virtuos plan file, e.g. : \"--" + OPTION_DOSE_LOAD_STYLE + " virtuos myFavorite.pln\")\n" "\"itk\": use itk image loading\n\"helax\": load a helax dose (choosing this style, the dose path should only be a directory).", defaultLoadingStyle, defaultLoadingStyle.at(0), 't', true, true); addOptionWithDefaultValue >(OPTION_STRUCT_LOAD_STYLE, OPTION_GROUP_REQUIRED, "The loading style for the dose. Available styles are:\n" "\"dicom\": normal dicom dose\n" "\"virtuos\": load of a virtuos dose (This style is a multi argument. The second argument specifies the virtuos plan file, e.g. : \"--" + OPTION_DOSE_LOAD_STYLE + " virtuos myFavorite.pln\")\n" "\"itk\": use itk image loading.", defaultLoadingStyle, defaultLoadingStyle.at(0), 'u', true, true); addOption(OPTION_DOSE_STATISTICS, OPTION_GROUP_OPTIONAL, "If dose statistics should be computed. The argument is the output file. Can be omitted if used as " "positional argument (see above).", 'y'); addOption(OPTION_DVH, OPTION_GROUP_OPTIONAL, "If the DVH should be computed. The argument is the output file", 'z'); addOption(OPTION_COMPLEX_STATISTICS, OPTION_GROUP_OPTIONAL, "If the complex dose statistics (Dx, Vx, MOHx, MOCx, MaxOHx, MinOCx) should be computed.", 'x'); addOption(OPTION_PRESCRIBED_DOSE, OPTION_GROUP_OPTIONAL, "The prescribed dose in Gy.", 'p'); addOption(OPTION_ALLOW_SELF_INTERSECTION_STRUCT, OPTION_GROUP_OPTIONAL, "If a struct file contains self intersecting contours: Allow the processing of these structures and ignore potential problems." "WARNING: only use this parameter if you know what you are doing.", 'a'); addOption(OPTION_MULTIPLE_STRUCTS_MODE, OPTION_GROUP_OPTIONAL, "If the regex agrees with multiple structs: write a dose statistic for every struct file." "The struct name will be appended to the chosen output filename.", 'm'); parse(argc, argv); } void DoseToolCmdLineParser::validateInput() const { std::vector doseLoadStyle = get >(OPTION_DOSE_LOAD_STYLE); std::string doseLoadStyleAbbreviation = doseLoadStyle.at(0); if (doseLoadStyleAbbreviation != "dicom" && doseLoadStyleAbbreviation != "virtuos" && doseLoadStyleAbbreviation != "itk" && doseLoadStyleAbbreviation != "helax") { throw cmdlineparsing::InvalidConstraintException("Unknown load style for dose file:" + doseLoadStyleAbbreviation + ".\nPlease refer to the help for valid loading style settings."); } if (doseLoadStyleAbbreviation == "virtuos") { if (doseLoadStyle.size() < 2) { throw cmdlineparsing::InvalidConstraintException("Cannot load virtuos dose. Plan file is missing. Specify plan file as 2nd io style argument."); } } std::vector structLoadStyle = get >(OPTION_STRUCT_LOAD_STYLE); std::string structLoadStyleAbbreviation = structLoadStyle.at(0); if (structLoadStyleAbbreviation != "dicom" && structLoadStyleAbbreviation != "virtuos" && structLoadStyleAbbreviation != "itk") { throw cmdlineparsing::InvalidConstraintException("Unknown load style for struct file:" + structLoadStyleAbbreviation + ".\nPlease refer to the help for valid loading style settings."); } if (structLoadStyleAbbreviation == "dicom" || structLoadStyleAbbreviation == "virtuos" || structLoadStyleAbbreviation == "helax") { if (get(OPTION_STRUCT_NAME) == "") { throw cmdlineparsing::InvalidConstraintException("The struct name (--" + OPTION_STRUCT_NAME + ") has to be defined for dicom, virtuos or helax struct files."); } } if (structLoadStyleAbbreviation == "virtuos") { if (structLoadStyle.size() < 2) { throw cmdlineparsing::InvalidConstraintException("Cannot load virtuos struct file. CTX file is missing. Specify CTX file as 2nd io style argument."); } } if (!isSet(OPTION_DVH) && !isSet(OPTION_DOSE_STATISTICS)) { throw cmdlineparsing::InvalidConstraintException("Neither the Dose statistics (--" + OPTION_DOSE_STATISTICS + "), nor the DVH (--" + OPTION_DVH + ") option was used."); } if (isSet(OPTION_DOSE_STATISTICS) && isSet(OPTION_COMPLEX_STATISTICS)) { if (!isSet(OPTION_PRESCRIBED_DOSE)) { throw cmdlineparsing::InvalidConstraintException("The prescribed dose (--" + OPTION_PRESCRIBED_DOSE + ") has to be set for computation of complex dose statistics."); } else { if (get(OPTION_PRESCRIBED_DOSE) <= 0) { throw cmdlineparsing::InvalidConstraintException("The prescribed dose (--" + OPTION_PRESCRIBED_DOSE + ") has to be >0!"); } } } } void DoseToolCmdLineParser::printHelp() const { cmdlineparsing::CmdLineParserBase::printHelp(); std::cout << "Example:" << std::endl << std::endl; std::cout << m_programName << " dose.dcm struct.dcm Liver result.xml --" + OPTION_DVH + " dvh.xml" << std::endl << std::endl; std::cout << "This will calculate the Dose statistic for liver using \"dose.dcm\" and the struct file \"struct.dcm\" and will write the dose statistics to \"result.xml\". " " The DVH is computed as well, its values are written to \"dvh.xml\". " << std::endl; } } } } diff --git a/demoapps/DoseTool/DoseToolCmdLineParser.h b/apps/DoseTool/DoseToolCmdLineParser.h similarity index 89% rename from demoapps/DoseTool/DoseToolCmdLineParser.h rename to apps/DoseTool/DoseToolCmdLineParser.h index b6804b6..6632b50 100644 --- a/demoapps/DoseTool/DoseToolCmdLineParser.h +++ b/apps/DoseTool/DoseToolCmdLineParser.h @@ -1,66 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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 __DOSETOOL_CMD_LINE_PARSER #define __DOSETOOL_CMD_LINE_PARSER #include "CmdLineParserBase.h" namespace rttb { namespace apps { namespace doseTool { /*! @class BioModelCmdLineParser @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); 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/demoapps/DoseTool/DoseToolHelper.cpp b/apps/DoseTool/DoseToolHelper.cpp similarity index 95% rename from demoapps/DoseTool/DoseToolHelper.cpp rename to apps/DoseTool/DoseToolHelper.cpp index 8bda333..8ee44e5 100644 --- a/demoapps/DoseTool/DoseToolHelper.cpp +++ b/apps/DoseTool/DoseToolHelper.cpp @@ -1,369 +1,369 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1334 $ (last changed revision) +// @date $Date: 2016-04-22 11:13:22 +0200 (Fr, 22 Apr 2016) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #include "DoseToolHelper.h" #include "boost/make_shared.hpp" #include "boost/shared_ptr.hpp" #include "boost/property_tree/ptree.hpp" #include "boost/filesystem.hpp" #include "rttbExceptionMacros.h" #include "rttbVirtuosPlanFileDoseAccessorGenerator.h" #include "rttbDicomFileDoseAccessorGenerator.h" #include "rttbDicomHelaxFileDoseAccessorGenerator.h" #include "rttbITKImageFileAccessorGenerator.h" #include "rttbStructureSetGeneratorInterface.h" #include "rttbDicomFileStructureSetGenerator.h" #include "rttbVirtuosFileStructureSetGenerator.h" #include "rttbITKImageFileMaskAccessorGenerator.h" #include "rttbDVHCalculator.h" #include "rttbDVHXMLFileWriter.h" #include "rttbDoseStatisticsCalculator.h" #include "rttbBoostMaskAccessor.h" #include "rttbGenericMaskedDoseIterator.h" #include "rttbDoseStatisticsXMLWriter.h" #include "rttbVOIindexIdentifier.h" rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseTool::loadDose(const std::string& fileName, const rttb::apps::doseTool::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::doseTool::loadDicomDose(const std::string& fileName) { rttb::io::dicom::DicomFileDoseAccessorGenerator generator(fileName); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseTool::loadHelaxDose(const std::string& path) { rttb::io::helax::DicomHelaxFileDoseAccessorGenerator generator(path); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseTool::loadITKDose(const std::string& fileName) { rttb::io::itk::ITKImageFileAccessorGenerator generator(fileName); return generator.generateDoseAccessor(); }; rttb::core::DoseAccessorInterface::DoseAccessorPointer rttb::apps::doseTool::loadVirtuosDose(const std::string& fileName, const std::string& planFileName) { rttb::io::virtuos::VirtuosPlanFileDoseAccessorGenerator generator(fileName, planFileName); return generator.generateDoseAccessor(); }; rttb::core::StructureSetGeneratorInterface::StructureSetPointer rttb::apps::doseTool::loadStruct( const std::string& fileName, const ApplicationData::LoadingStyleArgType& args, const std::string& structNameRegex) { rttb::core::StructureSetGeneratorInterface::StructureSetPointer result; std::cout << std::endl << "read struct file... "; if (args.empty() || args[0] == "dicom") { std::cout << "use RTTB dicom IO... "; result = loadDicomStruct(fileName, structNameRegex); } else if (args[0] == "virtuos") { std::cout << "use RTTB virtuos IO... " << std::endl; std::cout << " virtuos CTX file: " << args[1] << " ... "; result = loadVirtuosStruct(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::StructureSetGeneratorInterface::StructureSetPointer rttb::apps::doseTool::loadDicomStruct( const std::string& fileName, const std::string& structNameRegex) { rttb::io::dicom::DicomFileStructureSetGenerator generator(fileName); if (!structNameRegex.empty()) { generator.setStructureLableFilterActive(true); generator.setFilterRegEx(structNameRegex); } return generator.generateStructureSet(); } rttb::core::StructureSetGeneratorInterface::StructureSetPointer rttb::apps::doseTool::loadVirtuosStruct( const std::string& fileName, const std::string& ctxFileName) { rttb::io::virtuos::VirtuosFileStructureSetGenerator generator(fileName, ctxFileName.c_str()); return generator.generateStructureSet(); } void rttb::apps::doseTool::processData(rttb::apps::doseTool::ApplicationData& appData) { std::cout << std::endl << "generating masks... "; std::vector maskAccessorPtrVector = generateMasks( appData); std::cout << "done." << std::endl; for (size_t i = 0; i < maskAccessorPtrVector.size(); i++) { core::DoseIteratorInterface::DoseIteratorPointer spDoseIterator(generateMaskedDoseIterator( maskAccessorPtrVector.at(i), appData._dose)); if (appData._computeDoseStatistics) { std::cout << std::endl << "computing dose statistics... "; algorithms::DoseStatistics::DoseStatisticsPointer statistics = calculateDoseStatistics( spDoseIterator, appData._computeComplexDoseStatistics, appData._prescribedDose); std::cout << "done." << std::endl; std::cout << std::endl << "writing dose statistics to file... "; std::string outputFilename; if (appData._multipleStructsMode) { outputFilename = assembleFilenameWithStruct(appData._doseStatisticOutputFileName, appData._structNames.at(i)); } else { outputFilename = appData._doseStatisticOutputFileName; } writeDoseStatisticsFile(statistics, outputFilename, appData._structNames.at(i), appData); std::cout << "done." << std::endl; } if (appData._computeDVH) { std::cout << std::endl << "computing DVH... "; core::DVH::DVHPointer dvh = calculateDVH(spDoseIterator, appData._struct->getUID(), appData._dose->getUID()); std::cout << "done." << std::endl; std::cout << std::endl << "writing DVH to file... "; std::string outputFilename; if (appData._multipleStructsMode) { outputFilename = assembleFilenameWithStruct(appData._dvhOutputFilename, appData._structNames.at(i)); } else { outputFilename = appData._dvhOutputFilename; } writeDVHFile(dvh, outputFilename); std::cout << "done." << std::endl; } } } std::vector rttb::apps::doseTool::generateMasks( rttb::apps::doseTool::ApplicationData& appData) { std::vector maskAccessorPtrVector; if (appData._structLoadStyle.front() == "itk") { maskAccessorPtrVector.push_back(rttb::io::itk::ITKImageFileMaskAccessorGenerator( appData._structFileName).generateMaskAccessor()); } else { std::vector foundIndices = rttb::masks::VOIindexIdentifier::getIndicesByVoiRegex( appData._struct, appData._structNameRegex); std::vector relevantIndices; if (appData._multipleStructsMode) { relevantIndices = foundIndices; } else { if (!foundIndices.empty()) { relevantIndices.push_back(foundIndices.front()); } } appData._structIndices = relevantIndices; bool strict = !appData._allowSelfIntersection; for (size_t i = 0; i < appData._structIndices.size(); i++) { maskAccessorPtrVector.push_back( boost::make_shared (appData._struct->getStructure(appData._structIndices.at(i)), appData._dose->getGeometricInfo(), strict)); maskAccessorPtrVector.at(i)->updateMask(); appData._structNames.push_back(appData._struct->getStructure(appData._structIndices.at( i))->getLabel()); } } return maskAccessorPtrVector; } rttb::core::DoseIteratorInterface::DoseIteratorPointer rttb::apps::doseTool::generateMaskedDoseIterator( rttb::core::MaskAccessorInterface::MaskAccessorPointer maskAccessorPtr, rttb::core::DoseAccessorInterface::DoseAccessorPointer doseAccessorPtr) { boost::shared_ptr maskedDoseIterator = boost::make_shared(maskAccessorPtr, doseAccessorPtr); rttb::core::DoseIteratorInterface::DoseIteratorPointer doseIterator(maskedDoseIterator); return doseIterator; } rttb::algorithms::DoseStatistics::DoseStatisticsPointer rttb::apps::doseTool::calculateDoseStatistics( core::DoseIteratorInterface::DoseIteratorPointer doseIterator, bool calculateComplexDoseStatistics, DoseTypeGy prescribedDose) { rttb::algorithms::DoseStatisticsCalculator doseStatsCalculator(doseIterator); if (calculateComplexDoseStatistics) { return doseStatsCalculator.calculateDoseStatistics(prescribedDose); } else { return doseStatsCalculator.calculateDoseStatistics(); } } rttb::core::DVH::DVHPointer rttb::apps::doseTool::calculateDVH( core::DoseIteratorInterface::DoseIteratorPointer doseIterator, IDType structUID, IDType doseUID) { rttb::core::DVHCalculator calc(doseIterator, structUID, doseUID); rttb::core::DVH::DVHPointer dvh = calc.generateDVH(); return dvh; } void rttb::apps::doseTool::writeDoseStatisticsFile( rttb::algorithms::DoseStatistics::DoseStatisticsPointer statistics, const std::string& filename, const std::string& structName, rttb::apps::doseTool::ApplicationData& appData) { boost::property_tree::ptree originalTree = rttb::io::other::writeDoseStatistics(statistics); //add config part to xml originalTree.add("statistics.config.requestedStructRegex", appData._structNameRegex); originalTree.add("statistics.config.structName", structName); originalTree.add("statistics.config.doseUID", appData._dose->getUID()); originalTree.add("statistics.config.doseFile", appData._doseFileName); originalTree.add("statistics.config.structFile", appData._structFileName); boost::property_tree::ptree reorderedTree, configTree, resultsTree; configTree = originalTree.get_child("statistics.config"); resultsTree = originalTree.get_child("statistics.results"); reorderedTree.add_child("statistics.config", configTree); reorderedTree.add_child("statistics.results", resultsTree); boost::property_tree::write_xml(filename, reorderedTree, std::locale(), boost::property_tree::xml_writer_make_settings('\t', 1)); } std::string rttb::apps::doseTool::assembleFilenameWithStruct(const std::string& originalFilename, const std::string& structName) { boost::filesystem::path originalFile(originalFilename); std::string newFilename = originalFile.stem().string() + "_" + structName + originalFile.extension().string(); boost::filesystem::path newFile(originalFile.parent_path() / newFilename); return newFile.string(); } void rttb::apps::doseTool::writeDVHFile(core::DVH::DVHPointer dvh, const std::string& filename) { DVHType typeCum = { DVHType::Cumulative }; rttb::io::other::DVHXMLFileWriter dvhWriter(filename, typeCum); dvhWriter.writeDVH(dvh); } diff --git a/demoapps/DoseTool/DoseToolHelper.h b/apps/DoseTool/DoseToolHelper.h similarity index 94% rename from demoapps/DoseTool/DoseToolHelper.h rename to apps/DoseTool/DoseToolHelper.h index 8d62fac..399667e 100644 --- a/demoapps/DoseTool/DoseToolHelper.h +++ b/apps/DoseTool/DoseToolHelper.h @@ -1,134 +1,134 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1315 $ (last changed revision) +// @date $Date: 2016-04-12 14:18:24 +0200 (Di, 12 Apr 2016) $ (last change date) +// @author $Author: floca $ (last changed by) */ #ifndef __DOSETOOL_HELPER_H #define __DOSETOOL_HELPER_H #include "DoseToolApplicationData.h" #include "rttbDoseAccessorInterface.h" #include "rttbDoseIteratorInterface.h" #include "rttbMaskAccessorInterface.h" #include "rttbDoseStatistics.h" #include "rttbDVH.h" namespace rttb { namespace apps { namespace doseTool { /*! @brief loads a dose from a file based on the loadingStyle. @exception Throws an rttb::Exception if loading fails */ core::DoseAccessorInterface::DoseAccessorPointer loadDose(const std::string& fileName, const rttb::apps::doseTool::ApplicationData::LoadingStyleArgType& args); /*! @brief loads a dicom dose from a file. @exception Throws an rttb::Exception if loading fails @sa DicomFileDoseAccessorGenerator */ core::DoseAccessorInterface::DoseAccessorPointer loadDicomDose(const std::string& fileName); /*! @brief loads a helax dose from a file. @exception Throws an rttb::Exception if loading fails @sa DicomHelaxFileDoseAccessorGenerator */ core::DoseAccessorInterface::DoseAccessorPointer loadHelaxDose(const std::string& path); /*! @brief loads an itk dose from a file. @exception Throws an rttb::Exception if loading fails. @details Might be of all formats that ITK know (*.mhd, *.nrrd, ...). The absolute image values are taken as dose. @sa ITKImageFileAccessorGenerator */ core::DoseAccessorInterface::DoseAccessorPointer loadITKDose(const std::string& fileName); /*! @brief loads a virtuos dose from a file. @exception Throws an rttb::Exception if loading fails @sa VirtuosPlanFileDoseAccessorGenerator */ core::DoseAccessorInterface::DoseAccessorPointer loadVirtuosDose(const std::string& fileName, const std::string& planFileName); /*! @brief loads a struct from a file based on the loadingStyle. You may pass a structure name regex. If is not empty, it will be used to filter structure in the loading process. Only structures with a name matching the reg ex will be loaded. This speeds up the loading process significantly if you need only one structure out of a structure set. @exception Throws an rttb::Exception if loading fails @details voxelized itk images are read in generateMask() directly */ core::StructureSetGeneratorInterface::StructureSetPointer loadStruct(const std::string& fileName, const rttb::apps::doseTool::ApplicationData::LoadingStyleArgType& args, const std::string& structNameRegex = ""); /*! @brief loads a dicom struct from a file. You may pass a structure name regex. If is not empty, it will be used to filter structure in the loading process. Only structures with a name matching the reg ex will be loaded. This speeds up the loading process significantly if you need only one structure out of a structure set. @exception Throws an rttb::Exception if loading fails @sa DicomFileStructureSetGenerator */ core::StructureSetGeneratorInterface::StructureSetPointer loadDicomStruct( const std::string& fileName, const std::string& structNameRegex = ""); /*! @brief loads a virtuos struct from a file. @exception Throws an rttb::Exception if loading fails @sa VirtuosPlanFileDoseAccessorGenerator */ core::StructureSetGeneratorInterface::StructureSetPointer loadVirtuosStruct( const std::string& fileName, const std::string& ctxFileName); /*! @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); algorithms::DoseStatistics::DoseStatisticsPointer calculateDoseStatistics( core::DoseIteratorInterface::DoseIteratorPointer doseIterator, bool calculateComplexDoseStatistics, DoseTypeGy prescribedDose); core::DVH::DVHPointer calculateDVH(core::DoseIteratorInterface::DoseIteratorPointer doseIterator, IDType structUID, IDType doseUID); /*! @brief Writes the dose statistics as XML to a file @details adds a .... part to the RTTB generated xml where the used files and struct names are stored. */ void writeDoseStatisticsFile(algorithms::DoseStatistics::DoseStatisticsPointer statistics, const std::string& filename, const std::string& structName, rttb::apps::doseTool::ApplicationData& appData); void writeDVHFile(core::DVH::DVHPointer dvh, const std::string& filename); core::DoseIteratorInterface::DoseIteratorPointer generateMaskedDoseIterator( core::MaskAccessorInterface::MaskAccessorPointer maskAccessorPtr, core::DoseAccessorInterface::DoseAccessorPointer doseAccessorPtr); std::string assembleFilenameWithStruct(const std::string& originalFilename, const std::string& structName); } } } #endif diff --git a/demoapps/DoseTool/files.cmake b/apps/DoseTool/files.cmake similarity index 100% rename from demoapps/DoseTool/files.cmake rename to apps/DoseTool/files.cmake diff --git a/demoapps/VoxelizerTool/CMakeLists.txt b/apps/VoxelizerTool/CMakeLists.txt similarity index 100% rename from demoapps/VoxelizerTool/CMakeLists.txt rename to apps/VoxelizerTool/CMakeLists.txt diff --git a/demoapps/VoxelizerTool/files.cmake b/apps/VoxelizerTool/files.cmake similarity index 100% rename from demoapps/VoxelizerTool/files.cmake rename to apps/VoxelizerTool/files.cmake diff --git a/demoapps/VoxelizerTool/rttbCommandOptions.cpp b/apps/VoxelizerTool/rttbCommandOptions.cpp similarity index 94% rename from demoapps/VoxelizerTool/rttbCommandOptions.cpp rename to apps/VoxelizerTool/rttbCommandOptions.cpp index ec7c13e..6ad421d 100644 --- a/demoapps/VoxelizerTool/rttbCommandOptions.cpp +++ b/apps/VoxelizerTool/rttbCommandOptions.cpp @@ -1,181 +1,181 @@ // ----------------------------------------------------------------------- // 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) +// @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 "rttbCommandOptions.h" #include "rttbVoxelizerHelper.h" namespace rttb { namespace apps { namespace voxelizer { CommandOptions::CommandOptions(): PARAM_HELP("help"), PARAM_STRUCT_FILE("structFile"), PARAM_REFERENCE_FILE("referenceFile"), PARAM_OUT_FILE("output"), PARAM_REGEX("struct"), PARAM_MULTISTRUCT("multipleStructs"), PARAM_LEGACY_VOXELIZATION("legacyVoxelization"), PARAM_BOOST_VOXELIZATION("boostVoxelization"), PARAM_BOOLEAN_VOXELIZATION("booleanVoxelization"), PARAM_ADDSTRUCTURES("addStructures"), PARAM_ALLOW_SELF_INTERSECTIONS("selfIntersections"), _returnAfterHelp(false) { _params.multipleStructs = false; _params.legacyVoxelization = false; _params.booleanVoxelization = false; _params.addStructures = false; std::vector defaultRefLoadingStyle; defaultRefLoadingStyle.push_back("dicom"); po::options_description required("Required arguments"); addOption(required, PARAM_STRUCT_FILE, "s", po::value(&_params.structFile)->required(), "Filename of the structfile (*.dcm)"); addOption(required, PARAM_REFERENCE_FILE, "r", po::value(&_params.referenceFile)->required(), "Filename of the reference image (*.dcm)"); addOption(required, PARAM_REFERENCE_FILE_LOAD_STYLE, "y", po::value >(&_params.referenceFileLoadStyle)->required()->default_value( defaultRefLoadingStyle, "dicom"), "set the load style for the reference file. Available styles are:\n" "\"dicom\": normal dicom dose\n" "\"itk\": use itk image loading."); addOption(required, PARAM_REGEX, "e", po::value>(&_params.regEx)->multitoken()->required(), "set a regular expression describing the structs of interest"); addOption(required, PARAM_OUT_FILE, "o", po::value(&_params.outputFilename)->default_value("out.hdr"), "set output file name "); addOption(required, PARAM_BOOST_VOXELIZATION, "b", po::bool_switch()->default_value(true), "to use boost voxelization"); po::options_description optional("Optional arguments"); addOption(optional, PARAM_HELP, "h", nullptr, "Display help message"); addOption(optional, PARAM_MULTISTRUCT, "m", po::bool_switch(&_params.multipleStructs)->default_value(false), "if multiple structs match the regular expression (--struct), save all in files"); addOption(optional, PARAM_LEGACY_VOXELIZATION, "l", po::bool_switch(&_params.legacyVoxelization)->default_value(false), "to use legacy voxelization"); addOption(optional, PARAM_BOOLEAN_VOXELIZATION, "v", po::bool_switch(&_params.booleanVoxelization)->default_value(false), "Determines if the voxelization should be binarized (only values 0 or 1)"); addOption(optional, PARAM_ADDSTRUCTURES, "a", nullptr, "Voxelizes multiple structs in one result file."); addOption(optional, PARAM_ALLOW_SELF_INTERSECTIONS, "i", po::bool_switch(&_params.allowSelfIntersections)->default_value(false), "If self intersections of polygons should be tolerated."); _description.add(required).add(optional); } void CommandOptions::addOption(po::options_description& o, const std::string& name, const std::string& shortcut, const po::value_semantic* valueSemantic, const std::string& description) { if (valueSemantic) { o.add_options()((name + std::string(",") + shortcut).c_str(), valueSemantic, description.c_str()); } else { o.add_options()((name + std::string(",") + shortcut).c_str(), description.c_str()); } } void CommandOptions::showHelp() const { std::cout << "Usage: VoxelizerTool [options] \n"; std::cout << _description << std::endl; std::cout << "Example: VoxelizerTool -s structFile.dcm -r referenceFile.dcm -e Kidney -o outputFile.mhd -m" << std::endl; std::cout << "Computes a voxelization file outputFile.mhd based on the DICOMRT-STRUCT structFile.dcm in the geometry of referenceFile.dcm where"; std::cout << "the name of the struct matches the regular expression 'Kidney'." << std::endl; std::cout << "If structures 'Kidney_left' and 'Kidney_right' are defined, "; std::cout << "both are written under the names outputFile_Kidney_left.mhd and outputFile_Kidney_right.mhd (parameter -m)." << std::endl; } bool CommandOptions::command(int argc, char* argv[]) { try { po::variables_map var; po::store(po::command_line_parser(argc, argv).options(_description).run(), var); if (var.count(PARAM_HELP)) { showHelp(); _returnAfterHelp = true; return true; } po::notify(var); if (var.count(PARAM_BOOST_VOXELIZATION)) { _params.legacyVoxelization = false; } if (_params.outputFilename.find('.') == std::string::npos) { std::cout << "--output has to specify a file format (e.g. output.hdr). None is given: " << _params.outputFilename << std::endl; return false; } if (_params.referenceFileLoadStyle.empty() || (_params.referenceFileLoadStyle.at(0) != "dicom" && _params.referenceFileLoadStyle.at(0) != "itk")) { std::cout << "Unknown load style:" + _params.referenceFileLoadStyle.at(0) + ".\nPlease refer to the help for valid loading style settings." << std::endl; return false; } if (var.count(PARAM_ADDSTRUCTURES)) { _params.addStructures = true; _params.multipleStructs = false; } } catch (const std::exception& e) { std::cout << "Error: " << e.what() << std::endl; return false; } return true; } } } } \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbCommandOptions.h b/apps/VoxelizerTool/rttbCommandOptions.h similarity index 93% rename from demoapps/VoxelizerTool/rttbCommandOptions.h rename to apps/VoxelizerTool/rttbCommandOptions.h index d70a14a..17a3e7f 100644 --- a/demoapps/VoxelizerTool/rttbCommandOptions.h +++ b/apps/VoxelizerTool/rttbCommandOptions.h @@ -1,129 +1,129 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1155 $ (last changed revision) +// @date $Date: 2015-10-15 09:43:29 +0200 (Do, 15 Okt 2015) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #ifndef __CommandOptions_h #define __CommandOptions_h #include namespace rttb { namespace apps { namespace voxelizer { namespace po = boost::program_options; /** @brief Simple struct holding all variables. */ struct Parameters { /** @brief Filename of the StructFile*/ std::string structFile; /** @brief Filename of the ReferenceFile*/ std::string referenceFile; std::vector referenceFileLoadStyle; /** @brief Output Filename*/ std::string outputFilename; /** @brief Expressions from User*/ std::vector regEx; /** @brief for more than one struct*/ bool multipleStructs; /** @brief add: legacyVoxelization=false means boostVoxelization is turned on*/ bool legacyVoxelization; /** @brief voxelization should be binarized to value 0 or 1 */ bool booleanVoxelization ; /** @brief multiple structures voxelization should be combined in one file*/ bool addStructures; /** @brief requests a strict voxelization (non-strict: polygon intersections are tolerated)*/ bool allowSelfIntersections; }; /*! @class CommandOptions @brief CommandOptions Class, everything about the command line */ class CommandOptions { public: /** @details add the description for command line options * add parameter --h or --help for help informations, * --Structfile= to set a struct file, * --Reference= to set the reference file, * --Output= to set an output file name and * --struct= to add an expression like(SPINE). */ CommandOptions(); /** @brief Validates the given input parameters and fills the corresponding variables. @param argc Number of arguments. @param argv Array of individual arguments. @return true if all arguments were valid (i.e. none were missing or incorrect), otherwise false. */ bool command(int argc, char* argv[]); const Parameters& getParameters() const { return _params; } bool isReturnAfterHelp() const { return _returnAfterHelp; } private: /** *@brief Adds an option to the given option container. *@param o Option container the new option should be added to. *@param name Name of the new option (i.e. the actual parameter, e.g. "test" adds the option with the parameter "--test"). *@param shortcut A single letter that is used as a shortcut for this option (e.g. if the name is "test, the shortcut might be "t", so you can call the parameter with "-t" instead of "--test"). *@param valueSemantic The desired value semantic object, i.e. the object that binds this option's value to a variable. *@param description The description text for this option. */ void addOption(po::options_description& o, const std::string& name, const std::string& shortcut, const po::value_semantic* valueSemantic, const std::string& description); /*! @brief print out the dicription.*/ void showHelp()const; const std::string PARAM_STRUCT_FILE; const std::string PARAM_REFERENCE_FILE; const std::string PARAM_REFERENCE_FILE_LOAD_STYLE; const std::string PARAM_OUT_FILE; const std::string PARAM_REGEX; const std::string PARAM_MULTISTRUCT; const std::string PARAM_HELP; const std::string PARAM_LEGACY_VOXELIZATION; const std::string PARAM_BOOST_VOXELIZATION; const std::string PARAM_BOOLEAN_VOXELIZATION; const std::string PARAM_ADDSTRUCTURES; const std::string PARAM_ALLOW_SELF_INTERSECTIONS; /*! create description object */ po::options_description _description; Parameters _params; bool _returnAfterHelp; }; } } } #endif \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbMaskProcess.cpp b/apps/VoxelizerTool/rttbMaskProcess.cpp similarity index 88% rename from demoapps/VoxelizerTool/rttbMaskProcess.cpp rename to apps/VoxelizerTool/rttbMaskProcess.cpp index 058a1bb..3d5bf24 100644 --- a/demoapps/VoxelizerTool/rttbMaskProcess.cpp +++ b/apps/VoxelizerTool/rttbMaskProcess.cpp @@ -1,66 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @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 "rttbMaskProcess.h" #include #include "rttbBoostMaskAccessor.h" namespace rttb { namespace apps { namespace voxelizer { MaskProcess::MaskProcess(StructureSetPointer rtStructureSet, DoseAccessorPointer doseAccessor, bool legacy, bool allowSelfIntersection) : _rtStructureSet(rtStructureSet), _doseAccessor(doseAccessor), _legacyVoxelization(legacy), _allowSelfIntersection(allowSelfIntersection) { } MaskProcess::MaskAccessorPointer MaskProcess::createMask(unsigned int indexOfStructure) const { MaskAccessorPointer maskAccessorPtr; if (_doseAccessor != NULL && _rtStructureSet != NULL) { if (_legacyVoxelization) { maskAccessorPtr = boost::make_shared (_rtStructureSet->getStructure(indexOfStructure), _doseAccessor->getGeometricInfo()); } else { maskAccessorPtr = boost::make_shared (_rtStructureSet->getStructure(indexOfStructure), _doseAccessor->getGeometricInfo(), !_allowSelfIntersection); } maskAccessorPtr->updateMask(); } return maskAccessorPtr; } } } } \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbMaskProcess.h b/apps/VoxelizerTool/rttbMaskProcess.h similarity index 88% rename from demoapps/VoxelizerTool/rttbMaskProcess.h rename to apps/VoxelizerTool/rttbMaskProcess.h index d28fb22..a632c30 100644 --- a/demoapps/VoxelizerTool/rttbMaskProcess.h +++ b/apps/VoxelizerTool/rttbMaskProcess.h @@ -1,63 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @version $Revision: 1155 $ (last changed revision) +// @date $Date: 2015-10-15 09:43:29 +0200 (Do, 15 Okt 2015) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #ifndef __MaskProcess_h #define __MaskProcess_h #include "rttbDicomFileStructureSetGenerator.h" #include "rttbOTBMaskAccessor.h" namespace rttb { namespace apps { namespace voxelizer { /*! @class MaskProcess @brief MaskProcess create a Mask with the struct and reference object */ class MaskProcess { public: typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; typedef core::GenericDoseIterator::DoseAccessorPointer DoseAccessorPointer; typedef core::StructureSetGeneratorInterface::StructureSetPointer StructureSetPointer; /*!@brief Constructor @details save the rtStructureSet (structfile) object into _rtStructureSet and * doseAccessor (referencefile) object into _doseAccessor */ MaskProcess(StructureSetPointer rtStructureSet, DoseAccessorPointer doseAccessor, bool legacyVoxelization, bool allowSelfIntersection); /**@brief create a mask with _rtStructureSet and _doseAccessor object. @return a mask object */ MaskAccessorPointer createMask(unsigned int numberOfStructure) const; private: StructureSetPointer _rtStructureSet; DoseAccessorPointer _doseAccessor; bool _legacyVoxelization; bool _allowSelfIntersection; }; } } } #endif \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbMaskWriter.cpp b/apps/VoxelizerTool/rttbMaskWriter.cpp similarity index 92% rename from demoapps/VoxelizerTool/rttbMaskWriter.cpp rename to apps/VoxelizerTool/rttbMaskWriter.cpp index 3be65a4..c8996e3 100644 --- a/demoapps/VoxelizerTool/rttbMaskWriter.cpp +++ b/apps/VoxelizerTool/rttbMaskWriter.cpp @@ -1,133 +1,133 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1334 $ (last changed revision) +// @date $Date: 2016-04-22 11:13:22 +0200 (Fr, 22 Apr 2016) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #include "rttbMaskWriter.h" #include "itkImage.h" #include "itkImageFileWriter.h" #include "itkBinaryThresholdImageFilter.h" #include "itkAddImageFilter.h" namespace rttb { namespace apps { namespace voxelizer { MaskWriter::MaskWriter(std::vector maskPointer, bool voxelization) : _maskPointerVector(maskPointer), _booleanvoxelization(voxelization) { } void MaskWriter::writeMaskToFile(const std::string& outputFileName) const { if (!_maskPointerVector.empty()) { ITKImageTypeConstPointer itkImage; if (_maskPointerVector.size() > 1) { itkImage = addMultipleStructsToImage(); } else { io::itk::ITKImageMaskAccessorConverter maskAccessorConverter(_maskPointerVector.at(0)); maskAccessorConverter.process(); itkImage = maskAccessorConverter.getITKImage(); } if (_booleanvoxelization) { itkImage = applyThresholdFilter(itkImage); } writeITKImageToFile(itkImage, outputFileName); } } MaskWriter::ITKImageTypeConstPointer MaskWriter::addMultipleStructsToImage() const { std::vector listOfITKImages; for (size_t i = 0; i < _maskPointerVector.size(); i++) { io::itk::ITKImageMaskAccessorConverter maskAccessorConverter(_maskPointerVector.at(i)); maskAccessorConverter.process(); listOfITKImages.push_back(maskAccessorConverter.getITKImage()); } typedef itk::AddImageFilter AddImageFilterType; AddImageFilterType::Pointer addFilter = AddImageFilterType::New(); ITKImageTypePointer filterResult; for (size_t k = 1; k < listOfITKImages.size(); k++) { if (k == 1) { addFilter->SetInput1(listOfITKImages.at(0)); } else { addFilter->SetInput1(filterResult); } addFilter->SetInput2(listOfITKImages.at(k)); addFilter->Update(); filterResult = addFilter->GetOutput(); } ITKImageTypeConstPointer filterResultConst(filterResult); return filterResultConst; } MaskWriter::ITKImageTypeConstPointer MaskWriter::applyThresholdFilter( ITKImageTypeConstPointer itkImage) const { typedef itk::BinaryThresholdImageFilter< ITKMaskImageType, ITKMaskImageType > FilterType; FilterType::Pointer filter = FilterType::New(); filter->SetInput(itkImage); filter->SetLowerThreshold(0.5); filter->SetUpperThreshold(1.0); filter->SetInsideValue(1.0); filter->Update(); return filter->GetOutput(); } void MaskWriter::writeITKImageToFile(ITKImageTypeConstPointer itkImage, const std::string& outputfilename, bool useCompression) const { typedef itk::ImageFileWriter< ITKMaskImageType > WriterType; WriterType::Pointer writer = WriterType::New(); writer->SetFileName(outputfilename); writer->SetUseCompression(useCompression); writer->SetInput(itkImage); writer->Update(); } } } } diff --git a/demoapps/VoxelizerTool/rttbMaskWriter.h b/apps/VoxelizerTool/rttbMaskWriter.h similarity index 89% rename from demoapps/VoxelizerTool/rttbMaskWriter.h rename to apps/VoxelizerTool/rttbMaskWriter.h index 28cfdad..a19054a 100644 --- a/demoapps/VoxelizerTool/rttbMaskWriter.h +++ b/apps/VoxelizerTool/rttbMaskWriter.h @@ -1,71 +1,71 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1155 $ (last changed revision) +// @date $Date: 2015-10-15 09:43:29 +0200 (Do, 15 Okt 2015) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #ifndef __MaskWriter_h #define __MaskWriter_h #include "rttbITKImageMaskAccessorConverter.h" #include "rttbITKImageFileMaskAccessorGenerator.h" namespace rttb { namespace apps { namespace voxelizer { /*! @class MaskWriter @brief MaskWriter write a mask into a file */ class MaskWriter { public: typedef core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; typedef io::itk::ITKImageMaskAccessor::ITKMaskImageType::Pointer ITKImageTypePointer; typedef io::itk::ITKImageMaskAccessor::ITKMaskImageType::ConstPointer ITKImageTypeConstPointer; typedef itk::Image ITKMaskImageType; /*!@brief Constructor @details save the object parameter into _maskAccessorPtr objekt @param vector with MaskAccessorPointer object/s */ MaskWriter(std::vector maskPointer, bool voxelization); /**@brief write the mask into the outputfile @param Outputfilename */ void writeMaskToFile(const std::string& outputFileName) const; private: ITKImageTypeConstPointer addMultipleStructsToImage() const; ITKImageTypeConstPointer applyThresholdFilter(ITKImageTypeConstPointer itkImage) const; void writeITKImageToFile(ITKImageTypeConstPointer itkImage, const std::string& outputfilename, bool useCompression = true) const; //MaskAccessorPointer _maskAccessorPtr; bool _booleanvoxelization; std::vector _maskPointerVector; }; } } } #endif \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbStructDataReader.cpp b/apps/VoxelizerTool/rttbStructDataReader.cpp similarity index 91% rename from demoapps/VoxelizerTool/rttbStructDataReader.cpp rename to apps/VoxelizerTool/rttbStructDataReader.cpp index d1c29e7..8017531 100644 --- a/demoapps/VoxelizerTool/rttbStructDataReader.cpp +++ b/apps/VoxelizerTool/rttbStructDataReader.cpp @@ -1,117 +1,117 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1334 $ (last changed revision) +// @date $Date: 2016-04-22 11:13:22 +0200 (Fr, 22 Apr 2016) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #include "rttbStructDataReader.h" #include "rttbDicomFileDoseAccessorGenerator.h" #include "rttbITKImageFileAccessorGenerator.h" #include "rttbInvalidParameterException.h" namespace rttb { namespace apps { namespace voxelizer { StructDataReader::StructDataReader(const std::string& structFileName, const std::string& referenceFileName, const std::vector& referenceFileLoadingStyle) : _referenceFilename(referenceFileName), _structFilename(structFileName), _referenceFileLoadingStyle(referenceFileLoadingStyle) { } void StructDataReader::read() { _doseAccessor = readReferenceFile(_referenceFilename, _referenceFileLoadingStyle); _rtStructureSet = readStructFile(_structFilename); } std::vector StructDataReader::getAllLabels() const { std::vector allLabels; if (_rtStructureSet != NULL) { for (size_t j = 0; j < _rtStructureSet->getNumberOfStructures(); j++) { allLabels.push_back(_rtStructureSet->getStructure(j)->getLabel()); } } return allLabels; } StructDataReader::StructureSetPointer StructDataReader::getStructureSetPointer() const { return _rtStructureSet; } StructDataReader::DoseAccessorPointer StructDataReader::getDoseAccessorPointer() const { return _doseAccessor; } StructDataReader::DoseAccessorPointer StructDataReader::readReferenceFile( const std::string& filename, const std::vector& fileLoadingStyle) const { if (fileLoadingStyle.at(0) == "dicom") { return readDicomFile(filename); } else if (fileLoadingStyle.at(0) == "itk") { return readITKFile(filename); } else { return NULL; } } StructDataReader::DoseAccessorPointer StructDataReader::readDicomFile( const std::string& filename) const { rttb::io::dicom::DicomFileDoseAccessorGenerator doseAccessorGenerator(filename.c_str()); return doseAccessorGenerator.generateDoseAccessor(); } StructDataReader::DoseAccessorPointer StructDataReader::readITKFile(const std::string& filename) const { rttb::io::itk::ITKImageFileAccessorGenerator generator(filename); return generator.generateDoseAccessor(); } StructDataReader::StructureSetPointer StructDataReader::readStructFile( const std::string& filename) const { StructureSetPointer rtStructureSet = rttb::io::dicom::DicomFileStructureSetGenerator( filename.c_str()).generateStructureSet(); return rtStructureSet; } } } } diff --git a/demoapps/VoxelizerTool/rttbStructDataReader.h b/apps/VoxelizerTool/rttbStructDataReader.h similarity index 90% rename from demoapps/VoxelizerTool/rttbStructDataReader.h rename to apps/VoxelizerTool/rttbStructDataReader.h index bf43ff2..d699078 100644 --- a/demoapps/VoxelizerTool/rttbStructDataReader.h +++ b/apps/VoxelizerTool/rttbStructDataReader.h @@ -1,88 +1,88 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1155 $ (last changed revision) +// @date $Date: 2015-10-15 09:43:29 +0200 (Do, 15 Okt 2015) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #ifndef __StructDataReader_h #define __StructDataReader_h #include "rttbDicomFileStructureSetGenerator.h" #include "rttbOTBMaskAccessor.h" namespace rttb { namespace apps { namespace voxelizer { /*! @class StructDataReader @brief StructDataReader read struct and reference file */ class StructDataReader { public: typedef rttb::core::GenericDoseIterator::DoseAccessorPointer DoseAccessorPointer; typedef rttb::core::StructureSetGeneratorInterface::StructureSetPointer StructureSetPointer; StructDataReader(const std::string& structFileName, const std::string& referenceFileName, const std::vector& referenceFileLoadingStyle); /*!@brief Reads structure and reference file and saves the result in variables */ void read(); /**@brief read all labels an save it in a vector. @return a vector of all labels */ std::vector getAllLabels() const; /**@brief @return the object _rtStructureSet */ StructureSetPointer getStructureSetPointer() const; /**@brief @return the object _doseAccessor */ DoseAccessorPointer getDoseAccessorPointer() const; private: /**@brief read a reference file @return the result as object */ DoseAccessorPointer readReferenceFile(const std::string& filename, const std::vector& fileLoadingStyle) const; DoseAccessorPointer readDicomFile(const std::string& filename) const; DoseAccessorPointer readITKFile(const std::string& filename) const; /**@brief read a struct file @return the result as object */ StructureSetPointer readStructFile(const std::string& filename) const; StructureSetPointer _rtStructureSet; DoseAccessorPointer _doseAccessor; std::string _structFilename; std::string _referenceFilename; std::vector _referenceFileLoadingStyle; }; } } } #endif \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbVoxelizerHelper.cpp b/apps/VoxelizerTool/rttbVoxelizerHelper.cpp similarity index 89% rename from demoapps/VoxelizerTool/rttbVoxelizerHelper.cpp rename to apps/VoxelizerTool/rttbVoxelizerHelper.cpp index 071a4eb..22e6367 100644 --- a/demoapps/VoxelizerTool/rttbVoxelizerHelper.cpp +++ b/apps/VoxelizerTool/rttbVoxelizerHelper.cpp @@ -1,82 +1,82 @@ // ----------------------------------------------------------------------- // 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) +// @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 "rttbVoxelizerHelper.h" #include #include #include namespace rttb { namespace apps { namespace voxelizer { std::vector filterForExpression(const std::vector& listOfExpressions, const std::string& inputExpression) { std::vector listOfFoundElements; for (int j = 0; j < listOfExpressions.size(); j++) { boost::regex e(boost::algorithm::to_lower_copy(inputExpression)); std::string s = boost::algorithm::to_lower_copy(listOfExpressions.at(j)); if (boost::regex_match(s, e)) { listOfFoundElements.push_back(j); } } return listOfFoundElements; } void removeSpecialCharacters(std::string& label) { //Replace / to avoid problems with directories (struct "Magen/DD" --> Magen/DD.mhd), delete trailing . to avoid filenames with two trailing points (Niere re. --> Niere re..mhd) while (label.find("/") != std::string::npos) { label.replace(label.find("/"), 1, "_"); } if (*label.rbegin() == '.') { label.replace(label.size() - 1, 1, ""); } } std::string getFilenameWithoutEnding(const std::string& outfilename) { boost::filesystem::path p(outfilename); return p.stem().string(); } std::string getFileEnding(const std::string& outfilename) { boost::filesystem::path p(outfilename); return p.extension().string(); } } } } \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbVoxelizerHelper.h b/apps/VoxelizerTool/rttbVoxelizerHelper.h similarity index 85% rename from demoapps/VoxelizerTool/rttbVoxelizerHelper.h rename to apps/VoxelizerTool/rttbVoxelizerHelper.h index a630ac0..6c42b21 100644 --- a/demoapps/VoxelizerTool/rttbVoxelizerHelper.h +++ b/apps/VoxelizerTool/rttbVoxelizerHelper.h @@ -1,44 +1,44 @@ // ----------------------------------------------------------------------- // 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) +// @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 #include namespace rttb { namespace apps { namespace voxelizer { /**@brief ListofExpression contains input expression @return a vector of found labels */ std::vector filterForExpression(const std::vector& listOfExpressions, const std::string& inputExpression); /**@brief Search the label with the position from index @return a label from the list as string */ void removeSpecialCharacters(std::string& label); std::string getFilenameWithoutEnding(const std::string& outfilename); std::string getFileEnding(const std::string& outfilename); } } } \ No newline at end of file diff --git a/demoapps/VoxelizerTool/rttbVoxelizerTool.cpp b/apps/VoxelizerTool/rttbVoxelizerTool.cpp similarity index 93% rename from demoapps/VoxelizerTool/rttbVoxelizerTool.cpp rename to apps/VoxelizerTool/rttbVoxelizerTool.cpp index b6fbc66..e3a008f 100644 --- a/demoapps/VoxelizerTool/rttbVoxelizerTool.cpp +++ b/apps/VoxelizerTool/rttbVoxelizerTool.cpp @@ -1,181 +1,181 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1334 $ (last changed revision) +// @date $Date: 2016-04-22 11:13:22 +0200 (Fr, 22 Apr 2016) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #include #include "itkMacro.h" #include "rttbVoxelizerHelper.h" #include "rttbMaskProcess.h" #include "rttbMaskWriter.h" #include "rttbStructDataReader.h" #include "rttbCommandOptions.h" int main(int argc, char* argv[]) { typedef rttb::core::MaskAccessorInterface::MaskAccessorPointer MaskAccessorPointer; boost::shared_ptr co = boost::make_shared(); if (!co->command(argc, argv)) { return 1; } if (co->isReturnAfterHelp()) { return 0; } rttb::apps::voxelizer::Parameters params = co->getParameters(); boost::shared_ptr reader = boost::make_shared(params.structFile, params.referenceFile, params.referenceFileLoadStyle); std::cout << "reading reference and structure file..."; try { reader->read(); } catch (rttb::core::Exception& e) { std::cerr << "RTTB Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 2; } catch (const std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 2; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 2; } std::cout << "done." << std::endl; std::cout << "searching for structs..."; std::vector listOfCorrectElements; for (size_t i = 0; i < params.regEx.size(); i++) { std::vector indexOfCorrectElements; indexOfCorrectElements = rttb::apps::voxelizer::filterForExpression(reader->getAllLabels(), params.regEx.at(i)); std::copy(indexOfCorrectElements.begin(), indexOfCorrectElements.end(), std::back_inserter(listOfCorrectElements)); } std::cout << "done." << std::endl; boost::shared_ptr maskProcessor = boost::make_shared(reader->getStructureSetPointer(), reader->getDoseAccessorPointer(), params.legacyVoxelization, params.allowSelfIntersections); if (!listOfCorrectElements.empty()) { std::string fileName = rttb::apps::voxelizer::getFilenameWithoutEnding( params.outputFilename); std::string fileEnding = rttb::apps::voxelizer::getFileEnding(params.outputFilename); std::vector maskVector; if (params.addStructures) { std::string labelName; for (size_t i = 0; i < listOfCorrectElements.size(); i++) { int labelIndex = listOfCorrectElements.at(i); maskVector.push_back(maskProcessor->createMask(labelIndex)); std::vector labelVector = reader->getAllLabels(); std::string labelOfInterest = labelVector.at(labelIndex); rttb::apps::voxelizer::removeSpecialCharacters(labelOfInterest); labelName += "_" + labelOfInterest; } boost::shared_ptr writer = boost::make_shared(maskVector, params.booleanVoxelization); writer->writeMaskToFile(fileName + labelName + fileEnding); } else { unsigned int maxIterationCount = 1; if (params.multipleStructs) { maxIterationCount = listOfCorrectElements.size(); } for (unsigned int i = 0; i < maxIterationCount; i++) { std::cout << "creating mask..."; maskVector.push_back(maskProcessor->createMask(listOfCorrectElements.at(i))); std::cout << "done" << std::endl; int labelIndex = listOfCorrectElements.at(i); std::vector labelVector = reader->getAllLabels(); std::string labelOfInterest = labelVector.at(labelIndex); rttb::apps::voxelizer::removeSpecialCharacters(labelOfInterest); boost::shared_ptr MW = boost::make_shared(maskVector, params.booleanVoxelization); try { MW->writeMaskToFile(fileName + "_" + labelOfInterest + fileEnding); } catch (itk::ExceptionObject& err) { std::cerr << "ExceptionObject caught !" << std::endl; std::cerr << err << std::endl; return 3; } catch (const std::exception& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e.what() << std::endl; return 3; } catch (...) { std::cerr << "Error!!! unknown error while reading input image." << std::endl; return 3; } } } } else { std::cout << "No struct found" << std::endl; } return 0; } diff --git a/cmake/PackageDepends/RTTB_ArgumentParsingLib_Config.cmake b/cmake/PackageDepends/RTTB_ArgumentParsingLib_Config.cmake index 5f87b84..630082b 100644 --- a/cmake/PackageDepends/RTTB_ArgumentParsingLib_Config.cmake +++ b/cmake/PackageDepends/RTTB_ArgumentParsingLib_Config.cmake @@ -1,18 +1,14 @@ #----------------------------------------------------------------------------- -# Find ArgumentParsingLib +# ArgumentParsingLib is built automatically. Just set include dir and link directories #----------------------------------------------------------------------------- -FIND_PACKAGE(ArgumentParsingLib REQUIRED) -if (ArgumentParsingLib_DIR) - include(${ArgumentParsingLib_DIR}/ArgumentParsingLibConfig.cmake) - set(ArgumentParsingLib_INCLUDE_DIR ${ArgumentParsingLib_SOURCE_DIR}/main) - set(ArgumentParsingLib_LIBRARY_DIR ${ArgumentParsingLib_BINARY_DIR}/main) - set(ArgumentParsingLib_Boost_INCLUDE_DIR ${ArgumentParsingLib_Boost_INCLUDE_DIR}) - set(ArgumentParsingLib_Boost_LIBRARY_DIR ${ArgumentParsingLib_Boost_LIBRARY_DIR}) - set(ArgumentParsingLib_Boost_LIBRARIES ${ArgumentParsingLib_Boost_LIBRARIES}) -else() - message(FATAL_ERROR "Missing build directory of ArgumentParsingLib. Please specify it manually.") -endif() + +set(ArgumentParsingLib_INCLUDE_DIR ${ArgumentParsingLib_SOURCE_DIR}/main) +set(ArgumentParsingLib_LIBRARY_DIR ${ArgumentParsingLib_BUILD_DIR}/main) +set(ArgumentParsingLib_Boost_INCLUDE_DIR ${Boost_INCLUDE_DIR}) +set(ArgumentParsingLib_Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}) +set(ArgumentParsingLib_Boost_LIBRARIES ${Boost_LIBRARIES}) + LIST(APPEND ALL_INCLUDE_DIRECTORIES ${ArgumentParsingLib_INCLUDE_DIR} ${ArgumentParsingLib_Boost_INCLUDE_DIR}) LIST(APPEND ALL_LIBRARIES "${CMAKE_STATIC_LIBRARY_PREFIX}ArgumentParsingLib${CMAKE_STATIC_LIBRARY_SUFFIX}") LINK_DIRECTORIES(${ArgumentParsingLib_LIBRARY_DIR} ${ArgumentParsingLib_Boost_LIBRARY_DIR}) \ No newline at end of file diff --git a/cmake/PackageDepends/RTTB_Litmus_Config.cmake b/cmake/PackageDepends/RTTB_Litmus_Config.cmake index ff377b8..79f8f5f 100644 --- a/cmake/PackageDepends/RTTB_Litmus_Config.cmake +++ b/cmake/PackageDepends/RTTB_Litmus_Config.cmake @@ -1,26 +1,15 @@ #----------------------------------------------------------------------------- -# Find Litmus +# Litmus is built automatically. Just set include dir and link directories #----------------------------------------------------------------------------- -IF(DEFINED Litmus_DIR) - IF(NOT IS_ABSOLUTE ${Litmus_DIR}) - SET(Litmus_DIR "${RTToolbox_BINARY_DIR}/${Litmus_DIR}") - ENDIF(NOT IS_ABSOLUTE ${Litmus_DIR}) - SET(Litmus_DIR ${Litmus_DIR} CACHE PATH "Litmus binary dir.") -ENDIF(DEFINED Litmus_DIR) +set(Litmus_INCLUDE_DIRS "${LITMUS_SOURCE_DIR}/code/common;${LITMUS_SOURCE_DIR}/code/itk;${LITMUS_BUILD_DIR}") +set(Litmus_LIBRARY_DIRS "${LITMUS_BUILD_DIR}/bin") - - - -FIND_PACKAGE(Litmus) -IF(Litmus_FOUND) - INCLUDE(${Litmus_USE_FILE}) -ELSE(Litmus_FOUND) - MESSAGE(FATAL_ERROR - "Cannot build without Litmus. Please set Litmus_DIR.") -ENDIF(Litmus_FOUND) +IF ((BUILD_RTToolbox_io_Tester AND BUILD_IO_ITK) OR (BUILD_RTToolbox_interpolation_Tester AND BUILD_InterpolationMatchPointTransformation)) + SET(Litmus_ITK "LitmusITK") +ENDIF() LIST(APPEND ALL_INCLUDE_DIRECTORIES ${Litmus_INCLUDE_DIRS}) -LIST(APPEND ALL_LIBRARIES LitmusCommon) +LIST(APPEND ALL_LIBRARIES LitmusCommon ${Litmus_ITK}) LINK_DIRECTORIES(${Litmus_LIBRARY_DIRS}) diff --git a/demoapps/CMakeLists.txt b/demoapps/CMakeLists.txt deleted file mode 100644 index 388b9c9..0000000 --- a/demoapps/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -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) - -OPTION(BUILD_DemoApp_DoseTool "Determine if the demo application DoseTool will be generated." OFF) -IF(BUILD_DemoApp_DoseTool) -ADD_SUBDIRECTORY(DoseTool) -ENDIF(BUILD_DemoApp_DoseTool) -OPTION(BUILD_DemoApp_VoxelizerTool "Determine if the demo application VoxelizerTool will be generated." OFF) -IF(BUILD_DemoApp_VoxelizerTool) -ADD_SUBDIRECTORY(VoxelizerTool) -ENDIF(BUILD_DemoApp_VoxelizerTool) - -OPTION(BUILD_DemoApp_BioModelCalc "Determine if the demo application BioModelCalc will be generated." OFF) -IF(BUILD_DemoApp_BioModelCalc) -ADD_SUBDIRECTORY(BioModelCalc) -ENDIF(BUILD_DemoApp_BioModelCalc) diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index ecffee2..05399d5 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -1,70 +1,86 @@ MESSAGE(STATUS "processing RTToolbox testing code") # Testing branch PROJECT(RTTBTesting) #----------------------------------------------------------------------------- -# Find Litmus. +# extract and build Litmus #----------------------------------------------------------------------------- -MESSAGE(STATUS "searching Litmus") -FIND_PACKAGE(Litmus) -IF(Litmus_FOUND) -INCLUDE(${Litmus_USE_FILE}) -SET(ADDITIONAL_TEST_INCLUDES ${Litmus_USE_FILE}) -ELSE(Litmus_FOUND) -MESSAGE(FATAL_ERROR - "Cannot build without Litmus. Please set Litmus_DIR.") -ENDIF(Litmus_FOUND) + +include(ExternalProject) +message(STATUS "Litmus will be automatically downloaded and built.") +set(LITMUS_SOURCE_DIR "${CMAKE_BINARY_DIR}/external/Litmus-src") +set(LITMUS_BUILD_DIR "${CMAKE_BINARY_DIR}/external/Litmus-build") +set(LITMUS_CMAKE_DIR "${CMAKE_BINARY_DIR}/external/Litmus-cmake") + +IF ((BUILD_RTToolbox_interpolation_Tester AND BUILD_InterpolationMatchPointTransformation) OR (BUILD_RTToolbox_io_Tester AND BUILD_IO_ITK)) + set(ENABLE_ITK "-DLIT_ENABLE_ITK_SUPPORT:BOOL=ON") + set(ITK_DIRECTORY "-DITK_DIR:STRING=${ITK_DIR}") +ENDIF() +#extract and build Litmus +ExternalProject_Add( + Litmus + URL ${RTToolbox_SOURCE_DIR}/utilities/Litmus/Litmus.tar.gz + SOURCE_DIR ${LITMUS_SOURCE_DIR} + BINARY_DIR ${LITMUS_BUILD_DIR} + PREFIX ${LITMUS_CMAKE_DIR} + INSTALL_COMMAND "" + UPDATE_COMMAND "" # Don't update SVN on every build + CMAKE_ARGS + -DBUILD_TESTING:BOOL=OFF + ${ENABLE_ITK} + ${ITK_DIRECTORY} +) #----------------------------------------------------------------------------- # Configure Testing branch #----------------------------------------------------------------------------- MAKE_DIRECTORY(${RTTBTesting_BINARY_DIR}/Temporary) MESSAGE(STATUS "Process All Tests...") #----------------------------------------------------------------------------- # Include sub directories #----------------------------------------------------------------------------- OPTION(BUILD_RTToolbox_core_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_Test_examples "build project on/off" OFF) OPTION(BUILD_RTToolbox_algorithms_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_models_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_io_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_masks_Tester "build project on/off" OFF) OPTION(BUILD_RTToolbox_interpolation_Tester "build project on/off" OFF) -OPTION(BUILD_RTToolbox_demoapps_Tester "build project on/off" OFF) +OPTION(BUILD_RTToolbox_apps_Tester "build project on/off" OFF) IF(${BUILD_RTToolbox_core_Tester} STREQUAL ON) -ADD_SUBDIRECTORY(core) + ADD_SUBDIRECTORY(core) ENDIF(${BUILD_RTToolbox_core_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_Test_examples} STREQUAL ON) -ADD_SUBDIRECTORY(examples) + ADD_SUBDIRECTORY(examples) ENDIF(${BUILD_RTToolbox_Test_examples} STREQUAL ON) IF(${BUILD_RTToolbox_algorithms_Tester} STREQUAL ON) -ADD_SUBDIRECTORY(algorithms) + ADD_SUBDIRECTORY(algorithms) ENDIF(${BUILD_RTToolbox_algorithms_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_models_Tester} STREQUAL ON) -ADD_SUBDIRECTORY(models) + ADD_SUBDIRECTORY(models) ENDIF(${BUILD_RTToolbox_models_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_io_Tester} STREQUAL ON) -ADD_SUBDIRECTORY(io) + ADD_SUBDIRECTORY(io) ENDIF(${BUILD_RTToolbox_io_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_masks_Tester} STREQUAL ON) -ADD_SUBDIRECTORY(masks) + ADD_SUBDIRECTORY(masks) ENDIF(${BUILD_RTToolbox_masks_Tester} STREQUAL ON) IF(${BUILD_RTToolbox_interpolation_Tester} STREQUAL ON) -ADD_SUBDIRECTORY(interpolation) + ADD_SUBDIRECTORY(interpolation) ENDIF(${BUILD_RTToolbox_interpolation_Tester} STREQUAL ON) -IF(${BUILD_RTToolbox_demoapps_Tester} STREQUAL ON) -ADD_SUBDIRECTORY(demoapps) -ENDIF(${BUILD_RTToolbox_demoapps_Tester} STREQUAL ON) +IF(${BUILD_RTToolbox_apps_Tester} STREQUAL ON) + ADD_SUBDIRECTORY(apps) +ENDIF(${BUILD_RTToolbox_apps_Tester} STREQUAL ON) diff --git a/testing/demoapps/CMakeLists.txt b/testing/apps/CMakeLists.txt similarity index 57% rename from testing/demoapps/CMakeLists.txt rename to testing/apps/CMakeLists.txt index 0de5b53..d85d9f6 100644 --- a/testing/demoapps/CMakeLists.txt +++ b/testing/apps/CMakeLists.txt @@ -1,13 +1,13 @@ - MESSAGE (STATUS "Process All demoapps Tests...") + MESSAGE (STATUS "Process All apps Tests...") #----------------------------------------------------------------------------- # Include sub directories #----------------------------------------------------------------------------- -IF(BUILD_DemoApp_DoseTool) +IF(BUILD_App_DoseTool) ADD_SUBDIRECTORY (DoseTool) -ENDIF(BUILD_DemoApp_DoseTool) +ENDIF(BUILD_App_DoseTool) -IF(BUILD_DemoApp_VoxelizerTool) +IF(BUILD_App_VoxelizerTool) ADD_SUBDIRECTORY (VoxelizerTool) -ENDIF(BUILD_DemoApp_VoxelizerTool) +ENDIF(BUILD_App_VoxelizerTool) diff --git a/testing/demoapps/DoseTool/CMakeLists.txt b/testing/apps/DoseTool/CMakeLists.txt similarity index 100% rename from testing/demoapps/DoseTool/CMakeLists.txt rename to testing/apps/DoseTool/CMakeLists.txt diff --git a/testing/demoapps/DoseTool/DoseToolBasicUsageTest.cpp b/testing/apps/DoseTool/DoseToolBasicUsageTest.cpp similarity index 90% rename from testing/demoapps/DoseTool/DoseToolBasicUsageTest.cpp rename to testing/apps/DoseTool/DoseToolBasicUsageTest.cpp index d439d8e..0f2cff8 100644 --- a/testing/demoapps/DoseTool/DoseToolBasicUsageTest.cpp +++ b/testing/apps/DoseTool/DoseToolBasicUsageTest.cpp @@ -1,75 +1,75 @@ // ----------------------------------------------------------------------- // 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) +// @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 DoseToolBasicUsageTest(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 without parameters std::cout << "Command line call: " + doseToolExeWithPath << std::endl; CHECK_EQUAL(system(doseToolExeWithPath.c_str()) != 0, true); //call with help parameters std::string helpCommandShort = doseToolExeWithPath + " -h"; std::string helpCommandLong = doseToolExeWithPath + " --help"; std::cout << "Command line call: " + helpCommandShort << std::endl; CHECK_EQUAL(system(helpCommandShort.c_str()), 0); std::cout << "Command line call: " + helpCommandLong << std::endl; CHECK_EQUAL(system(helpCommandLong.c_str()), 0); //call with version parameter std::string versionCommandShort = doseToolExeWithPath + " -v"; std::string versionCommandLong = doseToolExeWithPath + " --version"; std::cout << "Command line call: " + versionCommandShort << std::endl; CHECK_EQUAL(system(versionCommandShort.c_str()), 0); std::cout << "Command line call: " + versionCommandLong << std::endl; CHECK_EQUAL(system(versionCommandLong.c_str()), 0); //call with RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/demoapps/DoseTool/DoseToolDVHTest.cpp b/testing/apps/DoseTool/DoseToolDVHTest.cpp similarity index 90% rename from testing/demoapps/DoseTool/DoseToolDVHTest.cpp rename to testing/apps/DoseTool/DoseToolDVHTest.cpp index 6d71d25..01325d5 100644 --- a/testing/demoapps/DoseTool/DoseToolDVHTest.cpp +++ b/testing/apps/DoseTool/DoseToolDVHTest.cpp @@ -1,106 +1,106 @@ // ----------------------------------------------------------------------- // 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) +// @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 #include #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; static std::string readFile(const std::string& filename); 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 voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + doseToolExecutable; std::string defaultOutputFilename = "dicomDVHOutput.xml"; std::string baseCommand = voxelizerToolExeWithPath; 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); //check if file is the same than reference file std::string defaultAsIs = readFile(defaultOutputFilename); std::string defaultExpected = readFile(referenceXMLFilename); CHECK_EQUAL(defaultAsIs, defaultExpected); //delete file again CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } std::string readFile(const std::string& filename) { std::ifstream fileStream(filename.c_str()); std::string content((std::istreambuf_iterator(fileStream)), (std::istreambuf_iterator())); return content; } } //namespace testing } //namespace rttb diff --git a/testing/demoapps/DoseTool/DoseToolDicomDoseTest.cpp b/testing/apps/DoseTool/DoseToolDicomDoseTest.cpp similarity index 93% rename from testing/demoapps/DoseTool/DoseToolDicomDoseTest.cpp rename to testing/apps/DoseTool/DoseToolDicomDoseTest.cpp index 7679251..fa7c4c3 100644 --- a/testing/demoapps/DoseTool/DoseToolDicomDoseTest.cpp +++ b/testing/apps/DoseTool/DoseToolDicomDoseTest.cpp @@ -1,150 +1,150 @@ // ----------------------------------------------------------------------- // 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) +// @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 #include #include "litCheckMacros.h" #include "boost/filesystem.hpp" #include "boost/algorithm/string.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; static std::string readFile(const std::string& filename); 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 = "dicomOutput.xml"; std::string defaultDVHOutputFilename = "dicomDVHOutput.xml"; std::string complexOutputFilename = "dicomOutputComplex.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 += " -x -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 is the same than reference file std::string defaultAsIs = readFile(defaultOutputFilename); std::string defaultExpected = readFile(referenceXMLFilename); //add doseFile and structFile std::string emptyDoseFileTag = ""; std::string validDoseFileTag = "" + doseFilename + ""; boost::replace_all(defaultExpected, emptyDoseFileTag, validDoseFileTag); std::string emptyStructFileTag = ""; std::string validStructFileTag = "" + structFilename + ""; boost::replace_all(defaultExpected, emptyStructFileTag, validStructFileTag); CHECK_EQUAL(defaultAsIs, defaultExpected); std::string defaultDVHAsIs = readFile(defaultDVHOutputFilename); std::string defaultDVHExpected = readFile(referenceDVHXMLFilename); CHECK_EQUAL(defaultDVHAsIs, defaultDVHExpected); //add doseFile and structFile std::string complexAsIs = readFile(complexOutputFilename); std::string complexExpected = readFile(referenceXMLComplexFilename); boost::replace_all(complexExpected, emptyDoseFileTag, validDoseFileTag); boost::replace_all(complexExpected, emptyStructFileTag, validStructFileTag); CHECK_EQUAL(complexAsIs, complexExpected); //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; } std::string readFile(const std::string& filename) { std::ifstream fileStream(filename.c_str()); std::string content((std::istreambuf_iterator(fileStream)), (std::istreambuf_iterator())); return content; } } //namespace testing } //namespace rttb diff --git a/testing/demoapps/DoseTool/DoseToolITKDoseTest.cpp b/testing/apps/DoseTool/DoseToolITKDoseTest.cpp similarity index 93% rename from testing/demoapps/DoseTool/DoseToolITKDoseTest.cpp rename to testing/apps/DoseTool/DoseToolITKDoseTest.cpp index 277b002..49c703d 100644 --- a/testing/demoapps/DoseTool/DoseToolITKDoseTest.cpp +++ b/testing/apps/DoseTool/DoseToolITKDoseTest.cpp @@ -1,143 +1,143 @@ // ----------------------------------------------------------------------- // 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) +// @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 #include #include "litCheckMacros.h" #include "boost/filesystem.hpp" #include "boost/algorithm/string.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; static std::string readFile(const std::string& filename); int DoseToolITKDoseTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseToolExecutable; std::string doseFilename; std::string structFilename; std::string structName; std::string ctxFilename; std::string referenceXMLFilename; std::string referenceXMLComplexFilename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 7) { doseToolExecutable = argv[1]; doseFilename = argv[2]; structFilename = argv[3]; ctxFilename = argv[4]; structName = argv[5]; referenceXMLFilename = argv[6]; referenceXMLComplexFilename = argv[7]; } std::string doseToolExeWithPath = callingPath.parent_path().string() + "/" + doseToolExecutable; std::string defaultOutputFilename = "itkOutput.xml"; std::string complexOutputFilename = "itkOutputComplex.xml"; std::string baseCommand = doseToolExeWithPath; baseCommand += " -d " + doseFilename; baseCommand += " -s " + structFilename; baseCommand += " -t itk "; if (structName != "") { baseCommand += " -n " + structName; if (ctxFilename != "") { baseCommand += " -u virtuos " + ctxFilename; } } 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 complexDoseStatisticsCommand = baseCommand + " -y " + complexOutputFilename; //prescribed dose is 14 Gy complexDoseStatisticsCommand += " -x -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 is the same than reference file std::string defaultAsIs = readFile(defaultOutputFilename); std::string defaultExpected = readFile(referenceXMLFilename); //add doseFile and structFile std::string emptyDoseFileTag = ""; std::string validDoseFileTag = "" + doseFilename + ""; boost::replace_all(defaultExpected, emptyDoseFileTag, validDoseFileTag); std::string emptyStructFileTag = ""; std::string validStructFileTag = "" + structFilename + ""; boost::replace_all(defaultExpected, emptyStructFileTag, validStructFileTag); CHECK_EQUAL(defaultAsIs, defaultExpected); //add doseFile and structFile std::string complexAsIs = readFile(complexOutputFilename); std::string complexExpected = readFile(referenceXMLComplexFilename); boost::replace_all(complexExpected, emptyDoseFileTag, validDoseFileTag); boost::replace_all(complexExpected, emptyStructFileTag, validStructFileTag); CHECK_EQUAL(complexAsIs, complexExpected); //delete file again CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); CHECK_EQUAL(std::remove(complexOutputFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } std::string readFile(const std::string& filename) { std::ifstream fileStream(filename.c_str()); std::string content((std::istreambuf_iterator(fileStream)), (std::istreambuf_iterator())); return content; } } //namespace testing } //namespace rttb diff --git a/testing/demoapps/DoseTool/DoseToolInvalidParametersTest.cpp b/testing/apps/DoseTool/DoseToolInvalidParametersTest.cpp similarity index 93% rename from testing/demoapps/DoseTool/DoseToolInvalidParametersTest.cpp rename to testing/apps/DoseTool/DoseToolInvalidParametersTest.cpp index 106fcdd..bec104f 100644 --- a/testing/demoapps/DoseTool/DoseToolInvalidParametersTest.cpp +++ b/testing/apps/DoseTool/DoseToolInvalidParametersTest.cpp @@ -1,109 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @version $Revision: 771 $ (last changed revision) +// @date $Date: 2014-09-25 14:41:34 +0200 (Do, 25 Sep 2014) $ (last change date) +// @author $Author: zhangl $ (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 virtuos dose load option, but without plan/ctx std::string invalidVirtuosDoseLoadOption = minimalCLI; invalidVirtuosDoseLoadOption += "-u virtuos"; std::cout << "Command line call: " + invalidVirtuosDoseLoadOption << std::endl; CHECK_EQUAL(system(invalidVirtuosDoseLoadOption.c_str()) != 0, true); std::string invalidVirtuosStructLoadOption = minimalCLI; invalidVirtuosStructLoadOption += "-t virtuos"; std::cout << "Command line call: " + invalidVirtuosStructLoadOption << std::endl; CHECK_EQUAL(system(invalidVirtuosStructLoadOption.c_str()) != 0, true); //call with complex dose statistics, but without prescribed dose std::string complexDoseWithoutPrescribedDoseCommand = minimalCLI; complexDoseWithoutPrescribedDoseCommand += "-x"; 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/demoapps/DoseTool/DoseToolRegexTest.cpp b/testing/apps/DoseTool/DoseToolRegexTest.cpp similarity index 94% rename from testing/demoapps/DoseTool/DoseToolRegexTest.cpp rename to testing/apps/DoseTool/DoseToolRegexTest.cpp index f76109c..5226155 100644 --- a/testing/demoapps/DoseTool/DoseToolRegexTest.cpp +++ b/testing/apps/DoseTool/DoseToolRegexTest.cpp @@ -1,144 +1,144 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 771 $ (last changed revision) +// @date $Date: 2014-09-25 14:41:34 +0200 (Do, 25 Sep 2014) $ (last change date) +// @author $Author: zhangl $ (last changed by) */ #include #include #include #include "litCheckMacros.h" #include "boost/filesystem.hpp" #include "boost/algorithm/string.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; static std::string readFile(const std::string& filename); 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 is the same than reference file std::string defaultAsIs = readFile(defaultExpectedOutputFilename); std::string defaultExpected = readFile(referenceXMLFilename); //add doseFile and structFile std::string emptyDoseFileTag = ""; std::string validDoseFileTag = "" + doseFilename + ""; boost::replace_all(defaultExpected, emptyDoseFileTag, validDoseFileTag); std::string emptyStructFileTag = ""; std::string validStructFileTag = "" + structFilename + ""; boost::replace_all(defaultExpected, emptyStructFileTag, validStructFileTag); std::string requestedStructRegexTag = "Nodes"; std::string validStructRegexTag = "" + structName + ""; boost::replace_all(defaultExpected, requestedStructRegexTag, validStructRegexTag); CHECK_EQUAL(defaultAsIs, defaultExpected); //add doseFile and structFile std::string default2AsIs = readFile(defaultExpectedOutputFilename2); std::string default2Expected = readFile(referenceXMLFilename2); boost::replace_all(default2Expected, emptyDoseFileTag, validDoseFileTag); boost::replace_all(default2Expected, emptyStructFileTag, validStructFileTag); requestedStructRegexTag = "Heart"; validStructRegexTag = "" + structName + ""; boost::replace_all(default2Expected, requestedStructRegexTag, validStructRegexTag); CHECK_EQUAL(default2AsIs, default2Expected); //delete file again CHECK_EQUAL(std::remove(defaultExpectedOutputFilename.c_str()), 0); CHECK_EQUAL(std::remove(defaultExpectedOutputFilename2.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } std::string readFile(const std::string& filename) { std::ifstream fileStream(filename.c_str()); std::string content((std::istreambuf_iterator(fileStream)), (std::istreambuf_iterator())); return content; } } //namespace testing } //namespace rttb diff --git a/testing/demoapps/DoseTool/DoseToolTests.cpp b/testing/apps/DoseTool/DoseToolTests.cpp similarity index 86% rename from testing/demoapps/DoseTool/DoseToolTests.cpp rename to testing/apps/DoseTool/DoseToolTests.cpp index 40003c8..18276bf 100644 --- a/testing/demoapps/DoseTool/DoseToolTests.cpp +++ b/testing/apps/DoseTool/DoseToolTests.cpp @@ -1,73 +1,73 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 771 $ (last changed revision) +// @date $Date: 2014-09-25 14:41:34 +0200 (Do, 25 Sep 2014) $ (last change date) +// @author $Author: zhangl $ (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" namespace rttb { namespace testing { const char* _callingAppPath = NULL; void registerTests() { LIT_REGISTER_TEST(DoseToolBasicUsageTest); LIT_REGISTER_TEST(DoseToolInvalidParametersTest); LIT_REGISTER_TEST(DoseToolVirtuosDoseTest); 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/demoapps/DoseTool/DoseToolVirtuosDoseTest.cpp b/testing/apps/DoseTool/DoseToolVirtuosDoseTest.cpp similarity index 93% rename from testing/demoapps/DoseTool/DoseToolVirtuosDoseTest.cpp rename to testing/apps/DoseTool/DoseToolVirtuosDoseTest.cpp index 252f0ed..297f501 100644 --- a/testing/demoapps/DoseTool/DoseToolVirtuosDoseTest.cpp +++ b/testing/apps/DoseTool/DoseToolVirtuosDoseTest.cpp @@ -1,133 +1,133 @@ // ----------------------------------------------------------------------- // 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) +// @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 #include #include "litCheckMacros.h" #include "boost/filesystem.hpp" #include "boost/algorithm/string.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; static std::string readFile(const std::string& filename); int DoseToolVirtuosDoseTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseToolExecutable; std::string doseFilename; std::string planFilename; std::string structFilename; std::string ctxFilename; std::string structName; std::string referenceXMLFilename; std::string referenceXMLComplexFilename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 8) { doseToolExecutable = argv[1]; doseFilename = argv[2]; planFilename = argv[3]; structFilename = argv[4]; ctxFilename = argv[5]; structName = argv[6]; referenceXMLFilename = argv[7]; referenceXMLComplexFilename = argv[8]; } std::string doseToolExeWithPath = callingPath.parent_path().string() + "/" + doseToolExecutable; std::string defaultOutputFilename = "virtuosOutput.xml"; std::string complexOutputFilename = "virtuosOutputComplex.xml"; std::string baseCommand = doseToolExeWithPath; baseCommand += " -d " + doseFilename; baseCommand += " -t virtuos " + planFilename; baseCommand += " -s " + structFilename; baseCommand += " -u virtuos " + ctxFilename; baseCommand += " -n " + structName; 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 50 Gy complexDoseStatisticsCommand += " -x -p 50"; 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 is the same than reference file std::string defaultAsIs = readFile(defaultOutputFilename); std::string defaultExpected = readFile(referenceXMLFilename); //add doseFile and structFile std::string emptyDoseFileTag = ""; std::string validDoseFileTag = "" + doseFilename + ""; boost::replace_all(defaultExpected, emptyDoseFileTag, validDoseFileTag); std::string emptyStructFileTag = ""; std::string validStructFileTag = "" + structFilename + ""; boost::replace_all(defaultExpected, emptyStructFileTag, validStructFileTag); CHECK_EQUAL(defaultAsIs, defaultExpected); //add doseFile and structFile std::string complexAsIs = readFile(complexOutputFilename); std::string complexExpected = readFile(referenceXMLComplexFilename); boost::replace_all(complexExpected, emptyDoseFileTag, validDoseFileTag); boost::replace_all(complexExpected, emptyStructFileTag, validStructFileTag); CHECK_EQUAL(complexAsIs, complexExpected); //delete file again CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); CHECK_EQUAL(std::remove(complexOutputFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } std::string readFile(const std::string& filename) { std::ifstream fileStream(filename.c_str()); std::string content((std::istreambuf_iterator(fileStream)), (std::istreambuf_iterator())); return content; } } //namespace testing } //namespace rttb diff --git a/testing/demoapps/DoseTool/files.cmake b/testing/apps/DoseTool/files.cmake similarity index 100% rename from testing/demoapps/DoseTool/files.cmake rename to testing/apps/DoseTool/files.cmake diff --git a/testing/demoapps/VoxelizerTool/CMakeLists.txt b/testing/apps/VoxelizerTool/CMakeLists.txt similarity index 100% rename from testing/demoapps/VoxelizerTool/CMakeLists.txt rename to testing/apps/VoxelizerTool/CMakeLists.txt diff --git a/testing/demoapps/VoxelizerTool/files.cmake b/testing/apps/VoxelizerTool/files.cmake similarity index 100% rename from testing/demoapps/VoxelizerTool/files.cmake rename to testing/apps/VoxelizerTool/files.cmake diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp b/testing/apps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp similarity index 91% rename from testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp rename to testing/apps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp index 09cb68d..e1107c5 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp +++ b/testing/apps/VoxelizerTool/rttbVoxelizerToolDifferentCommandsTest.cpp @@ -1,110 +1,110 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1333 $ (last changed revision) +// @date $Date: 2016-04-22 11:12:14 +0200 (Fr, 22 Apr 2016) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #include "litCheckMacros.h" #include #include #include /*! @brief VoxelizerToolTest3. Test the output, multipleStructs and the booleanVoxelization parameter. */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolDifferentCommandsTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; if (argc > 4) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; } std::vector commands; commands.push_back("\"Niere.*\" -m -o Test.hdr"); commands.push_back("\"Leber\" -o Boolean.hdr -v"); std::vector filenames; filenames.push_back("Test_Niere li"); filenames.push_back("Test_Niere re"); filenames.push_back("Boolean_Leber"); boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::string baseCommand = voxelizerToolExeWithPath; baseCommand += " -s " + structFile; baseCommand += " -r " + referenceFile; baseCommand += " -e "; for (size_t i = 0; i < commands.size(); i++) { std::string command = baseCommand + commands.at(i); int returnValue = system(command.c_str()); std::cout << "Command line call: " + command << std::endl; CHECK_EQUAL(returnValue, 0); } std::string helpCommand = voxelizerToolExeWithPath + " -h"; int returnValue = system(helpCommand.c_str()); std::cout << "Command line call: " + helpCommand << std::endl; CHECK_EQUAL(returnValue, 0); for (size_t i = 0; i < filenames.size(); i++) { const std::string HDRfileName = tempDirectory + "/" + filenames.at(i) + ".hdr"; boost::filesystem::path HDRFile(HDRfileName); const std::string IMGfileName = tempDirectory + "/" + filenames.at(i) + ".img"; boost::filesystem::path IMGFile(IMGfileName); CHECK_EQUAL(boost::filesystem::exists(HDRFile), true); CHECK_EQUAL(boost::filesystem::exists(IMGFile), true); if (boost::filesystem::exists(IMGFile)) { boost::filesystem::remove(IMGFile); } if (boost::filesystem::exists(HDRFile)) { boost::filesystem::remove(HDRFile); } } RETURN_AND_REPORT_TEST_SUCCESS; } } } diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp b/testing/apps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp similarity index 93% rename from testing/demoapps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp rename to testing/apps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp index b405efe..398b55d 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp +++ b/testing/apps/VoxelizerTool/rttbVoxelizerToolIncorrectCommandsTest.cpp @@ -1,120 +1,120 @@ // ----------------------------------------------------------------------- // 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) +// @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 /*! @brief VoxelizerToolTest4. Test incorrect commands with a wrong structfile, referencefile and a wrong struct. if the command return one, the program could not run to the end. return zero the command is correct */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolIncorrectCommandsTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string voxelizerToolExe; std::string structFile; std::string invalidStructFile; std::string invalidReferenceFile; std::string referenceFile; std::string structureName; std::string invalidStructureName; if (argc > 7) { voxelizerToolExe = argv[1]; structFile = argv[2]; invalidStructFile = argv[3]; referenceFile = argv[4]; invalidReferenceFile = argv[5]; structureName = argv[6]; invalidStructureName = argv[7]; } boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::string tooFewArgumentsCommand = voxelizerToolExeWithPath; tooFewArgumentsCommand += " -s " + invalidStructFile; tooFewArgumentsCommand += " -r " + referenceFile; std::cout << "Command line call: " + tooFewArgumentsCommand << std::endl; CHECK_EQUAL(system(tooFewArgumentsCommand.c_str()) != 0, true); tooFewArgumentsCommand = voxelizerToolExeWithPath; tooFewArgumentsCommand += " -s " + invalidStructFile; tooFewArgumentsCommand += " -e " + structureName; std::cout << "Command line call: " + tooFewArgumentsCommand << std::endl; CHECK_EQUAL(system(tooFewArgumentsCommand.c_str()) != 0, true); tooFewArgumentsCommand = voxelizerToolExeWithPath; std::cout << "Command line call: " + tooFewArgumentsCommand << std::endl; CHECK_EQUAL(system(tooFewArgumentsCommand.c_str()) != 0, true); std::string noOutputEndingCommand = voxelizerToolExeWithPath; noOutputEndingCommand += " -s " + invalidStructFile; noOutputEndingCommand += " -r " + referenceFile; noOutputEndingCommand += " -e " + structureName; noOutputEndingCommand += " -o bla"; std::cout << "Command line call: " + noOutputEndingCommand << std::endl; CHECK_EQUAL(system(noOutputEndingCommand.c_str()) != 0, true); std::string structCommand = voxelizerToolExeWithPath; structCommand += " -s " + invalidStructFile; structCommand += " -r " + referenceFile; structCommand += " -e " + structureName; std::cout << "Command line call: " + structCommand << std::endl; CHECK_EQUAL(system(structCommand.c_str()) != 0, true); std::string referenceCommand = voxelizerToolExeWithPath; referenceCommand += " -s " + structFile; referenceCommand += " -r " + invalidReferenceFile; referenceCommand += " -e " + structureName; std::cout << "Command line call: " + referenceCommand << std::endl; CHECK_EQUAL(system(referenceCommand.c_str()) != 0, true); std::string structureNameCommand = voxelizerToolExeWithPath; structureNameCommand += " -s " + structFile; structureNameCommand += " -r " + referenceFile; structureNameCommand += +" -e " + invalidStructureName; std::cout << "Command line call: " + structureNameCommand << std::endl; CHECK_EQUAL(system(structureNameCommand.c_str()), 0); std::string referenceLoadingStyleCommand = voxelizerToolExeWithPath; referenceLoadingStyleCommand += " -s " + structFile; referenceLoadingStyleCommand += " -r " + referenceFile; referenceLoadingStyleCommand += +" -e " + invalidStructureName; referenceLoadingStyleCommand += +" -y nonsense"; std::cout << "Command line call: " + referenceLoadingStyleCommand << std::endl; CHECK_EQUAL(system(referenceLoadingStyleCommand.c_str()) != 0, true); RETURN_AND_REPORT_TEST_SUCCESS; } } } diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolTests.cpp b/testing/apps/VoxelizerTool/rttbVoxelizerToolTests.cpp similarity index 85% rename from testing/demoapps/VoxelizerTool/rttbVoxelizerToolTests.cpp rename to testing/apps/VoxelizerTool/rttbVoxelizerToolTests.cpp index 2839bcb..2a55383 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolTests.cpp +++ b/testing/apps/VoxelizerTool/rttbVoxelizerToolTests.cpp @@ -1,69 +1,69 @@ // ----------------------------------------------------------------------- // 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) +// @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) */ // 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" namespace rttb { namespace testing { const char* _callingAppPath = NULL; void registerTests() { LIT_REGISTER_TEST(VoxelizerToolDifferentCommandsTest); LIT_REGISTER_TEST(VoxelizerToolVoxelizerBoostLegacy); LIT_REGISTER_TEST(VoxelizerToolVoxelValue); LIT_REGISTER_TEST(VoxelizerToolIncorrectCommandsTest); LIT_REGISTER_TEST(VoxelizerToolVoxelizerAllStructsTest); } } } 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/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelValueTest.cpp b/testing/apps/VoxelizerTool/rttbVoxelizerToolVoxelValueTest.cpp similarity index 92% rename from testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelValueTest.cpp rename to testing/apps/VoxelizerTool/rttbVoxelizerToolVoxelValueTest.cpp index 2db1965..272bfb1 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelValueTest.cpp +++ b/testing/apps/VoxelizerTool/rttbVoxelizerToolVoxelValueTest.cpp @@ -1,134 +1,134 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1333 $ (last changed revision) +// @date $Date: 2016-04-22 11:12:14 +0200 (Fr, 22 Apr 2016) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #include "litCheckMacros.h" #include #include "itkImage.h" #include "itkImageFileReader.h" #include #include /*! @brief VoxelizerToolTest5. Search the coordinate at the Image and return the Voxel(Pixel) value. */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolVoxelValue(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; typedef itk::Image< double, 3 > ImageType; typedef itk::ImageFileReader ReaderType; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; std::string structName; if (argc > 5) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; structName = argv[5]; } boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::string command = voxelizerToolExeWithPath; command += " -s " + structFile; command += " -r " + referenceFile; command += " -e " + structName; int returnValue = system(command.c_str()); CHECK_EQUAL(returnValue, 0); //image values taken in Mevislab //Index inside ImageType::IndexType voxelInside1 = {{20, 30, 30}}; ImageType::IndexType voxelInside2 = {{30, 10, 40}}; //Outside index ImageType::IndexType voxelOutside1 = {{40, 30, 30}}; ImageType::IndexType voxelOutside2 = {{10, 40, 30}}; //Border index ImageType::IndexType voxelBorder1 = {{12, 23, 27}}; ImageType::IndexType voxelBorder2 = {{34, 21, 31}}; std::vector voxelIndices = boost::assign::list_of(voxelInside1)(voxelInside2)( voxelOutside1)( voxelOutside2)(voxelBorder1)(voxelBorder2); std::vector expectedVoxelValues = boost::assign::list_of(1.0)(1.0)(0.0)(0.0)( 0.265865)(0.819613); std::string filenameHDRWithVoxelization = tempDirectory + "/out_" + structName + ".hdr"; std::string filenameIMGWithVoxelization = tempDirectory + "/out_" + structName + ".img"; CHECK(boost::filesystem::exists(filenameHDRWithVoxelization)); CHECK(boost::filesystem::exists(filenameIMGWithVoxelization)); if (boost::filesystem::exists(filenameHDRWithVoxelization)) { ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(filenameHDRWithVoxelization); reader->Update(); ReaderType::OutputImageType::ConstPointer image = reader->GetOutput(); for (size_t i = 0; i < voxelIndices.size(); i++) { ImageType::PixelType voxelValue = image->GetPixel(voxelIndices.at(i)); ImageType::PixelType expectedVoxelValue = expectedVoxelValues.at(i); if (expectedVoxelValue == 0.0 || expectedVoxelValue == 1.0) { CHECK_EQUAL(voxelValue, expectedVoxelValue); } else { CHECK_CLOSE(voxelValue, expectedVoxelValue, 1e-4); } } if (boost::filesystem::exists(filenameHDRWithVoxelization)) { boost::filesystem::remove(filenameHDRWithVoxelization); } if (boost::filesystem::exists(filenameIMGWithVoxelization)) { boost::filesystem::remove(filenameIMGWithVoxelization); } } RETURN_AND_REPORT_TEST_SUCCESS; } } } diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp b/testing/apps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp similarity index 91% rename from testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp rename to testing/apps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp index da93109..6e87e64 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp +++ b/testing/apps/VoxelizerTool/rttbVoxelizerToolVoxelizerAllStructsTest.cpp @@ -1,109 +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$ (last changed revision) -// @date $Date$ (last change date) -// @author $Author$ (last changed by) +// @version $Revision: 1333 $ (last changed revision) +// @date $Date: 2016-04-22 11:12:14 +0200 (Fr, 22 Apr 2016) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #include #include "litCheckMacros.h" #include #include /*! @brief VoxelizerToolTest. Tests a selection of structs. */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolVoxelizerAllStructsTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; if (argc > 4) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; } boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::vector structNames; structNames.push_back("Niere.*"); structNames.push_back("Magen/DD"); structNames.push_back("PTV"); //structure names will be used for file naming, BUT '.' in the end will be cropped and '/' will be replaced by '_'. Thus, the different filenames. std::vector filenames; filenames.push_back("Niere re"); filenames.push_back("Magen_DD"); filenames.push_back("PTV"); std::string baseCommand = voxelizerToolExeWithPath; baseCommand += " -s " + structFile; baseCommand += " -r " + referenceFile; baseCommand += " -e \""; for (size_t i = 0; i < structNames.size(); i++) { std::string command = baseCommand + structNames.at(i) + "\""; std::cout << "Command line call: " + command << std::endl; int returnValue = system(command.c_str()); CHECK_EQUAL(returnValue, 0); boost::filesystem::path HDRFile(tempDirectory); HDRFile /= "out_" + filenames.at(i) + ".hdr"; boost::filesystem::path IMGFile(tempDirectory); IMGFile /= "out_" + filenames.at(i) + ".img"; CHECK_EQUAL( boost::filesystem::exists(HDRFile), true); CHECK_EQUAL( boost::filesystem::exists(IMGFile), true); if (boost::filesystem::exists(IMGFile)) { boost::filesystem::remove(IMGFile); } if (boost::filesystem::exists(HDRFile)) { boost::filesystem::remove(HDRFile); } } RETURN_AND_REPORT_TEST_SUCCESS; } } } diff --git a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp b/testing/apps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp similarity index 90% rename from testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp rename to testing/apps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp index aad393b..cdc9448 100644 --- a/testing/demoapps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp +++ b/testing/apps/VoxelizerTool/rttbVoxelizerToolVoxelizerBoostLegacyTest.cpp @@ -1,104 +1,104 @@ // ----------------------------------------------------------------------- // 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) +// @version $Revision: 1333 $ (last changed revision) +// @date $Date: 2016-04-22 11:12:14 +0200 (Fr, 22 Apr 2016) $ (last change date) +// @author $Author: hentsch $ (last changed by) */ #include "litCheckMacros.h" #include #include #include /*! @brief VoxelizerToolTest5. Test the paramter boost and legacy Voxelization. */ namespace rttb { namespace testing { //path to the current running directory. VoxelizerTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int VoxelizerToolVoxelizerBoostLegacy(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string voxelizerToolExe; std::string tempDirectory; std::string structFile; std::string referenceFile; if (argc > 4) { voxelizerToolExe = argv[1]; tempDirectory = argv[2]; structFile = argv[3]; referenceFile = argv[4]; } std::vector commands; commands.push_back("PTV -o Legacy.hdr -l"); commands.push_back("PTV -o Boost.hdr -b"); std::vector filenames; filenames.push_back("Boost_PTV"); filenames.push_back("Legacy_PTV"); boost::filesystem::path callingPath(_callingAppPath); std::string voxelizerToolExeWithPath = callingPath.parent_path().string() + "/" + voxelizerToolExe; std::string baseCommand = voxelizerToolExeWithPath; baseCommand += " -s " + structFile; baseCommand += " -r " + referenceFile; baseCommand += " -e "; for (size_t i = 0; i < commands.size(); i++) { std::string command = baseCommand + commands.at(i); int returnValue = system(command.c_str()); std::cout << "Command line call: " + command << std::endl; CHECK_EQUAL(returnValue, 0); } for (size_t i = 0; i < filenames.size(); i++) { const std::string HDRfileName = tempDirectory + "/" + filenames.at(i) + ".hdr"; boost::filesystem::path HDRFile(HDRfileName); const std::string IMGfileName = tempDirectory + "/" + filenames.at(i) + ".img"; boost::filesystem::path IMGFile(IMGfileName); CHECK_EQUAL(boost::filesystem::exists(HDRFile), true); CHECK_EQUAL(boost::filesystem::exists(IMGFile), true); if (boost::filesystem::exists(IMGFile)) { boost::filesystem::remove(IMGFile); } if (boost::filesystem::exists(HDRFile)) { boost::filesystem::remove(HDRFile); } } RETURN_AND_REPORT_TEST_SUCCESS; } } } diff --git a/utilities/ArgumentParsingLib/ArgumentParsingLib.tar.gz b/utilities/ArgumentParsingLib/ArgumentParsingLib.tar.gz new file mode 100644 index 0000000..420a2dc Binary files /dev/null and b/utilities/ArgumentParsingLib/ArgumentParsingLib.tar.gz differ diff --git a/utilities/Litmus/Litmus.tar.gz b/utilities/Litmus/Litmus.tar.gz new file mode 100644 index 0000000..3232ded Binary files /dev/null and b/utilities/Litmus/Litmus.tar.gz differ