nipype
                                
                                 nipype copied to clipboard
                                
                                    nipype copied to clipboard
                            
                            
                            
                        unequal number of sessions with iterables
In my experiment subjects took part in several fmri sessions on different days. However, some subjects could only attend some of the sessions whereas others attended all of them. I'm struggling to define infosource.iterables such that this is taken into account. For example, let’s say sub-01 took part in session s1 and s2, whereas sub-02 took part in all sessions. If I wanted to extract the anat_file of each subject I could do:
subject_list = ["01","02"]
sessions = ["s1", "s2", "s3"]
infosource = Node(IdentityInterface(fields=[‘subject_id’]), name=“infosource”)
infosource.iterables = [("subject_id", subject_list), ("session", sessions)]
anat_file = opj("sub-{subject_id}", {session}, "sub-{subject_id}_{session}_T1w.nii.gz")
templates = {"anat": anat_file}
selectfiles = Node(SelectFiles(templates), name=“selectfiles”)
wf.connect([( infosource, selectfiles, (["subject_id","subject_id"]), (["session","session"]))])
However this will fail because it assumes both subjects took part in all sessions. Is there a workaround?
Based on this link I also tried:
infosource.iterables = [("subject_id", ["01","02"]), 
                        ("session", {"01":["s1","s2"],"02":["s1","s2","s3"]})]
OSError: No files were found matching anat template: /sub-01/01/sub-01_01_T1w.nii.gz
And also
infosource1 = Node(IdentityInterface(fields=["subject_id"]), name="infosource1")
infosource1.iterables = [("subject_id", ["01","02"])]
infosource2 = Node(IdentityInterface(fields=["session"]), name="infosource2")
infosource2.iterables = [("session", {"01":["s1","s2"],"02":["s1","s2","s3"]})]
infosource2.itersource = ("infosource1","subject_id")
ValueError: The node wf.infosource2 itersource infosource1 was not found among the iterable predecessor nodes
But none of these worked. Any thoughts?