Hi,
Please bear with me as I'm struggling to understand the logic behind IdentityInterface. I think there is a significant learning curve to learn how to collect data with Nipype, so I would appreciate any input here.
My MR scans do not easily conform to DataGrabber template, perhaps because there are more than one group and time point. So I found DataFinder with regex matching to be the most suitable way to collect my files from hard drive.
Having a look at Satra's tutorials on other interfaces, I have collected T1 and FLAIR scans separately this way:
#collecting FLAIR
df_flair = pe.Node(interface = DataFinder(), name = 'flair_input_patients')
df_flair.inputs.root_paths = '/data/'
df_flair.inputs.match_regex = #some regex
flair_list = df_flair.run()
#collecting T1
df_t1 = pe.Node(interface = DataFinder(), name = 't1_input_patients')
#df_t1 = DataFinder()
df_t1.inputs.root_paths = '/data/'
df_t1.inputs.match_regex = #some regex
t1_list = df_t1.run()
Assuming two lists of t1_list and flair_list are in the same sort, I thought to use Identity interface to tell Nipype that T1 and FLAIR pairs come from one single individual so that I could iterate over individuals, assuming subject list is subject_list (iterable) and has the same size as my other two lists:
infosource = pe.Node(interface=util.IdentityInterface(fields=['t1',
'flair',
'subject_list']),
name="infosource")
infosource.inputs.t1 = t1_list.outputs.out_paths
infosource.inputs.flair = flair_list.outputs.out_paths
infosource.iterables = ('subject_id', subject_list)
Now, when I pass t1 as an output of IdentityInterface to the next node, all subjects are passed not one by one. Any input is highly appreciated.
All the best,
Arman