Skip to content
Michael Ebner edited this page Oct 19, 2017 · 61 revisions

Installation of this ITK_NiftyMIC Package:

This repository contains numerous additional filters and functions to extend the standard ITK 4.13. The installation of this extended ITK package is a necessary requirement in order to use the Volumetric MRI Reconstruction Toolkit.

In order to install ITK, clone this repository and prepare for an out-of-source build by executing

  • git clone [email protected]:GIFT-Surg/ITK_NiftyMIC.git
  • mkdir ITK_NiftyMIC-build
  • cd ITK_NiftyMIC-build

Depending on your system configuration the respective variables need to be set for the compilation. Below you will find some further instructions on what to specify.

Standard Compilation (tested on local computers running Mac OS X 10.10-10.12 and Ubuntu 14.04)

Make sure that NumPy is installed (pip install numpy --upgrade). Then compile ITK -- including Python wrapping -- by running

  • cmake \ -D CMAKE_BUILD_TYPE=Release \ -D BUILD_TESTING=OFF \ -D BUILD_EXAMPLES=OFF \ -D BUILD_SHARED_LIBS=ON \ -D ITK_WRAP_PYTHON=ON \ -D ITK_LEGACY_SILENT=ON \ -D ITK_WRAP_float=ON \ -D ITK_WRAP_double=ON \ -D ITK_WRAP_signed_char=ON \ -D ITK_WRAP_signed_long=ON \ -D ITK_WRAP_signed_short=ON \ -D ITK_WRAP_unsigned_char=ON \ -D ITK_WRAP_unsigned_long=ON \ -D ITK_WRAP_unsigned_short=ON \ -D ITK_WRAP_vector_float=ON \ -D ITK_WRAP_vector_double=ON \ -D ITK_WRAP_covariant_vector_double=ON \ -D Module_ITKReview=ON \ -D Module_SmoothingRecursiveYvvGaussianFilter=ON \ -D Module_BridgeNumPy=ON \ ../ITK/
  • make -j8

Once the compilation was successful (which can take about 4 hours -- at least on my machine), the ITK path file needs to be linked so that Python can access it. More information on that is provided in "Link files to Python" below.

Compilation on UCL cluster (comic/wise)

First, enter the wise login node via

  • ssh wise

and change to gcc 4.9.2 via

  • source /opt/rh/devtoolset-3/enable

Both steps are required since comic threw an error message I couldn't get rid of during compilation saying "cc1plus: out of memory allocating 4064 bytes after a total of 145620992 bytes". Changing to wise doubled the memory (you can check via the command free) and using gcc 4.9.2 has worked too. (However, I didn't try compiling at wise without changing to gcc 4.9.2. So, this step might not be required).

For the compilation on the cluster I used cmake 3.6.2 with the following command

  • /share/apps/cmake-3.6.2/bin/cmake \ -D CMAKE_BUILD_TYPE=Release \ -D BUILD_TESTING=OFF \ -D BUILD_EXAMPLES=OFF \ -D BUILD_SHARED_LIBS=ON \ -D ITK_WRAP_PYTHON=ON \ -D ITK_LEGACY_SILENT=ON \ -D ITK_WRAP_float=ON \ -D ITK_WRAP_double=ON \ -D ITK_WRAP_signed_char=ON \ -D ITK_WRAP_signed_long=ON \ -D ITK_WRAP_signed_short=ON \ -D ITK_WRAP_unsigned_char=ON \ -D ITK_WRAP_unsigned_long=ON \ -D ITK_WRAP_unsigned_short=ON \ -D ITK_WRAP_vector_float=ON \ -D ITK_WRAP_vector_double=ON \ -D ITK_WRAP_covariant_vector_double=ON \ -D Module_ITKReview=ON \ -D Module_SmoothingRecursiveYvvGaussianFilter=ON \ -D Module_BridgeNumPy=ON \ -D NUMPY_INCLUDE_DIR=/home/mebner/extern/lib/python2.7/site-packages/numpy/core/include \ -D PYTHON_EXECUTABLE=/home/mebner/extern/bin/python2.7 \ -D PYTHON_INCLUDE_DIR=/home/mebner/extern/include/python2.7 \ -D PYTHON_LIBRARY=/home/mebner/extern/lib/libpython2.7.so \ -D PY_SITE_PACKAGES_PATH=/home/mebner/extern/lib/python2.7/site-packages \ ../ITK/

whereby python-2.7.12 was installed on the cluster as described below in section "Python on cluster". Then, run with a maxium of 4 threads on the login node (to use less memory) via

  • make -j4

It might be that the error "cc1plus: out of memory" still occurs but rerunning again with make -j4 worked out for me. So, maybe trying make -j2 in the first place (and bearing with slower compilation) will solve it entirely?

Link files to Python

In case you use a virtual environment, activate it first. Then, run the following command to find the path directory Python searches:

  • SITEDIR=$(python -m site --user-site)

Create the folder in case it does not already exist:

  • mkdir -p "$SITEDIR"

Copy the path-file to ITK:

  • cp Wrapping/Generators/Python/WrapITK.pth $SITEDIR

Usage: WrapITK in Python

ITK should now be available in Python. Check it by opening IPython and importing ITK, i.e.

  • ipython
  • import itk

You can check that everything was properly included by running an ITK command, e.g. print(itk.Image.D3.New()). In case everything went fine without any error you are ready to go to use ITK within Python now.

Notes

  • In case you encounter problems during compilation on Mac with an error message stating that the MD5 hash regarding Wrapping/Generators/CastXML/castxml-prefix/src/castxml-macosx.tar.gzdoes not match the expected value, download the file from here instead and replace it accordingly. For whatever reason, I have been having that problem for some time now when I compile for the first time again and could not get rid of it yet. On Linux, I haven't had that issue.
  • Similarly, when you attempt to commit to the git repository there might be an issue associated to KWStyle. In case that happens, copy the folders KWStyle-build and KWStyle-prefix to the build folder.

Collection of other installation instructions (for future reference)

Python on cluster

To install Python on the cluster the instructions on LinuxFromScratch are followed but with --prefix=/home/mebner/extern.

In .bashrc add the following lines

  • export PATH="/home/mebner/extern/bin:$PATH" export LD_LIBRARY_PATH="/home/mebner/extern/lib:${LD_LIBRARY_PATH}" export CPATH="/home/mebner/extern/include:${CPATH}" export PYTHONPATH=/home/mebner/extern/lib/python2.7/site-packages:$PYTHONPATH

Once this is done, set up a virtual environment with

  • virtualenv -p /share/apps/python-2.7.11-shared/bin/python2.7 /home/mebner/development/Python_virtualenv

and add the lines

  • export PATH="/home/mebner/development/NiftyReg/NiftyReg-build/install/bin:$PATH" export LD_LIBRARY_PATH="/home/mebner/development/NiftyReg/NiftyReg-build/install/lib:${LD_LIBRARY_PATH}" export LD_LIBRARY_PATH="/home/mebner/extern/lib:${LD_LIBRARY_PATH}" export CPATH="/home/mebner/extern/include:${CPATH}" export VOLUMETRIC_RECONSTRUCTION_DIR="/home/mebner/development/VolumetricReconstruction/"

at the end of /home/mebner/development/Python_virtualenv/bin/activate

Clone this wiki locally