Skip to content

Enh/openfmri #850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions examples/fmri_openfmri.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@ def analyze_openfmri_dataset(data_dir, subject=None, model_id=None,
Set up openfmri data specific components
"""

subjects = [path.split(os.path.sep)[-1] for path in
glob(os.path.join(data_dir, 'sub*'))]
subjects = sorted([path.split(os.path.sep)[-1] for path in
glob(os.path.join(data_dir, 'sub*'))])

infosource = pe.Node(niu.IdentityInterface(fields=['subject_id',
'model_id',
'task_id']),
name='infosource')
if subject is None:
infosource.iterables = [('subject_id', subjects[:2]),
infosource.iterables = [('subject_id', subjects),
('model_id', [model_id]),
('task_id', [task_id])]
else:
Expand Down Expand Up @@ -200,13 +200,19 @@ def get_highpass(TR, hpcutoff):
def get_contrasts(contrast_file, task_id, conds):
import numpy as np
contrast_def = np.genfromtxt(contrast_file, dtype=object)
if len(contrast_def.shape) == 1:
contrast_def = contrast_def[None, :]
contrasts = []
for row in contrast_def:
if row[0] != 'task%03d' % task_id:
continue
con = [row[1], 'T', ['cond%03d' % i for i in range(len(conds))],
con = [row[1], 'T', ['cond%03d' % (i + 1) for i in range(len(conds))],
row[2:].astype(float).tolist()]
contrasts.append(con)
# add auto contrasts for each column
for i, cond in enumerate(conds):
con = [cond, 'T', ['cond%03d' % (i + 1)], [1]]
contrasts.append(con)
return contrasts

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