Subject list remains undefined when included as a iterable in IdentityInterface


I have written a nipype preprocessing pipeline following the example posted here ( I have everything working except, I cannot seem to get the pipeline to iterate over a number of subjects.

I have defined a list of subject id’s:
subject_list = [‘0001, ‘5013’, ‘5014’, 5015’, ‘5016’]

Then built an IdentityInterface node to iterate over these ids and pass them to a SelectFiles node:
infosource = Node(IdentityInterface(fields=[‘subject_id’]), name=“infosource”)
infosource.interables = [(‘subject_id’, subject_list)]
anat_file = opj(‘sub-{subject_id}’, ‘anat’, ‘sub-{subject_id}_t1w_preproc.nii.gz’)
func_file = opj(‘sub-{subject_id}’, ‘func’, ‘norm’, ‘sub-{subject_id}_ses-norm_task-movie_bold.nii.gz’)
templates = {‘anat’: anat_file,
‘func’: func_file}
selectfiles = Node(SelectFiles(templates, base_directory=’/Users/switt/Documents/TBImovie’), name=“selectfiles”)

preproc_wf.connect([(infosource, selectfiles, [(‘subject_id’, ‘subject_id’)]),…

When I go to run the pipeline, I get the following error:
“OSError: No files were found matching anat template: /Users/switt/Documents/TBImovie/sub-< undefined >/anat/sub-< undefined >_t1w_preproc.nii.gz”

However, if I define my subject list as a single value:
subject_list = ‘0001’
and leave everything else the same, the pipeline runs without error. Specifying the subject_list as 'subject_list = [‘0001’] results in an error, as the SelectFiles node is then looking for a directory with the name, ‘sub-[‘0001’]/’.

I realize that I am probably missing something quite obvious, but I have been staring at this for a few days and comparing with other examples I can find here on NeuroStars and the nipype documentation and tutorials and cannot seem to figure out what I have done incorrectly.

Any help or suggestions would be appreciated.

I am working from a jupyter notebook launched from a terminal window, running on anaconda3, on a MacBook Pro with High Sierra (10.13.6)

Thanks in advance,


Hi Suzanne,

It looks like there is a typo when you are defining your iterables:

infosource.interables should be infosource.iterables (remove the n after the i in iterables).

Hopefully that solves the error!



Hi Amanda,

Thank you so much! Fixing the typo solved it :slight_smile: