Fastr User Reference¶
-
fastr.
tools
¶ A ToolManager containing all versions of all Tools loaded into the FASTR environment. The ToolManager can be indexed using the Tool id string or a tool id string and a version. For example if you have two versions (4.5 and 4.8) of a tool called Elastix:
>>> fastr.tools['elastix.Elastix'] Tool Elastix v4.8 (Elastix Registration) Inputs | Outputs -------------------------------------------------------------------------------------------------- fixed_image (ITKImageFile) | directory (Directory) moving_image (ITKImageFile) | transform (ElastixTransformFile) parameters (ElastixParameterFile) | log_file (ElastixLogFile) fixed_mask (ITKImageFile) | moving_mask (ITKImageFile) | initial_transform (ElastixTransformFile) | priority (__Elastix_4.8_interface__priority__Enum__) | threads (Int) | >>> fastr.tools['elastix.Elastix', '4.5'] Tool Elastix v4.5 (Elastix Registration) Inputs | Outputs -------------------------------------------------------------------------------------------------- fixed_image (ITKImageFile) | directory (Directory) moving_image (ITKImageFile) | transform (ElastixTransformFile) parameters (ElastixParameterFile) | log_file (ElastixLogFile) fixed_mask (ITKImageFile) | moving_mask (ITKImageFile) | initial_transform (ElastixTransformFile) | priority (__Elastix_4.5_interface__priority__Enum__) | threads (Int) |
-
fastr.
types
¶ A dictionary containing all types loaded into the FASTR environment. The keys are the typenames and the values are the classes.
-
fastr.
networks
¶ A dictionary containing all networks loaded in fastr
-
api.
create_network
(version=None)¶ Create a new Network object
-
api.
create_network_copy
()¶ Create a network based on another Network state. The network state can be a Network or the state gotten from a Network with __getstate__.
-
class
fastr.api.
Network
(id, version=None)[source]¶ Representation of a Network for the creating and adapting Networks
-
create_constant
(datatype, data, id=None, step_id=None, resources=None, node_group=None)[source]¶ Create a ConstantNode in this Network. The Node will be automatically added to the Network.
- Parameters
datatype (
Union
[BaseDataType
,str
]) – The DataType of the constant nodedata (
Dict
[str
,Union
[List
[Union
[str
,Tuple
[str
, …]]],Dict
[str
,Union
[str
,Tuple
[str
, …]]]]]) – The data to hold in the constant nodeid (
Optional
[str
]) – The id of the constant node to be createdstep_id (
Optional
[str
]) – The step to add the created constant node toresources (
Optional
[ResourceLimit
]) – The resources required to run this nodenode_group (
Optional
[str
]) – The group the node belongs to, this can be important for FlowNodes and such, as they will have matching dimension names.
- Return type
- Returns
the newly created constant node
-
create_link
(source, target, id=None, collapse=None, expand=False)[source]¶ Create a link between two Nodes and add it to the current Network.
- Parameters
source (
Union
[Input
,BaseInput
]) – the output that is the source of the linktarget (
Union
[Output
,BaseOutput
]) – the input that is the target of the linkcollapse (
Optional
[Tuple
[Union
[int
,str
], …]]) – The dimensions to collapse in this link.expand (
bool
) – Flag to expand cardinality into a new dimension
- Return type
- Returns
the created link
-
create_macro
(network, id=None)[source]¶ Create macro node (a node which actually contains a network used as node inside another network).
- Parameters
- Return type
- Returns
the newly created node
-
create_node
(tool, tool_version, id=None, step_id=None, resources=None, node_group=None)[source]¶ Create a Node in this Network. The Node will be automatically added to the Network.
- Parameters
tool (
Union
[Tool
,str
]) – The Tool to base the Node on in the form:name/space/toolname:version
tool_version (
str
) – The version of the tool wrapper to usestep_id (
Optional
[str
]) – The step to add the created node toresources (
Optional
[ResourceLimit
]) – The resources required to run this nodenode_group (
Optional
[str
]) – The group the node belongs to, this can be important for FlowNodes and such, as they will have matching dimension names.
- Return type
- Returns
the newly created node
-
create_sink
(datatype, id=None, step_id=None, resources=None, node_group=None)[source]¶ Create a SinkNode in this Network. The Node will be automatically added to the Network.
- Parameters
datatype (
Union
[BaseDataType
,str
]) – The DataType of the sink nodestep_id (
Optional
[str
]) – The step to add the created sink node toresources (
Optional
[ResourceLimit
]) – The resources required to run this nodenode_group (str) – The group the node belongs to, this can be important for FlowNodes and such, as they will have matching dimension names.
- Return type
- Returns
the newly created sink node
-
create_source
(datatype, id=None, step_id=None, resources=None, node_group=None)[source]¶ Create a SourceNode in this Network. The Node will be automatically added to the Network.
- Parameters
datatype (
BaseDataType
) – The DataType of the source source_nodeid (str) – The id of the source source_node to be created
step_id (str) – The step to add the created source source_node to
resources (
Optional
[ResourceLimit
]) – The resources required to run this nodenode_group (str) – The group the node belongs to, this can be important for FlowNodes and such, as they will have matching dimension names.
- Returns
the newly created source source_node
- Return type
SourceNode
-
draw
(file_path=None, draw_dimensions=True, hide_unconnected=True, expand_macros=1, font_size=14)[source]¶ Draw a graphical representation of the Network
- Parameters
file_path (str) – The path of the file to create, the extension will control the image type
draw_dimensions (bool) – Flag to control if the dimension sizes should be drawn in the figure, default is true
expand_macros (bool) – Flag to control if and how macro nodes should be expanded, by default 1 level is expanded
- Return type
- Returns
path of the image created or None if failed
-
execute
(source_data, sink_data, tmpdir=None, timestamp=None, blocking=True, execution_plugin=None)[source]¶ Execute the network with the given source and sink data.
- Parameters
source_data (
Dict
[str
,Union
[List
[Union
[str
,Tuple
[str
, …]]],Dict
[str
,Union
[str
,Tuple
[str
, …]]]]]) – Source data to use as an inputsink_data (
Union
[str
,Dict
[str
,str
]]) – Sink rules to use for determining the outputstmpdir (
Optional
[str
]) – The scratch directory to use for this network run, if an existing directory is given, fastr will try to resume a network run (see Continuing a Network)timestamp (
Union
[datetime
,str
,None
]) – The timestamp of the network run (useful for retrying or continuing previous runs)blocking (
bool
) – Flag to indicate if the execution should be blocking or launched in a background threadexecution_plugin (
Optional
[str
]) – The execution plugin to use for this run
- Return type
- Returns
The network run object for the started execution
-
-
class
fastr.api.
Link
(parent)[source]¶ Representation of a link for editing the Network
-
property
collapse
¶ The dimensions which the link will collapse into the cardinality
-
property
expand
¶ Flag that indicates if the Link will expand the cardinality into a new dimension.
- Return type
-
property
-
class
fastr.api.
Node
(parent)[source]¶ Representation of Node for editing the Network
-
property
input
¶ In case there is only a single Inputs in a Node, this can be used as a short hand. In that case it is basically the same as
list(node.inputs.values()[0])
.- Return type
-
property
inputs
¶ Mapping object containing all Inputs of a Node
- Return type
InputMap
-
property
output
¶ In case there is only a single Outputs in a Node, this can be used as a short hand. In that case it is basically the same as
list(node.outputs.values()[0])
.- Return type
-
property
-
class
fastr.api.
Input
(parent)[source]¶ Representation of an Input of a Node
-
__lshift__
(other)[source]¶ This operator allows the easy creation of Links to this Input using the
<<
operator. Creating links can be done by:# Generic form >> link = input << output >> link = input << ['some', 'data'] # Create a constant node # Examples >> link1 = addint.inputs['left_hand'] << source1.input >> link2 = addint.inputs['right_hand'] << [1, 2, 3] # Mutliple links >> links = addints.inputs['left_hand'] << (source1.output, source2.output, source3.output)
The last example would return a tuple with three links.
-
__rrshift__
(other)[source]¶ This operator allows to use the
>>
operator as alternative to using the<<
operator. See the__lshift__ operator
for details.
-
property
input_group
¶ The input group of this Input. This property can be read and changed. Changing the input group of an Input will influence the data flow in a Node (see Advanced flows in a Node for details).
- Return type
-
-
class
fastr.api.
Output
(parent)[source]¶ Representation of an Output of a Node
-
__getitem__
(item)[source]¶ Get a SubOuput of this Ouput. The SubOutput selects some data from the parent Output based on an index or slice of the cardinalty.
- Parameters
key – the key of the requested item, can be an index or slice
- Return type
- Returns
the requested SubOutput with a view of the data in this Output
-