Hello, I’m trying to model a processing pipeline from this (https://miykael.github.io/nipype_tutorial/notebooks/example_preprocessing.html) to preprocess data with nipype. I am new to this so I’m learning as I go and trying to achieve this first simple pipeline. I’m just trying to iterate over subjects and perform some simple analysis. When I run this pipeline it states “Workflow did not execute cleanly. Check log for details” then I check the crash file and I get the following
File: /home/luiscp/Documents/crash-20180910-163002-luiscp-selectfiles.a1-9ec6296c-3f3c-4317-8c70-d6eabe77928c.pklz
Node: preproc.selectfiles
_Working directory: /home/luiscp/Documents/Data/ADRC_90Plus/output/preproc/subject_id_234/selectfiles
Node inputs:
base_directory = Data/ADRC_90Plus
force_lists = False
raise_on_empty = True
sort_filelist = True
subject_id = 234
Traceback: _
Traceback (most recent call last):
_ File “/home/luiscp/anaconda3/envs/dwienv/lib/python2.7/site-packages/nipype/pipeline/plugins/multiproc.py”, line 69, in run_node
_ result[‘result’] = node.run(updatehash=updatehash)_
_ File “/home/luiscp/anaconda3/envs/dwienv/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py”, line 471, in run_
_ result = self.run_interface(execute=True)
_ File “/home/luiscp/anaconda3/envs/dwienv/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py”, line 555, in run_interface
_ return self.run_command(execute)
_ File “/home/luiscp/anaconda3/envs/dwienv/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py”, line 635, in run_command
_ result = self.interface.run(cwd=outdir)
_ File “/home/luiscp/anaconda3/envs/dwienv/lib/python2.7/site-packages/nipype/interfaces/base/core.py”, line 523, in run_
_ outputs = self.aggregate_outputs(runtime)_
_ File “/home/luiscp/anaconda3/envs/dwienv/lib/python2.7/site-packages/nipype/interfaces/base/core.py”, line 597, in aggregate_outputs_
_ predicted_outputs = self.list_outputs()
_ File “/home/luiscp/anaconda3/envs/dwienv/lib/python2.7/site-packages/nipype/interfaces/io.py”, line 1424, in list_outputs
_ raise IOError(msg)_
_IOError: No files were found matching dwi template: Documents/Data/ADRC_90Plus/output/preproc/subject_id_234/selectfiles/Data/ADRC_90Plus/sub_234/data.nii.gz
As you can see it’s searching for data in _Data/ADRC_90Plus/output/preproc/subject_id_234/selectfiles/Data/ADRC_90Plus/sub_234/data.nii.gz
but the data is located in Data/ADRC_90Plus/sub_234/data.nii.gz
Below is the entire pipeline (I think I’m setting the selectfiles base directory to Data/ADRC_90Plus and templates to sub_233/data.nii.gz but it seems to be adding the datasink options in the middle for no reason. Does anyone have an idea of my mistake.
from IPython import get_ipython
get_ipython().run_line_magic(‘matplotlib’, ‘inline’)
from os.path import join as opj
from nipype.interfaces.fsl import (BET, SUSAN)
from nipype.interfaces.afni import Retroicor
from nipype.interfaces.utility import IdentityInterface
from nipype.interfaces.io import SelectFiles, DataSink
from nipype import Workflow, Node
###############################
#experiment params
###############################
experiment_dir = ‘Data/ADRC_90Plus/output’
output_dir = ‘datasink’
subject_list = [‘233’,‘234’]
###############################
#specify nodes
###############################
#Motion Correction (AFNI)
realign = Node(Retroicor(outputtype = u’NIFTI_GZ’),
name=“realign”)
#Smoothing (FSL)
smooth = Node(SUSAN(fwhm = 2.0,
output_type =u’NIFTI_GZ’,
brightness_threshold=0),
name=“smooth”)
#Skull remove (FSL)
skullstrip = Node(BET(frac = 0.4,
robust=True,
output_type =u’NIFTI_GZ’,
mask = True),
name=“skullstrip”)
###############################
#specify input output
###############################
Infosource - a function free node to iterate over the list of subject names
infosource = Node(IdentityInterface(fields=[‘subject_id’]),
name=“infosource”)
infosource.iterables = [(‘subject_id’, subject_list)]
dwi_file = opj(‘sub_{subject_id}’,‘data.nii.gz’)
templates = {‘dwi’: dwi_file}
selectfiles = Node(SelectFiles(templates,
base_directory=‘Data/ADRC_90Plus’),
name=“selectfiles”)
datasink = Node(DataSink(base_directory=experiment_dir,
container=output_dir),
name=“datasink”)
substitutions = [(‘subject_id’, ‘sub_’),
]
datasink.inputs.substitutions = substitutions
###############################
#Specify workflow
###############################
preproc = Workflow(name=‘preproc’)
preproc.base_dir = experiment_dir
preproc.connect([(infosource, selectfiles, [(‘subject_id’,‘subject_id’)]),
(selectfiles, realign, [(‘dwi’, ‘in_file’)]),
(realign, smooth, [ (‘out_file’, ‘in_file’)]),
(smooth, skullstrip, [(‘smoothed_file’, ‘in_file’)]),
(skullstrip, datasink, [('inskull_mask_file', 'out_file')]),
])
#preproc.write_graph(graph2use=‘colored’, format=‘png’, simple_form=True)
preproc.run(‘MultiProc’, plugin_args={‘n_procs’: 16})