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]

etc…

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:

http://nipype.readthedocs.io/en/latest/users/joinnode_and_itersource.html#synchronize

1 Like

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 https://nipype.readthedocs.io/en/latest/users/joinnode_and_itersource.html#synchronize but haven’t been able to figure it out.

Thanks for your help,

Sebastian

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

https://miykael.github.io/nipype_tutorial/notebooks/basic_joinnodes.html