Problem running dmri fsl dti example

113 views
Skip to first unread message

Dylan Nielson

unread,
Jul 1, 2013, 12:05:56 PM7/1/13
to nipy...@googlegroups.com
Hi all,

I apologize for the basic question, but I'm trying to run the dmri fsl dti example and running into a bug that I can't solve. Any help would be greatly appreciated.

Here is the error I'm getting:

130701-12:01:08,892 workflow INFO:
	 ['check', 'execution', 'logging']
130701-12:01:08,966 workflow INFO:
	 Running serially.
130701-12:01:08,968 workflow INFO:
	 Executing node datasource.b0 in dir: /home/dylan/fsl_dti_tutorial/dwiproc/_subject_id_subj1/datasource
130701-12:01:08,975 workflow ERROR:
	 ['Node datasource.b0 failed to run on host gyrus.']
130701-12:01:08,975 workflow INFO:
	 Saving crash info to /home/dylan/crash-20130701-120108-dylan-datasource.b0.npz
130701-12:01:08,976 workflow INFO:
	 Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/nipype/pipeline/plugins/linear.py", line 37, in run
    node.run(updatehash=updatehash)
  File "/usr/lib/pymodules/python2.7/nipype/pipeline/engine.py", line 1282, in run
    self._run_interface()
  File "/usr/lib/pymodules/python2.7/nipype/pipeline/engine.py", line 1380, in _run_interface
    self._result = self._run_command(execute)
  File "/usr/lib/pymodules/python2.7/nipype/pipeline/engine.py", line 1504, in _run_command
    result = self._interface.run()
  File "/usr/lib/pymodules/python2.7/nipype/interfaces/base.py", line 883, in run
    self._check_mandatory_inputs()
  File "/usr/lib/pymodules/python2.7/nipype/interfaces/base.py", line 825, in _check_mandatory_inputs
    raise ValueError(msg)
ValueError: DataGrabber requires a value for input 'sort_filelist'. For a list of required inputs, see DataGrabber.help()

130701-12:01:08,979 workflow INFO:
	 ***********************************
130701-12:01:08,979 workflow ERROR:
	 could not run node: dwiproc.datasource.b0
130701-12:01:08,980 workflow INFO:
	 crashfile: /home/dylan/crash-20130701-120108-dylan-datasource.b0.npz
130701-12:01:08,981 workflow INFO:
	 ***********************************
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/home/dylan/<ipython-input-5-d010cba6b018> in <module>()
    274 
    275 if __name__ == '__main__':
--> 276     dwiproc.run()
    277     dwiproc.write_graph()

/usr/lib/pymodules/python2.7/nipype/pipeline/engine.pyc in run(self, plugin, plugin_args, updatehash)
    667         if str2bool(self.config['execution']['create_report']):
    668             self._write_report_info(self.base_dir, self.name, execgraph)
--> 669         runner.run(execgraph, updatehash=updatehash, config=self.config)
    670         return execgraph
    671 

/usr/lib/pymodules/python2.7/nipype/pipeline/plugins/linear.pyc in run(self, graph, config, updatehash)
     53                 if self._status_callback:
     54                     self._status_callback(node, 'exception')
---> 55         report_nodes_not_run(notrun)
     56 

/usr/lib/pymodules/python2.7/nipype/pipeline/plugins/base.pyc in report_nodes_not_run(notrun)
     87                 logger.debug(subnode._id)
     88         logger.info("***********************************")
---> 89         raise RuntimeError(('Workflow did not execute cleanly. '
     90                             'Check log for details'))
     91 

RuntimeError: Workflow did not execute cleanly. Check log for details




I've attached the crash file. Here is the script as I attempted to run it:
#!/usr/bin/env python
"""
===============
dMRI [DTI, FSL]
===============

A pipeline example that uses several interfaces to perform analysis on
diffusion weighted images using FSL FDT tools.

This tutorial is based on the 2010 FSL course and uses data freely available at
the FSL website at: http://www.fmrib.ox.ac.uk/fslcourse/fsl_course_data2.tar.gz

More details can be found at
http://www.fmrib.ox.ac.uk/fslcourse/lectures/practicals/fdt/index.htm

In order to run this tutorial you need to have fsl tools installed and
accessible from matlab/command line. Check by calling fslinfo from the command
line.

Tell python where to find the appropriate functions.
"""

import nipype.interfaces.io as nio           # Data i/o
import nipype.interfaces.fsl as fsl          # fsl
import nipype.interfaces.utility as util     # utility
import nipype.pipeline.engine as pe          # pypeline engine
import os                                    # system functions
from nipype.workflows.dmri.fsl.dti import create_eddy_correct_pipeline,\
    create_bedpostx_pipeline

"""
Confirm package dependencies are installed.  (This is only for the
tutorial, rarely would you put this in your own code.)
"""

from nipype.utils.misc import package_check

package_check('numpy', '1.3', 'tutorial1')
package_check('scipy', '0.7', 'tutorial1')
package_check('networkx', '1.0', 'tutorial1')
package_check('IPython', '0.10', 'tutorial1')


"""
Setting up workflows
--------------------

This is a generic workflow for DTI data analysis using the FSL

Data specific components
------------------------

The nipype tutorial contains data for two subjects.  Subject data is in two
subdirectories, ``dwis1`` and ``dwis2``.  Each subject directory contains each
of the following files: bvec, bval, diffusion weighted data, a set of target
masks, a seed file, and a transformation matrix.

Below we set some variables to inform the ``datasource`` about the
layout of our data.  We specify the location of the data, the subject
sub-directories and a dictionary that maps each run to a mnemonic (or
field) for the run type (``dwi`` or ``bvals``).  These fields become
the output fields of the ``datasource`` node in the pipeline.

Specify the subject directories
"""

subject_list = ['subj1']


"""
Map field names to individual subject runs
"""

info = dict(dwi=[['subject_id', 'data']],
            bvecs=[['subject_id','bvecs']],
            bvals=[['subject_id','bvals']],
            seed_file = [['subject_id','MASK_average_thal_right']],
            target_masks = [['subject_id',['MASK_average_M1_right',
                                           'MASK_average_S1_right',
                                           'MASK_average_occipital_right',
                                           'MASK_average_pfc_right',
                                           'MASK_average_pmc_right',
                                           'MASK_average_ppc_right',
                                           'MASK_average_temporal_right']]])

infosource = pe.Node(interface=util.IdentityInterface(fields=['subject_id']),
                     name="infosource")

"""
Here we set up iteration over all the subjects. The following line
is a particular example of the flexibility of the system.  The
``datasource`` attribute ``iterables`` tells the pipeline engine that
it should repeat the analysis on each of the items in the
``subject_list``. In the current example, the entire first level
preprocessing and estimation will be repeated for each subject
contained in subject_list.
"""

infosource.iterables = ('subject_id', subject_list)

"""
Now we create a :class:`nipype.interfaces.io.DataGrabber` object and
fill in the information from above about the layout of our data.  The
:class:`nipype.pipeline.engine.Node` module wraps the interface object
and provides additional housekeeping and pipeline specific
functionality.
"""

datasource = pe.Node(interface=nio.DataGrabber(infields=['subject_id'],
                                               outfields=info.keys()),
                     name = 'datasource')

datasource.inputs.template = "%s/%s"

# This needs to point to the fdt folder you can find after extracting
# http://www.fmrib.ox.ac.uk/fslcourse/fsl_course_data2.tar.gz
#was originally "... = os.path.abspath(~/fsl_course_data/fdt)"
datasource.inputs.base_directory = os.path.abspath('/home/dylan/fmri/nipype/fsl_dti_tutorial/fsl_course_data/fdt')

datasource.inputs.field_template = dict(dwi='%s/%s.nii.gz',
                                        seed_file="%s.bedpostX/%s.nii.gz",
                                        target_masks="%s.bedpostX/%s.nii.gz")
datasource.inputs.template_args = info


"""
Setup for Diffusion Tensor Computation
--------------------------------------

Here we will create a generic workflow for DTI computation
"""

computeTensor = pe.Workflow(name='computeTensor')

"""
extract the volume with b=0 (nodif_brain)
"""

fslroi = pe.Node(interface=fsl.ExtractROI(),name='fslroi')
fslroi.inputs.t_min=0
fslroi.inputs.t_size=1

"""
create a brain mask from the nodif_brain
"""

bet = pe.Node(interface=fsl.BET(),name='bet')
bet.inputs.mask=True
bet.inputs.frac=0.34

"""
correct the diffusion weighted images for eddy_currents
"""

eddycorrect = create_eddy_correct_pipeline('eddycorrect')
eddycorrect.inputs.inputnode.ref_num=0

"""
compute the diffusion tensor in each voxel
"""

dtifit = pe.Node(interface=fsl.DTIFit(),name='dtifit')

"""
connect all the nodes for this workflow
"""

computeTensor.connect([
                        (fslroi,bet,[('roi_file','in_file')]),
                        (eddycorrect, dtifit,[('outputnode.eddy_corrected','dwi')]),
                        (infosource, dtifit,[['subject_id','base_name']]),
                        (bet,dtifit,[('mask_file','mask')])
                      ])



"""
Setup for Tracktography
-----------------------

Here we will create a workflow to enable probabilistic tracktography
and hard segmentation of the seed region
"""

tractography = pe.Workflow(name='tractography')
tractography.base_dir = os.path.abspath('fsl_dti_tutorial')

"""
estimate the diffusion parameters: phi, theta, and so on
"""

bedpostx = create_bedpostx_pipeline()
bedpostx.get_node("xfibres").iterables = ("n_fibres",[1,2])


flirt = pe.Node(interface=fsl.FLIRT(), name='flirt')
flirt.inputs.in_file = fsl.Info.standard_image('MNI152_T1_2mm_brain.nii.gz')
flirt.inputs.dof = 12

"""
perform probabilistic tracktography
"""

probtrackx = pe.Node(interface=fsl.ProbTrackX(),name='probtrackx')
probtrackx.inputs.mode='seedmask'
probtrackx.inputs.c_thresh = 0.2
probtrackx.inputs.n_steps=2000
probtrackx.inputs.step_length=0.5
probtrackx.inputs.n_samples=5000
probtrackx.inputs.opd=True
probtrackx.inputs.os2t=True
probtrackx.inputs.loop_check=True


"""
perform hard segmentation on the output of probtrackx
"""

findthebiggest = pe.Node(interface=fsl.FindTheBiggest(),name='findthebiggest')


"""
connect all the nodes for this workflow
"""

tractography.add_nodes([bedpostx, flirt])
tractography.connect([(bedpostx,probtrackx,[('outputnode.thsamples','thsamples'),
                                            ('outputnode.phsamples','phsamples'),
                                            ('outputnode.fsamples','fsamples')
                                            ]),
                      (probtrackx,findthebiggest,[('targets','in_files')]),
                      (flirt, probtrackx, [('out_matrix_file','xfm')])
                     ])


"""
Setup data storage area
"""

datasink = pe.Node(interface=nio.DataSink(),name='datasink')
datasink.inputs.base_directory = os.path.abspath('dtiresults')

def getstripdir(subject_id):
    import os
    return os.path.join(os.path.abspath('data/workingdir/dwiproc'),'_subject_id_%s' % subject_id)


"""
Setup the pipeline that combines the two workflows: tractography and computeTensor
----------------------------------------------------------------------------------
"""

dwiproc = pe.Workflow(name="dwiproc")
dwiproc.base_dir = os.path.abspath('fsl_dti_tutorial')
dwiproc.connect([
                    (infosource,datasource,[('subject_id', 'subject_id')]),
                    (datasource,computeTensor,[('dwi','fslroi.in_file'),
                                               ('bvals','dtifit.bvals'),
                                               ('bvecs','dtifit.bvecs'),
                                               ('dwi','eddycorrect.inputnode.in_file')]),
                    (datasource,tractography,[('bvals','bedpostx.inputnode.bvals'),
                                              ('bvecs','bedpostx.inputnode.bvecs'),
                                              ('seed_file','probtrackx.seed'),
                                              ('target_masks','probtrackx.target_masks')
                                              ]),
                    (computeTensor,tractography,[('eddycorrect.outputnode.eddy_corrected','bedpostx.inputnode.dwi'),
                                                 ('bet.mask_file','bedpostx.inputnode.mask'),
                                                 ('bet.mask_file','probtrackx.mask'),
                                                 ('fslroi.roi_file','flirt.reference')]),
                    (infosource, datasink,[('subject_id','container'),
                                           (('subject_id', getstripdir),'strip_dir')]),
                    (tractography,datasink,[('findthebiggest.out_file','fbiggest.@biggestsegmentation')])
                ])

if __name__ == '__main__':
    dwiproc.run()
    dwiproc.write_graph()

crash-20130701-120108-dylan-datasource.b0.npz

Satrajit Ghosh

unread,
Jul 1, 2013, 12:10:55 PM7/1/13
to nipy-user
hi dylan,

add (assuming that a lexical sort is indeed what you want for your filenames):

datasource.inputs.sort_filelist = True

cheers,

satra




--
 
---
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/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages