pipeline.engine.workflows

Module: pipeline.engine.workflows

Inheritance diagram for nipype.pipeline.engine.workflows:

Inheritance diagram of nipype.pipeline.engine.workflows

Defines functionality for pipelined execution of interfaces

The Workflow class provides core functionality for batch processing.

Workflow

class nipype.pipeline.engine.workflows.Workflow(name, base_dir=None)

Bases: nipype.pipeline.engine.base.EngineBase

Controls the setup and execution of a pipeline of processes.

Methods

add_nodes(nodes) Add nodes to a workflow
clone(name) Clone a workflow
connect(\*args, \*\*kwargs) Connect nodes in the pipeline.
disconnect(\*args) Disconnect nodes See the docstring for connect for format.
export([filename, prefix, format, ...]) Export object into a different format
get_node(name) Return an internal node by name
list_node_names() List names of all nodes in a workflow
load(filename)
next()
remove_nodes(nodes) Remove nodes from a workflow
run([plugin, plugin_args, updatehash]) Execute the workflow
save([filename])
write_graph([dotfilename, graph2use, ...]) Generates a graphviz dot file and a png file
write_hierarchical_dotfile([dotfilename, ...])
__init__(name, base_dir=None)

Create a workflow object.

Parameters:

name : alphanumeric string

unique identifier for the workflow

base_dir : string, optional

path to workflow storage

add_nodes(nodes)

Add nodes to a workflow

Parameters:

nodes : list

A list of EngineBase-based objects

clone(name)

Clone a workflow

Note

Will reset attributes used for executing workflow. See _init_runtime_fields.

Parameters:

name: alphanumeric name :

unique name for the workflow

connect(*args, **kwargs)

Connect nodes in the pipeline.

This routine also checks if inputs and outputs are actually provided by the nodes that are being connected.

Creates edges in the directed graph using the nodes and edges specified in the connection_list. Uses the NetworkX method DiGraph.add_edges_from.

Parameters:

args : list or a set of four positional arguments

Four positional arguments of the form:

connect(source, sourceoutput, dest, destinput)

source : nodewrapper node sourceoutput : string (must be in source.outputs) dest : nodewrapper node destinput : string (must be in dest.inputs)

A list of 3-tuples of the following form:

[(source, target,
    [('sourceoutput/attribute', 'targetinput'),
    ...]),
...]

Or:

[(source, target, [(('sourceoutput1', func, arg2, ...),
                            'targetinput'), ...]),
...]
sourceoutput1 will always be the first argument to func
and func will be evaluated and the results sent ot targetinput

currently func needs to define all its needed imports within the
function as we use the inspect module to get at the source code
and execute it remotely
disconnect(*args)

Disconnect nodes See the docstring for connect for format.

export(filename=None, prefix=u'output', format=u'python', include_config=False)

Export object into a different format

Parameters:

filename: string :

file to save the code to; overrides prefix

prefix: string :

prefix to use for output file

format: string :

one of “python”

include_config: boolean :

whether to include node and workflow config values

fullname
get_node(name)

Return an internal node by name

inputs
itername
list_node_names()

List names of all nodes in a workflow

load(filename)
next()
outputs
remove_nodes(nodes)

Remove nodes from a workflow

Parameters:

nodes : list

A list of EngineBase-based objects

run(plugin=None, plugin_args=None, updatehash=False)

Execute the workflow

Parameters:

plugin: plugin name or object :

Plugin to use for execution. You can create your own plugins for execution.

plugin_args : dictionary containing arguments to be sent to plugin

constructor. see individual plugin doc strings for details.

save(filename=None)
write_graph(dotfilename=u'graph.dot', graph2use=u'hierarchical', format=u'png', simple_form=True)

Generates a graphviz dot file and a png file

Parameters:

graph2use: ‘orig’, ‘hierarchical’ (default), ‘flat’, ‘exec’, ‘colored’ :

orig - creates a top level graph without expanding internal workflow nodes; flat - expands workflow nodes recursively; hierarchical - expands workflow nodes recursively with a notion on hierarchy; colored - expands workflow nodes recursively with a notion on hierarchy in color; exec - expands workflows to depict iterables

format: ‘png’, ‘svg’ :

simple_form: boolean (default: True) :

Determines if the node name used in the graph should be of the form ‘nodename (package)’ when True or ‘nodename.Class.package’ when False.

write_hierarchical_dotfile(dotfilename=None, colored=False, simple_form=True)