Child pages
  • ARCHIVE - Invalid Nipype BRAINS wrapping demonstration

Nipype BRAINS Wrapping Demonstration

TODO: What we really need is a fresh machine to do the install on and all of the steps in order. As soon as I can get such a machine and root access, I will document everything needed to go from our default puppet install state to a working pipeline.

Nipype Installation

<<  Install dependancies -- add notes later >>

Download latest source code:  git clone git://

In this demonstration, we will wrap a simple BRAINS pipeline BRAINSFit and BRAINSResample into a pipeline over multiple subjects.  We will assume for the sake of this demonstration that you have a machine which currently has a working install of nipype.

Task statement: For all subjects in /hjohnson/HDNI/ixi_data/, register the T1 to the space of the file passed to our script on the command line.

1. Wrap BRAINSFit and BRAINSResample into nipype code.
1a. Download

Make sure that you download it properly. If you simply copy-paste, it can mess up spacing, which python relies on for control flow.

This script will build a nipype wrapper class for an XML-exporting command-line tool. If you wish to make it executable, add "#!/usr/bin/python" to the header and:

chmod +x
1b. Run over BRAINSFit and BRAINSResample
mkdir ~/mypython
mv BRAINS*.py ~/mypython
export PYTHON_PATH=~/mypython

This will also wrap a few other BRAINS commands, such as BRAINSDemonWarp and BRAINSROIAuto. To control what it wraps, simply adjust the module list near the top of the file; it's quite simple, and in my testing seems to work well.

2. Copy the datafiles used for the next test to your working directory, with the name "slicer_tutorial". You can find a copy in ~peasek/slicer_tutorial.
3. Run the attached file

The code has been attached to this wiki instead of inlined to prevent formatting issues, and has been documented to describe what is happening. For a related problem - remapping two sets of subjects to a file within each one's subject directory - check out It documents a slightly wider range of nipype capabilities.

Be sure to note the current limitations of nipype as described in

1) Datasinks currently behave in an undesirable manner.
2) Nipype is not symlink-aware. If your current path contains a symlink, and you try to reference a path further up the tree past your symlink, nipype will break. It converts absolute paths to relative paths using "../", which does not work when you try to go up from a symlink.

  • No labels