Commit 90aa952d authored by FBerendsen's avatar FBerendsen

Merge branch 'develop'

parents 40472598 69d97589
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
*.hxx text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Declare files that will always have LF line endings on checkout.
# Patch files need LF, see SuperElastix#59
*.patch text eol=lf
\ No newline at end of file
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
*.pyc
# 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
# OSs
.DS_Store
# IDEs
.idea
cmake-build-*
.kdev4
.vscode
# Source
Documentation/build
sudo: required
dist: trusty
language: cpp
os:
- linux
- osx
env:
global:
HOME_DIR=${TRAVIS_BUILD_DIR}/..
ExternalData_OBJECT_STORES=${HOME_DIR}/.ExternalData
ITK_URL=https://github.com/InsightSoftwareConsortium/ITK
ITK_SOURCE_DIR=${HOME_DIR}/ITK-source
ITK_BUILD_DIR=${HOME_DIR}/ITK-build
ELASTIX_URL=https://github.com/SuperElastix/elastix
ELASTIX_SOURCE_DIR=${HOME_DIR}/Elastix-source
ELASTIX_BUILD_DIR=${HOME_DIR}/Elastix-build
SUPERELASTIX_SOURCE_DIR=${TRAVIS_BUILD_DIR}/SuperBuild
SUPERELASTIX_BUILD_DIR=${HOME_DIR}/SuperElastix-build
CMAKE_DOWNLOAD_FILE=cmake-3.6.0-Linux-x86_64.sh
cache:
directories:
- ${ExternalData_OBJECT_STORES}
- ${ITK_SOURCE_DIR}
- ${ITK_BUILD_DIR}
- ${ELASTIX_SOURCE_DIR}
- ${ELASTIX_BUILD_DIR}
compiler:
- clang
- gcc
matrix:
include:
- os: linux
dist: trusty
sudo: required
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
env:
- GCC="CC=gcc-4.9 && CXX=g++-4.9"
- os: linux
dist: trusty
sudo: required
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
env:
- GCC="CC=gcc-5 && CXX=g++-5"
- os: linux
dist: trusty
sudo: required
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-6
env:
- GCC="CC=gcc-6 && CXX=g++-6"
- os: linux
dist: trusty
sudo: required
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env:
- GCC="CC=gcc-7 && CXX=g++-7"
- os: osx
compiler: clang
- os: osx
compiler: gcc
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then eval ${GCC}; fi;
before_script:
- export OMP_NUM_THREADS=2
- echo $OMP_NUM_THREADS
# Out-of-source build
- cd ..
- mkdir SuperElastix-build
- cd SuperElastix-build
- mkdir -p ${SUPERELASTIX_BUILD_DIR}
- mkdir -p ${ExternalData_OBJECT_STORES}
- if [[ "$TRAVIS_OS_NAME" == "linux" && ! -e "${ExternalData_OBJECT_STORES}/${CMAKE_DOWNLOAD_FILE}" ]]; then (cd ${ExternalData_OBJECT_STORES} && curl -sSO https://cmake.org/files/v3.6/${CMAKE_DOWNLOAD_FILE}); fi;
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo bash "${ExternalData_OBJECT_STORES}/${CMAKE_DOWNLOAD_FILE}" --prefix=/usr/local --exclude-subdir; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake --version; fi
script:
- cmake ../SuperElastix/SuperBuild
- make -j2
after_success:
- cd SuperElastix-build
- ctest
- 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.12.2 &&
mkdir -p ${ITK_BUILD_DIR} &&
cd ${ITK_BUILD_DIR} &&
cmake -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_VISIBILITY_INLINES_HIDDEN:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_SKIP_RPATH:BOOL=ON -DITK_LEGACY_REMOVE:BOOL=ON -DITK_USE_KWSTYLE:BOOL=OFF -DITK_BUILD_DEFAULT_MODULES:BOOL=ON -DModule_ITKReview:BOOL=ON ${ITK_SOURCE_DIR} &&
make --jobs=4; fi
- if [[ ! -e ${ELASTIX_BUILD_DIR}/ElastixConfig.cmake ]]; then
rm -rf ${ELASTIX_SOURCE_DIR} ${ELASTIX_BUILD_DIR} &&
git clone ${ELASTIX_URL} ${ELASTIX_SOURCE_DIR} &&
cd ${ELASTIX_SOURCE_DIR} &&
git checkout e8354222396c6bd78e9fe6d5a39e4ecac4bb0d52 &&
mkdir -p ${ELASTIX_BUILD_DIR} &&
cd ${ELASTIX_BUILD_DIR} &&
cmake -DBUILD_TESTING:BOOL=OFF -DELASTIX_BUILD_EXECUTABLE:BOOL=OFF -DITK_DIR=${ITK_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release ${ELASTIX_SOURCE_DIR} &&
make --jobs=4 &&
touch ${HOME_DIR}/built_cache; fi
- cd ${SUPERELASTIX_BUILD_DIR}
- if [[ ! -e ${HOME_DIR}/built_cache ]]; then
cmake -DBUILD_APPLICATIONS_EXTERNAL_PROJECT:BOOL=ON -DBUILD_TESTING:BOOL=ON -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_ITK:BOOL=ON -DITK_DIR=${ITK_BUILD_DIR} -DUSE_SYSTEM_ELASTIX:BOOL=ON -DElastix_DIR=${ELASTIX_BUILD_DIR} ${SUPERELASTIX_SOURCE_DIR} &&
make --jobs=4; fi
......@@ -17,42 +17,46 @@
#
#=========================================================================
# This CMakeLists.txt allows the Applications directory to be built as an
# external project.
cmake_minimum_required( VERSION 3.0.2 )
project(SuperElastixApplications)
if( NOT CMAKE_PROJECT_NAME STREQUAL "SuperElastix" )
# Examples are build as an external project, need to import dependencies
set(CMAKE_CXX_STANDARD 11)
# -----------------------------------------------------------------
# Compiler-dependent settings
# GCC
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL GNU )
add_definitions(
-DVCL_CAN_STATIC_CONST_INIT_FLOAT=0
-DVCL_CAN_STATIC_CONST_INIT_INT=0
)
endif()
#TODO SuperElastix Application should not link against elastix libraries
# If OpenMP is supported by this machine, elastix will be compiled with
# OpenMP flags, and we need to add them here as well
find_package( OpenMP )
if (OPENMP_FOUND)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
endif()
find_package( SuperElastix )
include( ${SUPERELASTIX_USE_FILE} )
find_package( ITK )
include( ${ITK_USE_FILE} )
message( STATUS "ELASTIX_USE_FILE: ${ELASTIX_USE_FILE}")
include( ${ELASTIX_USE_FILE} )
project( SuperElastixApplications )
# -----------------------------------------------------------------
# Compiler-dependent settings
enable_language( C )
enable_language( CXX )
set( CMAKE_CXX_STANDARD 11 )
# GCC
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL GNU )
add_definitions(
-DVCL_CAN_STATIC_CONST_INIT_FLOAT=0
-DVCL_CAN_STATIC_CONST_INIT_INT=0
)
endif()
# TODO: SuperElastix Application should not link against elastix libraries
# If OpenMP is supported by this machine, elastix will be compiled with
# OpenMP flags, and we need to add them here as well
find_package( OpenMP QUIET )
if (OPENMP_FOUND)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
endif()
add_subdirectory( CommandlineProgram )
\ No newline at end of file
find_package( SuperElastixSuperBuild )
include( ${SUPERELASTIXSUPERBUILD_USE_FILE} )
find_package( SuperElastix )
include( ${SUPERELASTIX_USE_FILE} )
find_package( ITK )
include( ${ITK_USE_FILE} )
find_package( Elastix )
include( ${ELASTIX_USE_FILE} )
add_subdirectory( CommandLineInterface )
......@@ -17,19 +17,19 @@
#
#=========================================================================
set( PROJECT GoogleBenchmark )
set( GOOGLEBENCHMARK_REPOSITORY https://github.com/google/benchmark.git )
set( GOOGLEBENCHMARK_TAG "v${GOOGLEBENCHMARK_VERSION_STRING")
set( ${APPLICATION}_TARGET_NAME SuperElastix )
ExternalProject_Add( ${PROJECT}
GIT_REPOSITORY ${GOOGLEBENCHMARK_REPOSITORY}
GIT_TAG ${GOOGLEBENCHMARK_TAG}
UPDATE_COMMAND ""
SOURCE_DIR ${PROJECT}
BINARY_DIR ${prPROJECToj}-build
CMAKE_ARGS
--no-warn-unused-cli
-DBENCHMARK_ENABLE_TESTING:BOOL=OFF
-DCMAKE_SKIP_RPATH:BOOL=ON
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
set( ${APPLICATION}_INCLUDE_DIRS
${${APPLICATION}_SOURCE_DIR}/include
)
set( ${APPLICATION}_SOURCE_FILES
${${APPLICATION}_SOURCE_DIR}/src/selxSuperElastix.cxx
)
set( ${APPLICATION}_MODULE_DEPENDENCIES
ModuleFilter
)
set( ${APPLICATION}_INTEGRATION_TEST_SOURCE_FILES
${${APPLICATION}_SOURCE_DIR}/test/integration.cmake
)
......@@ -17,34 +17,34 @@
#
#=========================================================================
# Collect header files for Visual Studio Project
# http://stackoverflow.com/questions/8316104/specify-how-cmake-creates-visual-studio-project
file(GLOB COMMANDLINE_HEADER_FILES "${COMMANDLINE_SOURCE_DIR}/*/include/*.*")
# This file allows the SuperElastix command line interface to be
# built as an external project.
# ---------------------------------------------------------------------
set( COMMANDLINE_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/selxSuperElastix.cxx
)
#set(Boost_DEBUG ON )
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib)
find_package(Boost COMPONENTS program_options system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
find_package(Boost COMPONENTS program_options filesystem system regex REQUIRED QUIET )
include_directories( ${Boost_INCLUDE_DIR} )
# Compile executable
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/include" )
add_executable( SuperElastix ${COMMANDLINE_SOURCE_FILES} ${COMMANDLINE_HEADER_FILES} )
target_link_libraries( SuperElastix ${SUPERELASTIX_LIBRARIES} ${Boost_LIBRARIES})
# InstallDemo copies SuperElastix executable, image data, configuration files and bat/bash scripts to the INSTALLDEMO_PREFIX directory
target_link_libraries( SuperElastix ${SUPERELASTIX_LIBRARIES} ${Boost_LIBRARIES} ${ITK_LIBRARIES} ${ELASTIX_LIBRARIES} )
set(INSTALLDEMO_PREFIX ${PROJECT_BINARY_DIR}/Demo CACHE PATH "Path where to copy the Demo files")
#add_custom_target( InstallDemo EXCLUDE_FROM_ALL DEPENDS SuperElastix)
# demo copies SuperElastix executable, image data, configuration files and bat/bash scripts to the DEMO_PREFIX directory
set( DEMO_PREFIX ${PROJECT_BINARY_DIR}/Demo CACHE PATH "Demo files will be copied to this directory" )
#Demo Image data
# Download demo data
include( ExternalData )
# Get the demo image data: from superelastix-build or otherwise download
list( APPEND ExternalData_URL_TEMPLATES
"file://${PROJECT_BINARY_DIR}/../SuperElastix-build/ExternalData/Objects/%(algo)/%(hash)"
......@@ -55,60 +55,73 @@ list( APPEND ExternalData_URL_TEMPLATES
file( GLOB_RECURSE DemoDataContentLinks "*.md5" )
foreach( DemoDataContentLink ${DemoDataContentLinks} )
string( REGEX REPLACE "\\.md5$" "" DemoDataContentLink ${DemoDataContentLink} )
ExternalData_Expand_Arguments( InstallDemo
InstallDemoFileName
ExternalData_Expand_Arguments( demo
demoFileName
DATA{${DemoDataContentLink}}
)
list( APPEND InstallDemoFileNames ${InstallDemoFileName} )
list( APPEND demoFileNames ${demoFileName} )
endforeach()
#Create target and reference the external data
ExternalData_Add_Target( InstallDemo )
#add_custom_target( InstallDemo EXCLUDE_FROM_ALL DEPENDS SuperElastix)
add_dependencies(InstallDemo SuperElastix )
set_target_properties(InstallDemo PROPERTIES EXCLUDE_FROM_ALL TRUE)
# Create target and reference the external data
ExternalData_Add_Target( demo )
add_dependencies( demo SuperElastix )
set_target_properties( demo PROPERTIES EXCLUDE_FROM_ALL TRUE )
foreach(InstallDemoFileName ${InstallDemoFileNames})
add_custom_command(TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Data
COMMAND ${CMAKE_COMMAND} -E copy ${InstallDemoFileName} ${INSTALLDEMO_PREFIX}/Data/)
foreach(demoFileName ${demoFileNames})
add_custom_command(
TARGET demo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEMO_PREFIX}/Data
COMMAND ${CMAKE_COMMAND} -E copy ${demoFileName} ${DEMO_PREFIX}/Data/
)
endforeach()
# Copy executable
add_custom_command(TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:SuperElastix> ${INSTALLDEMO_PREFIX}/$<TARGET_FILE_NAME:SuperElastix>)
add_custom_command(
TARGET demo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:SuperElastix> ${DEMO_PREFIX}/$<TARGET_FILE_NAME:SuperElastix>
)
# Copy Configuration files
set(ConfigFiles "itkv4_SVF_ANTsCC.json"
set( ConfigFiles
"itkv4_SVF_ANTsCC.json"
"itkv4_SVF_MSD.json"
"elastix_Bspline_NC.json"
"elastix_Bspline_MSD.json")
"elastix_Bspline_MSD.json"
"IdentityTransformRegistration.json"
"elastix3d.json"
)
foreach(ConfigFile ${ConfigFiles})
add_custom_command(TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Configuration
COMMAND ${CMAKE_COMMAND} -E
copy "${CMAKE_SOURCE_DIR}/../Testing/Unit/Data/Configuration/${ConfigFile}" ${INSTALLDEMO_PREFIX}/Configuration/${ConfigFile})
foreach( ConfigFile ${ConfigFiles} )
add_custom_command(
TARGET demo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEMO_PREFIX}/Configuration
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/../Testing/Data/Configuration/${ConfigFile}" ${DEMO_PREFIX}/Configuration/${ConfigFile}
)
endforeach()
# Copy bat/bash scripts
set(ScriptFiles "1A_SuperElastix_elastix_NC" "1B_SuperElastix_elastix_MSD" "2A_SuperElastix_itkv4_NC" "2B_SuperElastix_itkv4_MSD")
set( ScriptFiles
"1A_SuperElastix_elastix_NC"
"1B_SuperElastix_elastix_MSD"
"2A_SuperElastix_itkv4_NC"
"2B_SuperElastix_itkv4_MSD"
"IdentityTransformRegistration"
"elastix3d"
"graphviz_to_png"
)
if(WIN32)
foreach(ScriptFile ${ScriptFiles})
add_custom_command(TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Scripts
COMMAND ${CMAKE_COMMAND} -E
copy "${CMAKE_CURRENT_SOURCE_DIR}/Demo/Scripts_Windows/${ScriptFile}.bat" "${INSTALLDEMO_PREFIX}/Scripts/${ScriptFile}.bat")
endforeach()
foreach( ScriptFile ${ScriptFiles} )
add_custom_command(
TARGET demo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEMO_PREFIX}/Scripts
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/Demo/Scripts_Windows/${ScriptFile}.bat" "${DEMO_PREFIX}/Scripts/${ScriptFile}.bat")
endforeach()
else(WIN32)
foreach(ScriptFile ${ScriptFiles})
add_custom_command(TARGET InstallDemo PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Scripts
COMMAND ${CMAKE_COMMAND} -E
copy "${CMAKE_CURRENT_SOURCE_DIR}/Demo/Scripts_Linux/${ScriptFile}.sh" "${INSTALLDEMO_PREFIX}/Scripts/${ScriptFile}.sh")
endforeach()
foreach( ScriptFile ${ScriptFiles} )
add_custom_command(
TARGET demo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEMO_PREFIX}/Scripts
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/Demo/Scripts_Linux/${ScriptFile}.sh" "${DEMO_PREFIX}/Scripts/${ScriptFile}.sh")
endforeach()
endif(WIN32)
#
912bdab6529e435f5571457ad653a924
\ No newline at end of file
e4881caeeba92da2cc48bac8b2d7b310
\ No newline at end of file
4d089121887dd2661f8f61b534dd9f84
\ No newline at end of file
434570b4a64d5224cff499a6e7871fd8
\ No newline at end of file
#!/bin/bash
../SuperElastix --conf ../Configuration/IdentityTransformRegistration.json --in FixedImage=../Data/coneA2d64.mhd MovingImage=../Data/coneB2d64.mhd --out DisplacementField=IdentityDeformationField.mhd
# data from Namic - Deformable registration speed optimization http://www.insight-journal.org/midas/collection/view/29
../SuperElastix --conf ../Configuration/elastix3d.json --loglevel debug --in FixedImage=N012_S03_tof3d_multi_slab.mha MovingImage=N026_S02_tof3d_multi_slab.mha --out ResultImage=elastix3d_warped.mhd ResultDisplacementField=elastix3d_displacement.mhd
#!/bin/bash
#Helper script. Not intended to run directly.
#Please install graphviz
dot $1 -Tpng -o $1.png
..\SuperElastix.exe --conf ..\Configuration\elastix_Bspline_NC.json ..\Configuration\warp_3rd_image.json --graphout 1A_graph_elastix_NC_warp.dot --in FixedImage=..\Data\coneA2d64.mhd MovingImage=..\Data\coneB2d64.mhd WarpInputImage=..\Data\coneA2d64_label.mhd --out ResultImage=1A_image_elastix_NC.mhd WarpOutputImage=1A_image_elastix_NC_label.mhd
CALL graphviz_to_png 1A_graph_elastix_NC.dot
..\SuperElastix.exe --conf ..\Configuration\elastix.json ..\Configuration\elastix_Blueprint_Bspline_MSD.json --graphout 1B_graph_elastix_Commandline_Composed_MSD.dot --in FixedImage=..\Data\coneA2d64.mhd MovingImage=..\Data\coneB2d64.mhd --out ResultImage=1B_image_elastix_Commandline_Composed_MSD.mhd
CALL graphviz_to_png 1B_graph_elastix_Commandline_Composed_MSD.dot
..\SuperElastix.exe --conf ..\Configuration\elastix_Composed_with_Bspline_MSD.json --graphout 1B_graph_elastix_Composed_MSD.dot --in FixedImage=..\Data\coneA2d64.mhd MovingImage=..\Data\coneB2d64.mhd --out ResultImage=1B_image_elastix_Composed_MSD.mhd