Hi Nipype guys,
I tried to iterate subjects in an order specified by a subject list file. At each iteration, each subject was processed to return a scalar value, which was outputted to a new text file. The new text file was intended to store all subjects’ values in an order consistent with that of the subject list file.
However, after closely inspecting the new text file produced, I found that the order of values was inconsistent with that of the subject list file.
I can not figure out the reason, especially considering that I was using the “Linear” engine, which I expect would process subjects’ data in a one-by-one manner. However, from the executing process printed on the screen, it did seem to have processed data in a random order. I don’t know if there are some tricks behind to control the order of processing for each subject.
For your convenience, I also pasted the main script here. Thank you a lot for you reply…
38 dir = '/nfs/h1/workingshop/js/obj/'
39 f = open(os.path.join(dir,'sessidffaRGall'))
40 subj = [line.strip() for line in f]
41
42 pluginName = 'Linear'
43
44 #infosource - utility node to iterate over the list of subject names
45 infosource = Node(IdentityInterface(fields=['subject_id']),
46 name='infosource')
47 infosource.iterables = ('subject_id',subj)
48
49 #datasource - utility node to grab data
50 datasource = Node(DataGrabber(infields=['subject_id'],
51 outfields=['run1', 'run4', 'mask']),
52 name='datasource')
53 datasource.inputs.base_directory = dir
54 datasource.inputs.template = '%s/sess/rsProj/%s/%s.nii.gz'
55 datasource.inputs.template_args['run1'] = [['subject_id','psc','r1cp4psc_sm0']]
56 datasource.inputs.template_args['run4'] = [['subject_id','psc','r4cp4psc_sm0']]
57 datasource.inputs.template_args['mask'] = [['subject_id','roi','ffaRG']]
58 datasource.inputs.sort_filelist = False
59
60 #function nodes
61 PS = Node(Function(input_names=['run1','run4','mask'],
62 output_names=['corr'],
63 function=patternsimilarity),
64 name='PS')
65
66 savefile = Node(Function(input_names=['corr'],
67 output_names=[],
68 function=save2txt),
69 name='savefile')
70
71 #entire workflow
72 wf = Workflow(base_dir='/nfs/h1/workingshop/js/scripts', name='representation_stability')
73
74 wf.connect(infosource,'subject_id',datasource,'subject_id')
75 wf.connect(datasource,'run1',PS,'run1')
76 wf.connect(datasource,'run4',PS,'run4')
77 wf.connect(datasource,'mask',PS,'mask')
78 wf.connect(PS,'corr',savefile,'corr')
79
80 wf.run(plugin=pluginName)