Commit 84720e75 authored by Floris Berendsen's avatar Floris Berendsen
Browse files

Merge branch 'develop' into SELX-7-Logger

parents f3073292 53e80653
......@@ -36,8 +36,9 @@
# IDEs
.idea
.kdev4
cmake-build-*
.kdev4
.vscode
# Source
Documentation/build
......@@ -17,22 +17,42 @@
#
#=========================================================================
# This CMakeLists.txt allows the Applications directory to be built as an
# external project.
cmake_minimum_required( VERSION 3.0.2 )
project(SuperElastixExamples)
project( SuperElastixApplications )
if( NOT CMAKE_PROJECT_NAME STREQUAL "SuperElastix" )
# Examples are build as an external project, need to import dependencies
# -----------------------------------------------------------------
# Compiler-dependent settings
set(CMAKE_CXX_STANDARD 11)
find_package( SuperElastix )
include( ${SUPERELASTIX_USE_FILE} )
enable_language( C )
enable_language( CXX )
set( CMAKE_CXX_STANDARD 11 )
find_package( ITK )
include( ${ITK_USE_FILE} )
# 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()
message( STATUS "ELASTIX_USE_FILE: ${ELASTIX_USE_FILE}")
include( ${ELASTIX_USE_FILE} )
# 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( SuperElastix )
include( ${SUPERELASTIX_USE_FILE} )
find_package( ITK )
include( ${ITK_USE_FILE} )
include( ${ELASTIX_USE_FILE} )
add_subdirectory( CommandLineInterface )
......@@ -17,12 +17,22 @@
#
#=========================================================================
list( APPEND RequiredITKModules
ITKReview
set( ${APPLICATION}_TARGET_NAME SuperElastix )
set( ${APPLICATION}_SOURCE_FILES
${${APPLICATION}_SOURCE_DIR}/src/selxSuperElastix.cxx
)
set( ${APPLICATION}_LINK_LIBRARIES
${ITK_LIBRARIES}
elastix transformix
${Boost_LIBRARIES}
)
foreach( ITKModule ${RequiredITKModules} )
if( NOT ${ITKModule}_LOADED )
message( FATAL_ERROR "elastix requires that ITK is build with ${ITKModule}. Please rebuild ITK with Module_${ITKModule} set to ON." )
endif()
endforeach()
set( ${APPLICATION}_MODULE_DEPENDENCIES
ModuleCore
)
set( ${APPLICATION}_INTEGRATION_TEST_SOURCE_FILES
${${APPLICATION}_SOURCE_DIR}/test/integration.cmake
)
#=========================================================================
#
# Copyright Leiden University Medical Center, Erasmus University Medical
# Center and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#=========================================================================
# This file allows the SuperElastix command line interface to be
# built as an external project.
# ---------------------------------------------------------------------
# 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/*.*")
set( COMMANDLINE_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/selxSuperElastix.cxx
)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib)
find_package(Boost COMPONENTS program_options system filesystem REQUIRED QUIET )
include_directories(${Boost_INCLUDE_DIR})
# Compile executable
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
set( INSTALLDEMO_PREFIX ${PROJECT_BINARY_DIR}/Demo CACHE PATH "Demo files will be copied to this directory" )
# 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)"
"http://midas3.kitware.com/midas/api/rest?method=midas.bitstream.download&checksum=%(hash)&algorithm=%(algo)"
"https://midas3.kitware.com/midas/api/rest?method=midas.bitstream.download&checksum=%(hash)&algorithm=%(algo)"
)
file( GLOB_RECURSE DemoDataContentLinks "*.md5" )
foreach( DemoDataContentLink ${DemoDataContentLinks} )
string( REGEX REPLACE "\\.md5$" "" DemoDataContentLink ${DemoDataContentLink} )
ExternalData_Expand_Arguments( InstallDemo
InstallDemoFileName
DATA{${DemoDataContentLink}}
)
list( APPEND InstallDemoFileNames ${InstallDemoFileName} )
endforeach()
# Create target and reference the external data
ExternalData_Add_Target( InstallDemo )
add_dependencies( InstallDemo SuperElastix )
set_target_properties( InstallDemo 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/
)
endforeach()
# Copy executable
add_custom_command(
TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:SuperElastix> ${INSTALLDEMO_PREFIX}/$<TARGET_FILE_NAME:SuperElastix>
)
# Copy Configuration files
set( ConfigFiles
"itkv4_SVF_ANTsCC.json"
"itkv4_SVF_MSD.json"
"elastix_Bspline_NC.json"
"elastix_Bspline_MSD.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/Data/Configuration/${ConfigFile}" ${INSTALLDEMO_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"
)
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()
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()
endif(WIN32)
......@@ -23,9 +23,6 @@
#include "selxAnyFileReader.h"
#include "selxAnyFileWriter.h"
#include "selxDefaultComponents.h"
#include "selxTypeList.h"
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
......@@ -56,17 +53,8 @@ main( int ac, char * av[] )
{
typedef std::vector< std::string > VectorOfStringsType;
using Elastix3DComponents = selx::TypeList<
selx::MonolithicElastixComponent< 3, float >,
selx::MonolithicTransformixComponent< 3, float >,
selx::ItkImageSourceFixedComponent< 3, float >,
selx::ItkImageSourceMovingComponent< 3, float >,
selx::ItkImageSinkComponent< 3, float >,
selx::ItkImageRegistrationMethodv4Component< 3, float, float >
>;
using RegisterComponents = selx::list_append< selx::DefaultComponents, Elastix3DComponents >::type;
selx::SuperElastixFilter< RegisterComponents >::Pointer superElastixFilter = selx::SuperElastixFilter< RegisterComponents >::New();
// instantiate a SuperElastixFilter that is loaded with default components
selx::SuperElastixFilter::Pointer superElastixFilter = selx::SuperElastixFilter::New();
fs::path configurationPath;
VectorOfStringsType inputPairs;
......@@ -119,7 +107,7 @@ main( int ac, char * av[] )
}
//turn the blueprint into an itkObject to connect to the superElastix itkFilter
selx::SuperElastixFilter< RegisterComponents >::BlueprintPointer itkBluePrint = selx::SuperElastixFilter< RegisterComponents >::BlueprintType::New();
selx::SuperElastixFilter::BlueprintPointer itkBluePrint = selx::SuperElastixFilter::BlueprintType::New();
itkBluePrint->Set(blueprint);
superElastixFilter->SetBlueprint(itkBluePrint);
......
......@@ -17,21 +17,22 @@
#
#=========================================================================
# 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/*.*")
set( COMMANDLINE_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/selxSuperElastix.cxx
add_integration_test(
NAME SuperElastixIntegrationTest
DRIVER SuperElastix
ARGUMENTS --conf ${CMAKE_SOURCE_DIR}/Testing/Data/Configuration/itkv4_SVF_ANTsCC.json --in FixedImage=${CMAKE_BINARY_DIR}/Testing/Data/Input/coneA2d64.mhd MovingImage=${CMAKE_BINARY_DIR}/Testing/Data/Input/coneB2d64.mhd --out ResultImage=2A_image_itkv4_NC.mhd ResultDisplacementField=2A_deformation_itkv4_NC.mhd
)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib)
find_package(Boost COMPONENTS program_options system filesystem REQUIRED)
# Possible grand challenge CMake interface:
#
# add_grand_challenge_submission(
# NAME username
# DRIVER GrandChallengeDriver
# ARGUMENTS ...
# )
#
# The CMake mechanism would be similar to that of integration tests, except
# we would allow users to write their own driver and/or use an executable that
# contains additional functionality for saving results. The macro would also
# invoke a script that uploads results and configurition files to website.
include_directories(${Boost_INCLUDE_DIR})
# Compile executable
add_executable( superelastix ${COMMANDLINE_SOURCE_FILES} ${COMMANDLINE_HEADER_FILES} )
target_link_libraries( superelastix ${SUPERELASTIX_LIBRARIES} ${Boost_LIBRARIES})
......@@ -16,16 +16,32 @@
# limitations under the License.
#
#=========================================================================
set(Niftyreg_FIND_COMPONENTS _reg_aladin _reg_blockMatching _reg_f3d _reg_femTrans _reg_globalTrans _reg_localTrans _reg_maths _reg_measure _reg_ReadWriteImage _reg_resampling _reg_tools reg_nifti reg_png)
set( CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
)
# *NIX OSes use system png and zlib, for Windows OS Niftyreg is configured to build these libraries
if( WIN32)
list(APPEND Niftyreg_FIND_COMPONENTS png z)
endif (WIN32)
set(Niftyreg_INCLUDE_DIR ${NIFTYREG_DIR}/include CACHE PATH "Installed Include Directory of NiftyReg" )
#set(Niftyreg_LIBRARIES "" CACHE STRING "Found libraries NiftyReg" )
#message(STATUS NIFTYREG_DIR/lib "${NIFTYREG_DIR}/lib")
foreach(component ${Niftyreg_FIND_COMPONENTS})
# message(component: ${component})
find_library(Niftyreg_${component}_LIBRARY
${component}
"${NIFTYREG_DIR}/lib"
DOC "Path to NiftyReg library files (lib_*.a)"
)
set(Niftyreg_LIBRARIES ${Niftyreg_LIBRARIES} ${Niftyreg_${component}_LIBRARY})
endforeach()
# handle the QUIETLY and REQUIRED arguments and set Niftyreg_FOUND to TRUE if
# all listed variables are TRUE
#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Niftyreg DEFAULT_MSG Niftyreg_LIBRARIES Niftyreg_INCLUDE_DIR)
mark_as_advanced(
Niftyreg_INCLUDE_DIR
Niftyreg_LIBRARIES
)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment