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.
Examples
>>> 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¶
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.
Examples
>>> 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'] >>> realign.run()
- get_subnodes()¶
Generate subnodes of a mapnode and write pre-execution report
- property inputs¶
Return the inputs of the underlying interface
- num_subnodes()¶
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.
Examples
>>> 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 >>> realign.run()
- get_output(parameter)¶
Retrieve a particular output of the node
- hash_exists(updatehash=False)¶
Decorate the new is_cached method with hash updating to maintain backwards compatibility.
- help()¶
Print interface help
- property inputs¶
Return the inputs of the underlying interface
- property interface¶
Return the underlying interface object
- is_cached(rm_outdated=False)¶
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¶
- output_dir()¶
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)
- run(updatehash=False)¶
Execute the node in its directory.
- Parameters:
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(**opts)¶
Update inputs
- class nipype.pipeline.engine.nodes.NodeExecutionError¶
Bases:
RuntimeError
A nipype-specific name for exceptions when executing a Node.