Skip to content

Commit 83d23e6

Browse files
author
mahdieh-dst
committed
Revised workflow.py
1 parent 386a937 commit 83d23e6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

nipype2pydra/workflow.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
import black
44
from nipype.interfaces.base import isdefined
55
from .utils import load_class_or_func
6+
from nipype.pipeline.engine.workflows import Workflow
67

78

89
class WorkflowConverter:
9-
10+
#creating the wf
1011
def __init__(self, spec):
1112
self.spec = spec
1213
self.wf = load_class_or_func(self.spec['function'])(
1314
**self._parse_workflow_args(self.spec['args'])
14-
)
15+
) #loads the 'function' in smriprep.yaml, and implement the args (creates a dictionary)
1516

1617
def node_connections(self, workflow):
1718
connections = defaultdict(dict)
1819

19-
# Get connections from workflow graph
20+
# iterates over wf graph, Get connections from workflow graph, store connections in a dictionary
2021
for edge, props in workflow._graph.edges.items():
2122
src_node = edge[0].name
2223
dest_node = edge[1].name
@@ -32,7 +33,7 @@ def node_connections(self, workflow):
3233
connections[dest_node][dest_field] = f"{src_node}.lzout.{src_field}"
3334

3435
# Look for connections in nested workflows via recursion
35-
for node in workflow.find_name_of_appropriate_method(): # TODO: find the method that iterates through the nodes of the workflow (but not nested nodes)
36+
for node in workflow._get_all_nodes(): #TODO: find the method that iterates through the nodes of the workflow (but not nested nodes)---placeholder: find_name_of_appropriate_method
3637
if isinstance(node, Workflow): # TODO: find a way to check whether the node is a standard node or a nested workflow
3738
connections.update(self.node_connections(node))
3839
return connections
@@ -63,8 +64,8 @@ def generate(self, format_with_black=False):
6364
node_args += f",\n {arg}=wf.{val}"
6465

6566
out_text += f"""
66-
wf.add({task_type}(
67-
name="{node.name}"{node_args}
67+
wf.add({task_type}(
68+
name="{node.name}"{node_args}
6869
)"""
6970

7071
if format_with_black:

0 commit comments

Comments
 (0)