Skip to content

Commit ebfbc42

Browse files
committed
Merge branch 'fix/mnibias' of https://github.com/mgxd/nipype into fix/mnibias
2 parents 1e19bca + 2cecd53 commit ebfbc42

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

nipype/interfaces/freesurfer/preprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ class MNIBiasCorrectionInputSpec(FSTraitedSpec):
14671467
# mandatory
14681468
in_file = File(exists=True, mandatory=True, argstr="--i %s",
14691469
desc="input volume. Input can be any format accepted by mri_convert.")
1470-
out_file = File(argstr="--o %s", name_source=['in_file'],
1470+
out_file = File(argstr="--o %s", mandatory=True, name_source=['in_file'],
14711471
name_template='%s_output', hash_files=False, keep_extension=True,
14721472
desc="output volume. Output can be any format accepted by mri_convert. " +
14731473
"If the output format is COR, then the directory must exist.")

nipype/interfaces/freesurfer/tests/test_preprocess.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,28 @@ def test_synthesizeflash(create_files_in_directory):
8585
syn2 = freesurfer.SynthesizeFLASH(t1_image=filelist[0], pd_image=filelist[1], flip_angle=20, te=5, tr=25)
8686
assert syn2.cmdline == ('mri_synthesize 25.00 20.00 5.000 %s %s %s'
8787
% (filelist[0], filelist[1], os.path.join(outdir, 'synth-flash_20.mgz')))
88+
89+
@pytest.mark.skipif(freesurfer.no_freesurfer(), reason="freesurfer is not installed")
90+
def test_mandatory_outvol(create_files_in_directory):
91+
filelist, outdir = create_files_in_directory
92+
mni = freesurfer.MNIBiasCorrection()
93+
94+
# make sure command gets called
95+
assert mni.cmd == "mri_nu_correct.mni"
96+
97+
# test raising error with mandatory args absent
98+
with pytest.raises(ValueError): mni.run()
99+
100+
# test raising error with only partial mandatory args present
101+
mni.inputs.in_file = filelist[0] #mgz
102+
with pytest.raises(ValueError): mni.run()
103+
104+
# rest of mandatory inputs
105+
mni.inputs.out_file = 'bias_corrected_file'
106+
107+
assert mni.cmdline == ('mri_nu_correct.mni --i %s --n 4 --o bias_corrected_file.mgz'
108+
% filelist[0])
109+
# constructor based tests
110+
mni2 = freesurfer.MNIBiasCorrection(in_file=filelist[0], out_file='bias_corrected_file')
111+
assert mni2.cmdline == ('mri_nu_correct.mni --i %s --n 4 --o bias_corrected_file.mgz'
112+
% filelist[0])

0 commit comments

Comments
 (0)