Installing and building ITK-SNAP on a UNIX System

SnAP is distributed as a part of the ITK Applications installation. In order to build SNAP on a UNIX or Linux platform, you must install ITK, VTK and FLTK on their system. This document will guide you through that process.

An alternative to building SNAP is to download a binary version from itksnap.org; versions for Microsoft Windows and Linux are available there.

The following software must be installed on your system:

1. Directory Structure

Create the following directory structure, which is recommended and will be assumed in this document. Replace the directory basedir with your own directory name, i.e., /home/myuserid/tk. Experienced users can change the names and order of the subdirectories to their preference.

  basedir/
  basedir/app                          // Base directory for ITK applications
  basedir/app/bingcc                   // ITK Applications binary directory
  
  basedir/itk                          // Base directory for ITK
  basedir/itk/bingcc                   // ITK binary directory

  basedir/vtk                          // Base directory for VTK
  basedir/vtk/bingcc                   // VTK binary directory

  basedir/fltk                         // FLTK directory

2. Install and Build ITK

We will use CVS to download ITK. For more instructions, please refer to the ITK Software Guide located at www.itk.org

These instructions recommend that you download the release 2.6 of ITK. To use the latest version of ITK (at your own risk), remove the -r option in the cvs commands below.

  1. Go to the ITK root directory:
        cd [basedir]/itk
      
  2. Execute the following commands to download ITK. This will take several minutes.
        cvs -d :pserver:anonymous@www.itk.org:/cvsroot/Insight login
        (respond with password insight)
        
        cvs -d :pserver:anonymous@www.itk.org:/cvsroot/Insight co -r ITK-2-6 Insight 
      
  3. Go to the ITK build directory:
        cd [basedir]/itk/bingcc
      
  4. Execute the CMake command:
        ccmake ../Insight
      
  5. The CMake user interface will appear. Set the following options in this interface:
        BUILD_EXAMPLES = OFF
        BUILD_TESTING = OFF
        BUILD_SHARED_LIBS = OFF
        CMAKE_BUILD_TYPE = Release
      
  6. Use the c command (configure) one or more times until the g command (generate) becomes available. Then use the g command to generate makefiles.

  7. The following command will build ITK. This will take a while.
        make
      

At this point, you will have a working installation of ITK on your system. Please refer to ITK documentation for troubleshooting information.

3. Install and Build VTK

VTK installation is similar to the installation of ITK.

These instructions recommend that you download the release 4.4 of VTK. To use the latest version of VTK (at your own risk), remove the -r option in the cvs commands below.

  1. Go to the vtk root directory:
        cd [basedir]/vtk
      
  2. Execute the following commands to download VTK. This will take several minutes.
        cvs -d :pserver:anonymous@public.kitware.com:/cvsroot/VTK login
        (respond with password vtk)
    
        cvs -d :pserver:anonymous@public.kitware.com:/cvsroot/VTK co -r release-4-4 VTK 
      
  3. Go to the vtk build directory:
        cd [basedir]/vtk/bingcc
      
  4. Execute the CMake command:
        ccmake ../VTK
      
  5. The CMake user interface will appear. Set the following options in this interface:
        BUILD_EXAMPLES = OFF
        BUILD_TESTING = OFF
        CMAKE_BUILD_TYPE = Release
        VTK_USE_HYBRID = ON
        VTK_USE_PARALLEL= ON
        VTK_USE_RENDERING= ON
      
  6. Use the t command to show advanced VTK options, and set the following options:
        VTK_USE_ANSI_STDLIB = ON
        VTK_USE_SYSTEM_PNG = ON
        VTK_USE_SYSTEM_JPEG = ON
      
  7. Use the c command to configure VTK and use the g command to generate makefiles

  8. The following command will build VTK. This will take a longer while.
        make
      

At this point, you will have a working installation of ITK and VTK on your system. Please refer to VTK documentation (at www.vtk.org) for troubleshooting information.

4. Install and Build FLTK

FLTK is a multiplatform GUI toolkit. SnAP has been developed and tested using version 1.1.2 of FLTK, but later 1.1.* versions should work as well. In all the following commands, replace the * character with the correct version number, the current version is 1.1.4

  1. Download the 1.1.x FLTK tarball fltk-1.1.*-source.tar.gz from www.fltk.org/software.php. You will have to follow some links to start the download.

  2. Place the downloaded file fltk-1.1.*-source.tar.gz into the basedir/fltk directory. Execute the following command to uncompress FLTK
        cd [basedir]/fltk
        tar -xzvf fltk-1.1.*-source.tar.gz 
      
  3. [Optional]. To enable anti-aliased fonts on Linux, in the following step pass the option --enable-xft to the ./configure command. You will also need to specify the advanced option SNAP_USE_XFT_LIBRARY in Step 5.5

  4. [Optional]. If you don't have root access, in the following step pass the option --prefix=DIR where DIR is the directory where you want FLTK installed. Make sure that this directory exists! If you do this, you don't need to execute the su command below.

  5. Execute the following commands to build and install FLTK:
        cd [basedir]/fltk/fltk-1.1.*
        ./configure                           # See notes above for options
        make
        su                                    # Not required, see note above
        make install
        exit                                  # Only if you executed 'su'
      

At this point, you will have a working installation of FLTK on your system. Please refer to FLTK documentation (at www.fltk.org) for troubleshooting information.

5. Install and Build the ITK ITKApps directory

We will use CVS to download ITK Applications, including SNAP. For more instructions, please refer to the ITK Software Guide located at www.itk.org

  1. Enter the root directory for appilcations:
        cd [basedir]/app
      
  2. Execute the following command to download ITK Applications. This will take several minutes.
        cvs -d :pserver:anonymous@www.itk.org:/cvsroot/Insight co ITKApps
      
  3. Enter the build directory for appilcations:
        cd [basedir]/app/bingcc
      
  4. Execute the CMake command:
        ccmake ../ITKApps
      
  5. The CMake user interface will appear. Set the following options in this interface:
        BUILD_EXAMPLES = OFF
        BUILD_TESTING = OFF
        CMAKE_BUILD_TYPE = Release
        ITK_DIR = [basedir]/itk/bingcc
        USE_VTK = ON
        USE_FLTK = ON
      
  6. Use the c command to configure ITKApps. More options will appear:
  7.     VTK_DIR = [basedir]/vtk/bingcc
      
  8. [Linux, Optional]: If you installed FLTK in a non-system directory, you will need to point to it. You will probably need to only specify the first of these options, the rest will likely be filled in for you.
  9.     FLTK_INCLUDE_DIR = [dir]/include                # dir = Directory where you installed fltk
        FLTK_BASE_LIBRARY = [dir]/lib/libfltk.a
        FLTK_FORMS_LIBRARY = [dir]/lib/libfltk_forms.a
        FLTK_GL_LIBRARY = [dir]/lib/libfltk_gl.a
        FLTK_IMAGES_LIBRARY = [dir]/lib/libfltk_images.a
        FLTK_FLUID_EXECUTABLE = [dir]/bin/fluid
      
  10. [Optional]: You can specify the following additional advanced options (press t to toggle advanced mode)
  11.     USE_VTK_PATENTED                # Whether to use patented code. You must have a license
                                        # for using patented code from VTK to do this!
        SNAP_USE_XFT_LIBRARY            # Use if you built FLTK with --enable-xft
      
  12. Use the c command to configure ITKApps and use the g command to generate makefiles

  13. To build all ITK Applications, including SNAP, execute the following command. Alternatively, to only build SNAP, first change directory to basedir/app/bingcc/SNAP and run the same command.
        make
      

At this point, you will have a working installation of ITK ITKApps on your system. Please refer to ITK documentation for troubleshooting information.

6. Running SNAP

  1. Enter the SNAP binary directory:
        cd [basedir]/app/bingcc/SNAP
      
  2. Run the SNAP executable
        ./InsightSNAP
      
If all goes well, SNAP user interface will launch.

7. Installing SNAP to a Different Directory

You may wish to extract the files needed to run SNAP into a separate directory. To do so, execute the following commands:

  1. Copy the ITK-SNAP executable and program data to the destination directory (it can be any directory on your system, in this example we use /opt/snap)
        su
        mkdir /opt/snap                 # Replace /opt with desired directory      
        cp [basedir]/app/bingcc/SNAP/InsightSNAP /opt/snap
        cp -a [basedir]/app/bingcc/SNAP/ProgramData /opt/snap
    
  2. [Optional]. Create a symbolic link to the SNAP executable to make it easily accessible to all users on your system.
        ln -s /opt/snap/InsightSNAP /usr/local/InsightSNAP
      
  3. [Optional]. You may now delete directory [basedir] and its contents. However, we recommend that you keep the build tree intact in order to make future updates easier.

8. Troubleshooting

For troubleshooting the installation of ITK, VTK, FLTK and ITKApps, please refer to the corresponding web sites noted above

We recommend that you join the ITK-SNAP Forum or the ITK Users' Mailing List, where you can find answers to questions posed by other users as well as post your own questions.