Variable data from subject to subject

My group scans infants with fMRI, and the data we get from each subject is incomplete: a subset of up to two sessions * four tasks * three runs.

I am trying to understand the best way to use nipype with this variable input. One option is to scan the data before nipype gets it, and then to use an IdentityInterface with iterables providing the available combinations subject/session/task/run and synchronize=True so that each fMRI run is processed separately. But, then if I want to collapse across sessions, tasks and runs (e.g., to make a grand fMRI mean, or to do coreg to anatomy), or across tasks and runs (e.g., to apply fieldmaps acquired per session) it is difficult. Joinnode seems collapse across everything, so if I manually loop across subjects, I can do once-per-subject stuff, but not once-per-session.

I have as yet not been able to find a way of iterating through dynamically created lists. Am I correct that it isn’t possible to set the range of an iterable at the time of execution of a node using an input from another node?

Another option is to set up iterables of every possible combination, then use selectfiles with raise_on_empty=False and force_lists=True, and then use mapnode to iterate through the resulting lists, but then it is difficult to match up corresponding fMRI sessions across nodes (unless I hack it, with python’s zip or somesuch).

What would you recommend? Am I missing some key feature? Any advice gratefully received-
All the best,