NiPype's fsl.FIRST workflow outputs are being deleted

38 views
Skip to first unread message

Daniel Clark

unread,
Mar 24, 2014, 11:28:00 AM3/24/14
to nipy...@googlegroups.com
I am trying to implement a NiPype workflow for FSL's run_first_all command via nipype.interfaces.fsl.FIRST(). My worfklow class is as follows:

def create_subcort_seg(wf_name = 'subcort_seg'):
    """
    Create FIRST segmentation/registration tool workflow
    """
   
    # Create the workflow
    subcort_wf = pe.Workflow(name=wf_name)
   
    # Input node - load in the reoriented brain (original space, non-registered)
    inputNode = pe.Node(interface=util.IdentityInterface(fields=['reor_brain']),
                        name='inputspec')
   
    # FIRST Interface node
    funcNode = pe.Node(interface=fsl.FIRST(),
                        name='first_seg')
    # Set '-d' flag to keep intermediate files
    funcNode.inputs.no_cleanup = True

    # Output node - four outputs in FIRST we must define in the node
    outputNode = pe.Node(interface=util.IdentityInterface(fields=['vtk_out',
                                                                  'bvars_out',
                                                                  'orig_out',
                                                                  'seg_out']),
                         name='outputspec')
   
    # Connect the nodes together to form the workflow
    subcort_wf.connect(inputNode,'reor_brain',funcNode,'in_file')
    subcort_wf.connect(funcNode,'vtk_surfaces',outputNode,'vtk_out')
    subcort_wf.connect(funcNode,'bvars',outputNode,'bvars_out')
    subcort_wf.connect(funcNode,'original_segmentations',outputNode,'orig_out')
    subcort_wf.connect(funcNode,'segmentation_file',outputNode,'seg_out')

    # Return the workflow
    return subcort_wf

The problem with this is that only the first segment (BrStem)'s .bvars and .vtk files are being saved at the end of the workflow run (all 15 segments' files are being generated but all but the BrStem outputs are deleted after the run). I think the main reason for this is that when I connect the funcNode's 'bvars' and 'vtk_surfaces' fields to my outputNode's 'bvars_out' and 'vtk_out' fields, the outputNode is only grabbing the first item in the list of mesh structures (as 'vtk_surfaces' and 'bvars' from NiPype's fsl interface are lists, I believe). How do I route the entire list of structures to my outputNode to preserve the output mesh structures for all 15 segments?

I've also been told I should do this through Datasinks. In this case, there'd be like 15 Segments * (2 mesh files + 1 nifti file) = 45 outputs to sink for all of the segments. Is there an elegant way of doing this in code?

Thanks

Chris Filo Gorgolewski

unread,
Mar 24, 2014, 6:48:18 PM3/24/14
to nipy...@googlegroups.com
Could you do "ls -al" on the first directory and send the output?
Could you also share the file so I can try to replicate this?


--

---
You received this message because you are subscribed to the Google Groups "NiPy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nipy-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Clark

unread,
Mar 25, 2014, 10:33:15 AM3/25/14
to nipy...@googlegroups.com
If I ls -al, I get:

00365B_mprage.nii.gz (my anatomical input)
00365B_mprage_to_std_sub.mat
00365B_mprage_to_std_sub.nii.gz
first_class.py (my python script with the create_subcort_seg workflow function)
first_class.py~
first_class.pyc
subcort_seg/

Inside subcort_seg is:
d3.v3.min.js
first_seg/
graph1.json
graph.json
index.html

inside first_seg is: (first_seg is the name of my fsl.FIRST() node)
_0x52276a5a0834f6abd649c665b2e7b3ad.json
command.txt
_inputs.pklz
_node.pklz
_report/
result_first_seg.pklz
segmented_all_fast_firstseg.nii.gz
segmented_all_fast_origsegs.nii.gz
segmented-BrStem_first.bvars
segmnted0BrStem_first.vtk
segmented.logs/

Attached is my first_class.py file I'm using to create the workflow. How I run it is (in ipython):
import first_class
wf = first_class.create_subcort_seg()
wf.base_dir='/abs/path/to/my/work_dir'
wf..inputs.inputspec.reor_brain='/abs/path/to/my/work_dir/00365B_mprage.nii.gz'
wf.run()
first_class.py

Chris Filo Gorgolewski

unread,
Mar 25, 2014, 10:58:50 AM3/25/14
to nipy...@googlegroups.com

On Tue, Mar 25, 2014 at 3:33 PM, Daniel Clark <danielj...@gmail.com> wrote:
00365B_mprage.nii.gz

Could you also share "00365B_mprage.nii.gz"? Via dropbox or similar preferably.

Daniel Clark

unread,
Mar 25, 2014, 1:57:38 PM3/25/14
to nipy...@googlegroups.com
Sure, I'll actually use another nifti file that's from a publicly available dataset (I just tested it and got the same results).

https://dl.dropboxusercontent.com/u/5135327/mprage.nii.gz

Chris Filo Gorgolewski

unread,
Mar 25, 2014, 3:18:07 PM3/25/14
to nipy...@googlegroups.com
I think I found and fixed the problem. Could you check if this branch solves your issue: https://github.com/chrisfilo/nipype/tree/fix/first ?


--

Chris Filo Gorgolewski

unread,
Mar 27, 2014, 8:56:24 AM3/27/14
to nipy...@googlegroups.com

Any luck?

Daniel Clark

unread,
Mar 27, 2014, 2:10:28 PM3/27/14
to nipy...@googlegroups.com
Hey sorry, I didn't get a chance to test this out until today. Yep! That fixed it. Thanks Chris.


Any luck?

You received this message because you are subscribed to a topic in the Google Groups "NiPy Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nipy-user/Vou4ZfeMdQw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nipy-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages