Best way to iterate over tuples in nipype?



I now have lists for subjects, sessions, and runs that I iterate over, like:

inputnode.iterables = [
        ('subject_id', subject_list),
        ('session_id', session_list),
        ('run_id', run_list),

Is there an easy way to specify that I only want to include, say, runs 1 and 5 of session X and runs 2 and 5 of session Y? For example, run 2 of session X might need to be excluded from the study.

Would the recommended way of doing this be something like this:

inputnode.iterables = [
        ('subject_session_run_id', [('bob', 'X', 'run-01'),('bob', 'X', 'run-05'), ...]),

Then use:

def get_subj(ssr):
    return ssr[0]



It looks like using CSVReader is a nice alternative.


@Jonathan_R_Williford - take a look at this, i think it will do what you need:


Thanks @satra! Would a JoinNode be required down the line to return the inputs to lists?


@Jonathan_R_Williford - if you need to collect back the iterables then a JoinNode will be required, otherwise you just get different graphs for each iterable combo.


Hello everyone,

Similarly to @Jonathan_R_Williford I’ve got 3 iterables:

In my case the run_id depends on the task id. So for task A I’ve got 3 runs, for task B 4 runs etc…

So I would also iterate over it like this:

inputnode.iterables = [
(‘subject_id’, subject_list),
(‘task_id’, task_list),
(‘run_id’, run_list),

Is there a smart way to make the run_id dependent on the task id? I have checked out but haven’t been able to figure it out.

Thanks for your help,



This link seems to be broken now? Is there another?