Nipype Example: Cortical Surface Extraction

Acquiring the tutorial data

Download the tutorial data manually here, then unzip it into your ~/Documents directory.
Or, use the bash commands provided below:

curl -o “”
unzip -o -qq -d ~/Documents

Acquiring the workflow

We have created a sample workflow that uses the BrainSuite Nipype interface to run through the Cortical Surface Extraction routine. This workflow can also be used as a learning tool to help new users understand the basic syntax for setting up a Nipype workflow in Python. Download the workflow manually here, or run the following bash command to download the workflow:

curl -o “”

Running the workflow

The Nipype workflow must be run from the terminal. Cd to the directory where you saved, and run the following bash command:


Tips for creating your own workflows

  1. To use Nipype in a Python script, we must always import nipype’s pipeline engine:
    import nipype.pipeline.engine as pe
  2. Then import the interfaces you wish to use. The interfaces provide various classes that wrap command line executables. BSE and BFC are two examples of classes that are provided by the BrainSuite interface. In our example, we are only using the BrainSuite interface:
    import nipype.interfaces.brainsuite as bs
  3. Using the Node function of Nipype’s Pipeline engine, create Nipype nodes that contain an instance of an interface class:
    bse = pe.Node(interface=bs.Bse(), name=’BSE’)
  4. Not sure what to do next? Every class has a .help() method. Try running the following command:

    You can find the same help information for all of our classes on Nipype’s auto-generated documentation page, found here.

  5. You must specify all [Mandatory] inputs either by assigning a value to the mandatory input, or by connecting the output from another class to the mandatory input.

Additional information can be found on Nipype’s Interfaces tutorials, and Nipype’s Pipeline tutorials.

The file 2523412.nii.gz is part of the Beijing Enhanced dataset, released by Beijing Normal University as part of the International Neuroimaging Datasharing Initiative (INDI) under a Creative Commons Attribution-NonCommerical 3.0 Unported License (CC-BY-NC). More information on the complete dataset is available online here, and it can be downloaded from NITRC.