def test_MultipleRegressDesign(tmpdir): tmpdir.chdir() foo = fsl.MultipleRegressDesign() foo.inputs.regressors = dict(voice_stenght=[1, 1, 1], age=[0.2, 0.4, 0.5], BMI=[1, -1, 2]) con1 = ['voice_and_age', 'T', ['age', 'voice_stenght'], [0.5, 0.5]] con2 = ['just_BMI', 'T', ['BMI'], [1]] foo.inputs.contrasts = [con1, con2, ['con3', 'F', [con1, con2]]] res = foo.run() for ii in ["mat", "con", "fts", "grp"]: assert getattr(res.outputs, "design_" + ii) == tmpdir.join('design.' + ii).strpath design_mat_expected_content = """/NumWaves 3 /NumPoints 3 /PPheights 3.000000e+00 5.000000e-01 1.000000e+00 /Matrix 1.000000e+00 2.000000e-01 1.000000e+00 -1.000000e+00 4.000000e-01 1.000000e+00 2.000000e+00 5.000000e-01 1.000000e+00 """ design_con_expected_content = """/ContrastName1 voice_and_age /ContrastName2 just_BMI /NumWaves 3 /NumContrasts 2 /PPheights 1.000000e+00 1.000000e+00 /RequiredEffect 100.000 100.000 /Matrix 0.000000e+00 5.000000e-01 5.000000e-01 1.000000e+00 0.000000e+00 0.000000e+00 """ design_fts_expected_content = """/NumWaves 2 /NumContrasts 1 /Matrix 1 1 """ design_grp_expected_content = """/NumWaves 1 /NumPoints 3 /Matrix 1 1 1 """ for ii in ["mat", "con", "fts", "grp"]: assert tmpdir.join('design.' + ii).read() == eval("design_" + ii + "_expected_content")
def test_MultipleRegressDesign(): _, tp_dir = setup_infile() foo = fsl.MultipleRegressDesign() foo.inputs.regressors = dict(reg1=[1,1,1],reg2=[0.2,0.4,0.5],reg3=[1,-1,2]) con1 = ['con1','T',['reg1','reg2'],[0.5,0.5]] con2 = ['con2','T',['reg3'],[1]] foo.inputs.contrasts = [con1,con2,['con3','F',[con1,con2]]] res = foo.run() yield assert_equal, res.outputs.design_mat, os.path.join(os.getcwd(),'design.mat') yield assert_equal, res.outputs.design_con, os.path.join(os.getcwd(),'design.con') yield assert_equal, res.outputs.design_fts, os.path.join(os.getcwd(),'design.fts') yield assert_equal, res.outputs.design_grp, os.path.join(os.getcwd(),'design.grp')
def test_MultipleRegressDesign(tmpdir): designer = pe.Node(fsl.MultipleRegressDesign(), name='designer', base_dir=str(tmpdir)) designer.inputs.regressors = dict(voice_stenght=[1, 1, 1], age=[0.2, 0.4, 0.5], BMI=[1, -1, 2]) con1 = ["voice_and_age", "T", ["age", "voice_stenght"], [0.5, 0.5]] con2 = ["just_BMI", "T", ["BMI"], [1]] designer.inputs.contrasts = [ con1, con2, ["con3", "F", [con1, con2]], ["con4", "F", [con2]] ] res = designer.run() outputs = res.outputs.get_traitsfree() for ftype in ["mat", "con", "fts", "grp"]: assert Path(outputs["design_" + ftype]).exists() expected_content = {} expected_content["design_mat"] = """/NumWaves 3 /NumPoints 3 /PPheights 3.000000e+00 5.000000e-01 1.000000e+00 /Matrix 1.000000e+00 2.000000e-01 1.000000e+00 -1.000000e+00 4.000000e-01 1.000000e+00 2.000000e+00 5.000000e-01 1.000000e+00 """ expected_content["design_con"] = """/ContrastName1 voice_and_age /ContrastName2 just_BMI /NumWaves 3 /NumContrasts 2 /PPheights 1.000000e+00 1.000000e+00 /RequiredEffect 100.000 100.000 /Matrix 0.000000e+00 5.000000e-01 5.000000e-01 1.000000e+00 0.000000e+00 0.000000e+00 """ expected_content["design_fts"] = """/NumWaves 2 /NumContrasts 2 /Matrix 1 1 0 1 """ expected_content["design_grp"] = """/NumWaves 1 /NumPoints 3 /Matrix 1 1 1 """ for ftype in ["mat", "con", "fts", "grp"]: outfile = "design_" + ftype assert Path(outputs[outfile]).read_text() == expected_content[outfile]
def test_MultipleRegressDesign(): _, tp_dir = setup_infile() foo = fsl.MultipleRegressDesign() foo.inputs.regressors = dict(voice_stenght=[1, 1, 1], age=[0.2, 0.4, 0.5], BMI=[1, -1, 2]) con1 = ['voice_and_age', 'T', ['age', 'voice_stenght'], [0.5, 0.5]] con2 = ['just_BMI', 'T', ['BMI'], [1]] foo.inputs.contrasts = [con1, con2, ['con3', 'F', [con1, con2]]] res = foo.run() yield assert_equal, res.outputs.design_mat, os.path.join( os.getcwd(), 'design.mat') yield assert_equal, res.outputs.design_con, os.path.join( os.getcwd(), 'design.con') yield assert_equal, res.outputs.design_fts, os.path.join( os.getcwd(), 'design.fts') yield assert_equal, res.outputs.design_grp, os.path.join( os.getcwd(), 'design.grp') design_mat_expected_content = """/NumWaves 3 /NumPoints 3 /PPheights 3.000000e+00 5.000000e-01 1.000000e+00 /Matrix 1.000000e+00 2.000000e-01 1.000000e+00 -1.000000e+00 4.000000e-01 1.000000e+00 2.000000e+00 5.000000e-01 1.000000e+00 """ design_con_expected_content = """/ContrastName1 voice_and_age /ContrastName2 just_BMI /NumWaves 3 /NumContrasts 2 /PPheights 1.000000e+00 1.000000e+00 /RequiredEffect 100.000 100.000 /Matrix 0.000000e+00 5.000000e-01 5.000000e-01 1.000000e+00 0.000000e+00 0.000000e+00 """ design_fts_expected_content = """/NumWaves 2 /NumContrasts 1 /Matrix 1 1 """ design_grp_expected_content = """/NumWaves 1 /NumPoints 3 /Matrix 1 1 1 """ yield assert_equal, open(os.path.join(os.getcwd(), 'design.con'), 'r').read(), design_con_expected_content yield assert_equal, open(os.path.join(os.getcwd(), 'design.mat'), 'r').read(), design_mat_expected_content yield assert_equal, open(os.path.join(os.getcwd(), 'design.fts'), 'r').read(), design_fts_expected_content yield assert_equal, open(os.path.join(os.getcwd(), 'design.grp'), 'r').read(), design_grp_expected_content teardown_infile(tp_dir)