Skip to content

Commit

Permalink
moving files from svn
Browse files Browse the repository at this point in the history
  • Loading branch information
bkainz committed Oct 9, 2014
0 parents commit 21a0792
Show file tree
Hide file tree
Showing 729 changed files with 188,297 additions and 0 deletions.
180 changes: 180 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
__Generalized Fast Volume Reconstruction from Motion Corrupted 2D Slices__
======================

This software was used to produced the results shown in

Bernhard Kainz, Markus Steinberger, Christina Malamateniou, Wolfgang Wein, Maria Murgasova,
Kevin Keraudren, Thomas Torsney-Weir, Mary Rutherford, Joseph V. Hajnal, and Daniel Rueckert:
Generalized Fast Volume Reconstruction from Motion Corrupted 2D Slices.
IEEE Transactions on Medical Imaging, under review, 2014

Abstract
======================
Moving objects cause motion artefacts when their enclosing volume is acquired as a stack of image slices.
In this paper we present a fast multi-GPU accelerated implementation of slice-to-volume registration based super-resolution reconstruction with automatic outlier rejection and intensity bias correction.
We introduce a novel fully automatic selection procedure for the image stack with the least motion, which will serve as an initial registration template. We fully evaluate our method and its high dimensional parameter space. Testing is done using artificially motion corrupted phantom datasets and using real world scenarios for the reconstruction of foetal organs from in-utero prenatal Magnetic Resonance Imaging and for the motion compensation of freehand compound Ultrasound data.
On average we achieve a speed-up of more than 40x compared to a single CPU system, and another 1.70x for each additional GPU, while maintaining the same image quality as if calculated on a CPU. Our framework is qualitatively more accurate and on average $10\times$ times faster than currently available state-of-the-art multi-core methods.
The source code for this approach is open source and publicly available for download.

INSTALL
======================
The source code was successfully compiled on x86_64, CUDA 6.5, VS2012 (std-c++11), VS2013 (boost), and gcc 4.8. System: Intel Xeon E5-2630 v2 \@ 2.60GHz system with 16 GB RAM, an Nvidia Tesla K40 with 12 GB RAM and a Geforce 780 Graphics card with 6 GB RAM and also tested on a Nvidia Titan GPU.

#### Necessary Hardware requirements
* x86_64 CPU

#### Optional Hardware requirements
* Nvidia GPU compute capability >= 3.0
In case of no GPU: only CPU reconstruction will be available. Use --useCPU flag [CUDA is still necessary to compile!]

#### Necessary third party libraries
* Nvidia CUDA >= 6.0 https://developer.nvidia.com/cuda-downloads
* Boost (compiled libraries, we used 1.55.0) http://www.boost.org/users/download/
* Intel's TBB https://www.threadingbuildingblocks.org/

#### Optional third party libraries
* CULA http://www.culatools.com/
* IRTK http://www.doc.ic.ac.uk/~dr/software/ (This is already included in the source code repository as minimal build lib. We only use image handling and CPU registration functionality from IRTK)

BUILD INSTRUCTIONS
======================
* go to the source directory
* make a new directory "build"
* execute cmake .. in this directory (give paths to TBB and other third party libs if necessary using cmakegui .. or ccmake ..)
* make or open the Visual Studio Solution

Execute
======================
* get two or more overlapping stacks of image slices
* [optional]: generate a region of interest and sace as .nii or .nii.gz
* run the program __reconstruction_GPU2__
* Example: ./reconstruction_GPU2 -o 3T_GPUtest.nii -i ../../data/14_3T_nody_001.nii.gz ../../data/10_3T_nody_001.nii.gz ../../data/23_3T_nody_001.nii.gz ../../data/21_3T_nody_001.nii.gz -m ../../data/mask_10_3T_brain_smooth.nii.gz
* Options:

-h [ --help ] Print usage messages

-o [ --output ] arg Name for the reconstructed volume. Nifti
or Analyze format.

-m [ --mask ] arg Binary mask to define the region od
interest. Nifti or Analyze format.

-i [ --input ] arg [stack_1] .. [stack_N] The input stacks.
Nifti or Analyze format.

-t [ --transformation ] arg The transformations of the input stack to
template in 'dof' format used in IRTK.
Only rough alignment with correct
orienation and some overlap is needed. Use
'id' for an identity transformation for at
least one stack. The first stack with 'id'
transformation will be resampled as
template.

--thickness arg [th_1] .. [th_N] Give slice
thickness.[Default: twice voxel size in z
direction]

-p [ --packages ] arg Give number of packages used during
acquisition for each stack. The stacks
will be split into packages during
registration iteration 1 and then into odd
and even slices within each package during
registration iteration 2. The method will
then continue with slice to volume
approach. [Default: slice to volume
registration only]

--iterations arg (=4) Number of registration-reconstruction
iterations.

--sigma arg (=12) Stdev for bias field. [Default: 12mm]
--resolution arg (=0.75) Isotropic resolution of the volume.
[Default: 0.75mm]

--multires arg (=3) Multiresolution smooting with given number
of levels. [Default: 3]

--average arg (=700) Average intensity value for stacks
[Default: 700]

--delta arg (=150) Parameter to define what is an edge.
[Default: 150]

--lambda arg (=0.02) Smoothing parameter. [Default: 0.02]

--lastIterLambda arg (=0.01) Smoothing parameter for last iteration.
[Default: 0.01]

--smooth_mask arg (=4) Smooth the mask to reduce artefacts of
manual segmentation. [Default: 4mm]

--global_bias_correction arg (=0) Correct the bias in reconstructed image
against previous estimation.

--low_intensity_cutoff arg (=0.01) Lower intensity threshold for inclusion of
voxels in global bias correction.

--force_exclude arg force_exclude [number of slices] [ind1]
... [indN] Force exclusion of slices with
these indices.

--no_intensity_matching arg Switch off intensity matching.

--log_prefix arg Prefix for the log file.

--debug arg (=0) Debug mode - save intermediate results.

--debug_gpu Debug only GPU results.

--rec_iterations_first arg (=4) Set number of superresolution iterations

--rec_iterations_last arg (=13) Set number of superresolution iterations
for the last iteration

--num_stacks_tuner arg (=0) Set number of input stacks that are
really used (for tuner evaluation, use
only first x)

--no_log arg (=0) Do not redirect cout and cerr to log
files.

-d [ --devices ] arg Select the CP > 3.0 GPUs on which the
reconstruction should be executed.
Default: all devices > CP 3.0

--tfolder arg [folder] Use existing slice-to-volume
transformations to initialize the
reconstruction.

--sfolder arg [folder] Use existing registered slices
and replace loaded ones (have to be
equally many as loaded from stacks).

--referenceVolume arg Name for an optional reference volume.
Will be used as inital reconstruction.

--T1PackageSize arg is a test if you can register T1 to T2
using NMI and only one iteration

--useCPU use CPU for reconstruction and
registration; performs superresolution and
robust statistics on CPU. Default is using
the GPU

--useCPUReg use CPU for more flexible CPU
registration; performs superresolution and
robust statistics on GPU. [default, best
result]

--useGPUReg use faster but less accurate and flexible
GPU registration; performs superresolution
and robust statistics on GPU.

--useAutoTemplate select 3D registration template stack
automatically with matrix rank method.

--disableBiasCorrection disable bias field correction for cases
with little or no bias field
inhomogenities (makes it faster but less
reliable for stron intensity bias)
Binary file added data/10_3T_nody_001.nii.gz
Binary file not shown.
Binary file added data/10_3T_nody_002.nii.gz
Binary file not shown.
Binary file added data/14_3T_nody_001.nii.gz
Binary file not shown.
Binary file added data/14_3T_nody_002.nii.gz
Binary file not shown.
Binary file added data/21_3T_nody_001.nii.gz
Binary file not shown.
Binary file added data/21_3T_nody_002.nii.gz
Binary file not shown.
Binary file added data/23_3T_nody_001.nii.gz
Binary file not shown.
Binary file added data/23_3T_nody_002.nii.gz
Binary file not shown.
Binary file added data/mask_10_3T_brain_smooth.nii.gz
Binary file not shown.
90 changes: 90 additions & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
project(FetalReconstruction)

cmake_minimum_required(VERSION 2.8)
cmake_policy(SET CMP0010 OLD)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)

option(USE_SYSTEM_IRTK "use system IRTK version instead of simplified included version" OFF)
option(BUILD_WITH_CULA "build with CULA support, necessary for automatic motion measurement" OFF)

# Finding GNU scientific library GSL
FIND_PACKAGE(GSL REQUIRED)
set(GSL_LIBRARIES ${GSL_LIBRARIES} ${GSL_LIB})
#IF (GSL_FOUND)
INCLUDE_DIRECTORIES(${GSL_INCLUDE_DIR})
LINK_DIRECTORIES(${GSL_LINK_DIRECTORIES})
LINK_LIBRARIES(${GSL_LIBRARIES})
#ENDIF (GSL_FOUND)

SET(BUILD_OUT_OF_IRTK_TREE TRUE)
if(USE_SYSTEM_IRTK)
#if IRTK_SOURCE_DIR is set, we are building within the IRTK source tree
if(IRTK_SOURCE_DIR)
SET(BUILD_OUT_OF_IRTK_TREE FALSE)
else(IRTK_SOURCE_DIR)
SET(BUILD_OUT_OF_IRTK_TREE TRUE)
endif(IRTK_SOURCE_DIR)
INCLUDE_DIRECTORIES(${IRTK_DIR}/../packages/registration/include)
endif(USE_SYSTEM_IRTK)

if (WIN32)
# for msvc 8 deprecated warning removal
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE_GLOBALS)
add_definitions(-DWIN32 -D_WIN32)
add_definitions(-DNOMINMAX)

#set(CMAKE_DEBUG_POSTFIX "D")

set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT.lib;libcmtd.lib")
endif(WIN32)

if (WIN32)
add_definitions(-DGL_GLEXT_PROTOTYPES -bigobj)
endif()

if(BUILD_OUT_OF_IRTK_TREE AND USE_SYSTEM_IRTK)
# we do not need to search for IRTK for in source tree build
find_package(IRTK REQUIRED)
#message("${IRTK_LIBRARIES_DIR}")
include_directories(${IRTK_INCLUDE_DIRS})
link_directories(${IRTK_LIBRARIES_DIR})
endif(BUILD_OUT_OF_IRTK_TREE AND USE_SYSTEM_IRTK)


FIND_PACKAGE(TBB REQUIRED)
IF (TBB_FOUND)
# Attention: DO NOT define TBB_DEPRECATED by default or before including the
# other TBB header files, in particular parallel_for. The deprecated
# behavior of parallel_for is to not choose the chunk size (grainsize)
# automatically!
#
# http://software.intel.com/sites/products/documentation/doclib/tbb_sa/help/tbb_userguide/Automatic_Chunking.htm
ADD_DEFINITIONS(-DHAS_TBB)
INCLUDE_DIRECTORIES(${TBB_INCLUDE_DIRS})
LINK_DIRECTORIES(${TBB_LIBRARY_DIRS})
LINK_LIBRARIES(${TBB_LIBRARIES})
ENDIF (TBB_FOUND)
#message("ignore the support TBB error. it works. Do not ignore the not found error!")

if(USE_SYSTEM_IRTK)
FIND_PACKAGE(OpenCV REQUIRED)
include_directories(${OpenCV_DIR}/include ${OpenCV_DIR}/include/opencv)

find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
else(USE_SYSTEM_IRTK)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/IRTKSimple2/)
set(IRTK_LIBRARIES common++ contrib++ geometry++ image++ registration++ transformation++ zlib)
endif(USE_SYSTEM_IRTK)

INCLUDE_DIRECTORIES(${TBB_INSTALL_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR})

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/reconstructionGPU2/)


68 changes: 68 additions & 0 deletions source/IRTKSimple2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 2.6)
if(COMMAND cmake_policy)
# policy settings ...
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

PROJECT(IRTK)

#INCLUDE(CTest)

# Finding GNU scientific library GSL
FIND_PACKAGE(GSL REQUIRED)
IF (GSL_FOUND)
INCLUDE_DIRECTORIES(${GSL_INCLUDE_DIR})
LINK_DIRECTORIES(${GSL_LINK_DIRECTORIES})
LINK_LIBRARIES(${GSL_LIBRARIES})
ENDIF (GSL_FOUND)

# add boost dependencies
find_package( Boost 1.46 REQUIRED)

if ( NOT Boost_FOUND )
message( STATUS "Boost could not be found." )
set( BOOST_ROOT ${BOOST_ROOT} CACHE PATH "Please enter path to Boost include folder." FORCE )
endif ()

#message( STATUS "Boost_INCLUDE_DIRS : '" ${Boost_INCLUDE_DIRS} "'" )

include_directories(${Boost_INCLUDE_DIRS})

OPTION(USE_VXL "Use VXL library instead of Numerical Recipes" OFF)
IF (USE_VXL)
SUBDIRS(vxl)
# INCLUDE_DIRECTORIES(${VCL_INCLUDE_DIR} ${VXLCORE_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${IRTK_SOURCE_DIR}/vxl/core ${IRTK_SOURCE_DIR}/vxl/vcl)
ADD_DEFINITIONS(-DUSE_VXL)
ELSE (USE_VXL)

ENDIF (USE_VXL)

OPTION(BUILD_WITH_TBB "Use TBB library for multithreading support" ON)

#SUBDIRS(common++/src geometry++/src image++/src contrib++/src applications packages wrapping)
SUBDIRS(common++/src geometry++/src image++/src contrib++/src packages)

INCLUDE(${IRTK_SOURCE_DIR}/config/IRTKInclude.cmake)

SET(EXECUTABLE_OUTPUT_PATH ${IRTK_BINARY_DIR}/bin CACHE STRING
"Where to put the executables")
SET(LIBRARY_OUTPUT_PATH ${IRTK_BINARY_DIR}/lib CACHE STRING
"Where to put the libraries")

IF (BUILD_WITH_NIFTI)
SUBDIRS(nifti)
ENDIF (BUILD_WITH_NIFTI)

include_directories(${CMAKE_CURRENT_BINARY_DIR}/nifti/zlib)


CONFIGURE_FILE(${IRTK_SOURCE_DIR}/config/IRTKInclude.cmake
${IRTK_BINARY_DIR}/lib/IRTKInclude.cmake)

#CONFIGURE_FILE(${IRTK_SOURCE_DIR}/InstallerScripts/irtkInstaller.sh
# ${IRTK_BINARY_DIR}/bin/irtkInstaller.sh)

#EXEC_PROGRAM(chmod ${IRTK_BINARY_DIR}/bin ARGS +x;irtkInstaller.sh)

INCLUDE(${IRTK_SOURCE_DIR}/config/IRTKGenerateConfigFile.cmake)
Loading

0 comments on commit 21a0792

Please sign in to comment.