@@ -121,15 +121,15 @@ def analyze_openfmri_dataset(data_dir, subject=None, model_id=None,
121
121
Set up openfmri data specific components
122
122
"""
123
123
124
- subjects = [path .split (os .path .sep )[- 1 ] for path in
125
- glob (os .path .join (data_dir , 'sub*' ))]
124
+ subjects = sorted ( [path .split (os .path .sep )[- 1 ] for path in
125
+ glob (os .path .join (data_dir , 'sub*' ))])
126
126
127
127
infosource = pe .Node (niu .IdentityInterface (fields = ['subject_id' ,
128
128
'model_id' ,
129
129
'task_id' ]),
130
130
name = 'infosource' )
131
131
if subject is None :
132
- infosource .iterables = [('subject_id' , subjects [: 2 ] ),
132
+ infosource .iterables = [('subject_id' , subjects ),
133
133
('model_id' , [model_id ]),
134
134
('task_id' , [task_id ])]
135
135
else :
@@ -201,14 +201,18 @@ def get_contrasts(contrast_file, task_id, conds):
201
201
import numpy as np
202
202
contrast_def = np .genfromtxt (contrast_file , dtype = object )
203
203
if len (contrast_def .shape ) == 1 :
204
- contrast_def = [ contrast_def ]
204
+ contrast_def = contrast_def [ None , : ]
205
205
contrasts = []
206
206
for row in contrast_def :
207
207
if row [0 ] != 'task%03d' % task_id :
208
208
continue
209
- con = [row [1 ], 'T' , ['cond%03d' % i for i in range (len (conds ))],
209
+ con = [row [1 ], 'T' , ['cond%03d' % ( i + 1 ) for i in range (len (conds ))],
210
210
row [2 :].astype (float ).tolist ()]
211
211
contrasts .append (con )
212
+ # add auto contrasts for each column
213
+ for i , cond in enumerate (conds ):
214
+ con = [cond , 'T' , ['cond%03d' % (i + 1 )], [1 ]]
215
+ contrasts .append (con )
212
216
return contrasts
213
217
214
218
contrastgen = pe .Node (niu .Function (input_names = ['contrast_file' ,
@@ -260,8 +264,6 @@ def get_contrasts(contrast_file, task_id, conds):
260
264
"""
261
265
262
266
def sort_copes (files ):
263
- from nipype .utils .filemanip import filename_to_list
264
- files = filename_to_list (files )
265
267
numelements = len (files [0 ])
266
268
outfiles = []
267
269
for i in range (numelements ):
@@ -271,8 +273,6 @@ def sort_copes(files):
271
273
return outfiles
272
274
273
275
def num_copes (files ):
274
- from nipype .utils .filemanip import filename_to_list
275
- files = filename_to_list (files )
276
276
return len (files )
277
277
278
278
pickfirst = lambda x : x [0 ]
0 commit comments