Skip to content

Building SIRF and CIL with conda

Kris Thielemans edited this page Mar 20, 2024 · 15 revisions

These are instructions to build SIRF, CIL and all prerequisites using conda for dependencies. It is recommended to do this if you use conda for your normal python development. The instructions are for a Linux system although minor variations should work on other systems.

First, install miniconda.

Then follow these steps:

mkdir ~/devel
cd ~/devel
git clone https://github.com/SyneRBI/SIRF-SuperBuild
mkdir buildVM
cd buildVM

conda create --name cilsirfbuild python=3 numpy cxx-compiler cmake scipy python-wget cython six pillow nose h5py matplotlib boost pugixml libitk-devel libitk nlohmann_json libparallelproj swig fftw docopt pytest pytest-cov deprecation niftyreg -c conda-forge

conda activate cilsirfbuild

cmake -S ../SIRF-SuperBuild/ -B . -DCMAKE_INSTALL_PREFIX=../install -DUSE_SYSTEM_ACE=OFF -DUSE_SYSTEM_Boost=ON -DUSE_SYSTEM_ITK=ON -DUSE_SYSTEM_parallelproj=ON -DUSE_SYSTEM_FFTW3=ON -DUSE_SYSTEM_SWIG=ON -DUSE_SYSTEM_HDF5=ON -DUSE_SYSTEM_JSON=ON -DUSE_SYSTEM_NIFTYREG=ON -DUSE_ITK=ON -DBUILD_Gadgetron=OFF -DBUILD_CIL=ON

cmake --build . --config Release

Usual CMake build instructions apply. For instance, on some systems you might need to install a build tool such as make or Ninja (which can be done via conda). When using the latter, use cmake -G Ninja <other options from above>.

This will download, build, & install all CIL & SIRF dependencies in ~/devel/install, however without Gadgetron toolbox support (see below).

To run SIRF+CIL you need to create a shell script like the following and source it:

# activate conda environment
conda activate cilsirfbuild
# source the SIRF environment file
source ~/devel/install/bin/env_sirf.sh
# add CONDA_PREFIX/lib to LD_LIBRARY_PATH (probably not necessary)
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH

Note that ideally we'd have a requirements.yml to specify all of the above. Work in progress...

Building Gadgetron etc.

The above lines don't have all dependencies for Gadgetron, and you will therefore likely see failures. You could try to use conda to install Gadgetron as well. Please check the Gadgetron conda instructions, and add above dependencies to the suggested requirements.yml. We haven't tried this ourselves yet.