Skip to content

Commit 88d1d28

Browse files
authored
Merge pull request #3166 from AnnaD15/AnnaD15-patch-1
[FIX] FSL model.py make multiple F-tests
2 parents be9a98c + aa4d604 commit 88d1d28

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

.zenodo.json

+5
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,11 @@
765765
"name": "Mihai, Paul Glad",
766766
"orcid": "0000-0001-5715-6442"
767767
},
768+
{
769+
"affiliation": "Department of Psychology, University of Bielefeld, Bielefeld, Germany.",
770+
"name": "Doll, Anna",
771+
"orcid": "0000-0002-0799-0831"
772+
},
768773
{
769774
"affiliation": "Department of Psychology, Stanford University",
770775
"name": "Gorgolewski, Krzysztof J.",

nipype/interfaces/fsl/model.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1574,8 +1574,7 @@ def _run_interface(self, runtime):
15741574
for tcon in con[2]:
15751575
convals[tconmap[self.inputs.contrasts.index(tcon)]] = 1
15761576
fcon_txt.append(" ".join(["%d" % val for val in convals]))
1577-
fcon_txt = "\n".join(fcon_txt)
1578-
fcon_txt += "\n"
1577+
fcon_txt = "\n".join(fcon_txt) + "\n"
15791578
# write group file
15801579
grp_txt = ["/NumWaves 1", "/NumPoints %d" % npoints, "", "/Matrix"]
15811580
for i in range(npoints):

nipype/interfaces/fsl/tests/test_model.py

+20-18
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,28 @@
66
import pytest
77
import nipype.interfaces.fsl.model as fsl
88
from nipype.interfaces.fsl import no_fsl
9+
from pathlib import Path
10+
from ....pipeline import engine as pe
911

1012

1113
@pytest.mark.skipif(no_fsl(), reason="fsl is not installed")
1214
def test_MultipleRegressDesign(tmpdir):
13-
tmpdir.chdir()
14-
foo = fsl.MultipleRegressDesign()
15-
foo.inputs.regressors = dict(
15+
designer = pe.Node(fsl.MultipleRegressDesign(), name='designer', base_dir=str(tmpdir))
16+
designer.inputs.regressors = dict(
1617
voice_stenght=[1, 1, 1], age=[0.2, 0.4, 0.5], BMI=[1, -1, 2]
1718
)
1819
con1 = ["voice_and_age", "T", ["age", "voice_stenght"], [0.5, 0.5]]
1920
con2 = ["just_BMI", "T", ["BMI"], [1]]
20-
foo.inputs.contrasts = [con1, con2, ["con3", "F", [con1, con2]]]
21-
res = foo.run()
21+
designer.inputs.contrasts = [con1, con2, ["con3", "F", [con1, con2]], ["con4", "F", [con2]]]
22+
res = designer.run()
23+
outputs = res.outputs.get_traitsfree()
2224

23-
for ii in ["mat", "con", "fts", "grp"]:
24-
assert (
25-
getattr(res.outputs, "design_" + ii) == tmpdir.join("design." + ii).strpath
26-
)
25+
for ftype in ["mat", "con", "fts", "grp"]:
26+
assert Path(outputs["design_" + ftype]).exists()
2727

28-
design_mat_expected_content = """/NumWaves 3
28+
expected_content = {}
29+
30+
expected_content["design_mat"] = """/NumWaves 3
2931
/NumPoints 3
3032
/PPheights 3.000000e+00 5.000000e-01 1.000000e+00
3133
@@ -35,7 +37,7 @@ def test_MultipleRegressDesign(tmpdir):
3537
2.000000e+00 5.000000e-01 1.000000e+00
3638
"""
3739

38-
design_con_expected_content = """/ContrastName1 voice_and_age
40+
expected_content["design_con"] = """/ContrastName1 voice_and_age
3941
/ContrastName2 just_BMI
4042
/NumWaves 3
4143
/NumContrasts 2
@@ -47,22 +49,22 @@ def test_MultipleRegressDesign(tmpdir):
4749
1.000000e+00 0.000000e+00 0.000000e+00
4850
"""
4951

50-
design_fts_expected_content = """/NumWaves 2
51-
/NumContrasts 1
52+
expected_content["design_fts"] = """/NumWaves 2
53+
/NumContrasts 2
5254
5355
/Matrix
5456
1 1
57+
0 1
5558
"""
5659

57-
design_grp_expected_content = """/NumWaves 1
60+
expected_content["design_grp"] = """/NumWaves 1
5861
/NumPoints 3
5962
6063
/Matrix
6164
1
6265
1
6366
1
6467
"""
65-
for ii in ["mat", "con", "fts", "grp"]:
66-
assert tmpdir.join("design." + ii).read() == eval(
67-
"design_" + ii + "_expected_content"
68-
)
68+
for ftype in ["mat", "con", "fts", "grp"]:
69+
outfile = "design_" + ftype
70+
assert Path(outputs[outfile]).read_text() == expected_content[outfile]

0 commit comments

Comments
 (0)