Skip to content
Commits on Source (9)
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# Generated files and
help/
cmake*
Makefile
CMakeFiles/
CTestTestfile.cmake
language: cpp
env:
global:
ELASTIX_SOURCE_DIR=${TRAVIS_BUILD_DIR}
ELASTIX_BUILD_DIR=${HOME}/elastix-build
ITK_URL=https://github.com/InsightSoftwareConsortium/ITK
ITK_SOURCE_DIR=${HOME}/ITK-source
ITK_BUILD_DIR=${HOME}/ITK-build
OMP_NUM_THREADS=2
cache:
directories:
- ${ITK_SOURCE_DIR}
- ${ITK_BUILD_DIR}
matrix:
include:
- os: linux
dist: trusty
sudo: required
compiler: clang
- os: linux
dist: trusty
sudo: required
compiler: gcc
- os: osx
compiler: clang
- os: osx
compiler: gcc
before_script:
- mkdir -p ${ELASTIX_BUILD_DIR}
script:
- if [[ ! -e ${ITK_BUILD_DIR}/ITKConfig.cmake ]]; then
rm -rf ${ITK_SOURCE_DIR} {ITK_BUILD_DIR} &&
git clone ${ITK_URL} ${ITK_SOURCE_DIR} &&
cd ${ITK_SOURCE_DIR} &&
git checkout v4.11.1 &&
mkdir -p ${ITK_BUILD_DIR} &&
cd ${ITK_BUILD_DIR} &&
cmake -DBUILD_EXAMPLES=OFF -DBUILD_TESTING:BOOL=OFF -DITK_BUILD_DEFAULT_MODULES:BOOL=OFF -DITKGroup_IO:BOOL=ON -DModule_ITKDistanceMap:BOOL=ON -DModule_ITKImageFusion:BOOL=ON -DModule_ITKLabelMap:BOOL:=ON -DModule_ITKMathematicalMorphology:BOOL=ON -DModule_ITKOptimizers:BOOL=ON -DModule_ITKOptimizersv4:BOOL=ON -DModule_ITKRegistrationCommon:BOOL=ON -DModule_ITKVideoIO:BOOL=ON-DCMAKE_BUILD_TYPE=Release ${ITK_SOURCE_DIR} &&
make --jobs=4 &&
touch ${HOME}/built_cache; fi
- if [[ ! -e ${HOME}/built_cache ]]; then
cd ${ELASTIX_BUILD_DIR} &&
cmake -DELASTIX_USE_OPENMP=OFF -DITK_DIR=${ITK_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release ${ELASTIX_SOURCE_DIR} &&
make --jobs=4 &&
ctest --jobs=4 --verbose; fi
function(elastix_export_target tgt)
# Remove the build tree's ElastixTargets file if this is the first call:
get_property(first_time GLOBAL PROPERTY ELASTIX_FIRST_EXPORTED_TARGET)
if(NOT first_time)
file(REMOVE ${CMAKE_BINARY_DIR}/ElastixTargets.cmake)
set_property(GLOBAL PROPERTY ELASTIX_FIRST_EXPORTED_TARGET 1)
endif()
get_target_property( type ${tgt} TYPE )
if (type STREQUAL "STATIC_LIBRARY" OR
type STREQUAL "MODULE_LIBRARY" OR
type STREQUAL "SHARED_LIBRARY")
set_property(TARGET ${tgt} PROPERTY VERSION 1)
set_property(TARGET ${tgt} PROPERTY SOVERSION 1)
set_property(TARGET ${tgt} PROPERTY
OUTPUT_NAME ${tgt}-${ELASTIX_VERSION_MAJOR}.${ELASTIX_VERSION_MINOR})
endif()
export(TARGETS ${tgt}
APPEND FILE "${CMAKE_BINARY_DIR}/ElastixTargets.cmake"
)
endfunction()
\ No newline at end of file
#---------------------------------------------------------------------
cmake_minimum_required( VERSION 2.8 )
project( elastix )
#---------------------------------------------------------------------
cmake_policy( SET CMP0012 NEW )
if( POLICY CMP0033 )
# This policy was introduced in cmake 3, so we need to check for its
......@@ -8,8 +11,23 @@ if( POLICY CMP0033 )
cmake_policy( SET CMP0033 OLD )
endif()
cmake_policy( SET CMP0007 OLD )
cmake_policy( SET CMP0042 NEW )
#---------------------------------------------------------------------
project( elastix )
# Get version information.
# Get the version number of elastix
file( STRINGS ${elastix_SOURCE_DIR}/Core/Install/elxBaseComponent.h
ELASTIX_VERSION REGEX "\(#define\ __ELASTIX_VERSION\)" )
string( SUBSTRING ${ELASTIX_VERSION} 26 3 ELASTIX_VERSION )
# Split version in major minor. Assuming no patch number, just x.y
string( REGEX MATCH "[0-9]+" ELASTIX_VERSION_MAJOR "${ELASTIX_VERSION}" )
string( REGEX REPLACE "([0-9]+)\\." "" ELASTIX_VERSION_MINOR "${ELASTIX_VERSION}" )
#---------------------------------------------------------------------
include( CTest )
#---------------------------------------------------------------------
# Generate executable, static library or dynamic library.
......@@ -18,10 +36,26 @@ option( ELASTIX_BUILD_EXECUTABLE "Generate executable or library?" ON )
if( NOT ELASTIX_BUILD_EXECUTABLE )
add_definitions( -D_ELASTIX_BUILD_LIBRARY )
mark_as_advanced( ELASTIX_BUILD_SHARED_LIBS )
option( ELASTIX_BUILD_SHARED_LIBS "Build shared libraries?" ON )
if( ELASTIX_BUILD_SHARED_LIBS )
add_definitions( -D_ELASTIX_BUILD_SHARED_LIBRARY )
# The following may make smaller and quicker loading libraries,
# that hides unnecessary symbols. Available from CMake 3.0.0.
#set( CMAKE_C_VISIBILITY_PRESET hidden )
#set( CMAKE_CXX_VISIBILITY_PRESET hidden )
mark_as_advanced( BUILD_SHARED_LIBS )
option( BUILD_SHARED_LIBS "Build shared libraries?" OFF )
if( BUILD_SHARED_LIBS )
add_definitions( -D_ELASTIX_USE_SHARED_LIBRARY )
# We need to make sure that also the ITK is compiled with shared
# libraries on. Related to flag (ITK_)BUILD_SHARED_LIBS. todo
# In order to compile a shared library, all static sub-libraries
# need to build position independend code.
# Otherwise an error similar to the following is raised:
# relocation R_X86_64_32S against `.bss' can not be used when
# making a shared object; recompile with -fPIC
set( CMAKE_POSITION_INDEPENDENT_CODE ON )
endif()
endif()
......@@ -35,26 +69,23 @@ include( ${ITK_USE_FILE} )
# so that CMake is able to find the FindPackage modules.
list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake )
#---------------------------------------------------------------------
# Find CUDA.
mark_as_advanced( ELASTIX_USE_CUDA )
option( ELASTIX_USE_CUDA "Use CUDA enabled GPU" OFF )
if( ELASTIX_USE_CUDA )
find_package( CUDA REQUIRED )
mark_as_advanced( CUDA_BUILD_CUBIN )
mark_as_advanced( CUDA_BUILD_EMULATION )
mark_as_advanced( CUDA_VERBOSE_BUILD )
mark_as_advanced( CUDA_SDK_ROOT_DIR )
endif()
# Function for exporting targets
include(elastixExportTarget)
#---------------------------------------------------------------------
# Find OpenCL.
option( ELASTIX_USE_OPENCL "Use OpenCL enabled GPU" OFF )
if( ELASTIX_USE_OPENCL )
find_package( OpenCL REQUIRED )
find_package( OpenCL REQUIRED QUIET )
# Make sure ITK is not compiled with GPU extensions on,
# since elastix overrides ITK classes with new ones.
if( ${ITK_USE_GPU} )
message( FATAL_ERROR "ITK_USE_GPU: " ${ITK_USE_GPU}
"\nERROR: ITK should be compiled with ITK_USE_GPU OFF, as elastix overrides ITK classes." )
endif()
# Force OPENCL_OPTIMIZATION_MAD_ENABLE to on
if( DEFINED OPENCL_OPTIMIZATION_MAD_ENABLE )
set( OPENCL_OPTIMIZATION_MAD_ENABLE ON CACHE BOOL
......@@ -74,7 +105,7 @@ endif()
#---------------------------------------------------------------------
# Find Eigen
mark_as_advanced( ELASTIX_USE_EIGEN )
option( ELASTIX_USE_EIGEN "Use Eigen library" OFF )
option( ELASTIX_USE_EIGEN "Use Eigen library." OFF )
if( ELASTIX_USE_EIGEN )
find_package( Eigen3 REQUIRED )
......@@ -84,8 +115,11 @@ endif()
#---------------------------------------------------------------------
# Find OpenMP
find_package( OpenMP )
mark_as_advanced( ELASTIX_USE_OPENMP )
option( ELASTIX_USE_OPENMP "Use OpenMP to speed up certain computations." ON )
if( ELASTIX_USE_OPENMP )
find_package( OpenMP QUIET )
if( OPENMP_FOUND )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
......@@ -93,6 +127,7 @@ if( OPENMP_FOUND )
# ${OpenMP_EXE_LINKER_FLAGS}")
add_definitions( -DELASTIX_USE_OPENMP )
endif()
endif()
#----------------------------------------------------------------------
# Check for the SuiteSparse package
......@@ -108,7 +143,7 @@ if( USE_PreconditionedGradientDescent )
endif()
#---------------------------------------------------------------------
# Set single output directories for all executables and libraries.
# Set single (build-tree) output directories for all executables and libraries.
# This makes it easier to create an elxUseFile.cmake, that users can
# include in their programs to borrow elastix functionality.
......@@ -125,6 +160,23 @@ endif()
# Mark these variables as advanced; their default value is usually fine
mark_as_advanced( LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH )
#---------------------------------------------------------------------
# Define the install directory names, relative to install prefix
# given by CMAKE_INSTALL_PREFIX. All components should use the
# same name. Set as variable here for future customization; e.g.
# if desire to decorate with Elastix version.
# Allow user to customize.
mark_as_advanced( ELASTIX_ARCHIVE_DIR ELASTIX_INCLUDE_DIR ELASTIX_LIBRARY_DIR ELASTIX_RUNTIME_DIR )
set( ELASTIX_ARCHIVE_DIR "lib" CACHE STRING
"Directory for installing archive files; path is relative to CMAKE_INSTALL_PREFIX" )
set( ELASTIX_INCLUDE_DIR "include" CACHE STRING
"Directory for installing include files; path is relative to CMAKE_INSTALL_PREFIX" )
set( ELASTIX_LIBRARY_DIR "lib" CACHE STRING
"Directory for installing library files; path is relative to CMAKE_INSTALL_PREFIX" )
set( ELASTIX_RUNTIME_DIR "bin" CACHE STRING
"Directory for installing runtime files; path is relative to CMAKE_INSTALL_PREFIX" )
#---------------------------------------------------------------------
# Check if Mevis DicomTiff support is desired
mark_as_advanced( ELASTIX_USE_MEVISDICOMTIFF )
......@@ -142,13 +194,6 @@ mark_as_advanced( ELASTIX_USER_COMPONENT_DIRS )
set( ELASTIX_USER_COMPONENT_DIRS "" CACHE PATH
"directories with user defined elastix components" )
#---------------------------------------------------------------------
# elastix depends on some ITK settings
if( NOT ITKReview_LOADED )
message( SEND_ERROR "Module_ITKReview has not been set to ON when compiling ITK. This option is mandatory for elastix to build.\nPlease recompile your ITK installation." )
endif()
#---------------------------------------------------------------------
# If IDE supports it, do use folder view.
# gcc automatically ignores it. VC Express does not support and gives
......@@ -177,10 +222,7 @@ endif()
set( elxCommon_INCLUDE_DIRECTORIES
${elastix_SOURCE_DIR}/Common
${elastix_SOURCE_DIR}/Common/CostFunctions
${elastix_SOURCE_DIR}/Common/CUDA
${elastix_SOURCE_DIR}/Common/ImageSamplers
${elastix_SOURCE_DIR}/Common/KNN
${elastix_SOURCE_DIR}/Common/KNN/ann_1.1/include
${elastix_SOURCE_DIR}/Common/LineSearchOptimizers
${elastix_SOURCE_DIR}/Common/ParameterFileParser
${elastix_SOURCE_DIR}/Common/Transforms
......@@ -246,8 +288,7 @@ if( MSVC )
add_definitions(
/D_SCL_SECURE_NO_DEPRECATE
/D_CRT_SECURE_NO_DEPRECATE
/D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
)
/D_CRT_TIME_FUNCTIONS_NO_DEPRECATE )
# Increases address capacity
if( WIN32 )
......@@ -275,9 +316,9 @@ add_subdirectory( Core )
#---------------------------------------------------------------------
# Configure the examples
set( ELASTIX_DOX_DIR ${elastix_SOURCE_DIR}/../dox )
set( ELASTIX_TOOLS_DIR ${elastix_SOURCE_DIR}/../tools )
set( ELASTIX_HELP_DIR ${elastix_SOURCE_DIR}/../help CACHE PATH
set( ELASTIX_DOX_DIR ${elastix_SOURCE_DIR}/dox )
set( ELASTIX_TOOLS_DIR ${elastix_BINARY_DIR}/tools )
set( ELASTIX_HELP_DIR ${elastix_BINARY_DIR}/help CACHE PATH
"path to the doxygen generated help files and the examples" )
# Copy the examples to the help directory
......@@ -321,26 +362,15 @@ foreach( ELX_EXAMPLEINPUTFILE ${ELX_EXAMPLEINPUTFILES} )
COPYONLY )
endforeach()
#---------------------------------------------------------------------
# Get version information.
# Get the version number of elastix
file( STRINGS ${elastix_SOURCE_DIR}/Core/Install/elxBaseComponent.h
ELASTIX_VERSION REGEX "\(#define\ __ELASTIX_VERSION\)" )
string( SUBSTRING ${ELASTIX_VERSION} 26 3 ELASTIX_VERSION )
# Split version in major minor. Assuming no patch number, just x.y
string( REGEX MATCH "[0-9]+" ELASTIX_VERSION_MAJOR "${ELASTIX_VERSION}" )
string( REGEX REPLACE "([0-9]+)\\." "" ELASTIX_VERSION_MINOR "${ELASTIX_VERSION}" )
#---------------------------------------------------------------------
# Configure the doxygen-configuration
option( BUILD_DOCUMENTATION "Build elastix documentation." OFF )
if( ${BUILD_DOCUMENTATION} )
find_package( Doxygen QUIET )
string( COMPARE NOTEQUAL ${DOXYGEN} "DOXYGEN-NOTFOUND" Doxygen_FOUND )
if( Doxygen_FOUND )
# Set the path to the doxygen configuration source
set( ELASTIX_DOXYGEN_DIR ${ELASTIX_DOX_DIR}/doxygen )
......@@ -352,18 +382,13 @@ if( Doxygen_FOUND )
exec_program( "date '+%d-%m-%Y'" OUTPUT_VARIABLE ELASTIX_DOXYGEN_DATE )
endif()
if( WIN32 )
if( NOT CYGWIN )
if( NOT CYGWIN AND NOT MINGW )
execute_process( COMMAND "${ELASTIX_DOXYGEN_DIR}/doxdate.bat"
OUTPUT_VARIABLE ELASTIX_DOXYGEN_DATETEMP )
string( REPLACE "/" "-" ELASTIX_DOXYGEN_DATE ${ELASTIX_DOXYGEN_DATETEMP} )
endif()
endif()
# Configure the doxygen configuration
configure_file(
${ELASTIX_DOXYGEN_DIR}/doxyfile.in
${ELASTIX_HELP_DIR}/doxyfile.out @ONLY )
# Configure the footer of the help website.
configure_file(
${ELASTIX_DOXYGEN_DIR}/DoxygenFooter.html.in
......@@ -373,18 +398,14 @@ if( Doxygen_FOUND )
configure_file(
${ELASTIX_DOXYGEN_DIR}/MainPage.dox.in
${ELASTIX_HELP_DIR}/MainPage.dox @ONLY )
endif()
endif()
#---------------------------------------------------------------------
# Testing
set( ELASTIX_BUILD_TESTING OFF CACHE BOOL
"Perform some tests on basic functionality of elastix." )
if( ELASTIX_BUILD_TESTING )
enable_testing()
if( BUILD_TESTING )
add_subdirectory( Testing )
include( CTest )
endif()
#---------------------------------------------------------------------
......@@ -409,7 +430,7 @@ if( ELASTIX_ENABLE_PACKAGER )
# We have split the elastix package into two components:
# - the core: elastix and transformix
# - the libraries: ANNlib and cudart when ELASTIX_USE_CUDA ON
# - the libraries: ANNlib
# NOTE: Currently does not work for nsis. A bug related to this
# seems to be fixed in the upcoming CMake 2.8.3
# Therefore, disable component support for now.
......@@ -498,11 +519,11 @@ if( ELASTIX_ENABLE_PACKAGER )
# 2 The icon file(.ico) for the generated install program
# 3 The icon file(.ico) for the generated uninstall program
set( CPACK_PACKAGE_ICON
"${CMAKE_CURRENT_SOURCE_DIR}/../dox/art\\\\elastix_logo_full_small.bmp" )
"${CMAKE_CURRENT_SOURCE_DIR}/dox/art\\\\elastix_logo_full_small.bmp" )
set( CPACK_NSIS_MUI_ICON
"${CMAKE_CURRENT_SOURCE_DIR}/../dox/art\\\\elastix_logo_64.ico" )
"${CMAKE_CURRENT_SOURCE_DIR}/dox/art\\\\elastix_logo_64.ico" )
set( CPACK_NSIS_MUI_UNIICON
"${CMAKE_CURRENT_SOURCE_DIR}/../dox/art\\\\elastix_logo_64.ico" )
"${CMAKE_CURRENT_SOURCE_DIR}/dox/art\\\\elastix_logo_64.ico" )
# Create an option in the installer that asks if elastix
# needs to be added to the system path
......@@ -532,13 +553,16 @@ endif()
set( elxLIBRARY_DEPENDS_FILE ${elastix_BINARY_DIR}/elxLibraryDepends.cmake )
export_library_dependencies( ${elxLIBRARY_DEPENDS_FILE} )
# The "use" file.
set( elxUSE_FILE ${elastix_BINARY_DIR}/UseElastix.cmake )
# The build settings file. (necessary for elastix?)
#set( ITK_BUILD_SETTINGS_FILE ${ITK_BINARY_DIR}/ITKBuildSettings.cmake )
# Create the use file.
configure_file( ${elastix_SOURCE_DIR}/CMake/UseElastix.cmake.in
${elxUSE_FILE} @ONLY )
elastix_export_target( elastix )
elastix_export_target( transformix )
foreach( LIB IN LISTS AllComponentLibs )
elastix_export_target( ${LIB} )
endforeach()
configure_file( ${CMAKE_SOURCE_DIR}/ElastixConfig.cmake.in ${CMAKE_BINARY_DIR}/ElastixConfig.cmake @ONLY )
configure_file( ${CMAKE_SOURCE_DIR}/ElastixConfigVersion.cmake.in ${CMAKE_BINARY_DIR}/ElastixConfigVersion.cmake @ONLY )
configure_file( ${CMAKE_SOURCE_DIR}/UseElastix.cmake.in ${CMAKE_BINARY_DIR}/UseElastix.cmake @ONLY )
# Contributing to `elastix` #
**Thank you for considering contributing to `elastix`!**
### Do you have questions about the source code? ###
* Ask any question about how to use `elastix` on the _mailing list_. You can subscribe to the mailing list [here](http://lists.bigr.nl/mailman/listinfo/elastix), after which you can email to elastix@bigr.nl.
* Do not open an issue on GitHub for general questions, registration questions, or issues you may have while running `elastix`. _GitHub issues are primarily intended for bug reports and fixes._
* General information about `elastix` can be found on our [website](http://elastix.isi.uu.nl/).
* [The manual](http://elastix.isi.uu.nl/download/elastix_manual_v4.8.pdf) explains much of the inner workings of image registration.
### Did you find a bug? ###
* _Ensure the bug was not already reported_ by searching on GitHub under [Issues](https://github.com/SuperElastix/elastix/issues).
* If you're unable to find an open issue addressing the problem, you can [open a new one](https://github.com/SuperElastix/elastix/issues/new). Be sure to include a _title and clear description_, as much relevant information as possible. A _code sample with a test_ demonstrating the expected behavior that is not occurring would be awesome.
### Do you intend to add a new feature or change an existing one? ###
* Suggest your change on the `elastix` mailing list.
* Do not open an issue on GitHub until you have collected positive feedback about the change.
### Did you write a patch that fixes a bug? ###
* Open a new [GitHub pull request](https://github.com/SuperElastix/elastix/pull/new/develop) (PR) with the patch.
* Make sure the PR is done with respect to the [develop branch](https://github.com/SuperElastix/elastix/tree/develop).
* Ensure the PR description (log message) _clearly describes the problem and solution_. Include the relevant issue number if applicable. One-line messages are fine for small changes, but bigger changes should look like this:
$ git commit -m "ENH: A brief summary of the commit
>
> A paragraph describing what changed and its impact."
* We use the following tags for commit messages:
- ENH: for functional enhancements of the code
- BUG: for fixing runtime issues (crash, segmentation fault, exception, or incorrect result)
- COMP: for compilation issues (error or warning)
- PERF: for performance improvements
- STYLE: a change that does not impact the logic or execution of the code (improve coding style, comments, documentation)
* Ensure the PR adheres to our [coding conventions](#coding-conventions).
* We will review your PR and possibly suggest changes. We also have an automatic build and test system checking all PRs ([Travis-CI](https://travis-ci.org/)). When all lights are green, the PR will be merged.
* More information on pull requests can be found [here](https://help.github.com/articles/creating-a-pull-request/) and [here](https://gist.github.com/Chaser324/ce0505fbed06b947d962).
<!--
### **Do you want to contribute to the `elastix` documentation?*
* Please read [Contributing to the Rails Documentation](http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#contributing-to-the-rails-documentation).
-->
## Coding conventions ##
Start reading our code and you'll get the hang of it. We optimize for readability:
* We indent using two spaces (soft tabs). This ensures a consistent layout of the code on different text editors.
* We ALWAYS put spaces after list items and function arguments (`[1, 2, 3]`, not `[1,2,3]`), around operators (`x += 1`, not `x+=1`), etc.
* Use `/** ... */` style documentation.
* Member variables of classes should start their name with `m_`. For example: `m_NumberOfIterations`.
* Type definitions should start with a capital. ImageType for example, instead of imageType.
* This is open source software. Consider the people who will read your code, and make it look nice for them. It's sort of like driving a car: Perhaps you love doing donuts when you're alone, but with passengers the goal is to make the ride as smooth as possible.
Thanks,
The `elastix` team
......@@ -6,17 +6,8 @@ project( elxCommon )
add_subdirectory( ParameterFileParser )
add_subdirectory( xout )
if( USE_KNNGraphAlphaMutualInformationMetric )
add_subdirectory( KNN )
endif()
add_subdirectory( MevisDicomTiff )
if( ELASTIX_USE_CUDA )
add_subdirectory( CUDA )
endif()
if( ELASTIX_USE_OPENCL )
add_subdirectory( OpenCL )
endif()
......@@ -29,12 +20,24 @@ set( CommonFiles
itkAdvancedLinearInterpolateImageFunction.hxx
itkAdvancedRayCastInterpolateImageFunction.h
itkAdvancedRayCastInterpolateImageFunction.hxx
itkComputeDisplacementDistribution.h
itkComputeDisplacementDistribution.hxx
itkComputeJacobianTerms.h
itkComputeJacobianTerms.hxx
itkErodeMaskImageFilter.h
itkErodeMaskImageFilter.hxx
itkGenericMultiResolutionPyramidImageFilter.h
itkGenericMultiResolutionPyramidImageFilter.hxx
itkImageFileCastWriter.h
itkImageFileCastWriter.hxx
itkImageMaskSpatialObject2.h
itkImageMaskSpatialObject2.hxx
itkImageSpatialObject2.h
itkImageSpatialObject2.hxx
itkMeshFileReaderBase.h
itkMeshFileReaderBase.hxx
itkMultiOrderBSplineDecompositionImageFilter.h
itkMultiOrderBSplineDecompositionImageFilter.hxx
itkMultiResolutionGaussianSmoothingPyramidImageFilter.h
itkMultiResolutionGaussianSmoothingPyramidImageFilter.hxx
itkMultiResolutionImageRegistrationMethod2.h
......@@ -44,6 +47,14 @@ set( CommonFiles
itkNDImageBase.h
itkNDImageTemplate.h
itkNDImageTemplate.hxx
itkParabolicErodeDilateImageFilter.h
itkParabolicErodeDilateImageFilter.hxx
itkParabolicErodeImageFilter.h
itkParabolicMorphUtils.h
itkRecursiveBSplineInterpolationWeightFunction.h
itkRecursiveBSplineInterpolationWeightFunction.hxx
itkReducedDimensionBSplineInterpolateImageFunction.h
itkReducedDimensionBSplineInterpolateImageFunction.hxx
itkScaledSingleValuedNonLinearOptimizer.cxx
itkScaledSingleValuedNonLinearOptimizer.h
itkTransformixInputPointFileReader.h
......@@ -51,19 +62,6 @@ set( CommonFiles
TypeList.h
)
set( MaskFiles
itkImageMaskSpatialObject2.h
itkImageMaskSpatialObject2.hxx
itkImageSpatialObject2.h
itkImageSpatialObject2.hxx
itkErodeMaskImageFilter.h
itkErodeMaskImageFilter.hxx
itkParabolicErodeDilateImageFilter.h
itkParabolicErodeDilateImageFilter.hxx
itkParabolicErodeImageFilter.h
itkParabolicMorphUtils.h
)
set( CostFunctionFiles
CostFunctions/itkAdvancedImageToImageMetric.h
CostFunctions/itkAdvancedImageToImageMetric.hxx
......@@ -93,6 +91,8 @@ set( TransformFiles
Transforms/itkAdvancedBSplineDeformableTransform.hxx
Transforms/itkAdvancedCombinationTransform.h
Transforms/itkAdvancedCombinationTransform.hxx
Transforms/itkAdvancedEuler3DTransform.h
Transforms/itkAdvancedEuler3DTransform.hxx
Transforms/itkAdvancedIdentityTransform.h
Transforms/itkAdvancedMatrixOffsetTransformBase.h
Transforms/itkAdvancedMatrixOffsetTransformBase.hxx
......@@ -100,8 +100,19 @@ set( TransformFiles
Transforms/itkAdvancedRigid2DTransform.hxx
Transforms/itkAdvancedRigid3DTransform.h
Transforms/itkAdvancedRigid3DTransform.hxx
Transforms/itkAdvancedSimilarity2DTransform.h
Transforms/itkAdvancedSimilarity2DTransform.hxx
Transforms/itkAdvancedSimilarity3DTransform.h
Transforms/itkAdvancedSimilarity3DTransform.hxx
Transforms/itkAdvancedTransform.h
Transforms/itkAdvancedTransform.hxx
Transforms/itkAdvancedTranslationTransform.h
Transforms/itkAdvancedTranslationTransform.hxx
Transforms/itkAdvancedVersorTransform.h
Transforms/itkAdvancedVersorTransform.hxx
Transforms/itkAdvancedVersorRigid3DTransform.h
Transforms/itkAdvancedVersorRigid3DTransform.hxx
Transforms/itkBSplineDerivativeKernelFunction2.h
Transforms/itkBSplineInterpolationDerivativeWeightFunction.h
Transforms/itkBSplineInterpolationDerivativeWeightFunction.hxx
Transforms/itkBSplineInterpolationSecondOrderDerivativeWeightFunction.h
......@@ -110,16 +121,24 @@ set( TransformFiles
Transforms/itkBSplineInterpolationWeightFunction2.hxx
Transforms/itkBSplineInterpolationWeightFunctionBase.h
Transforms/itkBSplineInterpolationWeightFunctionBase.hxx
#Transforms/itkBSplineKernelFunction2.h
#Transforms/itkBSplineSecondOrderDerivativeKernelFunction.h
Transforms/itkBSplineKernelFunction2.h
Transforms/itkBSplineSecondOrderDerivativeKernelFunction2.h
Transforms/itkCyclicBSplineDeformableTransform.h
Transforms/itkCyclicBSplineDeformableTransform.hxx
Transforms/itkCyclicGridScheduleComputer.h
Transforms/itkCyclicGridScheduleComputer.hxx
Transforms/itkEulerTransform.h
Transforms/itkGridScheduleComputer.h
Transforms/itkGridScheduleComputer.hxx
Transforms/itkRecursiveBSplineTransform.hxx
Transforms/itkRecursiveBSplineTransform.h
Transforms/itkRecursiveBSplineTransformImplementation.h
Transforms/itkStackTransform.h
Transforms/itkStackTransform.hxx
Transforms/itkTransformToDeterminantOfSpatialJacobianSource.h
Transforms/itkTransformToDeterminantOfSpatialJacobianSource.hxx
Transforms/itkTransformToSpatialJacobianSource.h
Transforms/itkTransformToSpatialJacobianSource.hxx
Transforms/itkGridScheduleComputer.h
Transforms/itkGridScheduleComputer.hxx
Transforms/itkUpsampleBSplineParametersFilter.h
Transforms/itkUpsampleBSplineParametersFilter.hxx
)
......@@ -159,7 +178,7 @@ set( ImageSamplersFiles
#---------------------------------------------------------------------
# Construct source groups for nice visualisation in Visual Studio.
source_group( "Masks" FILES ${MaskFiles} )
source_group( "Common" FILES ${CommonFiles} )
source_group( "CostFunctions" FILES ${CostFunctionFiles} )
source_group( "Transforms" FILES ${TransformFiles} )
source_group( "LineSearchOptimizers" FILES ${LineSearchOptimizersFiles} )
......@@ -168,14 +187,17 @@ source_group( "ImageSamplers" FILES ${ImageSamplersFiles} )
#---------------------------------------------------------------------
# Create the elxCommon library.
add_library( elxCommon
${MaskFiles}
add_library( elxCommon STATIC
${CommonFiles}
${CostFunctionFiles}
${TransformFiles}
${LineSearchOptimizersFiles}
${ImageSamplersFiles}
)
install( TARGETS elxCommon
ARCHIVE DESTINATION ${ELASTIX_ARCHIVE_DIR}
LIBRARY DESTINATION ${ELASTIX_LIBRARY_DIR}
RUNTIME DESTINATION ${ELASTIX_RUNTIME_DIR} )
#---------------------------------------------------------------------
# Link against other libraries.
......
......@@ -159,6 +159,9 @@ public:
typedef AdvancedBSplineDeformableTransform< ScalarType, FixedImageDimension, 1 > BSplineOrder1TransformType;
typedef AdvancedBSplineDeformableTransform< ScalarType, FixedImageDimension, 2 > BSplineOrder2TransformType;
typedef AdvancedBSplineDeformableTransform< ScalarType, FixedImageDimension, 3 > BSplineOrder3TransformType;
typedef typename BSplineOrder1TransformType::Pointer BSplineOrder1TransformPointer;
typedef typename BSplineOrder2TransformType::Pointer BSplineOrder2TransformPointer;
typedef typename BSplineOrder3TransformType::Pointer BSplineOrder3TransformPointer;
/** Hessian type; for SelfHessian (experimental feature) */
typedef typename DerivativeType::ValueType HessianValueType;
......@@ -183,7 +186,7 @@ public:
/** Get the advanced transform. */
const AdvancedTransformType * GetTransform( void ) const
const AdvancedTransformType * GetTransform( void ) const ITK_OVERRIDE
{
return this->m_AdvancedTransform.GetPointer();
}
......@@ -254,7 +257,7 @@ public:
* \li Check if a B-spline interpolator has been set
* \li Check if an AdvancedTransform has been set
*/
virtual void Initialize( void ) throw ( ExceptionObject );
virtual void Initialize( void ) throw ( ExceptionObject ) ITK_OVERRIDE;
/** Experimental feature: compute SelfHessian.
* This base class just returns an identity matrix of the right size.
......@@ -334,20 +337,21 @@ protected:
mutable ImageSamplerPointer m_ImageSampler;
/** Variables for image derivative computation. */
bool m_InterpolatorIsLinear;
bool m_InterpolatorIsBSpline;
bool m_InterpolatorIsBSplineFloat;
bool m_InterpolatorIsReducedBSpline;
bool m_InterpolatorIsLinear;
LinearInterpolatorPointer m_LinearInterpolator;
BSplineInterpolatorPointer m_BSplineInterpolator;
BSplineInterpolatorFloatPointer m_BSplineInterpolatorFloat;
ReducedBSplineInterpolatorPointer m_ReducedBSplineInterpolator;
LinearInterpolatorPointer m_LinearInterpolator;
CentralDifferenceGradientFilterPointer m_CentralDifferenceGradientFilter;
/** Variables to store the AdvancedTransform. */
bool m_TransformIsAdvanced;
typename AdvancedTransformType::Pointer m_AdvancedTransform;
bool m_TransformIsBSpline;
mutable bool m_TransformIsBSpline;
/** Variables for the Limiters. */
FixedImageLimiterPointer m_FixedImageLimiter;
......@@ -363,6 +367,18 @@ protected:
/** Multi-threaded metric computation. */
/** Multi-threaded version of GetValue(). */
virtual inline void ThreadedGetValue( ThreadIdType threadID ){}
/** Finalize multi-threaded metric computation. */
virtual inline void AfterThreadedGetValue( MeasureType & value ) const {}
/** GetValue threader callback function. */
static ITK_THREAD_RETURN_TYPE GetValueThreaderCallback( void * arg );
/** Launch MultiThread GetValue. */
void LaunchGetValueThreaderCallback( void ) const;
/** Multi-threaded version of GetValueAndDerivative(). */
virtual inline void ThreadedGetValueAndDerivative(
ThreadIdType threadID ){}
......@@ -374,7 +390,7 @@ protected:
/** GetValueAndDerivative threader callback function. */
static ITK_THREAD_RETURN_TYPE GetValueAndDerivativeThreaderCallback( void * arg );
/** Launch MultiThread GetValueAndDerivative */
/** Launch MultiThread GetValueAndDerivative. */
void LaunchGetValueAndDerivativeThreaderCallback( void ) const;
/** AccumulateDerivatives threader callback function. */
......@@ -407,6 +423,19 @@ protected:
* these member variables are mutable.
*/
// test per thread struct with padding and alignment
struct GetValuePerThreadStruct
{
SizeValueType st_NumberOfPixelsCounted;
MeasureType st_Value;
};
itkPadStruct( ITK_CACHE_LINE_ALIGNMENT, GetValuePerThreadStruct,
PaddedGetValuePerThreadStruct );
itkAlignedTypedef( ITK_CACHE_LINE_ALIGNMENT, PaddedGetValuePerThreadStruct,
AlignedGetValuePerThreadStruct );
mutable AlignedGetValuePerThreadStruct * m_GetValuePerThreadVariables;
mutable ThreadIdType m_GetValuePerThreadVariablesSize;
// test per thread struct with padding and alignment
struct GetValueAndDerivativePerThreadStruct
{
......@@ -477,7 +506,7 @@ protected:
virtual void CheckForAdvancedTransform( void );
/** Check if the transform is a B-spline. Called by Initialize. */
virtual void CheckForBSplineTransform( void );
virtual void CheckForBSplineTransform( void ) const;
/** Transform a point from FixedImage domain to MovingImage domain.
* This function also checks if mapped point is within support region of
......
......@@ -51,14 +51,14 @@ AdvancedImageToImageMetric< TFixedImage, TMovingImage >
this->m_UseImageSampler = false;
this->m_RequiredRatioOfValidSamples = 0.25;
this->m_LinearInterpolator = 0;
this->m_BSplineInterpolator = 0;
this->m_BSplineInterpolatorFloat = 0;
this->m_ReducedBSplineInterpolator = 0;
this->m_LinearInterpolator = 0;
this->m_InterpolatorIsLinear = false;
this->m_InterpolatorIsBSpline = false;
this->m_InterpolatorIsBSplineFloat = false;
this->m_InterpolatorIsReducedBSpline = false;
this->m_InterpolatorIsLinear = false;
this->m_CentralDifferenceGradientFilter = 0;
this->m_AdvancedTransform = 0;
......@@ -85,6 +85,7 @@ AdvancedImageToImageMetric< TFixedImage, TMovingImage >
/** Threading related variables. */
this->m_UseMetricSingleThreaded = true;
this->m_UseMultiThread = false;
this->m_Threader->SetUseThreadPool( false ); // setting to true makes elastix hang
// at a WaitForSingleMethodThread()
......@@ -102,6 +103,8 @@ AdvancedImageToImageMetric< TFixedImage, TMovingImage >
this->m_ThreaderMetricParameters.st_Metric = this;
// Multi-threading structs
this->m_GetValuePerThreadVariables = NULL;
this->m_GetValuePerThreadVariablesSize = 0;
this->m_GetValueAndDerivativePerThreadVariables = NULL;
this->m_GetValueAndDerivativePerThreadVariablesSize = 0;
......@@ -116,6 +119,7 @@ template< class TFixedImage, class TMovingImage >
AdvancedImageToImageMetric< TFixedImage, TMovingImage >
::~AdvancedImageToImageMetric()
{
delete[] this->m_GetValuePerThreadVariables;
delete[] this->m_GetValueAndDerivativePerThreadVariables;
} // end Destructor
......@@ -193,6 +197,14 @@ AdvancedImageToImageMetric< TFixedImage, TMovingImage >
* This has performance benefits for larger vector sizes.
*/
/** Only resize the array of structs when needed. */
if( this->m_GetValuePerThreadVariablesSize != this->m_NumberOfThreads )
{
delete[] this->m_GetValuePerThreadVariables;
this->m_GetValuePerThreadVariables = new AlignedGetValuePerThreadStruct[ this->m_NumberOfThreads ];
this->m_GetValuePerThreadVariablesSize = this->m_NumberOfThreads;
}
/** Only resize the array of structs when needed. */
if( this->m_GetValueAndDerivativePerThreadVariablesSize != this->m_NumberOfThreads )
{
......@@ -204,6 +216,9 @@ AdvancedImageToImageMetric< TFixedImage, TMovingImage >
/** Some initialization. */
for( ThreadIdType i = 0; i < this->m_NumberOfThreads; ++i )
{
this->m_GetValuePerThreadVariables[ i ].st_NumberOfPixelsCounted = NumericTraits< SizeValueType >::Zero;
this->m_GetValuePerThreadVariables[ i ].st_Value = NumericTraits< MeasureType >::Zero;
this->m_GetValueAndDerivativePerThreadVariables[ i ].st_NumberOfPixelsCounted = NumericTraits< SizeValueType >::Zero;
this->m_GetValueAndDerivativePerThreadVariables[ i ].st_Value = NumericTraits< MeasureType >::Zero;
this->m_GetValueAndDerivativePerThreadVariables[ i ].st_Derivative.SetSize( this->GetNumberOfParameters() );
......@@ -578,7 +593,7 @@ AdvancedImageToImageMetric< TFixedImage, TMovingImage >
template< class TFixedImage, class TMovingImage >
void
AdvancedImageToImageMetric< TFixedImage, TMovingImage >
::CheckForBSplineTransform( void )
::CheckForBSplineTransform( void ) const
{
/** Check if this transform is a combo transform. */
CombinationTransformType * testPtr_combo
......@@ -655,8 +670,7 @@ AdvancedImageToImageMetric< TFixedImage, TMovingImage >
{
/** Compute moving image value and gradient using the B-spline kernel. */
movingImageValue = this->m_Interpolator->EvaluateAtContinuousIndex( cindex );
( *gradient )
= this->m_ReducedBSplineInterpolator->EvaluateDerivativeAtContinuousIndex( cindex );
( *gradient ) = this->m_ReducedBSplineInterpolator->EvaluateDerivativeAtContinuousIndex( cindex );
//this->m_ReducedBSplineInterpolator->EvaluateValueAndDerivativeAtContinuousIndex(
// cindex, movingImageValue, *gradient );
}
......@@ -906,6 +920,47 @@ AdvancedImageToImageMetric< TFixedImage, TMovingImage >
} // end BeforeThreadedGetValueAndDerivative()
/**
* **************** GetValueThreaderCallback *******
*/
template< class TFixedImage, class TMovingImage >
ITK_THREAD_RETURN_TYPE
AdvancedImageToImageMetric< TFixedImage, TMovingImage >
::GetValueThreaderCallback( void * arg )
{
ThreadInfoType * infoStruct = static_cast< ThreadInfoType * >( arg );
ThreadIdType threadID = infoStruct->ThreadID;
MultiThreaderParameterType * temp
= static_cast< MultiThreaderParameterType * >( infoStruct->UserData );
temp->st_Metric->ThreadedGetValue( threadID );
return ITK_THREAD_RETURN_VALUE;
} // end GetValueThreaderCallback()
/**
* *********************** LaunchGetValueThreaderCallback***************
*/
template< class TFixedImage, class TMovingImage >
void
AdvancedImageToImageMetric< TFixedImage, TMovingImage >
::LaunchGetValueThreaderCallback( void ) const
{
/** Setup threader. */
this->m_Threader->SetSingleMethod( this->GetValueThreaderCallback,
const_cast< void * >( static_cast< const void * >( &this->m_ThreaderMetricParameters ) ) );
/** Launch. */
this->m_Threader->SingleMethodExecute();
} // end LaunchGetValueThreaderCallback()
/**
* **************** GetValueAndDerivativeThreaderCallback *******
*/
......