DataFinder and IdentityInterface

54 views
Skip to first unread message

Arman Eshaghi

unread,
Jun 2, 2014, 3:58:04 PM6/2/14
to nipy...@googlegroups.com
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

Michael Waskom

unread,
Jun 6, 2014, 9:35:02 PM6/6/14
to nipy...@googlegroups.com
Hi Arman,

I would do this the other way around. Define the IdentityInterface first with just a list of subjects, and then write the DataFinder so that it takes a subject ID as a parameter and returns the scans for that subject.

I agree nipype has a steep learning curve. You may want to check out my tutorial notebook on iteration in nipype, it seems somewhat related to this problem.

Michael

Arman Eshaghi

unread,
Jun 7, 2014, 2:47:48 AM6/7/14
to nipy...@googlegroups.com
Thanks Michael. This notebook is exactly what I was looking for. 

All the best,
Arman


--

---
You received this message because you are subscribed to the Google Groups "NiPy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nipy-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages