Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synergistic IO dependency fix #1194

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ jobs:
DEVEL_BUILD: "ON"
EXTRA_BUILD_FLAGS: "-DUSE_ITK=ON"
CMAKE_BUILD_TYPE: "Release"
# need to upgrade Gadgetron before we can enable gcc 10
- os: ubuntu-latest
compiler: gcc
compiler_version: 9
DEVEL_BUILD: "ON"
EXTRA_BUILD_FLAGS: "-DUSE_ITK=ON -DDISABLE_Gadgetron:BOOL=ON"
CMAKE_BUILD_TYPE: "Release"
#- os: ubuntu-latest
# compiler: gcc
# compiler_version: 10
Expand Down
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# ChangeLog

## v3.5.0
* GitHub Action: remove temporarily the Ubuntu 20.04 build, #1178
* MR
- Re-designed handling of "irregular" ISMRMRD acquisitions, making it user-controlled and more flexible. See https://github.com/SyneRBI/SIRF/pull/1174 for more information
- Allow user to set radial, goldenangle, spiral and rpe trajectories
Expand All @@ -14,6 +13,13 @@
* C++
- added `examples_data_path` and utility functions such as `append_path` in `common/utilities.h`

* Other, including CMake files
- resolve dependencies such that DISABLE_Gadgetron works now
- split some C interfaces into separate libraries, i.e. cinterface-sirf and cinterface-Reg

* GitHub Action:
- add a build with DISABLE_Gadgetron

## v3.4.0

* MR:
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

#========================================================================
# Author: Kris Thielemans
# Copyright 2016 - 2020 University College London
# Author: Evgueni Ovtchinnikov
# Author: Edoardo Pasca
# Author: Richard Brown
# Copyright 2016 - 2023 University College London
# Copyright 2016 - 2020 Science Technology Facilities Council
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -40,7 +43,7 @@ option(DISABLE_Gadgetron "Disable building the SIRF interface to Gadgetron" OFF)
if (NOT DISABLE_Gadgetron)
set(default_CXX_version 17)
else()
message(WARNING "Gadgetron not found. Set gadgetron_DIR if you do have it.")
message(STATUS "Gadgetron disabled.")
set (default_CXX_version 11)
endif()
UseCXX(${default_CXX_version})
Expand Down
125 changes: 64 additions & 61 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

#========================================================================
# Author: Richard Brown, Kris Thielemans
# Copyright 2016 - 2020 University College London
# Copyright 2016 - 2020 Science Technology Facilities Council
# Author: Evgueni Ovtchinnikov
# Copyright 2016 - 2023 University College London
# Copyright 2016 - 2023 Science Technology Facilities Council
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,49 +34,13 @@ else()
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${ISMRMRD_DIR}")
find_package(FFTW3 COMPONENTS single REQUIRED)
ADD_SUBDIRECTORY(xGadgetron)
set(SIRF_BUILT_WITH_ISMRMRD TRUE PARENT_SCOPE)
set(SIRF_BUILT_WITH_ISMRMRD TRUE) # set for directories "below"
set(SIRF_BUILT_WITH_ISMRMRD TRUE PARENT_SCOPE) # set for directory "above"
set(ISMRMRD_VERSION ${ISMRMRD_VERSION} PARENT_SCOPE)
# TODO use target_compile_definitions
add_definitions(-DSIRF_BUILT_WITH_ISMRMRD)
endif()



##########################################################################
# Registration #
##########################################################################
option(DISABLE_Registration "Disable building the SIRF registration package" OFF)
if (DISABLE_Registration)
message(STATUS "Registration support disabled.")
set(SPM_BOOL_STR "0" PARENT_SCOPE)
set(SIRF_BUILT_WITH_REGISTRATION False PARENT_SCOPE)
else()
FIND_PACKAGE(NIFTYREG 1.5.61 REQUIRED)
# NIFTYREG
FOREACH(NR_lib ${NIFTYREG_LIBRARIES})
find_library(${NR_lib}_full_path "${NR_lib}" "${NIFTYREG_LIBRARY_DIRS}")
if(NOT ${NR_lib}_full_path)
message(FATAL_ERROR "${NR_lib} not found")
endif()
SET(NR_libs_full_path "${NR_libs_full_path};${${NR_lib}_full_path}")
ENDFOREACH()
# If niftyreg was bulit with OpenMP
if (NIFTYREG_BUILT_WITH_OPENMP)
find_package(OpenMP REQUIRED)
if (OpenMP_CXX_FOUND)
SET(NR_libs_full_path "${NR_libs_full_path};OpenMP::OpenMP_CXX")
endif()
endif()
# If niftyreg was bulit with CUDA
if (NIFTYREG_BUILT_WITH_CUDA)
find_package(CUDA REQUIRED)
SET(NR_libs_full_path "${NR_libs_full_path};${CUDA_CUDA_LIBRARY};${CUDA_CUDART_LIBRARY}")
endif()
ADD_SUBDIRECTORY(Registration)
set(SPM_BOOL_STR ${SPM_BOOL_STR} PARENT_SCOPE)
set(SIRF_BUILT_WITH_REGISTRATION TRUE PARENT_SCOPE)
endif()



##########################################################################
# STIR #
##########################################################################
Expand Down Expand Up @@ -111,38 +76,76 @@ else()
set(Parallelproj_BOOL_STR "0")
endif()
ADD_SUBDIRECTORY(xSTIR)
set(SIRF_BUILT_WITH_STIR TRUE)
set(SIRF_BUILT_WITH_STIR TRUE PARENT_SCOPE)
set(STIR_VERSION ${STIR_VERSION} PARENT_SCOPE)
# TODO use target_compile_definitions
add_definitions(-DSIRF_BUILT_WITH_STIR)

endif()
set(NiftyPET_BOOL_STR ${NiftyPET_BOOL_STR} PARENT_SCOPE)
set(Parallelproj_BOOL_STR ${Parallelproj_BOOL_STR} PARENT_SCOPE)


##########################################################################
# Synergistic #
# Registration #
##########################################################################
# Synergistic code currently only works if STIR (with ITK), ISMRMRD and Registration are built
option(DISABLE_Synergistic "Disable building the synergistic code" OFF)
if (DISABLE_Synergistic)
message(STATUS "Synergistic code disabled.")
# Note:
# The Python/MATLAB interface for Reg depends on STIR sadly, so STIR stuff
# needs to come first. We could add some checks here to see if Registration should be
# disabled, but we'll just check it in the cReg/CMakeLists.txt and leave it to the user
# to either enable STIR or disable Registration.
option(DISABLE_Registration "Disable building the SIRF registration package" OFF)
if (DISABLE_Registration)
message(STATUS "Registration support disabled.")
set(SPM_BOOL_STR "0" PARENT_SCOPE)
set(SIRF_BUILT_WITH_REGISTRATION False PARENT_SCOPE)
else()
if ((NOT DISABLE_STIR) AND (NOT DISABLE_Gadgetron) AND (NOT DISABLE_Registration) AND "${STIR_BUILT_WITH_ITK}")
MESSAGE(STATUS "Registration, ISMRMRD and STIR (with ITK) have been built. Building synergistic code.")
ADD_SUBDIRECTORY(Synergistic)
else()
MESSAGE(STATUS "One or more of the following components are missing: Registration, ISMRMRD and STIR (with ITK). Synergistic code will not be built.")
if (DISABLE_STIR)
MESSAGE(STATUS "STIR missing.")
elseif(NOT STIR_BUILT_WITH_ITK)
MESSAGE(STATUS "STIR not built with ITK.")
endif()
if (DISABLE_Gadgetron)
MESSAGE(STATUS "ISMRMRD missing.")
FIND_PACKAGE(NIFTYREG 1.5.61 REQUIRED)
# NIFTYREG
FOREACH(NR_lib ${NIFTYREG_LIBRARIES})
find_library(${NR_lib}_full_path "${NR_lib}" "${NIFTYREG_LIBRARY_DIRS}")
if(NOT ${NR_lib}_full_path)
message(FATAL_ERROR "${NR_lib} not found")
endif()
if (DISABLE_Registration)
MESSAGE(STATUS "Registration missing.")
SET(NR_libs_full_path "${NR_libs_full_path};${${NR_lib}_full_path}")
ENDFOREACH()
# If niftyreg was bulit with OpenMP
if (NIFTYREG_BUILT_WITH_OPENMP)
find_package(OpenMP REQUIRED)
if (OpenMP_CXX_FOUND)
SET(NR_libs_full_path "${NR_libs_full_path};OpenMP::OpenMP_CXX")
endif()
endif()
# If niftyreg was bulit with CUDA
if (NIFTYREG_BUILT_WITH_CUDA)
find_package(CUDA REQUIRED)
SET(NR_libs_full_path "${NR_libs_full_path};${CUDA_CUDA_LIBRARY};${CUDA_CUDART_LIBRARY}")
endif()
ADD_SUBDIRECTORY(Registration)
set(SPM_BOOL_STR ${SPM_BOOL_STR} PARENT_SCOPE)
set(SIRF_BUILT_WITH_REGISTRATION TRUE)
set(SIRF_BUILT_WITH_REGISTRATION TRUE PARENT_SCOPE)
# TODO use target_compile_definitions
add_definitions(-DSIRF_BUILT_WITH_REGISTRATION)
endif()


##########################################################################
# Synergistic #
##########################################################################
if (NOT BUILD_PYTHON AND NOT BUILD_MATLAB)
# Currently only offer to disable synergistic library when not using Python/MATLAB,
# as their ImageData.read depends on synergistic/ImageDataWrapper (TODO)
option(DISABLE_Synergistic "Disable building the synergistic code" OFF)
else()
# DISABLE_Synergistic will be not set, which in CMake means it is equivalent to FALSE
endif()

if (DISABLE_Synergistic)
message(STATUS "Synergistic code disabled.")
else()
ADD_SUBDIRECTORY(Synergistic)
endif()

ADD_SUBDIRECTORY(common)
19 changes: 13 additions & 6 deletions src/Registration/cReg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#========================================================================
# Author: Evgueni Ovtchinnikov
# Author: Kris Thielemans
# Author: Richard Brown
# Copyright 2018 - 2020 University College London
# Copyright 2018-2021, 2023 University College London
# Copyright 2018-2023 Science Technology Facilities Council
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,11 +37,6 @@ SET(SOURCES
"NiftiImageData3DDeformation.cpp"
"NiftiImageData3DDisplacement.cpp")

# If we're also wrapping to python or matlab, include the c-files
IF(BUILD_PYTHON OR BUILD_MATLAB)
SET(SOURCES ${SOURCES} "cReg.cpp" "cReg_p.cpp")
ENDIF()

# Add SPM source
IF(SPM_FOUND)
SET(SOURCES ${SOURCES} "SPMRegistration.cpp")
Expand Down Expand Up @@ -130,4 +128,13 @@ FOREACH(elem ${REG_executables})
INSTALL(TARGETS ${elem} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
ENDFOREACH(elem ${REG_executables})

IF(BUILD_PYTHON OR BUILD_MATLAB)
ADD_LIBRARY(cinterface-Reg cReg.cpp cReg_p.cpp)
# add dependencies. Note that cstir is required for deleteTextWriter sadly
if (NOT SIRF_BUILT_WITH_STIR)
message(FATAL_ERROR "Python/MATLAB interface for Registration currently depends on STIR.")
endif()
target_link_libraries(cinterface-Reg Reg cstir)
endif()

ADD_SUBDIRECTORY(tests)
8 changes: 1 addition & 7 deletions src/Registration/cReg/cReg_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
*/

#include "sirf/iUtilities/DataHandle.h"
#include "sirf/iUtilities/iutilities.h"
#include "sirf/Reg/cReg_p.h"
#include "sirf/Reg/NiftiImageData3D.h"
#include "sirf/Reg/Registration.h"
Expand All @@ -33,13 +34,6 @@ limitations under the License.

using namespace sirf;

extern "C"
char* charDataFromHandle(const void* ptr);
extern "C"
int intDataFromHandle(const void* ptr);
extern "C"
float floatDataFromHandle(const void* ptr);

static void*
parameterNotFound(const char* name, const char* file, int line)
{
Expand Down
1 change: 0 additions & 1 deletion src/Registration/cReg/include/sirf/Reg/NiftyResample.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ limitations under the License.
#include <vector>
#include <iostream>
#include "sirf/Reg/Resample.h"
#include "sirf/iUtilities/iutilities.h"

namespace NiftyMoMo {
class BSplineTransformation;
Expand Down
1 change: 0 additions & 1 deletion src/Registration/cReg/include/sirf/Reg/NiftyResampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ limitations under the License.
#include <vector>
#include <iostream>
#include "sirf/Reg/Resample.h"
#include "sirf/iUtilities/iutilities.h"

namespace NiftyMoMo {
class BSplineTransformation;
Expand Down
1 change: 0 additions & 1 deletion src/Registration/cReg/include/sirf/Reg/Resample.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ limitations under the License.
#include <vector>
#include <memory>
#include "sirf/Reg/Transformation.h"
#include "sirf/iUtilities/iutilities.h"

namespace sirf {

Expand Down
4 changes: 2 additions & 2 deletions src/Registration/mReg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ if(BUILD_MATLAB)
target_include_directories(mreg PUBLIC ${Matlab_INCLUDE_DIRS})
# fix output name and link flags
SET_TARGET_PROPERTIES(mreg PROPERTIES
SUFFIX ".${MATLAB_MEX_EXT}" PREFIX "${MATLAB_PREFIX}")
target_link_libraries(mreg Reg iutilities csirf cstir ${Matlab_LIBRARIES})
SUFFIX ".${MATLAB_MEX_EXT}" PREFIX "${MATLAB_PREFIX}")
target_link_libraries(mreg cinterface-Reg ${Matlab_LIBRARIES})
INSTALL(TARGETS mreg DESTINATION "${MATLAB_DEST}")
INSTALL(FILES ${mreg_h} DESTINATION "${MATLAB_DEST}")
INSTALL(FILES ${SOURCES} DESTINATION "${MATLAB_DEST}/+sirf/+Reg")
Expand Down
2 changes: 1 addition & 1 deletion src/Registration/mReg/printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ limitations under the License.

#include "stir/TextWriter.h"

class mexTextPrinter : public aTextWriter {
class mexTextPrinter : public stir::aTextWriter {
public:
virtual void write(const char* text) const {
//mexPrintf("mexPrintf is called...\n");
Expand Down
2 changes: 1 addition & 1 deletion src/Registration/pReg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ set(SWIG_MODULE_pyreg_EXTRA_DEPS "${cREG_INCLUDE_DIR}/sirf/Reg/cReg.h")

SWIG_ADD_LIBRARY(pyreg LANGUAGE python TYPE MODULE SOURCES pyreg.i)
TARGET_INCLUDE_DIRECTORIES(${SWIG_MODULE_pyreg_REAL_NAME} PUBLIC ${Python_INCLUDE_DIRS})
SWIG_LINK_LIBRARIES(pyreg PUBLIC Reg ${Python_LIBRARIES})
SWIG_LINK_LIBRARIES(pyreg PUBLIC cinterface-Reg ${Python_LIBRARIES})

INSTALL(TARGETS ${SWIG_MODULE_pyreg_REAL_NAME} DESTINATION "${PYTHON_DEST}/sirf")
INSTALL(FILES
Expand Down
10 changes: 7 additions & 3 deletions src/Synergistic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ SET(CMAKE_POSITION_INDEPENDENT_CODE True)

# Executables
SET(SYN_executables
sirf_convert_image_type
)
if (SIRF_BUILT_WITH_REGISTRATION)
list(APPEND SYN_executables
sirf_registration
sirf_do_images_match
sirf_resample
sirf_convert_image_type
)
)
endif()

FOREACH(elem ${SYN_executables})
ADD_EXECUTABLE(${elem} ${elem}.cpp ${STIR_REGISTRIES})
TARGET_LINK_LIBRARIES(${elem} LINK_PUBLIC csirf iutilities cstir cgadgetron Reg)
TARGET_LINK_LIBRARIES(${elem} LINK_PUBLIC csirf csyn)
INSTALL(TARGETS ${elem} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
ENDFOREACH(elem ${SYN_executables})

Expand Down
10 changes: 9 additions & 1 deletion src/Synergistic/cSyn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ target_include_directories(csyn PUBLIC
target_include_directories(csyn PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>$<INSTALL_INTERFACE:include>"
)
target_link_libraries(csyn PUBLIC cgadgetron cstir Reg)
if(SIRF_BUILT_WITH_ISMRMRD)
target_link_libraries(csyn PUBLIC cgadgetron)
endif()
if(SIRF_BUILT_WITH_STIR)
target_link_libraries(csyn PUBLIC cstir)
endif()
if(SIRF_BUILT_WITH_REGISTRATION)
target_link_libraries(csyn PUBLIC Reg)
endif()
target_compile_definitions(csyn PRIVATE WIN32_LEAN_AND_MEAN)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
Expand Down
5 changes: 4 additions & 1 deletion src/Synergistic/cSyn/include/sirf/Syn/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ limitations under the License.
*/

#pragma once

#include <string>
#include <memory>
namespace sirf {
class ImageData;

class ImageDataWrap {
public:
ImageDataWrap(const std::string &filename, const std::string &engine, bool verbose);
Expand Down
Loading