Closed PkuClosed closed 6 years ago
@PkuClosed you could either:
1) Assign the the hmc_pipeline
's working directory
hmc = hmc_pipeline(base_dir='/outputdir')
2) Make a DataSink
node and connect it to hmc_pipeline.outputnode
's outputs
https://github.com/nipy/nipype/blob/045b28ef9056fac1107bc4f0707859d043f3bfd1/nipype/workflows/dmri/fsl/artifacts.py#L459-L461
Hi @mgxd ,
Thanks for the reply. However, when I tried your first solution, I got the error:
hmc_pipeline() got an unexpected keyword argument 'base_dir’
I will take a look at your second solution. But since what I want is simply setting an output directory, I would appreciate it if there is something as simple as solution one.
Chuyang
The simplest approach would be to add hmc.base_dir = '/outputdir'
to your setup.
Hi @effigies ,
Thanks a lot. This works. But can I ask an additional question? After I run this, I can see the output at the designated directory. However, the elements in hmc.outputs.outputnode, i.e., out_file, out_bvec, out_xfms, are all None. I thought these were automatically determined. Did I understand this in a wrong way? I would like to feed out_xfms into the next eddy current correction pipeline, so I need to specify it.
Best, Chuyang
The hmc
object is a workflow that can be run. When it is run, it is used to construct an execution graph, whose nodes will actually store results, and this will be in the res_hmc
object. One component of constructing the execution graph is to remove IdentityInterface
s such as outputnode
, so you're not going to find that. If I have an IdentityInterface
node B with input from A and output to C, nipype will connect A directly to C in the execution graph.
You can still use this while connecting nodes to workflows, but if you're attempting to debug by looking at the outputs, you're going to run across this issue.
So what you might do is:
meta_wf = pe.Workflow(name='meta_wf', base_dir='/outputdir')
hmc = hmc_pipeline()
# Set up hmc as you like it
eddy = eddy_pipeline() # Assuming that eddy_pipeline returns a workflow
meta_wf.connect([(hmc, eddy, [('outputnode.out_xfms', 'inputnode.in_xfms')])])
If you're connecting the outputs of a workflow to a Node
, you might do:
meta_wf = pe.Workflow(name='meta_wf', base_dir='/outputdir')
hmc = hmc_pipeline()
# Set up hmc as you like it
eddy = pe.Node(Eddy(), name='eddy') # Assuming that eddy has an input called 'in_xfms'
meta_wf.connect([(hmc, eddy, [('outputnode.out_xfms', 'in_xfms')])])
You can then run hmc
and eddy
by running meta_wf.run()
. hmc
and eddy
base directories will be subdirectories of the meta_wf
base directory, so there's no point in setting them manually.
Does this make the approach a little clearer?
Hi @effigies
Thank you for the explanation and suggestion.
Chuyang
closing for now - @PkuClosed feel free to reopen if needed
Summary
I am able to run the FSL head motion correction pipeline, however, I am wondering how I can specify the output directory
Actual behavior
Here is a minimal example:
I am able to find the output files at /tmp/tmpVToGVC/motion_correct/, for example, /tmp/tmpVToGVC/motion_correct/DWICoregistration/B0Equalize/hmc_ref_corrected_enh.nii.gz. But is there a way I can designate the output directory.
Platform details:
{'nibabel_version': '2.2.1', 'sys_executable': '/Users/pkuclosed/anaconda2/bin/python', 'networkx_version': '2.0', 'numpy_version': '1.13.3', 'sys_platform': 'darwin', 'sys_version': '2.7.14 |Anaconda custom (64-bit)| (default, Oct 5 2017, 02:28:52) \n[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]', 'commit_source': 'installation', 'commit_hash': 'bded0d02', 'pkg_path': '/Users/pkuclosed/anaconda2/lib/python2.7/site-packages/nipype', 'nipype_version': '1.0.1', 'traits_version': '4.6.0', 'scipy_version': '0.19.1'} 1.0.1
Thank you in advance, Chuyang