Skip to content

Commit f061e93

Browse files
committed
Merge pull request #850 from satra/enh/openfmri
Enh/openfmri
2 parents 02158d6 + e8b7d58 commit f061e93

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

examples/fmri_openfmri.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ def analyze_openfmri_dataset(data_dir, subject=None, model_id=None,
121121
Set up openfmri data specific components
122122
"""
123123

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*'))])
126126

127127
infosource = pe.Node(niu.IdentityInterface(fields=['subject_id',
128128
'model_id',
129129
'task_id']),
130130
name='infosource')
131131
if subject is None:
132-
infosource.iterables = [('subject_id', subjects[:2]),
132+
infosource.iterables = [('subject_id', subjects),
133133
('model_id', [model_id]),
134134
('task_id', [task_id])]
135135
else:
@@ -200,13 +200,19 @@ def get_highpass(TR, hpcutoff):
200200
def get_contrasts(contrast_file, task_id, conds):
201201
import numpy as np
202202
contrast_def = np.genfromtxt(contrast_file, dtype=object)
203+
if len(contrast_def.shape) == 1:
204+
contrast_def = contrast_def[None, :]
203205
contrasts = []
204206
for row in contrast_def:
205207
if row[0] != 'task%03d' % task_id:
206208
continue
207-
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))],
208210
row[2:].astype(float).tolist()]
209211
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)
210216
return contrasts
211217

212218
contrastgen = pe.Node(niu.Function(input_names=['contrast_file',

0 commit comments

Comments
 (0)