ITK Pre-Processing Algorithm Wrappers in Python/InstructionsForWrapITKExternalProjects

From FarsightWiki
Jump to: navigation, search

Instructions for including External Projects in ITK, and create wrappers using WrapITK

This section describes the steps needed to include an external project into ITK and create Python wrappers using WrapITK. This is adapted from [WrapITK Guide]. In this page, the steps required to build an external project AnisotropicDiffusionVesselEnhancment are described . The C++ implementation of this algorithm using ITK was done by Enquobahrie et al., and was submitted it in Insight Journal as [Vessel Enhancing Diffusion Filter]. The files required to build this are present in the folder wrappers_itk_pre-processing/AnisotropicDiffusionVesselEnhancement in the Farsight SVN trunk.

Here are the steps to build an External Project.

  1. As a first step, WrapITK must have been build with ITK. A detailed description of installing WrapITK for ITK is present in [WrapITK Guide].
  2. It is necessary to create a CMakeLists.txt file for the project, on similar lines as one would do for running any C++ file using ITK. The file used for the example project AnisotropicDiffusionVesselEnhancement is present in wrappers_itk_pre-processing/AnisotropicDiffusionVesselEnhancement/CMakeLists.txt.
  3. The source files are present in the wrappers_itk_pre-processing/AnisotropicDiffusionVesselEnhancement/src directory.
  4. The files required for creating the Python wrappers are present in wrappers_itk_pre-processing/AnisotropicDiffusionVesselEnhancement/Wrapping directory. It contains a CMakelists.txt file that describes how to create a project to build the ITK wrappers for the various classes using WrapITK. The other files (*.cmake) in the folder describe what template arguments should the wrappers be created.
  5. Once these files are present, the external project can be built. For example project, CMake can be used to create the project with the source being set to the wrapper_itk_pre-processing/AnisotropicDiffusionVesselEnhancement folder.
  6. The choice of the binary folder can be anything.
  7. After the project is build, the INSTALL project needs to be run so that the files are copied to the appropriate directories.
  8. In order to ensure that Python is able to recognize the path to the External Project python module, there should be an {EXTERNAL_PROJECT_NAME}.pth file present in the {BINARY_DIR}\{EXTERNAL_PROJECT_NAME}\Python folder. Here "{EXTERNAL_PROJECT_NAME}" should be replaced by the name of the project, which in our example will be "AnisotropicDiffusionVesselEnhancement". If an IDE is used to build the project, then it will be present in the sub-directory corresponding to the build type. This file needs to be copied into the Lib/site-packages folder of the Python installation folder. The .pth file is read by the python interpreter each time it is started, and paths present in the files are added to the Python module search path. This enables Python to load the external project module.
  9. In order to check that the installation is complete, the Python interpreter can be started and the command "import {EXTERNAL_PROJECT_NAME}" can be given. If no error is obtained, the installation is successful.
Personal tools