nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
748 stars 530 forks source link

pushing the boundaries of joins-- joining outputs of multiple synchronized nested workflows before parent workflow proceeds? #2931

Closed dPys closed 5 years ago

dPys commented 5 years ago

Hi friends,

I have two nested workflows, one corresponding to an fMRI run, and the other corresponding to a dMRI run. The outputs of those nested workflows, when run independently, are connected back into the parent workflow via modality-specific 'pass' nodes-- pass_meta_ins_func_node or pass_meta_ins_dwi_node (see https://github.com/dPys/PyNets/blob/development/pynets/workflows.py#L160-L355 to conceptualize this).

These pass nodes, at least for now, further connect to a 'pass_meta_outs_node', which ultimately gets connected back into the parent workflow using various calls of wf.get_node('pass_meta_outs_node') (see appearances throughout https://github.com/dPys/PyNets/blob/development/pynets/pynets_run.py#L1130-L1170 for instance).

What I am needing to do is create some type of join-like node, that lives between the func/dwi pass_meta_ins and pass_meta_outs, that would allow me to adjoin the outputs (consisting of just lists of tuples) from both pass_meta_ins_func_node and pass_meta_ins_dwi_node into a single list of outputs when both nested workflows (i.e. for fMRI + dMRI) are run simultaneously. That merged list of outputs could then subsequently be mapped to pass_meta_outs_node. This is like a join, but with no iterables to source it. The issue that I am running into while attempting this so far is that trying to map both pass_meta_ins_func_node and pass_meta_ins_dwi_node to the same node (pass_meta_outs_node) is obviously not allowed in nipype, since the ports are already connected.

In fact, if I attempt this, I get an unsurprising error:

exception: Trying to connect Meta_wf_127.pass_meta_ins_func_node:conn_model_iterlist to Meta_wf_127.pass_meta_outs_node:conn_model_iterlist but input 'conn_model_iterlist' of node 'Meta_wf_127.pass_meta_outs_node' is already
connected.

How might I work around this issue without making substantive changes to the parent workflow? How might pydra accommodate for these types of combinations?

dPys commented 5 years ago

And to simplify this question-- how might I create a meta-mapnode that maps workflows in their entirety? If this were possible, then I could make a joinnode that references a common upstream source... @mgxd ? @satra ? Also, please let me know if I'm missing something obvious-

dPys commented 5 years ago

This has now been solved so I am closing this issue. The solution turned out to be easy--simply map the outputs of the multiple workflows to different version of the same variable. See: https://github.com/dPys/PyNets/blob/master/pynets/workflows.py#L204-L337