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/itksnap                      // Base directory for ITK-SNAP
  basedir/itksnap/bingcc               // ITK-SNAP 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
  basedir/fltk/bingcc                  // 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. We will use FLTK version 1.1.7, which is CMake-friendly

  1. Download the 1.1.7 FLTK tarball fltk-1.1.7-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.7-source.tar.gz into the basedir/fltk directory. Execute the following command to uncompress FLTK
        cd [basedir]/fltk
        tar -xzvf fltk-1.1.7-source.tar.gz 
      
  3. Go to the FLTK build directory:
        cd [basedir]/fltk/bingcc
      
  4. Execute the CMake command:
        ccmake ../fltk-1.1.7
      
  5. The CMake user interface will appear. Set the following options in this interface:
        BUILD_EXAMPLES = OFF
        CMAKE_BUILD_TYPE = Release
      
  6. Use the c command to configure FLTK and use the g command to generate makefiles

  7. The following command will build FLTK. This will be fairly fast
        make
      

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 ITK-SNAP

We will use CVS to download ITK-SNAP. SNAP is included as part of InsightApplications in ITK. However, starting with version 1.4.1, only major releases of SNAP will be placed in InsightApplications. Day-to-day development and interim releases use the SourceForge CVS, which is independent of ITK. We recommend that you use the SourceForge CVS links given below to download ITK-SNAP

  1. Enter the root directory for appilcations:
        cd [basedir]/itksnap
      
  2. Execute the following command to download ITK-SNAP. This will take several minutes. If you want a specific release, e.g., release 1.4.1., then add -r ITKSNAP-1-4-1 after the co command.
        cvs -d:pserver:anonymous@itk-snap.cvs.sourceforge.net:/cvsroot/itk-snap login
        (respond with empty password)
    
        cvs -z3 -d:pserver:anonymous@itk-snap.cvs.sourceforge.net:/cvsroot/itk-snap co itksnap
        cvs -d :pserver:anonymous@www.itk.org:/cvsroot/Insight co InsightApplications
      
  3. Enter the build directory for appilcations:
        cd [basedir]/itksnap/bingcc
      
  4. Execute the CMake command:
        ccmake ../InsightApplications
      
  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 InsightApplications. More options will appear:
  7.     VTK_DIR = [basedir]/vtk/bingcc
        FLTK_DIR = [basedir]/fltk/bingcc
      
  8. [Optional]: You can specify the following additional advanced options (press t to toggle advanced mode)
  9.     USE_VTK_PATENTED                # Whether to use patented code. You must have a license
                                        # for using patented code from VTK to do this!
      
  10. Use the c command to configure InsightApplications and use the g command to generate makefiles

  11. To build SNAP issue the following command:
        make
      

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

6. Running SNAP

  1. Enter the SNAP binary directory:
        cd [basedir]/itksnap/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]/itksnap/bingcc/InsightSNAP /opt/snap
        cp -a [basedir]/itksnap/bingcc/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 ITK-SNAP, 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.