nipype.pipeline.engine.nodes module

Defines functionality for pipelined execution of interfaces

The Node class provides core functionality for batch processing.

class nipype.pipeline.engine.nodes.JoinNode(interface, name, joinsource, joinfield=None, unique=False, **kwargs)

Bases: nipype.pipeline.engine.nodes.Node

Wraps interface objects that join inputs into a list.


>>> import nipype.pipeline.engine as pe
>>> from nipype import Node, JoinNode, Workflow
>>> from nipype.interfaces.utility import IdentityInterface
>>> from nipype.interfaces import (ants, dcm2nii, fsl)
>>> wf = Workflow(name='preprocess')
>>> inputspec = Node(IdentityInterface(fields=['image']),
...                     name='inputspec')
>>> inputspec.iterables = [('image',
...                        ['img1.nii', 'img2.nii', 'img3.nii'])]
>>> img2flt = Node(fsl.ImageMaths(out_data_type='float'),
...                   name='img2flt')
>>> wf.connect(inputspec, 'image', img2flt, 'in_file')
>>> average = JoinNode(ants.AverageImages(), joinsource='inputspec',
...                       joinfield='images', name='average')
>>> wf.connect(img2flt, 'out_file', average, 'images')
>>> realign = Node(fsl.FLIRT(), name='realign')
>>> wf.connect(img2flt, 'out_file', realign, 'in_file')
>>> wf.connect(average, 'output_average_image', realign, 'reference')
>>> strip = Node(fsl.BET(), name='strip')
>>> wf.connect(realign, 'out_file', strip, 'in_file')
property inputs

The JoinNode inputs include the join field overrides.

joinfield = None

the fields to join

property joinsource

the join predecessor iterable node

class nipype.pipeline.engine.nodes.MapNode(interface, iterfield, name, serial=False, nested=False, **kwargs)

Bases: nipype.pipeline.engine.nodes.Node

Wraps interface objects that need to be iterated on a list of inputs.


>>> from nipype import MapNode
>>> from nipype.interfaces import fsl
>>> realign = MapNode(fsl.MCFLIRT(), 'in_file', 'realign')
>>> realign.inputs.in_file = ['functional.nii',
...                           'functional2.nii',
...                           'functional3.nii']

Generate subnodes of a mapnode and write pre-execution report

property inputs

Return the inputs of the underlying interface


Get the number of subnodes to iterate in this MapNode

property outputs

Return the output fields of the underlying interface

set_input(parameter, val)

Set interface input value or nodewrapper attribute Priority goes to interface.

class nipype.pipeline.engine.nodes.Node(interface, name, iterables=None, itersource=None, synchronize=False, overwrite=None, needed_outputs=None, run_without_submitting=False, n_procs=None, mem_gb=0.2, **kwargs)

Bases: nipype.pipeline.engine.base.EngineBase

Wraps interface objects for use in pipeline

A Node creates a sandbox-like directory for executing the underlying interface. It will copy or link inputs into this directory to ensure that input data are not overwritten. A hash of the input state is used to determine if the Node inputs have changed and whether the node needs to be re-executed.


>>> from nipype import Node
>>> from nipype.interfaces import spm
>>> realign = Node(spm.Realign(), 'realign')
>>> realign.inputs.in_files = 'functional.nii'
>>> realign.inputs.register_to_mean = True

Retrieve a particular output of the node


Decorate the new is_cached method with hash updating to maintain backwards compatibility.


Print interface help

property inputs

Return the inputs of the underlying interface

property interface

Return the underlying interface object


Check if the interface has been run previously, and whether cached results are up-to-date.

property mem_gb

Get estimated memory (GB)

property n_procs

Get the estimated number of processes/threads

property needed_outputs

Return the location of the output directory for the node

property outputs

Return the output fields of the underlying interface

property result

Get result from result file (do not hold it in memory)


Execute the node in its directory.


updatehash (boolean) – When the hash stored in the output directory as a result of a previous run does not match that calculated for this execution, updatehash=True only updates the hash without re-running.

set_input(parameter, val)

Set interface input value


Update inputs