My NiPype pipeline aims to iterate across a known subject list (e.g. ['sub-001', 'sub-002']
), repeating the entire workflow for each subject. I have achieved this using an IdentityInterface
with the iterables
field set to the subject list.
The difficult part is that I also want to repeat the entire workflow again for each session. However, the session names are unknown until runtime, so they have to be set dynamically (unlike the subjects). I want something like this, but the n_selectSessions
node is invalid - you can’t set a dynamic iterable like I’ve attempted to do:
# iterate across subject list
n_selectSubjects = Node(
interface=IdentityInterface(
fields=['subject_id'],
),
name="select_subjects"
# input: 'subject_id'
# output: 'subject_id'
)
n_selectSubjects.iterables = ('subject_id', subject_list)
# select all session folders
n_selectSessions = Node(
interface=sf.SelectFiles(
templates={'session_dir' : '{subject_id_p}/ses*'},
base_directory=bids_dir
),
name='select_sessions'
)
wf.connect([
(n_selectSubjects, n_selectSessions, [('subject_id', 'subject_id_p')])
])
n_selectSessions.iterables = ('session_dir') # INVALID
# select all files
n_selectFiles = Node(
interface=sf.SelectFiles(
templates=bids_templates
),
iterfield='session_dir_p',
name='select_files'
)
wf.connect([
(n_selectSessions, n_selectFiles, [('session_dir', 'session_dir_p')])
])
Is there a way of achieving dynamic iterables or otherwise repeating the entire workflow both for subjects and sessions determined at runtime?
Thanks!