├── .clang-format
├── CMakeLists.txt
├── LICENSE.txt
├── cmake
├── FindACE.cmake
├── FindCULA.cmake
├── FindFFTW3.cmake
├── FindGLEW.cmake
├── FindGadgetron.cmake
├── FindIsmrmrd.cmake
├── FindNumpy.cmake
├── FindTinyXML.cmake
├── FindXSD.cmake
├── FindXalanC.cmake
└── FindXercesC.cmake
├── denoise
├── CMakeLists.txt
├── denoise_Edge.cpp
├── denoise_NLM.cpp
├── denoise_NLM2D.cpp
├── denoise_NLM2DPoisson.cpp
├── denoise_NLMPoisson.cpp
├── denoise_NLM_prior.cpp
├── nonlocalMeans.cu
├── nonlocalMeans.h
└── split_denoise.cpp
├── mri
├── CMakeLists.txt
├── main_fista.cpp
├── main_ncg.cpp
└── main_sbc.cpp
├── operators
├── BilateralPriorOperator.h
├── CMakeLists.txt
├── accumulateOperator.h
├── cuATVPrimalDualOperator.h
├── cuATrousOperator.h
├── cuATrousWavelet.cu
├── cuATrousWavelet.h
├── cuATvOperator.h
├── cuBilateralFilter.cu
├── cuBilateralFilter.h
├── cuBilateralPriorPrimalDualOperator.h
├── cuBoxFilterOperator.cu
├── cuBoxFilterOperator.h
├── cuDCT.cu
├── cuDCT.h
├── cuDCTDerivativeOperator.h
├── cuDCTOperator.h
├── cuEdgeATrousOperator.h
├── cuEdgeWavelet.cu
├── cuEdgeWavelet.h
├── cuFFTDerivativeOperator.h
├── cuFrameletOperator.cu
├── cuFrameletOperator.h
├── cuGaussianFilterOperator.cu
├── cuGaussianFilterOperator.h
├── cuHaarWaveletOperator.cu
├── cuHaarWaveletOperator.h
├── cuPICSDualOperator.h
├── cuPartialDifferenceOperator.cu
├── cuPartialDifferenceOperator.h
├── cuSSTVPrimalDualOperator.h
├── cuScaleOperator.cu
├── cuScaleOperator.h
├── cuSmallConvOperator.cu
├── cuSmallConvOperator.h
├── cuTFFT.cpp
├── cuTFFT.h
├── cuTFFTPrimalDualOperator.h
├── cuTV4DPrimalDualOperator.h
├── cuTVPrimalDualOperator.cu
├── cuTVPrimalDualOperator.h
├── cuTVTFFT.h
├── cuTensorFrameletOperator.cu
├── cuWTVPrimalDualOperator.cu
├── cuWTVPrimalDualOperator.h
├── hoCuHaarWaveletOperator.h
├── hoCuPartialDerivativeOperator.h
├── invertibleOperator.h
├── linearToSubsetOperator.h
├── primalDualOperator.h
├── projectionSpaceOperator.h
├── subselectionOperator.h
├── subsetAccumulateOperator.h
├── subsetConverter.h
└── weightingOperator.h
├── proton
├── CGhostProtonReconstruct.cpp
├── CMakeLists.txt
├── DROPProtonReconstruct.cpp
├── FilteredProton.h
├── FilteredProtonReconstruct.cpp
├── circulantPreconditioner.cpp
├── circulantPreconditioner.h
├── hdf5_utils.h
├── histogram.cu
├── histogram.h
├── hoCuParallelProjection.cu
├── hoCuParallelProjection.h
├── hoCuProtonBufferedSubsetOperator.h
├── hoCuSplineBackprojectionOperator.cu
├── hostBufferedSubsetProtonReconstruct.cpp
├── hostDROPProtonReconstruct.cpp
├── hostFilteredProtonReconstruct.cpp
├── hostProtonReconstruct.cpp
├── hostSBProtonReconstruct.cpp
├── hostSubsetProtonReconstruct.cpp
├── protonDataset.cu
├── protonDataset.h
├── protonForwardProject.cpp
├── protonPreconditioner.cu
├── protonPreconditioner.h
├── protonReconstruct.cpp
├── protonSubsetOperator.h
├── proton_kernels.cu
├── proton_kernels.h
├── proton_utils.cu
├── proton_utils.h
├── splineBackprojectionOperator.cu
├── splineBackprojectionOperator.h
└── subsetProtonReconstruct.cpp
├── python
├── cps2hdf5.py
├── hnd2hdf5.py
├── hndImageReader.pyx
├── hndreader.py
├── l1shroud.py
├── readReal.py
├── varian_utils.py
├── ximImageReader.pyx
└── ximreader.py
├── registration
├── CMakeLists.txt
├── Matrix.h
├── cuDemonsSolver.cu
├── cuDemonsSolver.h
├── matrix_utils.h
├── morphon.cu
├── morphon.h
├── quadratureKernels.cpp
├── quadratureKernels.h
├── register_Demons_3d.cpp
├── register_Demons_3dV2.cpp
└── register_Demons_4d.cpp
├── solvers
├── ABIBBSolver.h
├── ABOCSSolver.h
├── ADMM.h
├── ADMMSolver.h
├── BILBSolver.h
├── CMakeLists.txt
├── FISTASolver.h
├── acBbSolver.h
├── cgdescentSolver.h
├── cuMLSolver.h
├── cuNCGSolver.cu
├── cuNCGSolver.h
├── cuOSMOMSolverD.cu
├── cuOSMOMSolverD.h
├── cuSARTSolver.h
├── eigenTester.h
├── hoABIBBSolver.h
├── hoCuBILBSolver.h
├── hoCuCgDescentSolver.h
├── hoCuCgSolver.h
├── hoCuGPBBSolver.h
├── hoCuNCGSolver.h
├── hoCuOSNESTSolver.h
├── hoCuOSOMSolver.h
├── hoCuSbcCgSolver.h
├── hoCuSolverUtils.h
├── hoCuTTSSolver.h
├── hoGPBBSolver.h
├── hoNCGSolver.h
├── hoOSCGPBBSolver.h
├── hoOSCGSolver.h
├── hoOSGPBBSolver.h
├── mlSolver.h
├── ncgSolver.h
├── osAHZCSolver.h
├── osCGSolver.h
├── osGPBBSolver.h
├── osLALMSolver2.h
├── osLALMSolverD.h
├── osMOMSolverD.h
├── osMOMSolverD2.h
├── osMOMSolverD3.h
├── osMOMSolverDual.h
├── osMOMSolverF.h
├── osMOMSolverL1.h
├── osMOMSolverW.h
├── osPDsolver.h
├── osSARTSolver.h
├── osSPSSolver.h
├── osWLSSolver.h
├── oscGPBBSolver.h
├── protonDROPSolver.h
├── sartSolver.h
├── solver_utils.cu
├── solver_utils.h
└── subsetConverter2.h
├── test
├── CMakeLists.txt
├── tests.cpp
└── waveletTest.cpp
└── xray
├── CBCT_acquisition.h
├── CBCT_binning.h
├── CBCT_forwards_projection.cpp
├── CBOS_OF_reconstruct.cpp
├── CBOS_reconstruct.cpp
├── CBSubsetOperator.cpp
├── CBSubsetOperator.h
├── CBSubsetWeightOperator.h
├── CB_CGreconstruct.cpp
├── CB_OF_reconstruct.cpp
├── CB_SBreconstruct.cpp
├── CB_reconstruct.cpp
├── CMakeLists.txt
├── CTOS2_reconstruct.cpp
├── CTOS3_reconstruct.cpp
├── CTOS_reconstruct.cpp
├── CTProjectionOperator.cpp
├── CTProjectionOperator.h
├── CTStat_reconstruct.cpp
├── CTSubsetOperator.cpp
├── CTSubsetOperator.h
├── CT_acquisition.cpp
├── CT_acquisition.h
├── CT_reconstruct.cpp
├── FDK_reconstruct_3d.cpp
├── FDK_reconstruct_4d.cpp
├── compare_images.cpp
├── conebeam_projection.cu
├── conebeam_projection.h
├── convolveTest.cpp
├── ct_projection.cu
├── ct_projection.h
├── cuCBOS2_reconstruct.cpp
├── cuCBOSMOM.cpp
├── cuCBOSStat_reconstruct.cpp
├── cuCBOS_reconstruct.cpp
├── cuCB_reconstruct.cpp
├── cuCTOS_reconstruct.cpp
├── cuCT_reconstruct.cpp
├── cuConebeamProjectionOperator.cpp
├── cuConebeamProjectionOperator.h
├── cuHSTVOFSolver.h
├── denoise_TV.cpp
├── dicomCTWriter.cpp
├── dicomCTWriter.h
├── dicomWriter.cpp
├── dicomWriter.h
├── float3x3.h
├── hoCuCBOS_reconstruct.cpp
├── hoCuConebeamProjectionOperator.cpp
├── hoCuConebeamProjectionOperator.h
├── hoCuOFConebeamProjectionOperator.h
├── hoCuOFPartialDerivativeOperator.cpp
├── hoCuOFPartialDerivativeOperator.h
├── hoCuTVOFPartialDerivativeOperator.h
├── hoLinearResampleOperator.cpp
├── hoLinearResampleOperator.h
├── hoLinearResampleOperator_eigen.cpp
├── hoLinearResampleOperator_eigen.h
├── mssim.cpp
├── mssim.h
├── projection_utils.cpp
└── projection_utils.h
/.clang-format:
--------------------------------------------------------------------------------
1 | ---
2 | Language: Cpp
3 | BasedOnStyle: WebKit
4 | AccessModifierOffset: -4
5 | AlignTrailingComments: true
6 | AlignConsecutiveAssignments: true
7 | AlignOperands: true
8 |
9 | AllowShortFunctionsOnASingleLine: Empty
10 | AllowShortCaseLabelsOnASingleLine: true
11 | AlwaysBreakTemplateDeclarations: MultiLine
12 | ColumnLimit: 120
13 | CompactNamespaces: true
14 | BreakBeforeBraces: Attach
15 | ConstructorInitializerAllOnOneLineOrOnePerLine: true
16 | NamespaceIndentation: All
17 | SpaceBeforeCpp11BracedList: false
18 | ...
19 |
20 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.6)
2 |
3 | PROJECT(gt-tomography)
4 |
5 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
6 |
7 | find_package(Gadgetron REQUIRED)
8 |
9 |
10 |
11 | #find_path(GADGETRON_CMAKE_MODULES FindGadgetron.cmake HINTS
12 | #$ENV{GADGETRON_HOME}/cmake
13 | #/usr/local/gadgetron/cmake)
14 |
15 | #if (NOT GADGETRON_CMAKE_MODULES)
16 | # MESSAGE(FATAL_ERROR "GADGETRON_CMAKE_MODULES cannot be found.
17 | # Try to set GADGETRON_HOME environment variable.")
18 | #endif(NOT GADGETRON_CMAKE_MODULES)
19 |
20 |
21 | include_directories( "${GADGETRON_HOME}/include/gadgetron")
22 | include_directories( "/home/dch/.local/include")
23 | link_directories("${GADGETRON_LIB_DIR}/")
24 | # build options for OpenMP support
25 | find_package(OpenMP)
26 | if (OPENMP_FOUND)
27 | message("OpenMP multithreading enabled")
28 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
29 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
30 | OPTION(USE_OPENMP "Use OpenMP" On)
31 | else (OPENMP_FOUND)
32 | message("OpenMP multithreading not supported")
33 | endif (OPENMP_FOUND)
34 | if(USE_OPENMP)
35 | ADD_DEFINITIONS(-DUSE_OMP)
36 | endif(USE_OPENMP)
37 |
38 |
39 |
40 | option(BUILDCT "Build the spiral CT recon")
41 |
42 | find_package(Boost COMPONENTS system thread program_options filesystem REQUIRED)
43 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++14 -D_MWAITXINTRIN_H_INCLUDED")
44 | find_package(CUDA 9.0 REQUIRED)
45 |
46 | #ADD_DEFINITIONS(-D__STRICT_ANSI__)
47 |
48 | #ADD_DEFINITIONS(-D_MATRIX_INTRIN_H_INCLUDED)
49 | if (CUDA_FOUND)
50 |
51 | set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
52 | set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-gencode arch=compute_61,code=sm_61 --use_fast_math -lineinfo " )
53 | #set(CUDA_VERBOSE_BUILD ON)
54 |
55 | # Compile kernels for compute models 1.0 and 2.0 as default for Cuda 4.1
56 | # Support compute model 3.0 from Cuda 4.2 and up
57 | # Support compute model 3.5 from Cuda 5 and up
58 |
59 | MESSAGE("Compiling with ${CUDA_NVCC_FLAGS}")
60 | endif (CUDA_FOUND)
61 | find_package(OpenMP)
62 | if (OPENMP_FOUND)
63 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
64 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
65 | endif()
66 | find_package(GTest)
67 | #Add support for the default ubuntu package of gtest (which is not compiled
68 | if (NOT GTEST_FOUND)
69 | find_path(GTEST_SRC_DIR src/gtest.cc HINTS /usr/src/gtest)
70 | find_path(GTEST_INCLUDE_DIRS gtest.h HINTS /usr/include/gtest)
71 | if (GTEST_SRC_DIR AND GTEST_INCLUDE_DIRS)
72 | MESSAGE("GTest src package found. Compiling as part of Gadgetron.")
73 | add_subdirectory(${GTEST_SRC_DIR} ${CMAKE_BINARY_DIR}/gtest )
74 | include_directories(${GTEST_INCLUDE_DIRS})
75 | set(GTEST_FOUND 1)
76 | set(GTEST_LIBRARIES gtest gtest_main)
77 | endif (GTEST_SRC_DIR AND GTEST_INCLUDE_DIRS)
78 | endif (NOT GTEST_FOUND)
79 |
80 | INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
81 | add_subdirectory(solvers)
82 | add_subdirectory(operators)
83 | add_subdirectory(proton)
84 | add_subdirectory(registration)
85 | add_subdirectory(denoise)
86 | #add_subdirectory(xray)
87 | add_subdirectory(test)
88 | #add_subdirectory(mri)
89 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright 2018 David Christoffer Hansen
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
5 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
6 | persons to whom the Software is furnished to do so, subject to the following conditions:
7 |
8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
9 | Software.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
13 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/cmake/FindACE.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Find the ACE client includes and library
3 | #
4 |
5 | # This module defines
6 | # ACE_INCLUDE_DIR, where to find ace.h
7 | # ACE_LIBRARIES, the libraries to link against ... !! NOT header is old !! ...
8 | # ACE_FOUND, if false, you cannot build anything that requires ACE
9 |
10 | # This is the new header...
11 |
12 | ########################################################################
13 | ## check pkg-config for ace information, if available
14 |
15 | SET(ACE_INCLUDE_DIR_GUESS)
16 | SET(ACE_LIBRARY_DIR_GUESS)
17 | SET(ACE_LINK_FLAGS)
18 | IF(PKGCONFIG_EXECUTABLE)
19 | PKGCONFIG(ace ACE_INCLUDE_DIR_GUESS ACE_LIBRARY_DIR_GUESS ACE_LINK_FLAGS ACE_C_FLAGS)
20 | IF (NOT ACE_LINK_FLAGS)
21 | PKGCONFIG(ACE ACE_INCLUDE_DIR_GUESS ACE_LIBRARY_DIR_GUESS ACE_LINK_FLAGS ACE_C_FLAGS)
22 | ENDIF (NOT ACE_LINK_FLAGS)
23 | ADD_DEFINITIONS(${ACE_C_FLAGS})
24 | ENDIF(PKGCONFIG_EXECUTABLE)
25 |
26 | SET(ACE_LINK_FLAGS "${ACE_LINK_FLAGS}" CACHE INTERNAL "ace link flags")
27 |
28 | ########################################################################
29 | ## general find
30 |
31 | FIND_PATH(ACE_INCLUDE_DIR ace/ACE.h ${CMAKE_SOURCE_DIR}/../ACE_wrappers/ /usr/include /usr/local/include $ENV{ACE_ROOT} $ENV{ACE_ROOT}/include DOC "directory containing ace/*.h for ACE library")
32 |
33 | # in YARP1, config was in another directory
34 | SET(ACE_INCLUDE_CONFIG_DIR "" CACHE STRING "location of ace/config.h")
35 | MARK_AS_ADVANCED(ACE_INCLUDE_CONFIG_DIR)
36 |
37 | FIND_LIBRARY(ACE_LIBRARY NAMES ACE ace PATHS ${CMAKE_SOURCE_DIR}/../ACE_wrappers/lib/ /usr/lib /usr/local/lib $ENV{ACE_ROOT}/lib $ENV{ACE_ROOT} DOC "ACE library file")
38 |
39 | IF (WIN32 AND NOT CYGWIN)
40 | SET(CMAKE_DEBUG_POSTFIX "d")
41 | FIND_LIBRARY(ACE_DEBUG_LIBRARY NAMES ACE${CMAKE_DEBUG_POSTFIX} ace${CMAKE_DEBUG_POSTFIX} PATHS ${CMAKE_SOURCE_DIR}/../ACE_wrappers/lib/ /usr/lib /usr/local/lib $ENV{ACE_ROOT}/lib $ENV{ACE_ROOT} DOC "ACE library file (debug version)")
42 | ENDIF (WIN32 AND NOT CYGWIN)
43 |
44 |
45 | ########################################################################
46 | ## OS-specific extra linkage
47 |
48 | # Solaris needs some extra libraries that may not have been found already
49 | IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
50 | MESSAGE(STATUS "need to link solaris-specific libraries")
51 | # LINK_LIBRARIES(socket rt)
52 | SET(ACE_LIBRARY ${ACE_LIBRARY} socket rt nsl)
53 | ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
54 |
55 | # Windows needs some extra libraries
56 | IF (WIN32 AND NOT CYGWIN)
57 | MESSAGE(STATUS "need to link windows-specific libraries")
58 | #LINK_LIBRARIES(winmm)
59 | SET(ACE_LIBRARY ${ACE_LIBRARY} winmm)
60 | ENDIF (WIN32 AND NOT CYGWIN)
61 |
62 |
63 | ########################################################################
64 | ## finished - now just set up flags and complain to user if necessary
65 |
66 | IF (ACE_INCLUDE_DIR AND ACE_LIBRARY)
67 | SET(ACE_FOUND TRUE)
68 | ELSE (ACE_INCLUDE_DIR AND ACE_LIBRARY)
69 | SET(ACE_FOUND FALSE)
70 | ENDIF (ACE_INCLUDE_DIR AND ACE_LIBRARY)
71 |
72 | IF (ACE_DEBUG_LIBRARY)
73 | SET(ACE_DEBUG_FOUND TRUE)
74 | ELSE (ACE_DEBUG_LIBRARY)
75 | SET(ACE_DEBUG_LIBRARY ${ACE_LIBRARY})
76 | ENDIF (ACE_DEBUG_LIBRARY)
77 |
78 | IF (ACE_FOUND)
79 | IF (NOT Ace_FIND_QUIETLY)
80 | MESSAGE(STATUS "Found ACE library: ${ACE_LIBRARY}")
81 | MESSAGE(STATUS "Found ACE include: ${ACE_INCLUDE_DIR}")
82 | ENDIF (NOT Ace_FIND_QUIETLY)
83 | ELSE (ACE_FOUND)
84 | IF (Ace_FIND_REQUIRED)
85 | MESSAGE(FATAL_ERROR "Could not find ACE")
86 | ENDIF (Ace_FIND_REQUIRED)
87 | ENDIF (ACE_FOUND)
88 |
89 | # TSS: backwards compatibility
90 | SET(ACE_LIBRARIES ${ACE_LIBRARY})
91 |
--------------------------------------------------------------------------------
/cmake/FindCULA.cmake:
--------------------------------------------------------------------------------
1 | # - Find CULA
2 | # Find the native CULA includes and library
3 | #
4 | # CULA_FOUND - True if CULA found.
5 | # CULA_INCLUDE_DIR - where to find cula.h, etc.
6 | # CULA_LIBRARIES - List of libraries when using TinyXML.
7 | #
8 |
9 | IF( CULA_INCLUDE_DIR )
10 | # Already in cache, be silent
11 | SET( CULA_FIND_QUIETLY TRUE )
12 | ENDIF( CULA_INCLUDE_DIR )
13 |
14 | FIND_PATH( CULA_INCLUDE_DIR "cula.h"
15 | PATH_SUFFIXES "cula/include" )
16 |
17 | MESSAGE("CULA_INCLUDE_DIR = ${CULA_INCLUDE_DIR}")
18 |
19 |
20 | FIND_LIBRARY( CULA_LIBRARY
21 | NAMES "cula"
22 | PATH_SUFFIXES "cula/lib64" )
23 |
24 | FIND_LIBRARY( CULA_LAPACK_LIBRARY
25 | NAMES "cula_lapack"
26 | PATH_SUFFIXES "cula/lib64" )
27 |
28 | FIND_LIBRARY( CULA_CORE_LIBRARY
29 | NAMES "cula_core"
30 | PATH_SUFFIXES "cula/lib64" )
31 |
32 | FIND_LIBRARY( CULA_LAPACK_BASIC_LIBRARY
33 | NAMES "cula_lapack_basic"
34 | PATH_SUFFIXES "cula/lib64" )
35 |
36 | #This is version 12 of CULA
37 | if (CULA_LIBRARY)
38 | list(APPEND CULA_LIBRARIES ${CULA_LIBRARY})
39 | endif (CULA_LIBRARY)
40 |
41 | #This is version 13 of CULA
42 | if (CULA_LAPACK_LIBRARY)
43 | list(APPEND CULA_LIBRARIES ${CULA_LAPACK_LIBRARY})
44 | endif (CULA_LAPACK_LIBRARY)
45 |
46 | #This is version 13 of CULA
47 | if (CULA_CORE_LIBRARY)
48 | list(APPEND CULA_LIBRARIES ${CULA_CORE_LIBRARY})
49 | endif (CULA_CORE_LIBRARY)
50 |
51 | #This is version 17 of CULA
52 | if (CULA_LAPACK_BASIC_LIBRARY)
53 | list(APPEND CULA_LIBRARIES ${CULA_LAPACK_BASIC_LIBRARY})
54 | endif (CULA_LAPACK_BASIC_LIBRARY)
55 |
56 | MESSAGE("CULA_LIBRARIES = ${CULA_LIBRARIES}")
57 |
58 | # handle the QUIETLY and REQUIRED arguments and set CULA_FOUND to TRUE if
59 | # all listed variables are TRUE
60 | INCLUDE( "FindPackageHandleStandardArgs" )
61 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( "CULA" DEFAULT_MSG CULA_INCLUDE_DIR CULA_LIBRARIES )
62 |
63 | MARK_AS_ADVANCED( CULA_INCLUDE_DIR CULA_LIBRARIES )
64 |
--------------------------------------------------------------------------------
/cmake/FindFFTW3.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find FFTW3.
2 | # Usage: find_package(FFTW3 [COMPONENTS [single double long-double threads]])
3 | #
4 | # Variables used by this module:
5 | # FFTW3_ROOT_DIR - FFTW3 root directory
6 | # Variables defined by this module:
7 | # FFTW3_FOUND - system has FFTW3
8 | # FFTW3_INCLUDE_DIR - the FFTW3 include directory (cached)
9 | # FFTW3_INCLUDE_DIRS - the FFTW3 include directories
10 | # (identical to FFTW3_INCLUDE_DIR)
11 | # FFTW3[FL]?_LIBRARY - the FFTW3 library - double, single(F),
12 | # long-double(L) precision (cached)
13 | # FFTW3[FL]?_THREADS_LIBRARY - the threaded FFTW3 library - double, single(F),
14 | # long-double(L) precision (cached)
15 | # FFTW3_LIBRARIES - list of all FFTW3 libraries found
16 |
17 | # Copyright (C) 2009-2010
18 | # ASTRON (Netherlands Institute for Radio Astronomy)
19 | # P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
20 | #
21 | # This file is part of the LOFAR software suite.
22 | # The LOFAR software suite is free software: you can redistribute it and/or
23 | # modify it under the terms of the GNU General Public License as published
24 | # by the Free Software Foundation, either version 3 of the License, or
25 | # (at your option) any later version.
26 | #
27 | # The LOFAR software suite is distributed in the hope that it will be useful,
28 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
29 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 | # GNU General Public License for more details.
31 | #
32 | # You should have received a copy of the GNU General Public License along
33 | # with the LOFAR software suite. If not, see .
34 | #
35 | # $Id: FindFFTW3.cmake 15918 2010-06-25 11:12:42Z loose $
36 |
37 | # Use double precision by default.
38 | if(FFTW3_FIND_COMPONENTS MATCHES "^$")
39 | set(_components double)
40 | else()
41 | set(_components ${FFTW3_FIND_COMPONENTS})
42 | endif()
43 |
44 | # Loop over each component.
45 | set(_libraries)
46 | foreach(_comp ${_components})
47 | if(_comp STREQUAL "single")
48 | list(APPEND _libraries fftw3f)
49 | elseif(_comp STREQUAL "double")
50 | list(APPEND _libraries fftw3)
51 | elseif(_comp STREQUAL "long-double")
52 | list(APPEND _libraries fftw3l)
53 | elseif(_comp STREQUAL "threads")
54 | set(_use_threads ON)
55 | else(_comp STREQUAL "single")
56 | message(FATAL_ERROR "FindFFTW3: unknown component `${_comp}' specified. "
57 | "Valid components are `single', `double', `long-double', and `threads'.")
58 | endif(_comp STREQUAL "single")
59 | endforeach(_comp ${_components})
60 |
61 | # If using threads, we need to link against threaded libraries as well.
62 | if(_use_threads)
63 | set(_thread_libs)
64 | foreach(_lib ${_libraries})
65 | list(APPEND _thread_libs ${_lib}_threads)
66 | endforeach(_lib ${_libraries})
67 | set(_libraries ${_thread_libs} ${_libraries})
68 | endif(_use_threads)
69 |
70 | # Keep a list of variable names that we need to pass on to
71 | # find_package_handle_standard_args().
72 | set(_check_list)
73 |
74 | # Search for all requested libraries.
75 | foreach(_lib ${_libraries})
76 | string(TOUPPER ${_lib} _LIB)
77 | find_library(${_LIB}_LIBRARY ${_lib}
78 | HINTS ${FFTW3_ROOT_DIR} PATH_SUFFIXES lib)
79 | mark_as_advanced(${_LIB}_LIBRARY)
80 | list(APPEND FFTW3_LIBRARIES ${${_LIB}_LIBRARY})
81 | list(APPEND _check_list ${_LIB}_LIBRARY)
82 | endforeach(_lib ${_libraries})
83 |
84 | # Search for the header file.
85 | find_path(FFTW3_INCLUDE_DIR fftw3.h
86 | HINTS ${FFTW3_ROOT_DIR} PATH_SUFFIXES include)
87 | mark_as_advanced(FFTW3_INCLUDE_DIR)
88 | list(APPEND _check_list FFTW3_INCLUDE_DIR)
89 |
90 | # Handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
91 | # all listed variables are TRUE
92 | include(FindPackageHandleStandardArgs)
93 | find_package_handle_standard_args(FFTW3 DEFAULT_MSG ${_check_list})
94 |
--------------------------------------------------------------------------------
/cmake/FindGLEW.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find GLEW
2 | # Once done this will define
3 | #
4 | # GLEW_FOUND - system has GLEW
5 | # GLEW_INCLUDE_DIR - the GLEW include directory
6 | # GLEW_LIBRARY_DIR - where the libraries are
7 | # GLEW_LIBRARY - Link these to use GLEW
8 | #
9 |
10 | IF (GLEW_INCLUDE_DIR)
11 | # Already in cache, be silent
12 | SET(GLEW_FIND_QUIETLY TRUE)
13 | ENDIF (GLEW_INCLUDE_DIR)
14 |
15 | if( WIN32 )
16 | if( MSVC80 )
17 | set( COMPILER_PATH "C:/Program\ Files/Microsoft\ Visual\ Studio\ 8/VC" )
18 | endif( MSVC80 )
19 | if( MSVC71 )
20 | set( COMPILER_PATH "C:/Program\ Files/Microsoft\ Visual\ Studio\ .NET\ 2003/Vc7" )
21 | endif( MSVC71 )
22 | FIND_PATH( GLEW_INCLUDE_DIR gl/glew.h gl/wglew.h
23 | PATHS c:/glew/include ${COMPILER_PATH}/PlatformSDK/Include )
24 | SET( GLEW_NAMES glew32 )
25 | FIND_LIBRARY( GLEW_LIBRARY
26 | NAMES ${GLEW_NAMES}
27 | PATHS c:/glew/lib ${COMPILER_PATH}/PlatformSDK/Lib )
28 | else( WIN32 )
29 | FIND_PATH( GLEW_INCLUDE_DIR glew.h wglew.h
30 | PATHS /usr/local/include /usr/include
31 | PATH_SUFFIXES gl/ GL/ )
32 | SET( GLEW_NAMES glew GLEW )
33 | FIND_LIBRARY( GLEW_LIBRARY
34 | NAMES ${GLEW_NAMES}
35 | PATHS /usr/lib /usr/local/lib )
36 | endif( WIN32 )
37 |
38 | GET_FILENAME_COMPONENT( GLEW_LIBRARY_DIR ${GLEW_LIBRARY} PATH )
39 |
40 | IF (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
41 | SET(GLEW_FOUND TRUE)
42 | SET( GLEW_LIBRARY_DIR ${GLEW_LIBRARY} )
43 | ELSE (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
44 | SET( GLEW_FOUND FALSE )
45 | SET( GLEW_LIBRARY_DIR )
46 | ENDIF (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
47 |
48 | MARK_AS_ADVANCED(
49 | GLEW_LIBRARY
50 | GLEW_INCLUDE_DIR
51 | )
52 |
--------------------------------------------------------------------------------
/cmake/FindGadgetron.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Find the Gadgetron Installation
3 | #
4 |
5 | # This module defines
6 | # GADGETRON_INCLUDE_DIR, where to finds Gadget.h
7 | # GADGETRON_HOME, Gadgetron Root Dir
8 | # GADGETRON_LIB_DIR, This is where all the installed gadgetron libraries live
9 | # GADGETRON_FOUND, if false, you cannot build anything that requires ACE
10 |
11 | # Keep a list of variable names that we need to pass on to
12 | # find_package_handle_standard_args().
13 | set(_check_list)
14 |
15 | # Search for the header file.
16 | find_path(GADGETRON_HOME include/gadgetron/Gadget.h
17 | HINTS $ENV{GADGETRON_HOME} /usr/local/gadgetron /usr/gadgetron)
18 | mark_as_advanced(GADGETRON_HOME)
19 | list(APPEND _check_list GADGETRON_HOME)
20 |
21 | SET(GADGETRON_INCLUDE_DIR ${GADGETRON_HOME}/include/gadgetron)
22 | mark_as_advanced(GADGETRON_INCLUDE_DIR)
23 | list(APPEND _check_list GADGETRON_INCLUDE_DIR)
24 |
25 | SET(GADGETRON_LIB_DIR ${GADGETRON_HOME}/lib)
26 | mark_as_advanced(GADGETRON_LIB_DIR)
27 | list(APPEND _check_list GADGETRON_LIB_DIR)
28 |
29 | # Handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if
30 | # all listed variables are TRUE
31 | include(FindPackageHandleStandardArgs)
32 | find_package_handle_standard_args(Gadgetron DEFAULT_MSG ${_check_list})
33 |
34 | # If Cuda is detected on the system some header files will be needed
35 | # -- whether Cuda is used or not --
36 |
37 | find_package(CUDA)
38 | if (CUDA_FOUND)
39 | include_directories( ${CUDA_INCLUDE_DIRS} )
40 | endif (CUDA_FOUND)
41 |
--------------------------------------------------------------------------------
/cmake/FindIsmrmrd.cmake:
--------------------------------------------------------------------------------
1 | # - Find ISMRMRRD
2 | # ISMRMRD_FOUND - True if ISMRMRD found.
3 | # ISMRMRD_INCLUDE_DIR - where to find ismrmrd.h, etc.
4 | # ISMRMRD_LIBRARIES - libismrmrd.so.
5 | # ISMRMRD_XSD_LIBRARIES - libismrmrd.so.
6 | # ISMRMRD_SCHEMA_DIR - Where to find ismrmrd.xsd
7 |
8 | FIND_PATH( ISMRMRD_INCLUDE_DIR ismrmrd.h PATHS /usr/local/ /usr/include /usr/local/include PATH_SUFFIXES ismrmrd ismrmrd/include)
9 | FIND_PATH( ISMRMRD_SCHEMA_DIR ismrmrd.xsd PATHS /usr/local/ /usr/include /usr/local/include PATH_SUFFIXES ismrmrd ismrmrd/schema)
10 |
11 | FIND_LIBRARY( ISMRMRD_LIBRARIES
12 | NAMES "ismrmrd"
13 | PATHS /usr/local/lib ${ISMRMRD_INCLUDE_DIR}/../lib /usr/lib )
14 |
15 | FIND_LIBRARY( ISMRMRD_XSD_LIBRARIES
16 | NAMES "ismrmrd_xsd"
17 | PATHS /usr/local/lib ${ISMRMRD_INCLUDE_DIR}/../lib /usr/lib )
18 |
19 | INCLUDE( "FindPackageHandleStandardArgs" )
20 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( "Ismrmrd" DEFAULT_MSG ISMRMRD_INCLUDE_DIR ISMRMRD_LIBRARIES ISMRMRD_SCHEMA_DIR)
21 |
22 | MARK_AS_ADVANCED( ISMRMRD_INCLUDE_DIR ISMRMRD_LIBRARIES ISMRMRD_SCHEMA_DIR)
23 |
--------------------------------------------------------------------------------
/cmake/FindNumpy.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # $Id: $
3 | #
4 | # Author(s): Anton Deguet
5 | # Created on: 2010-01-20
6 | #
7 | # (C) Copyright 2010 Johns Hopkins University (JHU), All Rights
8 | # Reserved.
9 | #
10 | # --- begin cisst license - do not edit ---
11 | #
12 | # This software is provided "as is" under an open source license, with
13 | # no warranty. The complete license can be found in license.txt and
14 | # http://www.cisst.org/cisst/license.txt.
15 | #
16 | # --- end cisst license ---
17 | #
18 | # File based on FindNUMARRAY distributed with ITK 3.4 (see itk.org)
19 | #
20 | # Main modifications:
21 | # - use Numpy instead of Numarray for all naming
22 | # - added path for Python 2.5 and 2.6
23 | # - renamed python script generated (det_npp became determineNumpyPath)
24 | # - use lower case for CMake commands and keywords
25 | # - updated python script to use get_include, not get_numpy_include which is now deprecated
26 | #
27 | # ---
28 | #
29 | # Try to find numpy python package
30 | # Once done this will define
31 | #
32 | # PYTHON_NUMPY_FOUND - system has numpy development package and it should be used
33 | # PYTHON_NUMPY_INCLUDE_DIR - directory where the arrayobject.h header file can be found
34 | #
35 | #
36 | if(PYTHON_EXECUTABLE)
37 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/determineNumpyPath.py "try: import numpy; print numpy.get_include()\nexcept: pass\n")
38 | exec_program("${PYTHON_EXECUTABLE}"
39 | ARGS "\"${CMAKE_CURRENT_BINARY_DIR}/determineNumpyPath.py\""
40 | OUTPUT_VARIABLE NUMPY_PATH
41 | )
42 | endif(PYTHON_EXECUTABLE)
43 |
44 | find_path(PYTHON_NUMPY_INCLUDE_DIR arrayobject.h
45 | "${NUMPY_PATH}/numpy/"
46 | "${PYTHON_INCLUDE_PATH}/numpy/"
47 | /usr/include/python2.6/numpy/
48 | /usr/include/python2.5/numpy/
49 | /usr/include/python2.4/numpy/
50 | /usr/include/python2.3/numpy/
51 | /usr/include/numpy/
52 | DOC "Directory where the arrayobject.h header file can be found. This file is part of the numpy package"
53 | )
54 |
55 | if(PYTHON_NUMPY_INCLUDE_DIR)
56 | set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy development package is available")
57 | endif(PYTHON_NUMPY_INCLUDE_DIR)
58 |
59 |
--------------------------------------------------------------------------------
/cmake/FindTinyXML.cmake:
--------------------------------------------------------------------------------
1 | # - Find TinyXML
2 | # Find the native TinyXML includes and library
3 | #
4 | # TINYXML_FOUND - True if TinyXML found.
5 | # TINYXML_INCLUDE_DIR - where to find tinyxml.h, etc.
6 | # TINYXML_LIBRARIES - List of libraries when using TinyXML.
7 | #
8 |
9 | IF( TINYXML_INCLUDE_DIR )
10 | # Already in cache, be silent
11 | SET( TinyXML_FIND_QUIETLY TRUE )
12 | ENDIF( TINYXML_INCLUDE_DIR )
13 |
14 | FIND_PATH( TINYXML_INCLUDE_DIR "tinyxml.h"
15 | PATH_SUFFIXES "tinyxml" )
16 |
17 | FIND_LIBRARY( TINYXML_LIBRARIES
18 | NAMES "tinyxml"
19 | PATH_SUFFIXES "tinyxml" )
20 |
21 | # handle the QUIETLY and REQUIRED arguments and set TINYXML_FOUND to TRUE if
22 | # all listed variables are TRUE
23 | INCLUDE( "FindPackageHandleStandardArgs" )
24 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( "TinyXML" DEFAULT_MSG TINYXML_INCLUDE_DIR TINYXML_LIBRARIES )
25 |
26 | MARK_AS_ADVANCED( TINYXML_INCLUDE_DIR TINYXML_LIBRARIES )
27 |
--------------------------------------------------------------------------------
/cmake/FindXSD.cmake:
--------------------------------------------------------------------------------
1 | # - Find CodeSource Xsd
2 | # This module can be used to find Xsd and it's include path
3 | # Variables:
4 | # XSD_EXECUTABLE
5 | # XSD_INCLUDE_DIR
6 | # XSD_FOUND
7 |
8 | SET(XSD_FOUND FALSE)
9 |
10 | if(WIN32)
11 | SET(__XSD_NAME xsd.exe)
12 | else(WIN32)
13 | SET(__XSD_NAME xsdcxx xsd)
14 | endif(WIN32)
15 |
16 | if(XSD_INCLUDE_DIR)
17 | #in cache already
18 | SET(XSD_FOUND TRUE)
19 | else(XSD_INCLUDE_DIR)
20 | find_program(XSD_EXECUTABLE NAMES ${__XSD_NAME}
21 | PATHS
22 | ${XSD_DIR}/bin
23 | )
24 |
25 | if(XSD_EXECUTABLE)
26 | SET(XSD_FOUND TRUE)
27 | else(XSD_EXECUTABLE)
28 | SET(XSD_EXECUTABLE "xsd-NOTFOUND" CACHE FILE "xsd executable path")
29 | endif(XSD_EXECUTABLE)
30 |
31 | find_path(XSD_INCLUDE_DIR NAMES xsd
32 | PATHS
33 | ${XSD_DIR}/include
34 | /usr/include
35 | /usr/local/include
36 | )
37 |
38 | if(XSD_INCLUDE_DIR)
39 | SET(XSD_FOUND TRUE)
40 | else(XSD_INCLUDE_DIR)
41 | SET(XSD_INCLUDE_DIR "xsd-include-NOTFOUND" CACHE PATH "xsd include path")
42 | endif(XSD_INCLUDE_DIR)
43 | endif(XSD_INCLUDE_DIR)
44 |
45 | FUNCTION(XSD_EXTRACT_OPTIONS _xsd_files _xsd_options)
46 | foreach(current_arg ${ARGN})
47 | IF(${current_arg} STREQUAL "OPTIONS")
48 | SET(_XSD_DOING_OPTIONS TRUE)
49 | else(${current_arg} STREQUAL "OPTIONS")
50 | if(_XSD_DOING_OPTIONS)
51 | SET(_xsd_options_p ${_xsd_options_p} ${current_arg})
52 | else(_XSD_DOING_OPTIONS)
53 | SET(_xsd_files_p ${_xsd_files_p} ${current_arg})
54 | endif(_XSD_DOING_OPTIONS)
55 | endif(${current_arg} STREQUAL "OPTIONS")
56 | endforeach(current_arg)
57 | SET(${_xsd_files} ${_xsd_files_p} PARENT_SCOPE)
58 | SET(${_xsd_options} ${_xsd_options_p} PARENT_SCOPE)
59 | ENDFUNCTION(XSD_EXTRACT_OPTIONS)
60 |
61 |
62 | FUNCTION(WRAP_XSD XSD_SRCS XSD_INCLUDES OUT_PATH)
63 | SET(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/xsd)
64 | FILE(MAKE_DIRECTORY ${OUTPUT_DIR})
65 | SET(${XSD_INCLUDES} ${OUTPUT_DIR} PARENT_SCOPE)
66 | XSD_EXTRACT_OPTIONS(xsd_files xsd_options ${ARGN})
67 | FOREACH(it ${xsd_files})
68 | STRING(REGEX REPLACE ".*/" "" BARE_XSD "${it}" )
69 | STRING(REGEX REPLACE ".xsd" ".cxx" SOURCE "${BARE_XSD}" )
70 | STRING(REGEX REPLACE ".xsd" ".hxx" HEADER "${BARE_XSD}" )
71 | CONFIGURE_FILE(${it} ${OUT_PATH}/${BARE_XSD} COPY_ONLY)
72 | SET(SOURCE ${OUTPUT_DIR}/${SOURCE})
73 | SET(HEADER ${OUTPUT_DIR}/${HEADER})
74 | ADD_CUSTOM_COMMAND(OUTPUT ${SOURCE} ${HEADER}
75 | COMMAND ${XSD_EXECUTABLE} ${xsd_options} "--output-dir" ${OUTPUT_DIR} ${OUT_PATH}/${BARE_XSD}
76 | DEPENDS ${it}
77 | VERBATIM
78 | )
79 | set_source_files_properties(${HEADER} PROPERTIES GENERATED TRUE)
80 | set_source_files_properties(${SOURCE} PROPERTIES GENERATED TRUE)
81 | SET(_XSD_SRCS ${_XSD_SRCS} ${SOURCE} ${HEADER})
82 | ENDFOREACH(it)
83 | SET(${XSD_SRCS} ${_XSD_SRCS} PARENT_SCOPE)
84 | ENDFUNCTION(WRAP_XSD)
85 |
86 |
--------------------------------------------------------------------------------
/cmake/FindXalanC.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find XalanC
2 | # Once done this will define
3 | #
4 | # XALANC_FOUND - System has XalanC
5 | # XALANC_INCLUDE_DIR - The XalanC include directory
6 | # XALANC_LIBRARY_DIR - The XalanC library dir
7 | # XALANC_LIBRARIES - The libraries needed to use XalanC
8 | # XALANC_DEFINITIONS - Compiler switches required for using XalanC
9 |
10 | # Copyright (c) 2009, Helio Chissini de Castro,
11 | #
12 | # Redistribution and use is allowed according to the terms of the BSD license.
13 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
14 |
15 |
16 | IF (XALANC_INCLUDE_DIR AND XALANC_LIBRARIES)
17 | # in cache already
18 | SET(XalanC_FIND_QUIETLY TRUE)
19 | ENDIF (XALANC_INCLUDE_DIR AND XALANC_LIBRARIES)
20 |
21 |
22 | FIND_PATH(XALANC_INCLUDE_DIR DOMSupport/DOMServices.hpp
23 | PATHS
24 | /usr/local/include/xalanc
25 | /usr/include/xalanc
26 | PATH_SUFFIXES
27 | xalanc
28 | )
29 |
30 | FIND_LIBRARY(XALANC_LIBRARIES NAMES xalan-c xalanMsg)
31 |
32 | INCLUDE(FindPackageHandleStandardArgs)
33 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(XalanC DEFAULT_MSG XALANC_LIBRARIES XALANC_INCLUDE_DIR)
34 |
35 | MARK_AS_ADVANCED(XALANC_INCLUDE_DIR XALANC_LIBRARIES XALANC_LIBRARY_DIR)
36 |
--------------------------------------------------------------------------------
/cmake/FindXercesC.cmake:
--------------------------------------------------------------------------------
1 | # This module defines
2 | # XERCESC_INCLUDE_DIR, where to find ptlib.h, etc.
3 | # XERCESC_LIBRARIES, the libraries to link against to use pwlib.
4 | # XERCESC_FOUND, If false, don't try to use pwlib.
5 |
6 | FIND_PATH(XERCESC_INCLUDE_DIR xercesc/dom/DOM.hpp
7 | "[HKEY_CURRENT_USER\\software\\xerces-c\\src]"
8 | "[HKEY_CURRENT_USER\\xerces-c\\src]"
9 | $ENV{XERCESCROOT}/src/
10 | /usr/local/include
11 | /usr/include
12 | )
13 |
14 | FIND_LIBRARY(XERCESC_LIBRARIES
15 | NAMES
16 | xerces-c
17 | PATHS
18 | "[HKEY_CURRENT_USER\\software\\xerces-c\\lib]"
19 | "[HKEY_CURRENT_USER\\xerces-c\\lib]"
20 | $ENV{XERCESCROOT}/lib
21 | /usr/local/lib
22 | /usr/lib
23 | )
24 |
25 | # if the include a the library are found then we have it
26 | IF(XERCESC_INCLUDE_DIR)
27 | IF(XERCESC_LIBRARIES)
28 | SET( XERCESC_FOUND "YES" )
29 | ENDIF(XERCESC_LIBRARIES)
30 | ENDIF(XERCESC_INCLUDE_DIR)
31 |
32 |
33 |
34 | MARK_AS_ADVANCED(
35 | XERCESC_INCLUDE_DIR
36 | XERCESC_LIBRARIES
37 | )
--------------------------------------------------------------------------------
/denoise/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories(
2 | ${CUDA_INCLUDE_DIRS}
3 | ${Boost_INCLUDE_DIR}
4 | ${GADGETRON_INCLUDE_DIR}
5 | ${CMAKE_SOURCE_DIR}/solvers
6 | ${CMAKE_SOURCE_DIR}/operators
7 | ${CMAKE_SOURCE_DIR}/proton
8 | )
9 |
10 | cuda_add_library(denoise_kernels SHARED
11 | nonlocalMeans.cu
12 | )
13 |
14 | target_link_libraries(denoise_kernels gadgetron_toolbox_gpucore gadgetron_toolbox_gpunfft gadgetron_toolbox_gpucore gadgetron_toolbox_gpufft gadgetron_toolbox_gpureg ${CUDA_LIBRARIES})
15 |
16 |
17 | add_executable(split_denoise split_denoise.cpp)
18 | target_link_libraries(split_denoise tomography_operators tomography_solvers gadgetron_toolbox_gpusolvers gadgetron_toolbox_gpuoperators gadgetron_toolbox_log gadgetron_toolbox_cpucore gadgetron_toolbox_cpucore_math gadgetron_toolbox_cpureg gadgetron_toolbox_gpucore gadgetron_toolbox_hostutils ${HDF5_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CULA_LIBRARIES} ${CUDA_LIBRARIES} ${Boost_LIBRARIES})
19 |
20 | add_executable(denoise_NLM denoise_NLM.cpp)
21 | target_link_libraries(denoise_NLM denoise_kernels tomography_operators tomography_solvers gadgetron_toolbox_gpusolvers gadgetron_toolbox_gpuoperators gadgetron_toolbox_log gadgetron_toolbox_cpucore gadgetron_toolbox_cpucore_math gadgetron_toolbox_cpureg gadgetron_toolbox_gpucore gadgetron_toolbox_hostutils ${HDF5_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CULA_LIBRARIES} ${CUDA_LIBRARIES} ${Boost_LIBRARIES})
22 |
23 | add_executable(denoise_NLM_prior denoise_NLM_prior.cpp)
24 | target_link_libraries(denoise_NLM_prior denoise_kernels tomography_operators tomography_solvers gadgetron_toolbox_gpusolvers gadgetron_toolbox_gpuoperators gadgetron_toolbox_log gadgetron_toolbox_cpucore gadgetron_toolbox_cpucore_math gadgetron_toolbox_cpureg gadgetron_toolbox_gpucore gadgetron_toolbox_hostutils ${HDF5_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CULA_LIBRARIES} ${CUDA_LIBRARIES} ${Boost_LIBRARIES})
25 |
26 |
27 | add_executable(denoise_NLMPoisson denoise_NLMPoisson.cpp)
28 | target_link_libraries(denoise_NLMPoisson denoise_kernels tomography_operators tomography_solvers gadgetron_toolbox_gpusolvers gadgetron_toolbox_gpuoperators gadgetron_toolbox_log gadgetron_toolbox_cpucore gadgetron_toolbox_cpucore_math gadgetron_toolbox_cpureg gadgetron_toolbox_gpucore gadgetron_toolbox_hostutils ${HDF5_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CULA_LIBRARIES} ${CUDA_LIBRARIES} ${Boost_LIBRARIES})
29 |
30 |
31 | add_executable(denoise_NLM2D denoise_NLM2D.cpp)
32 | target_link_libraries(denoise_NLM2D denoise_kernels tomography_operators tomography_solvers gadgetron_toolbox_gpusolvers gadgetron_toolbox_gpuoperators gadgetron_toolbox_log gadgetron_toolbox_cpucore gadgetron_toolbox_cpucore_math gadgetron_toolbox_cpureg gadgetron_toolbox_gpucore gadgetron_toolbox_hostutils ${HDF5_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CULA_LIBRARIES} ${CUDA_LIBRARIES} ${Boost_LIBRARIES})
33 |
34 |
35 | add_executable(denoise_NLM2DPoisson denoise_NLM2DPoisson.cpp)
36 | target_link_libraries(denoise_NLM2DPoisson denoise_kernels tomography_operators tomography_solvers gadgetron_toolbox_gpusolvers gadgetron_toolbox_gpuoperators gadgetron_toolbox_log gadgetron_toolbox_cpucore gadgetron_toolbox_cpucore_math gadgetron_toolbox_cpureg gadgetron_toolbox_gpucore gadgetron_toolbox_hostutils ${HDF5_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CULA_LIBRARIES} ${CUDA_LIBRARIES} ${Boost_LIBRARIES})
37 |
38 |
39 |
40 | add_executable(denoise_Edge denoise_Edge.cpp)
41 | target_link_libraries(denoise_Edge denoise_kernels tomography_operators tomography_solvers gadgetron_toolbox_gpusolvers gadgetron_toolbox_gpuoperators gadgetron_toolbox_log gadgetron_toolbox_cpucore gadgetron_toolbox_cpucore_math gadgetron_toolbox_cpureg gadgetron_toolbox_gpucore gadgetron_toolbox_hostutils ${HDF5_LIBRARIES} ${CUDA_CUFFT_LIBRARIES} ${CULA_LIBRARIES} ${CUDA_LIBRARIES} ${Boost_LIBRARIES})
42 |
--------------------------------------------------------------------------------
/denoise/denoise_NLM.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * split_denoise.cpp
3 |
4 | *
5 | * Created on: Dec 10, 2015
6 | * Author: dch
7 | */
8 |
9 |
10 | #include "hoNDArray_fileio.h"
11 | #include "hoCuNDArray_math.h"
12 | #include "vector_td_utilities.h"
13 | #include "hoNDArray_utils.h"
14 | #include "GPUTimer.h"
15 | #include "cuATrousOperator.h"
16 | #include "cuEdgeATrousOperator.h"
17 | #include "cuSbCgSolver.h"
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include "subsetAccumulateOperator.h"
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include "cuSolverUtils.h"
30 | #include "osPDsolver.h"
31 | #include "osLALMSolver.h"
32 | #include "osLALMSolver2.h"
33 | #include "cuATrousOperator.h"
34 | #include "hdf5_utils.h"
35 | #include "cuEdgeATrousOperator.h"
36 | #include "cuDCTOperator.h"
37 | #include "cuDCTDerivativeOperator.h"
38 | #include "weightingOperator.h"
39 | #include "hoNDArray_math.h"
40 | #include "cuNCGSolver.h"
41 | #include "accumulateOperator.h"
42 | #include "subselectionOperator.h"
43 | #include "subsetConverter.h"
44 | #include "nonlocalMeans.h"
45 | using namespace std;
46 | using namespace Gadgetron;
47 | using namespace std;
48 |
49 | namespace po = boost::program_options;
50 | int main(int argc, char** argv){
51 |
52 | po::options_description desc("Allowed options");
53 | unsigned int iterations;
54 | int device;
55 | float noise;
56 | string outputFile;
57 | desc.add_options()
58 | ("help", "produce help message")
59 | ("input,a", po::value(), "Input filename")
60 | ("output,f", po::value(&outputFile)->default_value("denoised.real"), "Output filename")
61 | ("device",po::value(&device)->default_value(0),"Number of the device to use (0 indexed)")
62 | ("noise",po::value(&noise)->default_value(1),"noise level")
63 | ("block","Use blockwise algorithm")
64 |
65 | ;
66 |
67 | po::variables_map vm;
68 | po::store(po::parse_command_line(argc, argv, desc), vm);
69 | po::notify(vm);
70 |
71 | if (vm.count("help")) {
72 | cout << desc << "\n";
73 | return 1;
74 | }
75 |
76 | std::stringstream command_line_string;
77 | std::cout << "Command line options:" << std::endl;
78 | for (po::variables_map::iterator it = vm.begin(); it != vm.end(); ++it){
79 | boost::any a = it->second.value();
80 | command_line_string << it->first << ": ";
81 | if (a.type() == typeid(std::string)) command_line_string << it->second.as();
82 | else if (a.type() == typeid(int)) command_line_string << it->second.as();
83 | else if (a.type() == typeid(unsigned int)) command_line_string << it->second.as();
84 | else if (a.type() == typeid(float)) command_line_string << it->second.as();
85 | else command_line_string << "Unknown type" << std::endl;
86 | command_line_string << std::endl;
87 | }
88 | std::cout << command_line_string.str();
89 |
90 | cudaSetDevice(device);
91 | cudaDeviceReset();
92 |
93 | string filename = vm["input"].as();
94 |
95 | auto hoInput = read_nd_array(filename.c_str());
96 |
97 |
98 | auto input = cuNDArray(*hoInput);
99 |
100 | auto output = input;
101 | if (vm.count("block"))
102 | nonlocal_means_block(&input,&output,noise);
103 | else
104 | nonlocal_means(&input,&output,noise);
105 |
106 | write_nd_array(&output,outputFile);
107 |
108 | }
109 |
110 |
--------------------------------------------------------------------------------
/denoise/denoise_NLMPoisson.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * split_denoise.cpp
3 |
4 | *
5 | * Created on: Dec 10, 2015
6 | * Author: dch
7 | */
8 |
9 |
10 | #include "hoNDArray_fileio.h"
11 | #include "hoCuNDArray_math.h"
12 | #include "vector_td_utilities.h"
13 | #include "hoNDArray_utils.h"
14 | #include "GPUTimer.h"
15 | #include "cuATrousOperator.h"
16 | #include "cuEdgeATrousOperator.h"
17 | #include "cuSbCgSolver.h"
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include "subsetAccumulateOperator.h"
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include "cuSolverUtils.h"
30 | #include "osPDsolver.h"
31 | #include "osLALMSolver.h"
32 | #include "osLALMSolver2.h"
33 | #include "cuATrousOperator.h"
34 | #include "hdf5_utils.h"
35 | #include "cuEdgeATrousOperator.h"
36 | #include "cuDCTOperator.h"
37 | #include "cuDCTDerivativeOperator.h"
38 | #include "weightingOperator.h"
39 | #include "hoNDArray_math.h"
40 | #include "cuNCGSolver.h"
41 | #include "accumulateOperator.h"
42 | #include "subselectionOperator.h"
43 | #include "subsetConverter.h"
44 | #include "nonlocalMeans.h"
45 | using namespace std;
46 | using namespace Gadgetron;
47 | using namespace std;
48 |
49 | namespace po = boost::program_options;
50 | int main(int argc, char** argv){
51 |
52 | po::options_description desc("Allowed options");
53 | unsigned int iterations;
54 | int device;
55 | float noise;
56 | string outputFile;
57 | desc.add_options()
58 | ("help", "produce help message")
59 | ("input,a", po::value(), "Input filename")
60 | ("output,f", po::value(&outputFile)->default_value("denoised.real"), "Output filename")
61 | ("device",po::value(&device)->default_value(0),"Number of the device to use (0 indexed)")
62 | ("noise",po::value(&noise)->default_value(1),"noise level")
63 |
64 | ;
65 |
66 | po::variables_map vm;
67 | po::store(po::parse_command_line(argc, argv, desc), vm);
68 | po::notify(vm);
69 |
70 | if (vm.count("help")) {
71 | cout << desc << "\n";
72 | return 1;
73 | }
74 |
75 | std::stringstream command_line_string;
76 | std::cout << "Command line options:" << std::endl;
77 | for (po::variables_map::iterator it = vm.begin(); it != vm.end(); ++it){
78 | boost::any a = it->second.value();
79 | command_line_string << it->first << ": ";
80 | if (a.type() == typeid(std::string)) command_line_string << it->second.as();
81 | else if (a.type() == typeid(int)) command_line_string << it->second.as();
82 | else if (a.type() == typeid(unsigned int)) command_line_string << it->second.as();
83 | else if (a.type() == typeid(float)) command_line_string << it->second.as();
84 | else command_line_string << "Unknown type" << std::endl;
85 | command_line_string << std::endl;
86 | }
87 | std::cout << command_line_string.str();
88 |
89 | cudaSetDevice(device);
90 | cudaDeviceReset();
91 |
92 | string filename = vm["input"].as();
93 |
94 | auto hoInput = read_nd_array(filename.c_str());
95 |
96 |
97 | auto input = cuNDArray(*hoInput);
98 |
99 | auto output = input;
100 | nonlocal_meansPoisson(&input,&output,noise);
101 |
102 | write_nd_array(&output,outputFile);
103 |
104 | }
105 |
106 |
--------------------------------------------------------------------------------
/denoise/denoise_NLM_prior.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * split_denoise.cpp
3 |
4 | *
5 | * Created on: Dec 10, 2015
6 | * Author: dch
7 | */
8 |
9 |
10 | #include "hoNDArray_fileio.h"
11 | #include "hoCuNDArray_math.h"
12 | #include "vector_td_utilities.h"
13 | #include "hoNDArray_utils.h"
14 | #include "GPUTimer.h"
15 | #include "cuATrousOperator.h"
16 | #include "cuEdgeATrousOperator.h"
17 | #include "cuSbCgSolver.h"
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include "subsetAccumulateOperator.h"
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include "cuSolverUtils.h"
30 | #include "osPDsolver.h"
31 | #include "osLALMSolver.h"
32 | #include "osLALMSolver2.h"
33 | #include "cuATrousOperator.h"
34 | #include "hdf5_utils.h"
35 | #include "cuEdgeATrousOperator.h"
36 | #include "cuDCTOperator.h"
37 | #include "cuDCTDerivativeOperator.h"
38 | #include "weightingOperator.h"
39 | #include "hoNDArray_math.h"
40 | #include "cuNCGSolver.h"
41 | #include "accumulateOperator.h"
42 | #include "subselectionOperator.h"
43 | #include "subsetConverter.h"
44 | #include "nonlocalMeans.h"
45 | using namespace std;
46 | using namespace Gadgetron;
47 | using namespace std;
48 |
49 | namespace po = boost::program_options;
50 | int main(int argc, char** argv){
51 |
52 | po::options_description desc("Allowed options");
53 | unsigned int iterations;
54 | int device;
55 | float noise;
56 | string outputFile;
57 | desc.add_options()
58 | ("help", "produce help message")
59 | ("input,a", po::value(), "Input filename")
60 | ("prior,p", po::value(), "Prior filename")
61 | ("output,f", po::value(&outputFile)->default_value("denoised.real"), "Output filename")
62 | ("device",po::value(&device)->default_value(0),"Number of the device to use (0 indexed)")
63 | ("noise",po::value(&noise)->default_value(1),"noise level")
64 |
65 |
66 | ;
67 |
68 | po::variables_map vm;
69 | po::store(po::parse_command_line(argc, argv, desc), vm);
70 | po::notify(vm);
71 |
72 | if (vm.count("help")) {
73 | cout << desc << "\n";
74 | return 1;
75 | }
76 |
77 | std::stringstream command_line_string;
78 | std::cout << "Command line options:" << std::endl;
79 | for (po::variables_map::iterator it = vm.begin(); it != vm.end(); ++it){
80 | boost::any a = it->second.value();
81 | command_line_string << it->first << ": ";
82 | if (a.type() == typeid(std::string)) command_line_string << it->second.as();
83 | else if (a.type() == typeid(int)) command_line_string << it->second.as();
84 | else if (a.type() == typeid(unsigned int)) command_line_string << it->second.as();
85 | else if (a.type() == typeid(float)) command_line_string << it->second.as();
86 | else command_line_string << "Unknown type" << std::endl;
87 | command_line_string << std::endl;
88 | }
89 | std::cout << command_line_string.str();
90 |
91 | cudaSetDevice(device);
92 | cudaDeviceReset();
93 |
94 | string filename = vm["input"].as();
95 |
96 | auto hoInput = read_nd_array(filename.c_str());
97 |
98 |
99 | auto input = cuNDArray(*hoInput);
100 |
101 | auto prior = cuNDArray(*read_nd_array(vm["prior"].as().c_str()));
102 |
103 | float* input_ptr = input.get_data_ptr();
104 | for (int i = 0; i < input.get_size(3); i++) {
105 | cuNDArray out_view(prior.get_dimensions(),input_ptr);
106 | auto in_view = out_view;
107 | nonlocal_means_ref(&in_view,&out_view, &prior, noise);
108 | input_ptr += in_view.get_number_of_elements();
109 | }
110 |
111 |
112 | write_nd_array(&input,outputFile);
113 |
114 | }
115 |
116 |
--------------------------------------------------------------------------------
/denoise/nonlocalMeans.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | namespace Gadgetron{
4 | void nonlocal_means( cuNDArray *input, cuNDArray *output , float Noise);
5 | void nonlocal_meansPoisson( cuNDArray *input, cuNDArray *output , float Noise);
6 | void nonlocal_means_block( cuNDArray *input, cuNDArray *output , float Noise);
7 | void nonlocal_means_ref( cuNDArray *input,cuNDArray* output, cuNDArray *ref , float Noise);
8 | void nonlocal_means2D( cuNDArray *input, cuNDArray *output , float Noise);
9 | void nonlocal_means2DPoisson( cuNDArray *input, cuNDArray *output , float Noise);
10 | void nonlocal_means_block2DPoisson( cuNDArray *input, cuNDArray *output , float Noise);
11 |
12 | };
--------------------------------------------------------------------------------
/mri/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | include_directories(${CMAKE_SOURCE_DIR}/operators)
2 | include_directories(${CMAKE_SOURCE_DIR}/solvers)
3 |
4 | #add_executable(radial_sense_sbc main_sbc.cpp)
5 | add_executable(radial_sense_ncg main_ncg.cpp)
6 | #add_executable(radial_sense_fista main_fista.cpp)
7 |
8 | MESSAGE("CUDA LIBRARIES: ${CUDA_LIBRARIES}")
9 |
10 | #target_link_libraries(radial_sense_sbc tomography_operators gpuoperators cpucore gpucore gpuparallelmri gpunfft hostutils gpusolvers ${CUDA_LIBRARIES})
11 |
12 | target_link_libraries(radial_sense_ncg tomography_operators tomography_solvers gpuoperators cpucore gpucore gpuparallelmri gpunfft hostutils gpusolvers ${CUDA_LIBRARIES} ${CULA_LIBRARIES})
13 | #target_link_libraries(radial_sense_fista tomography_operators gpuoperators cpucore gpucore gpuparallelmri gpunfft hostutils gpusolvers ${CUDA_LIBRARIES})
14 |
15 |
--------------------------------------------------------------------------------
/operators/BilateralPriorOperator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "cuNDArray.h"
3 | #include "cuBilateralFilter.h"
4 |
5 | namespace Gadgetron {
6 |
7 | class BilateralPriorOperator : public linearOperator> {
8 | public:
9 | BilateralPriorOperator() : sigma_int(1),sigma_spatial(1) {}
10 |
11 | void mult_M(cuNDArray* in, cuNDArray* out, bool accumulate = false) override{
12 | auto out_tmp = out;
13 | if (accumulate) out_tmp = new cuNDArray(in->get_dimensions());
14 | *out_tmp = *in;
15 |
16 |
17 | std::vector dims3D{in->get_size(0),in->get_size(1),in->get_size(2)};
18 |
19 | auto out_ptr = out_tmp->get_data_ptr();
20 | auto in_ptr = in->get_data_ptr();
21 |
22 | for (int i = 0; i < in->get_size(3); i++) {
23 |
24 | cuNDArray out3D(dims3D,out_ptr);
25 | bilateral_filter(&out3D, prior.get(), sigma_spatial, sigma_int);
26 | out_ptr += out3D.get_number_of_elements();
27 | }
28 | *out_tmp -= *in;
29 |
30 | if (accumulate) {
31 | *out += *out_tmp;
32 | delete out_tmp;
33 | }
34 | }
35 |
36 | void mult_MH(cuNDArray* in, cuNDArray* out, bool accumulate = false) override {
37 |
38 | if (!norm_image) update_norm();
39 |
40 | auto out_tmp = out;
41 | if (accumulate) out_tmp = new cuNDArray(in->get_dimensions());
42 | *out_tmp = *in;
43 |
44 |
45 | std::vector dims3D{in->get_size(0),in->get_size(1),in->get_size(2)};
46 |
47 | auto out_ptr = out_tmp->get_data_ptr();
48 | auto in_ptr = in->get_data_ptr();
49 |
50 | for (int i = 0; i < in->get_size(3); i++) {
51 |
52 | cuNDArray out3D(dims3D,out_ptr);
53 | out3D /= *norm_image;
54 | bilateral_filter_unnormalized(&out3D, prior.get(), sigma_spatial, sigma_int);
55 | out_ptr += out3D.get_number_of_elements();
56 | }
57 | *out_tmp -= *in;
58 |
59 | if (accumulate) {
60 | *out += *out_tmp;
61 | delete out_tmp;
62 | }
63 | }
64 |
65 | void set_prior(boost::shared_ptr> p){
66 | prior = p;
67 | norm_image = boost::shared_ptr>();
68 | }
69 |
70 | void set_sigma_int(float sigma) {
71 | sigma_int = sigma;
72 | norm_image = boost::shared_ptr>();
73 | }
74 | void set_sigma_spatial(float sigma) {
75 | sigma_spatial = sigma;
76 | norm_image = boost::shared_ptr>();
77 | }
78 | protected:
79 |
80 | void update_norm(){
81 | norm_image = boost::make_shared>(prior->get_dimensions());
82 | fill(norm_image.get(),1.0f);
83 | bilateral_filter_unnormalized(norm_image.get(),prior.get(),sigma_spatial,sigma_int);
84 | }
85 |
86 | float sigma_int,sigma_spatial;
87 | boost::shared_ptr> prior;
88 | boost::shared_ptr> norm_image;
89 |
90 |
91 | };
92 |
93 | };
--------------------------------------------------------------------------------
/operators/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if (WIN32)
2 | ADD_DEFINITIONS(-D__BUILD_GADGETRON_SOLVERS__)
3 | endif (WIN32)
4 |
5 |
6 | cuda_add_library( tomography_operators SHARED
7 | cuHaarWaveletOperator.cu
8 | cuGaussianFilterOperator.cu
9 | cuATrousWavelet.cu
10 | cuEdgeWavelet.cu
11 | cuDCT.cu
12 | cuPartialDifferenceOperator.cu
13 | cuSmallConvOperator.cu
14 | cuScaleOperator.cu
15 | cuTVPrimalDualOperator.cu
16 | cuWTVPrimalDualOperator.cu
17 | cuBilateralFilter.cu
18 | cuTFFT.cpp
19 | cuBoxFilterOperator.cu
20 | )
21 | target_link_libraries(tomography_operators gadgetron_toolbox_gpusolvers gadgetron_toolbox_gpucore gadgetron_toolbox_gpuoperators gadgetron_toolbox_gpunfft gadgetron_toolbox_gpucore gadgetron_toolbox_gpufft gadgetron_toolbox_gpureg ${CUDA_LIBRARIES} ${DCMTK_dcmdata_LIBRARY} ${DCMTK_oflog_LIBRARY} ${DCMTK_ofstd_LIBRARY} ${GDCM_LIBRARIES})
22 | install(FILES
23 | cuPartialDifferenceOperator.h
24 | hoCuPartialDerivativeOperator.h
25 | cuGaussianFilterOperator.h
26 | # subsetOperator.h
27 | cuATrousWavelet.h
28 | invertibleOperator.h
29 | cuDCT.h
30 | DESTINATION include)
31 |
--------------------------------------------------------------------------------
/operators/accumulateOperator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "linearOperator.h"
4 |
5 | namespace Gadgetron {
6 |
7 | template class accumulateOperator : public linearOperator{
8 | public:
9 | accumulateOperator(boost::shared_ptr > op_) : linearOperator(), op(op_){}
10 |
11 | virtual void mult_M(ARRAY* in, ARRAY* out, bool accumulate = false ){
12 | auto dims = *in->get_dimensions();
13 | auto back_dim = dims.back();
14 | dims.pop_back();
15 | ARRAY tmp(dims);
16 | clear(&tmp);
17 | auto elements = tmp.get_number_of_elements();
18 |
19 | for (auto i =0u; i < back_dim; i++){
20 | ARRAY view(dims,in->get_data_ptr()+elements*i);
21 | tmp += view;
22 | }
23 |
24 | op->mult_M(&tmp,out,accumulate);
25 |
26 | }
27 |
28 | virtual void mult_MH(ARRAY* in, ARRAY* out, bool accumulate = false ){
29 | auto dims = *out->get_dimensions();
30 | auto back_dim = dims.back();
31 | dims.pop_back();
32 | ARRAY tmp(dims);
33 | auto elements = tmp.get_number_of_elements();
34 | op->mult_MH(in,&tmp);
35 | for (auto i =0u; i < back_dim; i++){
36 | ARRAY view(dims,out->get_data_ptr()+elements*i);
37 | if (accumulate)
38 | view += tmp;
39 | else
40 | view = tmp;
41 | }
42 |
43 | }
44 | protected:
45 | boost::shared_ptr> op;
46 | };
47 | }
48 |
--------------------------------------------------------------------------------
/operators/cuATVPrimalDualOperator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "primalDualOperator.h"
4 | #include "cuTVPrimalDualOperator.h"
5 | #include
6 | #include "cuBoxFilterOperator.h"
7 | namespace Gadgetron {
8 | template
9 | class cuATVPrimalDualOperator : public cuTVPrimalDualOperator {
10 | typedef cuTVPrimalDualOperator parent;
11 |
12 | cuScaleOperator scaleOp;
13 | //cuBoxFilterOperator scaleOp;
14 | public:
15 | cuATVPrimalDualOperator() : parent() {}
16 | cuATVPrimalDualOperator(T alpha_ ) : parent(alpha_){}
17 | virtual void primalDual(cuNDArray* in, cuNDArray* out,T sigma, bool accumulate) override {
18 | auto dims_small = *in->get_dimensions();
19 | for (int i = 0; i < 3; i++)
20 | dims_small[i] /= 2;
21 |
22 | cuNDArray tmp_in(dims_small);
23 | cuNDArray tmp_out(dims_small);
24 |
25 | scaleOp.mult_M(in,&tmp_in);
26 | parent::primalDual(&tmp_in,&tmp_out,sigma,false);
27 | scaleOp.mult_MH(&tmp_out,out,accumulate);
28 |
29 |
30 |
31 | };
32 |
33 |
34 |
35 |
36 | };
37 | }
--------------------------------------------------------------------------------
/operators/cuATrousWavelet.cu:
--------------------------------------------------------------------------------
1 | #include "cuATrousWavelet.h"
2 | #include "complext.h"
3 | //#include "setup_grid.h"
4 | #include "cuNDArray_math.h"
5 | #include "cudaDeviceManager.h"
6 | using namespace Gadgetron;
7 |
8 | static inline
9 | void setup_grid( unsigned int number_of_elements, dim3 *blockDim, dim3* gridDim, unsigned int num_batches = 1 )
10 | {
11 | int cur_device = cudaDeviceManager::Instance()->getCurrentDevice();
12 | //int maxGridDim = cudaDeviceManager::Instance()->max_griddim(cur_device);
13 | int maxBlockDim = cudaDeviceManager::Instance()->max_blockdim(cur_device);
14 | int maxGridDim = 65535;
15 |
16 | // The default one-dimensional block dimension is...
17 | *blockDim = dim3(256);
18 | *gridDim = dim3((number_of_elements+blockDim->x-1)/blockDim->x, num_batches);
19 |
20 | // Extend block/grid dimensions if we exceeded the maximum grid dimension
21 | if( gridDim->x > maxGridDim){
22 | blockDim->x = maxBlockDim;
23 | gridDim->x = (number_of_elements+blockDim->x-1)/blockDim->x;
24 | }
25 |
26 | if( gridDim->x > maxGridDim ){
27 | gridDim->x = (unsigned int)std::floor(std::sqrt(float(number_of_elements)/float(blockDim->x)));
28 | unsigned int num_elements_1d = blockDim->x*gridDim->x;
29 | gridDim->y *= ((number_of_elements+num_elements_1d-1)/num_elements_1d);
30 | }
31 |
32 | if( gridDim->x > maxGridDim || gridDim->y > maxGridDim){
33 | // If this ever becomes an issue, there is an additional grid dimension to explore for compute models >= 2.0.
34 | throw cuda_error("setup_grid(): too many elements requested.");
35 | }
36 | }
37 | static __device__ void atomicAdd(float_complext * ptr, float_complext val){
38 |
39 | atomicAdd((float*) ptr, real(val));
40 | atomicAdd(((float*)ptr)+1,imag(val));
41 | }
42 | template __global__ void aTrous_kernel(const T* __restrict__ image, T* __restrict__ out, int stepsize, int stride, int dim_length, typename realType::Type * kernel, int kernel_length, int tot_elements){
43 |
44 | const int idx = blockIdx.y*gridDim.x*blockDim.x + blockIdx.x*blockDim.x + threadIdx.x;
45 |
46 | if (idx < tot_elements){
47 | T result = 0;
48 |
49 | const int dim_pos = (idx/stride)%dim_length;
50 | const int offset = idx-dim_pos*stride;
51 | for (int i = -kernel_length/2; i <= kernel_length/2; i++){
52 | int pos = (dim_pos+i*stepsize+dim_length)%dim_length;
53 | result += image[pos*stride+offset]*kernel[i+kernel_length/2];
54 | }
55 | atomicAdd(out+idx,result);
56 | }
57 | }
58 |
59 |
60 |
61 | template void Gadgetron::aTrousWavelet(cuNDArray* in, cuNDArray* out, thrust::device_vector::Type>* kernel, int stepsize,int dim, bool accumulate){
62 |
63 | dim3 dimGrid,dimBlock;
64 | setup_grid(in->get_number_of_elements(),&dimBlock,&dimGrid,1);
65 |
66 | if (dim >= in->get_number_of_dimensions())
67 | throw std::runtime_error("aTrousWavelet: input array has insufficient number of dimensions");
68 |
69 | int max_grid = cudaDeviceManager::Instance()->max_griddim();
70 |
71 |
72 | int stride = 1;
73 | for (int i = 0; i < dim; i++) stride *= in->get_size(i);
74 |
75 | if (!accumulate)
76 | clear(out);
77 | aTrous_kernel<<>>(in->get_data_ptr(), out->get_data_ptr(),stepsize,stride,in->get_size(dim),thrust::raw_pointer_cast(kernel->data()),kernel->size(),in->get_number_of_elements());
78 |
79 | }
80 |
81 |
82 | template void Gadgetron::aTrousWavelet(cuNDArray*, cuNDArray*, thrust::device_vector*, int, int, bool);
83 | template void Gadgetron::aTrousWavelet(cuNDArray*, cuNDArray*, thrust::device_vector*, int, int, bool);
84 |
--------------------------------------------------------------------------------
/operators/cuATrousWavelet.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include "cuNDArray.h"
5 | namespace Gadgetron {
6 |
7 |
8 | template void aTrousWavelet(cuNDArray* in, cuNDArray* out, thrust::device_vector::Type>* kernel, int stepsize,int dim, bool accumulate);
9 |
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/operators/cuATvOperator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "gpuoperators_export.h"
4 | #include "cuNDArray_math.h"
5 | #include "generalOperator.h"
6 |
7 | #include "complext.h"
8 | #include "cuScaleOperator.h"
9 |
10 | namespace Gadgetron{
11 |
12 | template class cuATvOperator
13 | : public cuTvOperator
14 | {
15 |
16 |
17 | public:
18 | typedef typename realType::Type REAL;
19 |
20 | cuATvOperator() : cuTvOperator(){
21 |
22 | }
23 |
24 | virtual ~cuATvOperator(){};
25 |
26 | virtual void gradient(cuNDArray* in ,cuNDArray* out, bool accumulate=false){
27 | auto dims_small = *in->get_dimensions();
28 | for (int i = 0; i < 3; i++)
29 | dims_small[i] /= 2;
30 |
31 | cuNDArray tmp_in(dims_small);
32 | cuNDArray tmp_out(dims_small);
33 |
34 | scaleOp.mult_M(in,&tmp_in);
35 | parent::gradient(&tmp_in,&tmp_out,false);
36 | scaleOp.mult_MH(&tmp_out,out,accumulate);
37 |
38 |
39 | };
40 | virtual REAL magnitude(cuNDArray* in){
41 | auto dims_small = *in->get_dimensions();
42 | for (int i = 0; i < 3; i++)
43 | dims_small[i] /= 2;
44 |
45 | cuNDArray tmp_in(dims_small);
46 | return parent::magnitude(&tmp_in);
47 | }
48 |
49 | protected:
50 | typedef cuTvOperator parent;
51 | protected:
52 | REAL limit_;
53 | cuScaleOperator scaleOp;
54 | };
55 | }
56 |
--------------------------------------------------------------------------------
/operators/cuBilateralFilter.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "cuNDArray.h"
3 |
4 | namespace Gadgetron {
5 | void bilateral_filter(cuNDArray* image, cuNDArray* ref_image,float sigma_spatial,float sigma_int);
6 | void bilateral_filter_unnormalized(cuNDArray* image, cuNDArray* ref_image,float sigma_spatial,float sigma_int);
7 | }
8 |
--------------------------------------------------------------------------------
/operators/cuBilateralPriorPrimalDualOperator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "primalDualOperator.h"
4 | #include "cuTVPrimalDualOperator.h"
5 | #include "cuWTVPrimalDualOperator.h"
6 | #include
7 | #include "BilateralPriorOperator.h"
8 |
9 | namespace Gadgetron {
10 |
11 | class cuBilateralPriorPrimalDualOperator : public cuTVPrimalDualOperator {
12 | typedef cuTVPrimalDualOperator parent;
13 |
14 |
15 | BilateralPriorOperator bilOp;
16 | public:
17 | cuBilateralPriorPrimalDualOperator() : parent() {
18 | }
19 | cuBilateralPriorPrimalDualOperator(float sigma_int, float sigma_spatial, boost::shared_ptr> prior, float alpha_= 0 ) : parent(alpha_){
20 | bilOp = BilateralPriorOperator();
21 | bilOp.set_sigma_spatial(sigma_spatial);
22 | bilOp.set_sigma_int(sigma_int);
23 | bilOp.set_prior(prior);
24 | }
25 | virtual void primalDual(cuNDArray* in, cuNDArray* out,float sigma, bool accumulate) override {
26 |
27 |
28 | cuNDArray tmp_in = *in;
29 | cuNDArray tmp_out = *out;
30 | bilOp.mult_M(in,&tmp_in);
31 | parent::primalDual(&tmp_in,&tmp_out,sigma,false);
32 | bilOp.mult_MH(&tmp_out,out,accumulate);
33 |
34 |
35 |
36 | };
37 |
38 |
39 |
40 |
41 |
42 |
43 | };
44 | }
--------------------------------------------------------------------------------
/operators/cuBoxFilterOperator.cu:
--------------------------------------------------------------------------------
1 | #include "cuBoxFilterOperator.h"
2 |
3 | #include "gpuoperators_export.h"
4 | #include "vector_td_utilities.h"
5 |
6 | using namespace Gadgetron;
7 |
8 |
9 |
10 |
11 | template static __global__ void
12 | box_kernel_simpel(T* __restrict__ in, T* __restrict__ out, vector_td dims,int direction){
13 |
14 | const int ixo = blockDim.x * blockIdx.x + threadIdx.x;
15 | const int iyo = blockDim.y * blockIdx.y + threadIdx.y;
16 | const int izo = blockDim.z * blockIdx.z + threadIdx.z;
17 |
18 |
19 | vector_td coord(ixo,iyo,izo);
20 | vector_td coord2(ixo,iyo,izo);
21 | if (ixo < dims[0] && iyo < dims[1] && izo < dims[2]){
22 |
23 |
24 | T res = T(0);
25 |
26 |
27 | for (int i = 0; i < 2; i++){
28 | coord2[D] = coord[D]+ direction*i;
29 | res += in[co_to_idx<3>((coord2+dims)%dims,dims)];
30 |
31 | }
32 |
33 | //atomicAdd(&out[co_to_idx<3>(coord,dims)],res/norm);
34 | out[co_to_idx<3>(coord,dims)] = res*0.5f;
35 | }
36 |
37 | }
38 | template static void boxFilter(cuNDArray* in,cuNDArray* out, bool accumulate,int direction){
39 |
40 |
41 | vector_td dims = from_std_vector(*(in->get_dimensions()));
42 |
43 | *out = *in;
44 | std::vector batch_dim = to_std_vector(dims);
45 | size_t elements = prod(dims);
46 | for (int batch =0; batch < in->get_number_of_elements()/elements; batch++){
47 |
48 |
49 | T* outptr = out->get_data_ptr()+batch*elements;
50 | cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc();
51 | cudaExtent extent;
52 | extent.width = in->get_size(0);
53 | extent.height = in->get_size(1);
54 | extent.depth = in->get_size(2);
55 |
56 | dim3 threads(8,8,8);
57 |
58 | dim3 grid((extent.width+threads.x-1)/threads.x, (extent.height+threads.y-1)/threads.y,(extent.depth+threads.z-1)/threads.z);
59 |
60 | for (int d = 0; d < D; d++){
61 | if (dims[d] ==1) continue;
62 |
63 | cuNDArray tmp(elements);
64 | cudaMemcpy(tmp.get_data_ptr(),outptr,elements*sizeof(T),cudaMemcpyDeviceToDevice);
65 | if (d == 0)
66 | box_kernel_simpel<<>>(tmp.get_data_ptr(),outptr,vector_td(extent.width,extent.height,extent.depth),direction);
67 | else if (d == 1)
68 | box_kernel_simpel<<>>(tmp.get_data_ptr(),outptr,vector_td(extent.width,extent.height,extent.depth),direction);
69 | else if (d == 2)
70 | box_kernel_simpel<<>>(tmp.get_data_ptr(),outptr,vector_td(extent.width,extent.height,extent.depth),direction);
71 | else throw std::runtime_error("Unsupported number of dimensions for Gaussian kernel");
72 |
73 |
74 |
75 | }
76 |
77 |
78 |
79 |
80 | //cudaFreeArray(image_array);
81 | if (accumulate) *out += *in;
82 |
83 |
84 | }
85 |
86 |
87 |
88 | }
89 |
90 |
91 | template void cuBoxFilterOperator::mult_M(cuNDArray* in,cuNDArray* out, bool accumulate){
92 | boxFilter(in,out,accumulate,1);
93 | }
94 |
95 |
96 | template void cuBoxFilterOperator::mult_MH(cuNDArray* in,cuNDArray* out, bool accumulate){
97 | boxFilter(in,out,accumulate,-1);
98 | }
99 |
100 |
101 | template EXPORTGPUOPERATORS class cuBoxFilterOperator;
102 | template EXPORTGPUOPERATORS class cuBoxFilterOperator;
103 | template EXPORTGPUOPERATORS class cuBoxFilterOperator;
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/operators/cuBoxFilterOperator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "linearOperator.h"
3 | #include "cuNDArray.h"
4 | #include "cuNDArray_math.h"
5 | namespace Gadgetron{
6 |
7 |
8 | template class cuBoxFilterOperator : public linearOperator > {
9 | typedef typename realType::Type REAL;
10 | public:
11 | void mult_M( cuNDArray* in, cuNDArray* out, bool accumulate = false);
12 | void mult_MH( cuNDArray* in, cuNDArray* out, bool accumulate = false);
13 |
14 |
15 |
16 | };
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/operators/cuDCT.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "cuNDArray.h"
3 |
4 | namespace Gadgetron {
5 | template void dct2(cuNDArray* image,int offset=0);
6 | template void idct2(cuNDArray* image, int offset=0);
7 | template void dct(cuNDArray* image,int dim, int offset=0);
8 | template void idct(cuNDArray* image, int dim, int offset=0);
9 | }
10 |
--------------------------------------------------------------------------------
/operators/cuDCTDerivativeOperator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "linearOperator.h"
3 | #include "cuPartialDerivativeOperator.h"
4 |
5 | namespace Gadgetron {
6 |
7 | template class cuDCTDerivativeOperator : public linearOperator> {
8 |
9 |
10 | public:
11 |
12 | cuDCTDerivativeOperator(size_t dim) : linearOperator>() {
13 | pD = cuPartialDerivativeOperator(dim);
14 | }
15 |
16 |
17 | virtual void mult_M(cuNDArray* in, cuNDArray* out, bool accumulate) override {
18 |
19 | auto tmp = out;
20 | if (accumulate) tmp = new cuNDArray(out->get_dimensions());
21 | pD.mult_M(in,tmp,false);
22 | dct(tmp,3);
23 | if (accumulate){
24 | *out += *tmp;
25 | delete tmp;
26 | }
27 | }
28 |
29 | virtual void mult_MH(cuNDArray* in, cuNDArray* out, bool accumulate) override {
30 |
31 | auto tmp = *in;
32 | idct(&tmp,3);
33 | pD.mult_MH(&tmp,out,accumulate);
34 |
35 | }
36 |
37 |
38 | protected:
39 | cuPartialDerivativeOperator pD;
40 | };
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/operators/cuDCTOperator.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "cuDCT.h"
3 |
4 | #include "invertibleOperator.h"
5 |
6 | namespace Gadgetron {
7 |
8 | template class cuDCTOperator : public Gadgetron::invertibleOperator> {
9 |
10 | static constexpr int stencil_size = 8;
11 | public:
12 |
13 | cuDCTOperator(): invertibleOperator>(){
14 | repetitions = 2;
15 | };
16 |
17 | virtual ~cuDCTOperator(){};
18 | virtual void mult_M(cuNDArray* in, cuNDArray* out, bool accumulate=false) override {
19 |
20 | cuNDArray* tmp = out;
21 |
22 | if (accumulate) tmp = new cuNDArray(out->get_dimensions());
23 |
24 | auto in_dims = in->get_dimensions();
25 | size_t elements = in->get_number_of_elements();
26 | for (auto i = 0; i < repetitions; i++){
27 | cuNDArray tmp_view(in_dims,tmp->get_data_ptr()+elements*i);
28 | tmp_view = *in;
29 | dct2(&tmp_view,i*stencil_size/repetitions);
30 | if (in->get_size(2) > 1)
31 | dct(&tmp_view,2,i*stencil_size/repetitions);
32 | if (in->get_size(3) > 1)
33 | dct(&tmp_view,3,i*10/repetitions);
34 | //dct2(&tmp_view,2);
35 | }
36 |
37 | *tmp /= std::sqrt(T(repetitions));
38 | if (accumulate){
39 | *out += *tmp;
40 | delete tmp;
41 | }
42 |
43 | }
44 |
45 |
46 | virtual void mult_MH(cuNDArray* in, cuNDArray* out, bool accumulate=false) override {
47 |
48 |
49 | if (!accumulate) clear(out);
50 |
51 | auto out_dims = out->get_dimensions();
52 | size_t elements = out->get_number_of_elements();
53 | for (auto i = 0; i < repetitions; i++){
54 | cuNDArray in_view(out_dims,in->get_data_ptr()+i*elements);
55 | cuNDArray tmp(in_view);
56 | idct2(&tmp,i*stencil_size/repetitions);
57 | if (out->get_size(2) > 1)
58 | idct(&tmp,2,i*stencil_size/repetitions);
59 | if (out->get_size(3) > 1)
60 | idct(&tmp,3,i*10/repetitions);
61 | //idct2(&tmp,2);
62 | axpy(std::sqrt(T(1)/repetitions),&tmp,out);
63 | }
64 |
65 | }
66 |
67 | virtual void inverse(cuNDArray* in, cuNDArray* out, bool accumulate=false) override {
68 | mult_MH(in,out,accumulate);
69 | }
70 |
71 |
72 |
73 | virtual void set_domain_dimensions(std::vector* dims) override {
74 | std::vector codims = *dims;
75 | codims.push_back(repetitions);
76 | linearOperator>::set_codomain_dimensions(&codims);
77 | linearOperator>::set_domain_dimensions(dims);
78 | }
79 |
80 | virtual void set_codomain_dimensions(std::vector* dims) override {
81 | throw std::runtime_error("Do not set codomain dimensions manually");
82 | }
83 |
84 | protected:
85 | unsigned int repetitions;
86 |
87 |
88 | };
89 | };
90 |
--------------------------------------------------------------------------------
/operators/cuEdgeWavelet.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include "cuNDArray.h"
5 | namespace Gadgetron {
6 |
7 |
8 | template void EdgeWavelet(cuNDArray* in, cuNDArray* out, thrust::device_vector::Type>* kernel, int stepsize,int dim,typename realType::Type sigma, bool accumulate);
9 |
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/operators/cuFFTDerivativeOperator.h:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 | #include "linearOperator.h"
4 | #include "cuPartialDerivativeOperator.h"
5 | #include "cuRFFTOperator.h"
6 |
7 | namespace Gadgetron {
8 |
9 | template class cuDCTDerivativeOperator : public linearOperator