Difference between revisions of "User:Mseeland"

From NAMIC Wiki
Jump to: navigation, search
Line 109: Line 109:
 
* This code is enabled by compiling Teem with TEEM_LEVMAR defined. The include paths and library link paths need also be defined for everything to work.
 
* This code is enabled by compiling Teem with TEEM_LEVMAR defined. The include paths and library link paths need also be defined for everything to work.
 
* There are problems compiling LEVMAR with cmake. I found no way to create a build of levmar that allows Teem to say in Teem's CMakeLists.txt simply: FIND_PACKAGE(LEVMAR)). Therefore I compiled levmar myself and then changed Teem's CMake stuff so that the user sets the Teem_LEVMAR_LIB and Teem_LEVMAR_IPATH variables directly (so that the user does by hand what's normally done by "FIND_PACKAGE(LEVMAR)",
 
* There are problems compiling LEVMAR with cmake. I found no way to create a build of levmar that allows Teem to say in Teem's CMakeLists.txt simply: FIND_PACKAGE(LEVMAR)). Therefore I compiled levmar myself and then changed Teem's CMake stuff so that the user sets the Teem_LEVMAR_LIB and Teem_LEVMAR_IPATH variables directly (so that the user does by hand what's normally done by "FIND_PACKAGE(LEVMAR)",
 +
 +
====Python processing package====
 +
 +
* This package needs to be downloaded here:
 +
http://pypi.python.org/pypi/processing
  
 
==Status/Progress==
 
==Status/Progress==

Revision as of 05:36, 22 April 2009

Wiki of Madeleine Seeland

General Information

About myself

I am a grad student of Management Information Systems at the University of Mannheim, Germany. I'm involved in the Diffusion Tensor Imaging (DTI) project in the Laboratory of Mathematics in Imaging. Currently I'm working on two-tensor tractograohy for Neurosurgery. I will document my research experience as a diploma thesis, which I need for completing my studies in Germany.

Contact information

E-mail: mseeland (at sign) bwh.harvard.edu

Collaborators & Contacts

  • Supervisors: C-F Westin, Nobuhiko Hata
  • Gordon Kindlmann (Teem)
  • Sharon Peled
  • Alireza Radmanesh
  • Isaiah Norton
  • Regarding Python: Steve Pieper, Julien de Siebenthal, Sylvain Bouix, Demian Wassermann, Luca Antiga

Project: Two-Tensor Tractography integration into Slicer

Project Description

  • Integration of Two-Tensor Tractography into Slicer using Python and the novel Python wrapping for Teem
  • Use of existing tractography methods in Teem (http://teem.sourceforge.net/)
  • My part: Interface between Slicer->Python->Teem and Teem->Python->Slicer
    • pass data from VTK through Python to Teem
    • make use of Teem tractography function calls
    • pass resulting fiber data from Teem to Python to VTK and display fiber tracts in Slicer

How to enable Python in Slicer 3.3

  • The current version of Slicer, Slicer 3.2, does not support Python. In order to use Python you need to install Slicer 3.3.
  • To build Slicer Version 3.3, just do the following two commands:
 svn co http://svn.slicer.org/Slicer3/trunk Slicer3
 ./Slicer3/Scripts/getbuildtest.tcl
  • In Slicer 3.3, Python support is disabled by default. In order to enable Python, just follow the next steps:
  1. Edit slicer_variables.tcl
    1. Change "set ::USE_PYTHON "off"" to "on"
  2. Optional: If you prefer to use your system Python installation, see here: [1]
  3. Optional: installing SciPy, see here: [2]. However, there are still problems adding scipy in Slicer, whcih are not fixed yet.
  • Rebuild Slicer3 using "getbuildtest.tcl":
./Slicer3/Scripts/getbuildtest.tcl

A new menu command Python Interpreter should appear on the Window menu in Slicer. This command should bring up the Python Console window.


Requirements for running the Two-Tensor Tractography method

Teem Python wrapping

BACKGROUND
  • Teem Python wrapping is needed to make use of existing Two-Tensor tractography functions in Teem in Python
  • The Python wrappings are based on ctypes, as well as a ctypes code generator (called "ctypeslib")
  • Ctypes is a standard part of python, by which C functions in a shared library can be called from Python
  • The ctypes code generator converts declarations in C header files into executable Python code: enums, structs, unions, function declarations, com interfaces, and preprocessor definitions.
  • Creating wrappers for C header file(s) is a two step process.
    • First, the ``h2xml.py`` script runs GCC-XML_ over the include file(s), creating a XML file containing declarations and definitions.
    • Second, the ``xml2py.py`` script parses the XML files and creates Python code containing all or a subset of these definitions.
  • Python code is generated for C enums, structure, unions, typedefs and function declarations.
REQUIREMENTS
  • Ctypeslib: ctypeslib is an extension package for ctypes. It contains a ctypes code generator.
  • GCC-XML (from http://www.gccxml.org/) is required to parse C header files into an XML description.
GETTING THE SOFTWARE
 http://svn.python.org/projects/ctypes/branches/ctypeslib-gccxml-0.9
  • But this requires some patches to work; the content of the "fixes.patch" file can be found here: [[3]]:
  svn co http://svn.python.org/projects/ctypes/branches/ctypeslib-gccxml-0.9
  cd ctypeslib-gccxml-0.9
  patch -p0 < ../fixes.patch
  cd ..
  • ctypeslib is written in python => there's nothing new to compile at this point
CREATING PYTHON/TEEM
  • First get Teem (starting from whatever directory should contain the "teem" source dir):
 svn co https://teem.svn.sourceforge.net/svnroot/teem/teem/trunk teem

and compile it as a shared library. Directions for doing this with cmake are here:

 http://teem.sourceforge.net/build.html
  • create the wrappings in a new directory (e.g. "teem-wrap"), where the XML and Python output will be
  • Set the environment variables that identify where Teem and ctypeslib are:
    • TEEM is where Teem's "make install" put subdirectories "bin", "lib", and "include" (e.g. ~/teem-build)
    • CTYPES is the full path of ctypeslib-gccxml-0.9
  • First create (in, for example, "teem-wrap") a meta-header for all the Teem header files (in tcsh):
  mkdir teemincl
  cp -r ${TEEM}/include/teem teemincl
  cd teemincl
  ls -1 teem/*.h | awk '{print "#include <"$1">"}' > all.h
  cd ..
  • Then create teem.xml:
  setenv PYTHONPATH $CTYPES
  python $CTYPES/scripts/h2xml.py `pwd`/teemincl/all.h -I teemincl -o teem.xml 
  • Then create teem.py (use DYLD_LIBRARY_PATH in a mac):
  setenv LD_LIBRARY_PATH ${TEEM}/lib
  python $CTYPES/scripts/xml2py.py teem.xml -llibteem.so -o teem.py \
       -r "(air|hest|biff|nrrd|ell|unrrdu|moss|gage|bane|limn|seek|hoover|echo|ten|dye|mite).*"

LEVMAR

  • The 2-tensor tractography depends on Levenberg-Marquardt nonlinear optimization of Sharon Peled's constrained two-tensor model. I used the following implementation for it: http://www.ics.forth.gr/~lourakis/levmar/
  • This code is enabled by compiling Teem with TEEM_LEVMAR defined. The include paths and library link paths need also be defined for everything to work.
  • There are problems compiling LEVMAR with cmake. I found no way to create a build of levmar that allows Teem to say in Teem's CMakeLists.txt simply: FIND_PACKAGE(LEVMAR)). Therefore I compiled levmar myself and then changed Teem's CMake stuff so that the user sets the Teem_LEVMAR_LIB and Teem_LEVMAR_IPATH variables directly (so that the user does by hand what's normally done by "FIND_PACKAGE(LEVMAR)",

Python processing package

  • This package needs to be downloaded here:

http://pypi.python.org/pypi/processing

Status/Progress

Month Week # Start Date - End Date Done Date Done
Find optimal parameter setting of the Two-Tensor Tractography method
Extend Two-Tensor Tractography module by fiducial seeding x
NA-MIC Project Week in Salt Lake City ([4],[5]) x
January Week 2 05.01 - 11.01
IGT Project Week x
Week 50 08.12 - 14.12
x
December Week 49 01.12 - 07.12
Try to compile teem with levmar (= Levenberg-Marquardt nonlinear least squares algorithm) x Mon Dec, 1st
Week 48 24.11 - 30.11
document the results of the two-tensor tractography given a tensor volume x
Try to do mutli trace tractography given a DWI volume x Mon Nov, 17th
Week 47 17.11 - 23.11
Working on Python tractography module for multi fiber tracing given a tensor volume x Mon Nov, 17th
Week 46 10.11 - 16.11
Get vertex data out of the nvert nrrd filled by the tractography back to Slicer x
Try to pass image data from Python to Teem through nrrdWrap_nva function x
Try to generate a list of point locations that were used as tractography seedpoints in the VTK tractography x Thu Nov, 13th
Implement Python tractography module for single fiber tracing given a seeding starting point and a tensor volume x Fri, Nov, 7th
Week 45 03.11 - 09.11
Try to get image data from numpy (= Python package) to Teem nrrd struct x
November Week 44 27.10 - 02.11
Try to get image data from numpy (= Python package) to Teem nrrd struct x
Week 43 20.10 - 26.10
Try to access DWI volumes through Python x Fri Oct, 17th
Get Teem wrapped in Python x Fri Oct, 19th
Week 42 13.10 - 19.10
Try to implement the seeding part of the (VTK) one-tensor tractography module in Python x Tue Oct, 14th
Week 41 06.10 - 12.10
Try to implement the seeding part of the (VTK) one-tensor tractography module in Python x Tue Oct, 14th
October Week 40 29.09 - 5.10
Totally understand existing Python modules in Slicer x
understand existing one-tensor streamline tractography in Slicer (VTK) x Tue Sep, 23rd
Totally understand existing Python modules in Slicer x Tue Sep, 23rd
Week 39 22.09 - 28.09
Slicer & Python Tutorials x
Enable Python in Slicer x Mon Sep, 22nd
September Week 38 14.09 - 21.09

Information

Python: