Nipype: Difference between revisions

From Grid5000
Jump to navigation Jump to search
No edit summary
Line 5: Line 5:


== What is Nipype? ==
== What is Nipype? ==
[[File:Fninf-05-00013-g001.jpg|150px|thumb|left]]


[https://nipype.readthedocs.io/en/latest/ Nipype] (Neuroimaging in Python Pipelines and Interfaces) is a flexible, lightweight and extensible neuroimaging data processing framework in Python. It is a community-developed initiative under the umbrella of [https://nipy.org/ Nipy]. It addresses the heterogeneous collection of specialized applications in neuroimaging: SPM in MATLAB, FSL in shell, and Nipy in Python. A uniform interface is proposed to facilitate interaction between these different packages within a single workflow.
{| border="0" cellpadding="5"
|-
|valign="top"|
 
 
|valign="top"| [[File:Fninf-05-00013-g001.jpg|thumb|left|top|180px]]
[https://nipype.readthedocs.io/en/latest/ Nipype] (Neuroimaging in Python Pipelines and Interfaces) is a flexible, lightweight and extensible neuroimaging data processing framework in Python.  
 
It is a community-developed initiative under the umbrella of [https://nipy.org/ Nipy].  
 
It addresses the heterogeneous collection of specialized applications in neuroimaging: SPM in MATLAB, FSL in shell, and Nipy in Python.  
 
'''A uniform interface''' is proposed to facilitate interaction between these different packages within a single workflow.


The source code, issues and pull requests can be found [https://github.com/nipy/nipype here].  
The source code, issues and pull requests can be found [https://github.com/nipy/nipype here].  


The fundamental parts of Nipype are Interfaces, the Workflow Engine and the Execution Plugins, as you can see in the figure at the left:
The fundamental parts of Nipype are '''Interfaces''', the '''Workflow Engine''' and the '''Execution Plugins''', as you can see in the figure at the left:
* Interface: wraps a program or function
* '''Interface''': wraps a program or function
* (Map)Node: wraps an Interface for use in a Workflow
* '''(Map)Node''': wraps an Interface for use in a Workflow
* Workflow: a graph or a forest of graphs whose edges represent data flow
* '''Workflow''': a graph or a forest of graphs whose edges represent data flow
* Plugin: a component which describes how a Workflow should be executed
* '''Plugin''': a component which describes how a Workflow should be executed
 
Among the execution plugins, you can find


Among the execution plugs, you can find anOAR plugin [https://github.com/nipy/nipype/blob/master/nipype/pipeline/plugins/oar.py here].
* an OAR plugin [https://github.com/nipy/nipype/blob/master/nipype/pipeline/plugins/oar.py here].
* an Slurm plugin [https://github.com/nipy/nipype/blob/master/nipype/pipeline/plugins/slurm.py here].
 
|}




== Installation ==
== Installation ==
<code class="command">pip</code> can be used to install the stable release of Nipype:
{{Term|location=fontend.site|cmd=<code class="command">pip install --user nipype</code>}}
It is recommended to install python dependencies within a virtual environment. To do so, execute the following commands before running the  <code class="command">pip</code> command:
{{Term|location=frontend.site|cmd=<code class="command">python3 -m venv nipype</code>}}
{{Term|location=frontend.site|cmd=<code class="command">source nipype/bin/activate</code>}}
{{Term|location=frontend.site|cmd=<code class="command">pip install nipype</code>}}


== Basic usage ==
== Basic usage ==
Let's assume that you have previously installed Nipype's dependencies and you have installed [https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FslInstallation/Linux fsl] to process the [https://openneuro.org/datasets/ds000003/versions/1.0.0 Rhyme judgment dataset] available on OpenNeuro.
Here, we present an basic example of performing pre-processing using Nipype:
<syntaxhighlight lang="python">
import nipype.interfaces.fsl as fsl
from nipype import Node, Workflow
preprocessing = Workflow(name='preprocessing')
mcflirt = Node(fsl.MCFLIRT(), name='mcflirt')
mean = Node(fsl.MeanImage(), name='mean')
preprocessing.connect(mcflirt, 'out_file', mean, 'in_file')
mcflirt.inputs.in_file = '/home/ychi/nipype/ds000003/sub-01/func/sub-01_task-rhymejudgment_bold.nii.gz'
preprocessing.run()
</syntaxhighlight>


== Pydra==  
== Pydra==  

Revision as of 17:10, 6 November 2023

Note.png Note

This page is actively maintained by the Grid'5000 team. If you encounter problems, please report them (see the Support page). Additionally, as it is a wiki page, you are free to make minor corrections yourself if needed. If you would like to suggest a more fundamental change, please contact the Grid'5000 team.

Nipype

What is Nipype?


Fninf-05-00013-g001.jpg

Nipype (Neuroimaging in Python Pipelines and Interfaces) is a flexible, lightweight and extensible neuroimaging data processing framework in Python.

It is a community-developed initiative under the umbrella of Nipy.

It addresses the heterogeneous collection of specialized applications in neuroimaging: SPM in MATLAB, FSL in shell, and Nipy in Python.

A uniform interface is proposed to facilitate interaction between these different packages within a single workflow.

The source code, issues and pull requests can be found here.

The fundamental parts of Nipype are Interfaces, the Workflow Engine and the Execution Plugins, as you can see in the figure at the left:

  • Interface: wraps a program or function
  • (Map)Node: wraps an Interface for use in a Workflow
  • Workflow: a graph or a forest of graphs whose edges represent data flow
  • Plugin: a component which describes how a Workflow should be executed

Among the execution plugins, you can find

  • an OAR plugin here.
  • an Slurm plugin here.


Installation

pip can be used to install the stable release of Nipype:

Terminal.png fontend.site:
pip install --user nipype

It is recommended to install python dependencies within a virtual environment. To do so, execute the following commands before running the pip command:

Terminal.png frontend.site:
python3 -m venv nipype
Terminal.png frontend.site:
source nipype/bin/activate
Terminal.png frontend.site:
pip install nipype


Basic usage

Let's assume that you have previously installed Nipype's dependencies and you have installed fsl to process the Rhyme judgment dataset available on OpenNeuro.

Here, we present an basic example of performing pre-processing using Nipype:

import nipype.interfaces.fsl as fsl
from nipype import Node, Workflow

preprocessing = Workflow(name='preprocessing')

mcflirt = Node(fsl.MCFLIRT(), name='mcflirt')

mean = Node(fsl.MeanImage(), name='mean')

preprocessing.connect(mcflirt, 'out_file', mean, 'in_file')

mcflirt.inputs.in_file = '/home/ychi/nipype/ds000003/sub-01/func/sub-01_task-rhymejudgment_bold.nii.gz'

preprocessing.run()

Pydra

Pydra is a part of the second generation of the Nipype ecosystem, which is meant to provide additional flexibility and reproducibility. Pydra rewrites Nipype engine with mapping and joining as first-class operations. However, Pydra does not have OAR Support. Examples and details of Pydra's OAR extension can be found here.