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

NiftyPET version 2 #1292

Closed
wants to merge 14 commits into from
Closed
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
49 changes: 44 additions & 5 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- os: ubuntu-latest
compiler: gcc
compiler_version: 9
cuda_version: "0"
BUILD_FLAGS: "-DSTIR_OPENMP=ON"
BUILD_TYPE: "Release"
parallelproj: "ON"
Expand All @@ -45,6 +46,7 @@ jobs:
- os: ubuntu-latest
compiler: clang
#compiler_version:
cuda_version: "0"
BUILD_FLAGS: "-DSTIR_OPENMP=ON"
BUILD_TYPE: "Release"
parallelproj: "ON"
Expand All @@ -54,6 +56,7 @@ jobs:
- os: ubuntu-latest
compiler: gcc
compiler_version: 10
cuda_version: "0"
BUILD_FLAGS: "-DSTIR_OPENMP=ON -DCMAKE_CXX_STANDARD=17"
BUILD_TYPE: "Debug"
parallelproj: "OFF"
Expand All @@ -62,14 +65,25 @@ jobs:
- os: ubuntu-latest
compiler: gcc
compiler_version: 12
cuda_version: "0"
BUILD_FLAGS: "-DSTIR_OPENMP=ON -DCMAKE_CXX_STANDARD=14"
BUILD_TYPE: "RelWithDebInfo"
parallelproj: "ON"
ROOT: "OFF"
ITK: "ON"
- os: ubuntu-latest
compiler: gcc
compiler_version: 12
cuda_version: "12.1.0"
BUILD_FLAGS: "-DSTIR_OPENMP=ON -DCMAKE_CXX_STANDARD=14"
BUILD_TYPE: "Release"
parallelproj: "ON"
ROOT: "OFF"
ITK: "ON"
- os: macOS-latest
compiler: gcc
compiler_version: 11
cuda_version: "0"
BUILD_FLAGS: "-DSTIR_OPENMP=OFF"
parallelproj: "OFF"
BUILD_TYPE: "Debug"
Expand All @@ -88,7 +102,7 @@ jobs:
# let's run all of them, as opposed to aborting when one fails
fail-fast: false

name: ${{ matrix.os }}-${{ matrix.compiler }}${{ matrix.compiler_version }}-${{ matrix.BUILD_TYPE }}-pp=${{ matrix.parallelproj }}-ROOT=${{ matrix.ROOT }}
name: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.compiler_version }}-cuda${{ matrix.cuda_version }}-${{ matrix.BUILD_TYPE }}-pp=${{ matrix.parallelproj }}-ROOT=${{ matrix.ROOT }}

steps:
- name: disk space
Expand Down Expand Up @@ -152,6 +166,13 @@ jobs:
echo CC="$CC" >> $GITHUB_ENV
echo CXX="$CXX" >> $GITHUB_ENV

- if: matrix.cuda_version != '0'
uses: Jimver/[email protected]
id: cuda-toolkit
with:
cuda: ${{ matrix.cuda_version }}
linux-local-args: '["--toolkit"]'

- name: install_dependencies
shell: bash
run: |
Expand Down Expand Up @@ -212,10 +233,22 @@ jobs:
git clone --depth 1 --branch v1.3.7 https://github.com/gschramm/parallelproj
mkdir parallelproj/build
cd parallelproj/build
cmake .. -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DSKIP_CUDA_LIB:BOOL=ON
if test "${{matrix.cuda_version}}" == "0"; then
extra_args="-DSKIP_CUDA_LIB:BOOL=ON"
fi
cmake .. -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ${extra_args}
cmake --build . --target install --config Release
cd ../..
fi
# Install NiftyPET
if test ! "${{matrix.cuda_version}}" == "0"; then
export PATHTOOLS=${GITHUB_WORKSPACE}/NiftyPET_tools
export HMUDIR=${GITHUB_WORKSPACE}/mmr_hardwareumaps
python -m pip install "nipet>=2"
niftypet_cmake_prefix=$(python -c "from niftypet.nipet import cmake_prefix; print(cmake_prefix)")
find /home/runner/work/STIR/STIR/my-env/ -name prjb.h
echo NiftyPET_DIR="$niftypet_cmake_prefix" >> $GITHUB_ENV
fi

# Install ROOT (warning: currently only valid on Ubuntu)
if test "${{matrix.ROOT}}XX" == "ONXX"; then
Expand Down Expand Up @@ -243,7 +276,7 @@ jobs:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.compiler_version }}-${{ matrix.BUILD_TYPE }}
key: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.compiler_version }}-cuda${{ matrix.cuda_version }}-${{ matrix.BUILD_TYPE }}
max-size: "2G"

- name: configure
Expand All @@ -265,6 +298,7 @@ jobs:
echo CMAKE_INSTALL_PREFIX="$CMAKE_INSTALL_PREFIX" >> $GITHUB_ENV
EXTRA_BUILD_FLAGS="-DBUILD_SWIG_PYTHON=ON -DPYTHON_EXECUTABLE=`which python`"
EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DNiftyPETnipet_DIR=${NiftyPET_DIR}"
EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DDOWNLOAD_ZENODO_TEST_DATA=ON"
EXTRA_BUILD_FLAGS="${EXTRA_BUILD_FLAGS} -DDISABLE_STIR_LOCAL=OFF -DSTIR_LOCAL=${GITHUB_WORKSPACE}/examples/C++/src"
echo "cmake flags $BUILD_FLAGS $EXTRA_BUILD_FLAGS"
Expand All @@ -288,8 +322,9 @@ jobs:
run: |
cd ${GITHUB_WORKSPACE}/build;
source ${GITHUB_WORKSPACE}/my-env/bin/activate
cmake --build . -j 2 --config ${BUILD_TYPE}} --target install

cmake --build . -j 2 --config ${BUILD_TYPE}} --target install || true
#debug
make VERBOSE=ON
- name: ctest
shell: bash
env:
Expand All @@ -300,6 +335,10 @@ jobs:
if test ${BUILD_TYPE} = Debug; then
EXCLUDE="-E test_data_processor_projectors|test_export_array|test_ArcCorrection|test_blocks_on_cylindrical_projectors"
fi
if test ${{matrix.cuda_version}} != "0"; then
# No CUDA drivers on GitHub Actions
EXCLUDE="${EXCLUDE}|parallelproj|NiftyPET|test_blocks_on_cylindrical_projectors"
fi
ctest --output-on-failure -C ${BUILD_TYPE} ${EXCLUDE}

- name: recon_test_pack
Expand Down
10 changes: 3 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
# See STIR/LICENSE.txt for details

# cmake file for building STIR. See the STIR User's Guide and http://www.cmake.org.
if (CMAKE_HOST_WIN32)
cmake_minimum_required(VERSION 3.12.0)
else()
cmake_minimum_required(VERSION 3.1.0)
endif()
cmake_minimum_required(VERSION 3.14.0)

# enable ccache https://ccache.samba.org/
find_program(CCACHE_PROGRAM ccache)
Expand Down Expand Up @@ -183,8 +179,8 @@ endif()

if(NOT DISABLE_NiftyPET_PROJECTOR)
if (CUDAToolkit_FOUND)
find_package(NiftyPET)
if (NiftyPET_FOUND)
find_package(NiftyPETnipet COMPONENTS mmr_auxe mmr_lmproc petprj CONFIG)
if (NiftyPETnipet_FOUND)
set(STIR_WITH_NiftyPET_PROJECTOR ON)
endif()
endif()
Expand Down
2 changes: 1 addition & 1 deletion examples/C++/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(dir examples)
set(dir_EXE_SOURCES ${dir}_EXE_SOURCES)

set(${dir_EXE_SOURCES}
demo1 demo2 demo3 demo4_obj_fun demo5_line_search
demo1.cxx demo2.cxx demo3.cxx demo4_obj_fun.cxx demo5_line_search.cxx
)


Expand Down
82 changes: 0 additions & 82 deletions src/cmake/FindNiftyPET.cmake

This file was deleted.

4 changes: 4 additions & 0 deletions src/listmode_buildblock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@ endif()
include(stir_lib_target)

target_link_libraries(listmode_buildblock PUBLIC data_buildblock )

if (STIR_WITH_NiftyPET_PROJECTOR)
target_link_libraries(listmode_buildblock PRIVATE NiftyPET::mmr_auxe NiftyPET::mmr_lmproc NiftyPET::petprj)
endif()
4 changes: 2 additions & 2 deletions src/listmode_utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ if (HAVE_ECAT)
endif()

if (STIR_WITH_NiftyPET_PROJECTOR)
list(APPEND ${dir_EXE_SOURCES} conv_NiftyPET_stir)
list(APPEND ${dir_EXE_SOURCES} lm_to_projdata_NiftyPET)
list(APPEND ${dir_EXE_SOURCES} conv_NiftyPET_stir.cxx)
list(APPEND ${dir_EXE_SOURCES} lm_to_projdata_NiftyPET.cxx)
endif()


Expand Down
5 changes: 1 addition & 4 deletions src/recon_buildblock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ endif()
target_link_libraries(recon_buildblock PUBLIC modelling_buildblock display numerics_buildblock listmode_buildblock data_buildblock buildblock spatial_transformation_buildblock )

if (STIR_WITH_NiftyPET_PROJECTOR)
target_link_libraries(recon_buildblock PUBLIC NiftyPET::petprj)
target_link_libraries(recon_buildblock PUBLIC NiftyPET::mmr_auxe)
target_link_libraries(recon_buildblock PUBLIC NiftyPET::mmr_lmproc)
target_link_libraries(recon_buildblock PUBLIC CUDA::cudart)
target_link_libraries(recon_buildblock PRIVATE NiftyPET::mmr_auxe NiftyPET::mmr_lmproc NiftyPET::petprj)
endif()

if (STIR_WITH_Parallelproj_PROJECTOR)
Expand Down
4 changes: 3 additions & 1 deletion src/recon_buildblock/NiftyPET_projector/NiftyPETHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ shared_ptr<Cnst> get_cnst(const Scanner &scanner, const bool cuda_verbose, const
shared_ptr<Cnst> cnt_sptr = MAKE_SHARED<Cnst>();

cnt_sptr->DEVID = cuda_device; // device (GPU) ID. allows choosing the device on which to perform calculations
cnt_sptr->VERBOSE = cuda_verbose;
cnt_sptr->LOG = cuda_verbose;

if (scanner.get_type() == Scanner::Siemens_mMR) {
if (!(span==0 || span==1 || span==11))
Expand Down Expand Up @@ -123,8 +123,10 @@ shared_ptr<Cnst> get_cnst(const Scanner &scanner, const bool cuda_verbose, const
cnt_sptr->MRD = mxRD; // maximum ring difference

cnt_sptr->ALPHA = aLPHA; //angle subtended by a crystal
#if 0 // NiftyPET v1 or so. Now this is hardwored as R_RING in sct.h
float R = 32.8f; // ring radius
cnt_sptr->RE = R + 0.67f; // effective ring radius accounting for the depth of interaction
#endif
cnt_sptr->AXR = SZ_RING; //axial crystal dim

cnt_sptr->COSUPSMX = 0.725f; //cosine of max allowed scatter angle
Expand Down
4 changes: 2 additions & 2 deletions src/test/NiftyPET_projector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ set(dir_INVOLVED_TEST_EXE_SOURCES ${dir}_INVOLVED_TEST_EXE_SOURCES)
set(dir_SIMPLE_TEST_EXE_SOURCES_NO_REGISTRIES ${dir}_SIMPLE_TEST_EXE_SOURCES_NO_REGISTRIES)

set(${dir_INVOLVED_TEST_EXE_SOURCES}
test_ProjectorNiftyPET_adjoint
test_ProjectorNiftyPET_adjoint.cxx
)

ADD_TEST(test_ProjectorNiftyPET_adjoint
${CMAKE_CURRENT_BINARY_DIR}/test_ProjectorNiftyPET_adjoint 3)

include(stir_test_exe_targets)
include(stir_test_exe_targets)
Loading