diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a692f9..8f3bf3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,320 +1,320 @@ #----------------------------------------------------------------------------- # This is the root RTToolbox CMakeList file. #----------------------------------------------------------------------------- PROJECT(RTToolbox) CMAKE_MINIMUM_REQUIRED(VERSION 3.1) # RTToolbox version number. SET(RTToolbox_VERSION_MAJOR "5") SET(RTToolbox_VERSION_MINOR "1") SET(RTToolbox_VERSION_PATCH "0") # 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}") SET(RTToolbox_PREFIX "RTTB") # default build type SET(CMAKE_BUILD_TYPE Release) MARK_AS_ADVANCED(BUILD_SHARED_LIBS) IF (WIN32) IF (MSVC_VERSION LESS 1800) MESSAGE(FATAL_ERROR "RTToolbox requires at least Visual Studio 2013.") ELSEIF (MSVC_VERSION GREATER_EQUAL 1910) IF (${CMAKE_VERSION} VERSION_LESS "3.10.3") MESSAGE(AUTHOR_WARNING "Please use CMake version 3.10.3 or newer for Visual Studio 2017 as new boost versions are not recognized using old CMake versions.") ENDIF() ENDIF() add_definitions(-D_SCL_SECURE_NO_WARNINGS) ELSE (WIN32) IF (CMAKE_COMPILER_IS_GNUCC) IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.3) MESSAGE(AUTHOR_WARNING "RTToolbox was tested with GCC 5 and GCC 7 only. You are using GCC " ${CMAKE_CXX_COMPILER_VERSION} ". You might need to change some code in order to compile RT Toolbox.") ENDIF() ELSE() MESSAGE(AUTHOR_WARNING "RTToolbox was only tested with GCC. This compiler might not work.") ENDIF() ENDIF(WIN32) #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(cmake/rttbMacroCreateModuleConf.cmake) include(cmake/rttbMacroCreateApplication.cmake) include(cmake/rttbFunctionCreateModule.cmake) include(cmake/rttbFunctionCheckModuleDependencies.cmake) include(cmake/rttbFunctionUseModules.cmake) include(cmake/rttbFunctionOrganizeSources.cmake) include(cmake/rttbMacroCreateTestModule.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. #----------------------------------------------------------------------------- #build no tests as default OPTION(BUILD_TESTING "build tests" OFF) IF(BUILD_TESTING) SET(CTEST_NEW_FORMAT 1) INCLUDE(CTest) ENABLE_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 #----------------------------------------------------------------------------- SET(RTTOOLBOX_INSTALL_VERSION_PATH "RTTB-${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}") 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_INCLUDE_DIR) SET(RTTOOLBOX_INSTALL_INCLUDE_DIR "include/${RTTOOLBOX_INSTALL_VERSION_PATH}") ENDIF(NOT RTTOOLBOX_INSTALL_INCLUDE_DIR) IF(NOT RTTOOLBOX_INSTALL_PACKAGE_DIR) SET(RTTOOLBOX_INSTALL_PACKAGE_DIR "${RTTOOLBOX_INSTALL_LIB_DIR}/cmake/${RTTOOLBOX_INSTALL_VERSION_PATH}") ENDIF(NOT RTTOOLBOX_INSTALL_PACKAGE_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 (NOT RTTB_CXX_STANDARD) set(RTTB_CXX_STANDARD 11) ENDIF (NOT RTTB_CXX_STANDARD) set(CMAKE_CXX_STANDARD ${RTTB_CXX_STANDARD} CACHE STRING "") set(CMAKE_CXX_STANDARD_REQUIRED 1) OPTION(CMAKE_CXX_EXTENSIONS "" ON) MARK_AS_ADVANCED(CMAKE_CXX_STANDARD CMAKE_CXX_STANDARD_REQUIRED CMAKE_CXX_EXTENSIONS) 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}) #Raise warning level (MSVC has W3 default warning level) IF (WIN32) IF(NOT BUILD_SHARED_LIBS) set(CMAKE_CXX_FLAGS "/W4 /EHsc") ENDIF() ELSE() IF (CMAKE_COMPILER_IS_GNUCC) set(CMAKE_CXX_FLAGS "-Wall") ENDIF() ENDIF() +IF (MSVC_VERSION) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") +ENDIF() + 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}) #----------------------------------------------------------------------------- # Dispatch the build into the proper subdirectories. #----------------------------------------------------------------------------- OPTION(BUILD_All_Modules "All modules will be built" OFF) OPTION(BUILD_Apps "Determine if the CLI applications will be generated." OFF) MESSAGE (STATUS "generating Project RTToolbox") ADD_SUBDIRECTORY (code) IF (BUILD_Apps) ADD_SUBDIRECTORY (apps) ENDIF() -IF (BUILD_All_Modules OR BUILD_IO_ITK) - OPTION(RTTB_ITK5_SUPPORT "Determine if ITK v5 should be supported." OFF) -ENDIF() - IF (BUILD_TESTING) ADD_SUBDIRECTORY (testing) ENDIF (BUILD_TESTING) ADD_SUBDIRECTORY (documentation) #----------------------------------------------------------------------------- # Help other projects use RTToolbox. #----------------------------------------------------------------------------- EXPORT(PACKAGE RTToolbox) # ---------------- Export targets ----------------- SET(RTToolbox_TARGETS_FILE "${RTToolbox_BINARY_DIR}/RTToolboxTargets.cmake") FILE(WRITE ${RTToolbox_TARGETS_FILE} "# Generated by CMake, do not edit!") set(targets_to_export) get_property(module_targets GLOBAL PROPERTY RTTB_MODULE_TARGETS) if(module_targets) list(APPEND targets_to_export ${module_targets}) endif() export(TARGETS ${targets_to_export} APPEND FILE ${RTToolbox_TARGETS_FILE}) # 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 DESTINATION ${RTTOOLBOX_INSTALL_PACKAGE_DIR} COMPONENT Development ) ENDIF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) diff --git a/README.md b/README.md index 538ff38..feb402c 100644 --- a/README.md +++ b/README.md @@ -1,208 +1,204 @@ # RTToolbox RTToolbox is a software library to support quantitative analysis of treatment outcome for radiotherapy. The RTToolbox was designed following object-oriented design (OOD) principles and was implemented in the language C++. Features include: * import of radiotherapy data (e.g. dose distributions and structure sets) from DICOM-RT format and other standard image processing formats * DVH calculation * Dose statistic calculation * arithmetic operations on dose distributions * structure relationship analyses (e.g. fully-contained, partially-contained) * Calculation of dose comparison indices such as Conformity Index (CI), Homogeneity Index (HI) and Conformation Number (CN) * Calculation of biological models including TCP, NTCP, EUD and BED Also, the RTToolbox provides apps e.g. for DVH/Dose Statistic calculation or Dose accumulation that provides a convenient access of RT scenarios without computer-science knowledge. ## Getting Started These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. ### Prerequisites #### Build system * [CMake](https://cmake.org), version 3.1 or higher #### Compiler * Visual Studio 2013 * Visual Studio 2015 * Visual Studio 2017 * GCC 5.4 * GCC 7.3 Other compilers may work as well, but are not tested. #### Linking Static/Dynamic library support Can be changed with advanced option `BUILD_SHARED_LIBS` :warning: building RTToolbox as dynamic library under Windows and as static library under Linux is an experimental feature. #### Third party libraries * [boost](http://www.boost.org ), version 1.64.0 or higher * [DCMTK](http://dicom.offis.de/dcmtk.php.en ) 3.6.5 or higher -* [ITK](https://itk.org ), version 4.4 or higher (*optional*) +* [ITK](https://itk.org ), version 5.2 or higher (*optional*) * for DoseInterpolation support with ITK transformation or ITK File IO support * [MatchPoint](http://mitk.org/download/thirdparty/MatchPoint_rev1610.tar.gz ), version 0.12 or higher (*optional*) * for DoseInterpolation support with MatchPoint registration objects :information_source: To make sure everything runs smoothly, please make sure that all libraries and the RTToolbox are either compiled with `/MD` or `/MT` flags. ##### Boost In case you work with Windows, we recommend using the [pre-build versions of boost](https://sourceforge.net/projects/boost/files/boost-binaries/). If you want to build the library yourself, consider the following: Build (using the same compiler options as RTToolbox, usually `STATIC LINKING` and `x64` architecture). The following components are needed: * `filesystem`, * `system` and * `program_options` * if you plan to build the apps (*optional*) :information_source: eventually, it might be needed to add the CMake variable `BOOST_LIBRARYDIR` and set it to the respective library path of boost. For Windows: To build Boost open a command prompt, change to your boost source directory and copy following command(s): Debug: `b2 -j12 --with-filesystem --with-system --with-thread --with-program_options --with-date_time --with-atomic --with-chrono toolset= address-model=64 variant=debug threading=multi link=shared define=_BIND_TO_CURRENT_VCLIBS_VERSION` Release: `b2 -j12 --with-filesystem --with-system --with-thread --with-program_options --with-date_time --with-atomic --with-chrono toolset= address-model=64 variant=release threading=multi link=shared` Set the in the commands above accordingly. If you don´t require `program_options` delete `--with-program_options` from the command before executing it. ##### DCMTK For Windows: To compile DCMTK with `/MD` flags (standard for all other libs), you need to set DCMTK_COMPILE_WIN32_MULTITHREADED_DLL to "ON". `BUILD_APPS` can be switched off. Then build DCMTK. For Linux: install required dependencies (Ubuntu 18.04 and newer): `sudo apt-get install libpng-dev libtiff5-dev libxml2-dev libjpeg8-dev zlib1g-dev libwrap0-dev libssl-dev` install required dependencies (Ubuntu 17.10 and older): `sudo apt-get install libpng12-dev libtiff5-dev libxml2-dev libjpeg8-dev zlib1g-dev libwrap0-dev libssl-dev` Enable `BUILD_SHARED_LIBS`. `BUILD_APPS` can be switched off. ##### ITK Build ITK with default options. :warning: ensure that compiler enables C++11 features by setting `CMAKE_CXX_STANDARD=11` (default for supported compilers) -:warning: if you use ITK 5, turn on `RTTB_ITK5_SUPPORT` - :warning: Only use one ITK version consistently throughout all libraries and RTToolbox! Otherwise, linker errors will occur. ##### MatchPoint Configure MatchPoint. Please disable `BUILD_TESTING` before building it. :warning: ensure that compiler enables C++11 features by setting `CMAKE_CXX_STANDARD=11` (default for supported compilers) :warning: Only use one ITK version consistently throughout all libraries and RTToolbox! Otherwise, linker errors will occur. -:warning: MatchPoint currently does not support ITK 5 - ### Building RT-Toolbox * Configure with CMake * Set `BOOST_INCLUDE_DIR` to the main boost directory. Eventually set `BOOST_LIBRARYDIR` to the respective path (e.g. `/lib64-msvc-14.1\` for Visual Studio 2017 and 64-bit) * Select all packages you like to build (Parameters `BUILD_*` ; e.g. `BUILD_IO_Dicom`). * `BUILD_IO_Dicom`: Reading and writing of DICOM-RT files * `BUILD_IO_HELAX`: Reading of Helax DICOM files * `BUILD_IO_ITK`: Generic reading/writing with ITK * `BUILD_Interpolation`: Dose Interpolation * `BUILD_InterpolationMatchPointTransformation`: Dose Interpolation with Match Point registration support. * `BUILD_Masks`: Voxelization support * `BUILD_Models`: Calculation of dosimetrical models like TCP, NTCP etc. * `BUILD_Apps`: To build the RTTB command line apps (five available) * `BioModelCalc`: calculate the radiobiological effect based on dose * `DoseAcc`: Do dose accumulation * `DoseMap`: Do dose mapping * `DoseTool`: Compute Dose statistics and DVH * `VoxelizerTool`: Voxelize an RTSTRUCT file Some modules of RT-Toolbox are mandatory (e.g. `RTTBCore`) and build automatically. :information_source: enabling `BUILD_All_Modules` builds all modules (except Apps and Testing modules). :information_source: if you build RTTB with VS dynamic, you must ensure that code that uses RTTB DLLs uses the same STL Set `DCMTK_DIR` to your dcmtk binary file directory and `DCMTK_SOURCE_DIR` to your dcmtk source directory. If you want to build RT-Toolbox with ITK and/or MatchPoint set your `ITK_DIR` to your itk binary file directory and/or `MatchPoint_DIR` to your binary matchpoint directory. All directory entries left empty do not require a manual input. Finally, Generate the compilation files for your environment and built it. ### Examples Some examples can be found in ´testing/examples´: * `RTBioModelExampleTest`: Computation of Biological model indices (TCP/NTCP) from a given DVH * `RTDoseStatisticsDicomTest`: Computation of dose statistics (max dose/mean dose/min dose/Dx/Vx) based on dose data for a specified structure * `RTDVHTest`: Computation of statistics (max value/mean value/min value/Dx/Vx) based on a DVH Other examples include: * `DVHCalculatorTest` (`testing/core`): Computation of a DVH from dose and structure * `VoxelizationValidationTest` (`testing/validation`): Computation of a voxelization * `ITKDoseAccessorConverterTest`: (`testing/io/itk`): Saving image RTToolbox image data as an ITK file * `DoseIndex tests`: (`testing/indices`): Computation of different dose indices (e.g. Conformation Number, Conformal Index, Conformity index) ## Running the tests [CTest](https://cmake.org/Wiki/CMake/Testing_With_CTest) is used as testing framework. See their documentation for general testing questions. :information_source: The used testing library Litmus is build automatically. :warning: currently, you have access to testing data only with ssh. That means that a [phabricator](https://phabricator.mitk.org/) account and access to `RTTB-data` repository is mandatory. Please contact rttb(at)dkfz.de for further information. Enabling testing is done as follows: * Enable `BUILD_TESTING` * Configure with CMake * Enable tests of interest * Generate CMake configuration * Build RT-Toolbox * Run tests (build `RUN_TESTS` project or call `ctest` in commandline) to ensure that everything is correct. :information_source: `BUILD_Tester_All` builds all test modules. ## Contributing Please add a github issue and send a pull request if you want to contribute. ## Versioning We use the Ubuntu Release versioning scheme. v2017.02 was released in February 2017. We aim at releasing stable versions once a year. For the versions available, see the [tags on this repository](https://github.com/MIC-DKFZ/RTTB/tags). ## Authors See the list of [contributors](https://github.com/MIC-DKFZ/RTTB/contributors) who participated in this project. ## License This project is licensed under the BSD License - see the [LICENSE](LICENSE) file for details ## Contact Software Development for Integrated Diagnostics and Therapy (SIDT), German Cancer Research Center (DKFZ), Heidelberg, Germany. Web: https://www.dkfz-heidelberg.de/en/mic/research/SIDT/sidt_projects.html E-mail: rttb(at)dkfz.de ## Acknowledgments * **Billie Thompson** - *Template of the readme* - [PurpleBooth](https://github.com/PurpleBooth) diff --git a/cmake/PackageDepends/RTTB_ITK_Config.cmake b/cmake/PackageDepends/RTTB_ITK_Config.cmake index 9e2e23c..adbd349 100644 --- a/cmake/PackageDepends/RTTB_ITK_Config.cmake +++ b/cmake/PackageDepends/RTTB_ITK_Config.cmake @@ -1,44 +1,38 @@ #----------------------------------------------------------------------------- # Find ITK. #----------------------------------------------------------------------------- -FIND_PACKAGE(ITK 4.4 REQUIRED) +FIND_PACKAGE(ITK 5.2 REQUIRED) IF(ITK_FOUND) INCLUDE(${ITK_USE_FILE}) ELSE(ITK_FOUND) MESSAGE(FATAL_ERROR "Cannot build without ITK. Please set ITK_DIR.") ENDIF(ITK_FOUND) -IF(${ITK_VERSION_MAJOR} GREATER 5 OR ${ITK_VERSION_MAJOR} EQUAL 5) - IF (NOT RTTB_ITK5_SUPPORT) - MESSAGE (WARNING "You have to activate RTTB_ITK5_SUPPORT for ITK 5 support!") - ENDIF() -ENDIF() - LIST(APPEND ALL_INCLUDE_DIRECTORIES ${ITK_INCLUDE_DIRS}) LIST(APPEND ALL_LIBRARIES ${ITK_LIBRARIES}) LINK_DIRECTORIES(${ITK_LIBRARY_DIRS}) OPTION(RTTB_USE_SYSTEM_GDCM "Activate checker to choose a GDCM installation that should be linked with ITK. (This is needed e.g. when building against an ITK that is distributed with MITK. MITK uses its own GDCM and not the one distributed with ITK.)" OFF) IF (RTTB_USE_SYSTEM_GDCM) MESSAGE (STATUS "RTTB uses system GDCM instead of ITK distribution.") FIND_PACKAGE(GDCM PATHS ${ITK_GDCM_DIR} ${GDCM_DIR} REQUIRED) INCLUDE(${GDCM_USE_FILE}) LIST(APPEND ALL_INCLUDE_DIRECTORIES ${GDCM_INCLUDE_DIRS}) LIST(APPEND ALL_LIBRARIES ${GDCM_LIBRARIES}) ENDIF (RTTB_USE_SYSTEM_GDCM) OPTION(RTTB_USE_SYSTEM_HDF5 "Activate checker to choose a HDF5 installation that should be linked with ITK. (This is needed e.g. when building against an ITK that is distributed with MITK. MITK uses its own HDF5 and not the one distributed with ITK.)" OFF) IF (RTTB_USE_SYSTEM_HDF5) MESSAGE (STATUS "RTTB uses system HDF5 instead of ITK distribution.") FIND_PACKAGE(HDF5 PATHS ${HDF5_DIR} REQUIRED) LIST(APPEND ALL_INCLUDE_DIRECTORIES ${HDF5_INCLUDE_DIRS}) LIST(APPEND ALL_LIBRARIES ${HDF5_LIBRARIES}) ENDIF (RTTB_USE_SYSTEM_HDF5) CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/ITKConfig.cmake.in ${RTTB_MODULES_CONF_DIR}/ITKConfig.cmake @ONLY) diff --git a/code/io/itk/CMakeLists.txt b/code/io/itk/CMakeLists.txt index 5b27e61..7e6f406 100644 --- a/code/io/itk/CMakeLists.txt +++ b/code/io/itk/CMakeLists.txt @@ -1,9 +1 @@ -IF(RTTB_ITK5_SUPPORT) - SET(ITK_DEPENDENT_HEADER_FILES "ITK5/itkDoseAccessorImageFilter.h" "ITK5/itkMaskAccessorImageSource.h" ) - SET(ITK_DEPENDENT_SOURCE_FILES "ITK5/itkDoseAccessorImageFilter.cpp" "ITK5/itkMaskAccessorImageSource.cpp") - RTTB_CREATE_MODULE(RTTBITKIO INCLUDE_DIRS PRIVATE ITK5 DEPENDS PUBLIC RTTBCore PACKAGE_DEPENDS PUBLIC ITK) -ELSE() - SET(ITK_DEPENDENT_HEADER_FILES "ITK4/itkDoseAccessorImageFilter.h" "ITK4/itkMaskAccessorImageSource.h") - SET(ITK_DEPENDENT_SOURCE_FILES "ITK4/itkDoseAccessorImageFilter.cpp" "ITK4/itkMaskAccessorImageSource.cpp") - RTTB_CREATE_MODULE(RTTBITKIO INCLUDE_DIRS PRIVATE ITK4 DEPENDS PUBLIC RTTBCore PACKAGE_DEPENDS PUBLIC ITK) -ENDIF() \ No newline at end of file +RTTB_CREATE_MODULE(RTTBITKIO DEPENDS PUBLIC RTTBCore PACKAGE_DEPENDS PUBLIC ITK) diff --git a/code/io/itk/ITK4/itkDoseAccessorImageFilter.cpp b/code/io/itk/ITK4/itkDoseAccessorImageFilter.cpp deleted file mode 100644 index 642a13d..0000000 --- a/code/io/itk/ITK4/itkDoseAccessorImageFilter.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notices for more information. -// -//------------------------------------------------------------------------ - -#include "itkDoseAccessorImageFilter.h" -#include "itkImageRegionIterator.h" -#include "itkImageRegionConstIteratorWithIndex.h" -#include "itkProgressReporter.h" - -namespace itk -{ - /** - * Constructor - */ - DoseAccessorImageFilter - ::DoseAccessorImageFilter() - { - this->SetNumberOfRequiredInputs(1); - } - - void - DoseAccessorImageFilter - ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) - { - ProgressReporter progress(this, threadId, - outputRegionForThread.GetNumberOfPixels()); - - using ImageRegionConstIteratorType = ImageRegionConstIteratorWithIndex; - using OutputImageRegionIteratorType = ImageRegionIterator; - - InputImagePointer inputPtr = dynamic_cast< InputImageType* >(ProcessObject::GetInput(0)); - ImageRegionConstIteratorType inputItr; - - if (inputPtr) - { - inputItr = ImageRegionConstIteratorType(inputPtr, outputRegionForThread); - } - - OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); - OutputImageRegionIteratorType outputItr; - - if (outputPtr) - { - outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); - } - - if (inputPtr && outputPtr) - { - while (!(outputItr.IsAtEnd())) - { - ImageRegionConstIteratorType::IndexType index = inputItr.GetIndex(); - rttb::VoxelGridIndex3D doseIndex(index[0], index[1], index[2]); - - outputItr.Set(m_Accessor->getValueAt(doseIndex)); - - ++outputItr; - ++inputItr; - - progress.CompletedPixel(); - } - } - } -} // end namespace itk - diff --git a/code/io/itk/ITK4/itkDoseAccessorImageFilter.h b/code/io/itk/ITK4/itkDoseAccessorImageFilter.h deleted file mode 100644 index 33d8f73..0000000 --- a/code/io/itk/ITK4/itkDoseAccessorImageFilter.h +++ /dev/null @@ -1,112 +0,0 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notices for more information. -// -//------------------------------------------------------------------------ - -#ifndef __itkDoseAccessorImageFilter_h -#define __itkDoseAccessorImageFilter_h - -#include "itkImageToImageFilter.h" - -#include "rttbDoseAccessorInterface.h" -#include "rttbITKImageAccessor.h" - -namespace itk -{ - /** \class DoseAccessorImageFilter - * \brief Perform a generic pixel-wise operation on the input image by setting its pixel values according to the dose accessor output. - * - * \ingroup IntensityImageFilters MultiThreaded - * \ingroup ITKImageIntensity - */ - - typedef rttb::io::itk::ITKImageAccessor::ITKImageType RTTBDoseImageType; - - class ITK_EXPORT DoseAccessorImageFilter: - public ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > - - { - public: - /** Standard class typedefs. */ - typedef DoseAccessorImageFilter Self; - typedef ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > Superclass; - typedef SmartPointer< Self > Pointer; - typedef SmartPointer< const Self > ConstPointer; - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Run-time type information (and related methods). */ - itkTypeMacro(DoseAccessorImageFilter, ImageToImageFilter); - - /** Some typedefs. */ - typedef RTTBDoseImageType InputImageType; - typedef InputImageType::Pointer InputImagePointer; - typedef InputImageType::RegionType InputImageRegionType; - typedef InputImageType::PixelType InputImagePixelType; - typedef RTTBDoseImageType OutputImageType; - typedef OutputImageType::Pointer OutputImagePointer; - typedef OutputImageType::RegionType OutputImageRegionType; - typedef OutputImageType::PixelType OutputImagePixelType; - - typedef rttb::core::DoseAccessorInterface DoseAccessorType; - typedef rttb::core::DoseAccessorInterface::Pointer DoseAccessorPointer; - - /** Get the accessor pointer. */ - DoseAccessorPointer GetAccessor() - { - return m_Accessor; - } - - /** Set the accessor pointer. */ - void SetAccessor(DoseAccessorPointer accessor) - { - if (m_Accessor != accessor) - { - m_Accessor = accessor; - this->Modified(); - } - } - - /** ImageDimension constants */ - itkStaticConstMacro( - InputImageDimension, unsigned int, InputImageType::ImageDimension); - itkStaticConstMacro( - OutputImageDimension, unsigned int, OutputImageType::ImageDimension); - - protected: - DoseAccessorImageFilter(); - ~DoseAccessorImageFilter() override {} - - /** DoseAccessorImageFilter can be implemented as a multi threaded filter. - * Therefore, this implementation provides a ThreadedGenerateData() routine - * which is called for each processing thread. The output image data is - * allocated automatically by the superclass prior to calling - * ThreadedGenerateData(). ThreadedGenerateData can only write to the - * portion of the output image specified by the parameter - * "outputRegionForThread" - * - * \sa ImageToImageFilter::ThreadedGenerateData(), - * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) override; - - private: - DoseAccessorImageFilter(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - - DoseAccessorPointer m_Accessor; - }; -} // end namespace itk - - -#endif diff --git a/code/io/itk/ITK4/itkMaskAccessorImageSource.cpp b/code/io/itk/ITK4/itkMaskAccessorImageSource.cpp deleted file mode 100644 index 5f6aaaf..0000000 --- a/code/io/itk/ITK4/itkMaskAccessorImageSource.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notices for more information. -// -//------------------------------------------------------------------------ - -#include "itkMaskAccessorImageSource.h" -#include "itkImageRegionIterator.h" -#include "itkImageRegionConstIteratorWithIndex.h" -#include "itkProgressReporter.h" -#include "itkExceptionObject.h" - -#include "rttbGeometricInfo.h" - -namespace itk -{ - /** - * Constructor - */ - MaskAccessorImageSource - ::MaskAccessorImageSource() - = default; - - void - MaskAccessorImageSource - ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) - { - ProgressReporter progress(this, threadId, - outputRegionForThread.GetNumberOfPixels()); - - using OutputImageRegionIteratorType = ImageRegionIterator; - - OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); - OutputImageRegionIteratorType outputItr; - - if (outputPtr) - { - outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); - - for (; !(outputItr.IsAtEnd()); ++outputItr) - { - OutputImageType::IndexType index = outputItr.GetIndex(); - rttb::VoxelGridIndex3D maskIndex(index[0], index[1], index[2]); - rttb::VoxelGridID id = 0; - - if (m_Accessor->getGeometricInfo().convert(maskIndex, id)) - { - auto finding = m_idMap.find(id); - if (finding != m_idMap.end()) - { - // Set the current pixel - outputItr.Set(m_MaskedVoxels->at(finding->second).getRelevantVolumeFraction()); - } - } - else - { - if (m_FailsOnInvalidIDs) - { - itkExceptionMacro(<<"invalid Mask index. Index:"<(ProcessObject::GetOutput(0)); - outputPtr->FillBuffer(0.0); - - //The id map approach and working with relevant voxel vector is a workarround till task T22067 is solved and and can be used again. - m_MaskedVoxels = m_Accessor->getRelevantVoxelVector(); - - m_idMap.clear(); - - for (rttb::core::MaskAccessorInterface::MaskVoxelList::size_type pos = 0; pos < m_MaskedVoxels->size(); ++pos) - { - m_idMap.insert(std::make_pair((*m_MaskedVoxels)[pos].getVoxelGridID(), pos)); - } - } -} // end namespace itk - diff --git a/code/io/itk/ITK4/itkMaskAccessorImageSource.h b/code/io/itk/ITK4/itkMaskAccessorImageSource.h deleted file mode 100644 index 20d6a06..0000000 --- a/code/io/itk/ITK4/itkMaskAccessorImageSource.h +++ /dev/null @@ -1,105 +0,0 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notices for more information. -// -//------------------------------------------------------------------------ - -#ifndef __itkMaskAccessorImageSource_h -#define __itkMaskAccessorImageSource_h - -#include "itkGenerateImageSource.h" - -#include "rttbMaskAccessorInterface.h" -#include "rttbITKImageMaskAccessor.h" - -namespace itk -{ - /** \class MaskAccessorImageSource - * \brief Converts a given mask accessor into an itk image. - * - */ - - typedef rttb::io::itk::ITKImageMaskAccessor::ITKMaskImageType RTTBMaskImageType; - - class ITK_EXPORT MaskAccessorImageSource: - public GenerateImageSource< RTTBMaskImageType> - - { - public: - /** Standard class typedefs. */ - typedef MaskAccessorImageSource Self; - typedef GenerateImageSource< RTTBMaskImageType > Superclass; - typedef SmartPointer< Self > Pointer; - typedef SmartPointer< const Self > ConstPointer; - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Run-time type information (and related methods). */ - itkTypeMacro(MaskAccessorImageSource, ImageToImageFilter); - - /** Some typedefs. */ - typedef RTTBMaskImageType OutputImageType; - typedef OutputImageType::Pointer OutputImagePointer; - typedef OutputImageType::RegionType OutputImageRegionType; - typedef OutputImageType::PixelType OutputImagePixelType; - - typedef rttb::core::MaskAccessorInterface AccessorType; - typedef rttb::core::MaskAccessorInterface::Pointer AccessorPointer; - - /** Get the accessor pointer. */ - itkGetConstMacro(Accessor, AccessorPointer); - - /** Set the accessor pointer. */ - void SetAccessor(AccessorPointer accessor) - { - if (m_Accessor != accessor) - { - m_Accessor = accessor; - this->Modified(); - } - } - - itkSetMacro(FailsOnInvalidIDs, bool); - itkGetConstMacro(FailsOnInvalidIDs, bool); - - itkSetMacro(InvalidMaskValue, OutputImageType::ValueType); - itkGetConstMacro(InvalidMaskValue, OutputImageType::ValueType); - - /** ImageDimension constants */ - itkStaticConstMacro( - OutputImageDimension, unsigned int, OutputImageType::ImageDimension); - - protected: - MaskAccessorImageSource(); - ~MaskAccessorImageSource() override {} - - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) override; - - void BeforeThreadedGenerateData() override; - - private: - MaskAccessorImageSource(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - - typedef std::map VoxelMapType; - VoxelMapType m_idMap; - rttb::core::MaskAccessorInterface::MaskVoxelListPointer m_MaskedVoxels; - - AccessorPointer m_Accessor; - bool m_FailsOnInvalidIDs{true}; - OutputImageType::ValueType m_InvalidMaskValue{0}; - }; -} // end namespace itk - - -#endif diff --git a/code/io/itk/ITK5/itkMaskAccessorImageSource.cpp b/code/io/itk/ITK5/itkMaskAccessorImageSource.cpp deleted file mode 100644 index d1b8173..0000000 --- a/code/io/itk/ITK5/itkMaskAccessorImageSource.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notices for more information. -// -//------------------------------------------------------------------------ - -#include "itkMaskAccessorImageSource.h" -#include "itkImageRegionIterator.h" -#include "itkImageRegionConstIteratorWithIndex.h" -#include "itkExceptionObject.h" - -#include "rttbGeometricInfo.h" - -namespace itk -{ - /** - * Constructor - */ - MaskAccessorImageSource - ::MaskAccessorImageSource() - = default; - - void - MaskAccessorImageSource - ::DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) - { - using OutputImageRegionIteratorType = ImageRegionIterator; - - OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); - OutputImageRegionIteratorType outputItr; - - if (outputPtr) - { - outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); - - for (; !(outputItr.IsAtEnd()); ++outputItr) - { - OutputImageType::IndexType index = outputItr.GetIndex(); - rttb::VoxelGridIndex3D maskIndex(index[0], index[1], index[2]); - rttb::VoxelGridID id = 0; - - if (m_Accessor->getGeometricInfo().convert(maskIndex, id)) - { - auto finding = m_idMap.find(id); - if (finding != m_idMap.end()) - { - // Set the current pixel - outputItr.Set(m_MaskedVoxels->at(finding->second).getRelevantVolumeFraction()); - } - } - else - { - if (m_FailsOnInvalidIDs) - { - itkExceptionMacro(<<"invalid Mask index. Index:"<(ProcessObject::GetOutput(0)); - outputPtr->FillBuffer(0.0); - - //The id map approach and working with relevant voxel vector is a workarround till task T22067 is solved and and can be used again. - m_MaskedVoxels = m_Accessor->getRelevantVoxelVector(); - - m_idMap.clear(); - - for (rttb::core::MaskAccessorInterface::MaskVoxelList::size_type pos = 0; pos < m_MaskedVoxels->size(); ++pos) - { - m_idMap.insert(std::make_pair((*m_MaskedVoxels)[pos].getVoxelGridID(), pos)); - } - } -} // end namespace itk - diff --git a/code/io/itk/ITK5/itkMaskAccessorImageSource.h b/code/io/itk/ITK5/itkMaskAccessorImageSource.h deleted file mode 100644 index f890c87..0000000 --- a/code/io/itk/ITK5/itkMaskAccessorImageSource.h +++ /dev/null @@ -1,104 +0,0 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notices for more information. -// -//------------------------------------------------------------------------ - -#ifndef __itkMaskAccessorImageSource_h -#define __itkMaskAccessorImageSource_h - -#include "itkGenerateImageSource.h" - -#include "rttbMaskAccessorInterface.h" -#include "rttbITKImageMaskAccessor.h" - -namespace itk -{ - /** \class MaskAccessorImageSource - * \brief Converts a given mask accessor into an itk image. - * - */ - - typedef rttb::io::itk::ITKImageMaskAccessor::ITKMaskImageType RTTBMaskImageType; - - class ITK_EXPORT MaskAccessorImageSource: - public GenerateImageSource< RTTBMaskImageType> - - { - public: - /** Standard class typedefs. */ - typedef MaskAccessorImageSource Self; - typedef GenerateImageSource< RTTBMaskImageType > Superclass; - typedef SmartPointer< Self > Pointer; - typedef SmartPointer< const Self > ConstPointer; - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Run-time type information (and related methods). */ - itkTypeMacro(MaskAccessorImageSource, ImageToImageFilter); - - /** Some typedefs. */ - typedef RTTBMaskImageType OutputImageType; - typedef OutputImageType::Pointer OutputImagePointer; - typedef OutputImageType::RegionType OutputImageRegionType; - typedef OutputImageType::PixelType OutputImagePixelType; - - typedef rttb::core::MaskAccessorInterface AccessorType; - typedef rttb::core::MaskAccessorInterface::Pointer AccessorPointer; - - /** Get the accessor pointer. */ - itkGetConstMacro(Accessor, AccessorPointer); - - /** Set the accessor pointer. */ - void SetAccessor(AccessorPointer accessor) - { - if (m_Accessor != accessor) - { - m_Accessor = accessor; - this->Modified(); - } - } - - itkSetMacro(FailsOnInvalidIDs, bool); - itkGetConstMacro(FailsOnInvalidIDs, bool); - - itkSetMacro(InvalidMaskValue, OutputImageType::ValueType); - itkGetConstMacro(InvalidMaskValue, OutputImageType::ValueType); - - /** ImageDimension constants */ - itkStaticConstMacro( - OutputImageDimension, unsigned int, OutputImageType::ImageDimension); - - protected: - MaskAccessorImageSource(); - ~MaskAccessorImageSource() override {} - - void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override; - - void BeforeThreadedGenerateData() override; - - private: - MaskAccessorImageSource(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - - typedef std::map VoxelMapType; - VoxelMapType m_idMap; - rttb::core::MaskAccessorInterface::MaskVoxelListPointer m_MaskedVoxels; - - AccessorPointer m_Accessor; - bool m_FailsOnInvalidIDs{true}; - OutputImageType::ValueType m_InvalidMaskValue{0}; - }; -} // end namespace itk - - -#endif diff --git a/code/io/itk/files.cmake b/code/io/itk/files.cmake index 0d031e6..aeb35c4 100644 --- a/code/io/itk/files.cmake +++ b/code/io/itk/files.cmake @@ -1,38 +1,40 @@ SET(CPP_FILES + itkDoseAccessorImageFilter.cpp + itkMaskAccessorImageSource.cpp rttbFileDispatch.cpp rttbGenericImageReader.cpp rttbImageWriter.cpp rttbITKImageAccessor.cpp rttbITKImageAccessorConverter.cpp rttbITKImageAccessorGenerator.cpp rttbITKImageFileAccessorGenerator.cpp rttbITKImageFileMaskAccessorGenerator.cpp rttbITKImageMaskAccessor.cpp rttbITKImageMaskAccessorGenerator.cpp rttbITKImageMaskAccessorConverter.cpp rttbITKIOHelper.cpp - ${ITK_DEPENDENT_SOURCE_FILES} ) SET(H_FILES + itkDoseAccessorImageFilter.h + itkMaskAccessorImageSource.h rttbDoseAccessorConversionSettingInterface.h rttbDoseAccessorProcessorBase.h rttbDoseAccessorProcessorInterface.h rttbFileDispatch.h rttbGenericImageReader.h rttbImageReader.h rttbImageReader.tpp rttbImageWriter.h rttbITKException.h rttbITKImageAccessor.h rttbITKImageAccessorConverter.h rttbITKImageAccessorGenerator.h rttbITKImageFileAccessorGenerator.h rttbITKImageFileMaskAccessorGenerator.h rttbITKImageMaskAccessor.h rttbITKImageMaskAccessorConverter.h rttbITKImageMaskAccessorGenerator.h rttbITKIOHelper.h rttbITKIOHelper.tpp - ${ITK_DEPENDENT_HEADER_FILES} ) \ No newline at end of file diff --git a/code/io/itk/ITK5/itkDoseAccessorImageFilter.cpp b/code/io/itk/itkDoseAccessorImageFilter.cpp similarity index 100% rename from code/io/itk/ITK5/itkDoseAccessorImageFilter.cpp rename to code/io/itk/itkDoseAccessorImageFilter.cpp diff --git a/code/io/itk/ITK5/itkDoseAccessorImageFilter.h b/code/io/itk/itkDoseAccessorImageFilter.h similarity index 100% rename from code/io/itk/ITK5/itkDoseAccessorImageFilter.h rename to code/io/itk/itkDoseAccessorImageFilter.h diff --git a/code/io/itk/itkMaskAccessorImageSource.cpp b/code/io/itk/itkMaskAccessorImageSource.cpp index 2a523f9..a1364db 100644 --- a/code/io/itk/itkMaskAccessorImageSource.cpp +++ b/code/io/itk/itkMaskAccessorImageSource.cpp @@ -1,101 +1,94 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include "itkMaskAccessorImageSource.h" #include "itkImageRegionIterator.h" #include "itkImageRegionConstIteratorWithIndex.h" -#include "itkProgressReporter.h" -#include "itkExceptionObject.h" +#include "itkMacro.h" #include "rttbGeometricInfo.h" namespace itk { /** * Constructor */ MaskAccessorImageSource ::MaskAccessorImageSource() = default; void MaskAccessorImageSource - ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) + ::DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) { - ProgressReporter progress(this, threadId, - outputRegionForThread.GetNumberOfPixels()); - using OutputImageRegionIteratorType = ImageRegionIterator; OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); OutputImageRegionIteratorType outputItr; if (outputPtr) { outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); for (; !(outputItr.IsAtEnd()); ++outputItr) { OutputImageType::IndexType index = outputItr.GetIndex(); rttb::VoxelGridIndex3D maskIndex(index[0], index[1], index[2]); rttb::VoxelGridID id = 0; if (m_Accessor->getGeometricInfo().convert(maskIndex, id)) { auto finding = m_idMap.find(id); if (finding != m_idMap.end()) { // Set the current pixel outputItr.Set(m_MaskedVoxels->at(finding->second).getRelevantVolumeFraction()); } } else { if (m_FailsOnInvalidIDs) { itkExceptionMacro(<<"invalid Mask index. Index:"<(ProcessObject::GetOutput(0)); outputPtr->FillBuffer(0.0); //The id map approach and working with relevant voxel vector is a workarround till task T22067 is solved and and can be used again. m_MaskedVoxels = m_Accessor->getRelevantVoxelVector(); m_idMap.clear(); for (rttb::core::MaskAccessorInterface::MaskVoxelList::size_type pos = 0; pos < m_MaskedVoxels->size(); ++pos) { m_idMap.insert(std::make_pair((*m_MaskedVoxels)[pos].getVoxelGridID(), pos)); } } } // end namespace itk diff --git a/code/io/itk/itkMaskAccessorImageSource.h b/code/io/itk/itkMaskAccessorImageSource.h index c16a034..ed99ff0 100644 --- a/code/io/itk/itkMaskAccessorImageSource.h +++ b/code/io/itk/itkMaskAccessorImageSource.h @@ -1,105 +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. // //------------------------------------------------------------------------ #ifndef __itkMaskAccessorImageSource_h #define __itkMaskAccessorImageSource_h #include "itkGenerateImageSource.h" #include "rttbMaskAccessorInterface.h" #include "rttbITKImageMaskAccessor.h" namespace itk { /** \class MaskAccessorImageSource * \brief Converts a given mask accessor into an itk image. * */ typedef rttb::io::itk::ITKImageMaskAccessor::ITKMaskImageType RTTBMaskImageType; class ITK_EXPORT MaskAccessorImageSource: public GenerateImageSource< RTTBMaskImageType> { public: /** Standard class typedefs. */ typedef MaskAccessorImageSource Self; typedef GenerateImageSource< RTTBMaskImageType > Superclass; typedef SmartPointer< Self > Pointer; typedef SmartPointer< const Self > ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(MaskAccessorImageSource, ImageToImageFilter); /** Some typedefs. */ typedef RTTBMaskImageType OutputImageType; typedef OutputImageType::Pointer OutputImagePointer; typedef OutputImageType::RegionType OutputImageRegionType; typedef OutputImageType::PixelType OutputImagePixelType; typedef rttb::core::MaskAccessorInterface AccessorType; typedef rttb::core::MaskAccessorInterface::Pointer AccessorPointer; /** Get the accessor pointer. */ itkGetConstMacro(Accessor, AccessorPointer); /** Set the accessor pointer. */ void SetAccessor(AccessorPointer accessor) { if (m_Accessor != accessor) { m_Accessor = accessor; this->Modified(); } } itkSetMacro(FailsOnInvalidIDs, bool); itkGetConstMacro(FailsOnInvalidIDs, bool); itkSetMacro(InvalidMaskValue, OutputImageType::ValueType); itkGetConstMacro(InvalidMaskValue, OutputImageType::ValueType); /** ImageDimension constants */ itkStaticConstMacro( OutputImageDimension, unsigned int, OutputImageType::ImageDimension); protected: MaskAccessorImageSource(); ~MaskAccessorImageSource() override {} - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) override; + void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override; void BeforeThreadedGenerateData() override; private: MaskAccessorImageSource(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented typedef std::map VoxelMapType; VoxelMapType m_idMap; rttb::core::MaskAccessorInterface::MaskVoxelListPointer m_MaskedVoxels; AccessorPointer m_Accessor; bool m_FailsOnInvalidIDs{true}; OutputImageType::ValueType m_InvalidMaskValue{0}; }; } // end namespace itk #endif diff --git a/code/io/itk/rttbGenericImageReader.cpp b/code/io/itk/rttbGenericImageReader.cpp index 9d3d872..6bb0786 100644 --- a/code/io/itk/rttbGenericImageReader.cpp +++ b/code/io/itk/rttbGenericImageReader.cpp @@ -1,294 +1,294 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include "rttbGenericImageReader.h" namespace rttb { namespace io { namespace itk { void GenericImageReader::load() { _spImage = nullptr; FileNameString probeFileName = this->_fileName; if (this->_seriesReadStyle == ImageSeriesReadStyle::Numeric) { using NamesType = ::itk::NumericSeriesFileNames; NamesType::Pointer names = NamesType::New(); names->SetStartIndex(1); names->SetEndIndex(1); names->SetSeriesFormat(this->_fileName.c_str()); probeFileName = names->GetFileNames()[0]; } ::itk::ImageIOBase::Pointer imageIO = ::itk::ImageIOFactory::CreateImageIO(probeFileName.c_str(), - ::itk::ImageIOFactory::ReadMode); + ::itk::IOFileModeEnum::ReadMode); if (!imageIO) { throw ::itk::ExceptionObject("No ImageIO found for given file. Please check if the file exists and has a supported format. File:" + probeFileName); } // Now that we found the appropriate ImageIO class, ask it to // read the meta data from the image file. imageIO->SetFileName(probeFileName.c_str()); imageIO->ReadImageInformation(); this->_loadedComponentType = imageIO->GetComponentType(); this->_loadedPixelType = imageIO->GetPixelType(); - if (this->_loadedPixelType == ::itk::ImageIOBase::RGB && imageIO->GetNumberOfComponents() == 1) + if (this->_loadedPixelType == ::itk::IOPixelEnum::RGB && imageIO->GetNumberOfComponents() == 1) { //if only one channel per pixel handle as scalar as long as RGB etc. is not supported - this->_loadedPixelType = ::itk::ImageIOBase::SCALAR; + this->_loadedPixelType = ::itk::IOPixelEnum::SCALAR; } this->_loadedComponentTypeStr = imageIO->GetComponentTypeAsString(this->_loadedComponentType); this->_loadedPixelTypeStr = imageIO->GetPixelTypeAsString(this->_loadedPixelType); this->_loadedDimensions = imageIO->GetNumberOfDimensions(); if (this->_seriesReadStyle == ImageSeriesReadStyle::Numeric && this->_loadedDimensions == 2) { this->_loadedDimensions = 3; //it is a stack of 2D images -> 3D } if (this->_loadedDimensions < 2 || this->_loadedDimensions > 3) { throw ::itk::ExceptionObject("The file uses a number of dimensions that is not supported in this application. Only dim<=3 supported "); } switch (_loadedPixelType) { - case ::itk::ImageIOBase::SCALAR: + case ::itk::IOPixelEnum::SCALAR: { if (this->_loadedDimensions == 2) { loadScalar<2>(); } else { loadScalar<3>(); } break; } default: { throw ::itk::ExceptionObject("The file uses a pixel type that is not supported in this application. Only SCALAR pixel type supported "); } } _upToDate = true; }; template void GenericImageReader:: loadScalar() { // Use the pixel type to instantiate the appropriate reader switch (this->_loadedComponentType) { - case ::itk::ImageIOBase::UCHAR: + case ::itk::IOComponentEnum::UCHAR: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } - case ::itk::ImageIOBase::CHAR: + case ::itk::IOComponentEnum::CHAR: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } - case ::itk::ImageIOBase::USHORT: + case ::itk::IOComponentEnum::USHORT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } - case ::itk::ImageIOBase::SHORT: + case ::itk::IOComponentEnum::SHORT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } - case ::itk::ImageIOBase::UINT: + case ::itk::IOComponentEnum::UINT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } - case ::itk::ImageIOBase::INT: + case ::itk::IOComponentEnum::INT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } - case ::itk::ImageIOBase::ULONG: + case ::itk::IOComponentEnum::ULONG: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } - case ::itk::ImageIOBase::LONG: + case ::itk::IOComponentEnum::LONG: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } - case ::itk::ImageIOBase::FLOAT: + case ::itk::IOComponentEnum::FLOAT: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } - case ::itk::ImageIOBase::DOUBLE: + case ::itk::IOComponentEnum::DOUBLE: { this->_spImage = readImage(_fileName, _seriesReadStyle, false, 0, 0, _upperSeriesLimit, &_dictionaryArray); break; } default: { throw ::itk::ExceptionObject("The file uses a pixel component type that is not supported in this application. ComponentType: " + this->_loadedComponentTypeStr); } } }; const FileNameString& GenericImageReader:: getFileName() const { return _fileName; }; void GenericImageReader:: setFileName(const FileNameString& fileName) { if (fileName != _fileName) { _upToDate = false; _fileName = fileName; } } const unsigned int GenericImageReader:: getUpperSeriesLimit() const { return _upperSeriesLimit; }; void GenericImageReader:: setUpperSeriesLimit(const unsigned int upperLimit) { if (upperLimit != _upperSeriesLimit) { _upToDate = false; _upperSeriesLimit = upperLimit; }; }; const ImageSeriesReadStyle::Type GenericImageReader:: getSeriesReadStyle() const { return _seriesReadStyle; }; void GenericImageReader:: setSeriesReadStyle(ImageSeriesReadStyle::Type readStyle) { if (readStyle != _seriesReadStyle) { _upToDate = false; _seriesReadStyle = readStyle; }; }; GenericImageReader::GenericOutputImageType* GenericImageReader:: GetOutput(unsigned int& loadedDimensions, LoadedPixelType& loadedPixelType, LoadedComponentType& loadedComponentType) { if (!_upToDate) { load(); loadedPixelType = _loadedPixelType; loadedComponentType = _loadedComponentType; loadedDimensions = _loadedDimensions; }; return _spImage; }; GenericImageReader:: GenericImageReader() : _fileName() { }; GenericImageReader:: ~GenericImageReader() = default; const GenericImageReader::MetaDataDictionaryArrayType& GenericImageReader:: getMetaDictionaryArray() { return _dictionaryArray; }; }//end namespace itk }//end namespace io }//end namespace rttb diff --git a/code/io/itk/rttbGenericImageReader.h b/code/io/itk/rttbGenericImageReader.h index cfead1f..45c0d4e 100644 --- a/code/io/itk/rttbGenericImageReader.h +++ b/code/io/itk/rttbGenericImageReader.h @@ -1,156 +1,156 @@ // ----------------------------------------------------------------------- // MatchPoint - DKFZ translational registration framework // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See mapCopyright.txt or // http://www.dkfz.de/en/sidt/projects/MatchPoint/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #ifndef __RTTB_GENERIC_IMAGE_READER_H #define __RTTB_GENERIC_IMAGE_READER_H #include "rttbImageReader.h" namespace rttb { namespace io { namespace itk { /** @class ImageReader * @brief Helper class manages the generic loading (unspecified dimension and pixel type) of 2D/3D images ... * * GenericImageReader uses the ImageReader class and dispatches the dimension and pixel type information from the specified image file. * GenericImageReader supports 2D and 3D images and the following pixel types: * - (unsigned) char * - (unsigned) short * - (unsigned) int * - (unsigned) long * - float * - double * . * Due to the fact that it builds upon the itk io infrastructure, all formats supported by ITK * can be read. * For further information regarding the usage see documentation of ImageReader. * @sa ImageReader * @note code copied from MatchPoint, see documentation (http://sourceforge.net/projects/matchpoint/) */ class GenericImageReader : public ::itk::Object { public: using Self = rttb::io::itk::GenericImageReader; using Superclass = ::itk::Object; using Pointer = ::itk::SmartPointer; using ConstPointer = ::itk::SmartPointer; itkTypeMacro(GenericImageReader, ::itk::Object); itkNewMacro(Self); using GenericOutputImageType = ::itk::DataObject; - using LoadedPixelType = ::itk::ImageIOBase::IOPixelType; + using LoadedPixelType = ::itk::IOPixelEnum; - using LoadedComponentType = ::itk::ImageIOBase::IOComponentType; + using LoadedComponentType = ::itk::IOComponentEnum; using MetaDataDictionaryArrayType = std::vector< ::itk::MetaDataDictionary>; private: /** Loaded Image.*/ GenericOutputImageType::Pointer _spImage; /** The file name of the image. */ FileNameString _fileName; /** The upper limit for the searching of series files in the path.*/ unsigned int _upperSeriesLimit{255}; /** Indicates if the image data is up to date or should be read again.*/ bool _upToDate{false}; /** Defines if the specified image file is part of a series and the * whole series should be read into one image. Only relevant for 3D images.*/ ImageSeriesReadStyle::Type _seriesReadStyle{ImageSeriesReadStyle::Default}; unsigned int _loadedDimensions; LoadedPixelType _loadedPixelType; LoadedComponentType _loadedComponentType; std::string _loadedComponentTypeStr; std::string _loadedPixelTypeStr; MetaDataDictionaryArrayType _dictionaryArray; /** Loads the image. First identifies pixel type and dimension and then deligates according * to the pixel type. * @exception map::core::ExceptionObject If no ImageIO is found. * @exception map::core::ExceptionObject If dimension of the image is not supported. Only 2D/3D is supported. * @exception map::core::ExceptionObject If pixel type is not supported. Currently only scalar pixels are supported. */ void load(); /** Loads an scalar image. * @exception map::core::ExceptionObject If pixel component type is not supported. */ template void loadScalar(); //template //void loadRGB(); public: /** Function to access the member variable _FileName. _FileName represents the filename of the * headerfile. The path must be included, the file extension may left away. * @return File name of the header file.*/ const FileNameString& getFileName() const; /** Function to access the member variable _FileName. _FileName represents the filename of the * headerfile. The path must be included, the file extension may left away. * @param [in] sFileName The file name of the header file.*/ void setFileName(const FileNameString& sFileName); /** Function to access the member variable _upperSeriesLimit. _upperSeriesLimit represents * the upper limit for the series file search. * @return The upper limit of the series search.*/ const unsigned int getUpperSeriesLimit() const; /** Function to access the member variable _upperSeriesLimit. _upperSeriesLimit represents * the upper limit for the series file search. Changing the series limit out dates the ImageReader. * @remark It is only relevant if series style is set to "Numeric". * @param [in] upperLimit The upper limit of the header file.*/ void setUpperSeriesLimit(const unsigned int upperLimit); /** Function to access the member variable _seriesReadStyle (see member description for more information).*/ const ImageSeriesReadStyle::Type getSeriesReadStyle() const; /** Function to access the member variable _seriesReadStyle (see member description for more information). * Changing the style out dates the ImageReader.*/ void setSeriesReadStyle(ImageSeriesReadStyle::Type readStyle); /** Function loads the image if needed and returns the data. * @return Pointer to loaded image. * @exception map::core::ExceptionObject If no ImageIO is found. * @exception map::core::ExceptionObject If dimension of the image is not supported. Only 2D/3D is supported. * @exception map::core::ExceptionObject If pixel type is not supported. Currently only scalar pixels are supported. * @exception map::core::ExceptionObject If pixel component type is not supported. */ GenericOutputImageType* GetOutput(unsigned int& loadedDimensions, LoadedPixelType& loadedPixelType, LoadedComponentType& loadedComponentType); /** Function returns the reference to the meta data dictionary(ies) of the latest file(s) loaded by this class. * Array may be empty if no MetaDictionary exists.*/ const MetaDataDictionaryArrayType& getMetaDictionaryArray(); protected: GenericImageReader(); ~GenericImageReader() override; }; }//end namespace itk }//end namespace io }//end namespace rttb #endif diff --git a/code/io/itk/rttbITKIOHelper.cpp b/code/io/itk/rttbITKIOHelper.cpp index be8ee1d..a6d44ea 100644 --- a/code/io/itk/rttbITKIOHelper.cpp +++ b/code/io/itk/rttbITKIOHelper.cpp @@ -1,165 +1,165 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include "rttbITKIOHelper.h" #include "rttbException.h" #include "rttbInvalidDoseException.h" #include "rttbInvalidParameterException.h" namespace rttb { namespace io { namespace itk { ITKImageType::Pointer readITKDoubleImage(FileNameType aITKImageFile, bool isDicom) { ITKImageType::Pointer itkDoubleImage; GenericImageReader::Pointer spReader = GenericImageReader::New(); if (isDicom) { spReader->setSeriesReadStyle(ImageSeriesReadStyle::Type::Dicom); } spReader->setFileName(aITKImageFile); GenericImageReader::GenericOutputImageType::Pointer itkGenericImage; ITKImageType::ConstPointer itkDoubleImageConst; try { unsigned int loadedDimensions; GenericImageReader::LoadedPixelType loadedPixelType; GenericImageReader::LoadedComponentType loadedComponentType; itkGenericImage = spReader->GetOutput(loadedDimensions, loadedPixelType, loadedComponentType); if (loadedDimensions != 3) { throw core::InvalidParameterException("image dimensions != 3. Only dim = 3 supported."); } - if (loadedPixelType != ::itk::ImageIOBase::SCALAR) + if (loadedPixelType != ::itk::IOPixelEnum::SCALAR) { throw core::InvalidParameterException("image component type != SCALAR. Only SCALAR supported."); } - if (loadedComponentType == ::itk::ImageIOBase::DOUBLE) + if (loadedComponentType == ::itk::IOComponentEnum::DOUBLE) { itkDoubleImage = dynamic_cast(itkGenericImage.GetPointer()); } else { itkDoubleImage = handleGenericImage(itkGenericImage, loadedComponentType); } if (itkDoubleImage.IsNull()) { throw core::InvalidDoseException("Error!!! unable to load input image. File is not existing or has an unsupported format."); } } catch (::itk::ExceptionObject& e) { std::cerr << "Error!!!" << std::endl; std::cerr << e << std::endl; throw rttb::core::InvalidDoseException(e.GetDescription()); } return itkDoubleImage; } ITKImageType::Pointer handleGenericImage( GenericImageReader::GenericOutputImageType* itkGenericImage, - ::itk::ImageIOBase::IOComponentType& loadedComponentType) + ::itk::IOComponentEnum& loadedComponentType) { ITKImageType::Pointer itkDoubleImage; switch (loadedComponentType) { - case ::itk::ImageIOBase::UCHAR: + case ::itk::IOComponentEnum::UCHAR: { itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::CHAR: + case ::itk::IOComponentEnum::CHAR: { itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::USHORT: + case ::itk::IOComponentEnum::USHORT: { itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::SHORT: + case ::itk::IOComponentEnum::SHORT: { itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::UINT: + case ::itk::IOComponentEnum::UINT: { itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::INT: + case ::itk::IOComponentEnum::INT: { itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::ULONG: + case ::itk::IOComponentEnum::ULONG: { itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::LONG: + case ::itk::IOComponentEnum::LONG: { itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::FLOAT: + case ::itk::IOComponentEnum::FLOAT: { itkDoubleImage = doCasting(itkGenericImage); break; } - case ::itk::ImageIOBase::DOUBLE: + case ::itk::IOComponentEnum::DOUBLE: { itkDoubleImage = doCasting(itkGenericImage); break; } default: { throw core::InvalidParameterException("image type unknown"); } } return itkDoubleImage; } }//end namespace itk }//end namespace io }//end namespace rttb diff --git a/code/io/itk/rttbITKIOHelper.h b/code/io/itk/rttbITKIOHelper.h index 7757582..630945c 100644 --- a/code/io/itk/rttbITKIOHelper.h +++ b/code/io/itk/rttbITKIOHelper.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. // //------------------------------------------------------------------------ #ifndef __ITK_IO_HELPER_H #define __ITK_IO_HELPER_H #include "rttbBaseType.h" #include "rttbGenericImageReader.h" #include "itkImage.h" namespace rttb { namespace io { namespace itk { typedef ::itk::Image ITKImageType; /*! @brief Read a itk image file into itkImage */ ITKImageType::Pointer readITKDoubleImage(FileNameType aITKImageFile, bool isDicom = false); /*! @brief Converts a generic image to itkImage @param itkGenericImage the image read by GenericImageReader @param loadedComponentType the component type (used for casting later on) @exception InvalidParameterException if component type is not supported @sa GenericImageReader */ ITKImageType::Pointer handleGenericImage(GenericImageReader::GenericOutputImageType* itkGenericImage, - ::itk::ImageIOBase::IOComponentType& loadedComponentType); + ::itk::IOComponentEnum& loadedComponentType); /*! @brief Casts into itkImage */ template ITKImageType::Pointer doCasting( GenericImageReader::GenericOutputImageType* genericImage); }//end namespace itk }//end namespace io }//end namespace rttb #include "rttbITKIOHelper.tpp" #endif