Skip to content

Instantly share code, notes, and snippets.

@satra
Created February 17, 2011 02:13
Show Gist options
  • Save satra/830808 to your computer and use it in GitHub Desktop.
Save satra/830808 to your computer and use it in GitHub Desktop.
Nipype: SPM two sample t-test workflow
l2BGflow = pe.Workflow(name='l2BGflow')
# setup a between group 2-sample t-test node
twosamplettestdes = pe.Node(interface=spm.TwoSampleTTestDesign(), name="twosampttestdes")
twosamplettestdes.inputs.explicit_mask_file = os.path.abspath('/software/spm8/apriori/brainmask.nii')
l2BGestimate = pe.Node(interface=spm.EstimateModel(), name="twosampleestimate")
l2BGestimate.inputs.estimation_method = {'Classical' : 1}
l2BGconestimate = pe.Node(interface = spm.EstimateContrast(), name="twosampleconestimate")
con_1 = ('Controls','T', ['Group_{1}'],[1])
con_2 = ('Patients','T', ['Group_{2}'],[1])
con_3 = ('Controls>Patients','T',['Group_{1}','Group_{2}'],[1,-1])
con_4 = ('Patients>Controls','T',['Group_{1}','Group_{2}'],[-1,1])
l2BGconestimate.inputs.contrasts = [con_1,con_2,con_3,con_4]
l2BGconestimate.inputs.group_contrast = True
l2BGflow.connect([(twosamplettestdes,l2BGestimate,[('spm_mat_file','spm_mat_file')]),
(l2BGestimate,l2BGconestimate,[('spm_mat_file','spm_mat_file'),
('beta_images','beta_images'),
('residual_image','residual_image')]),
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment