Skip to content

small edit of the MCFLIRT tests #1979

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 1 commit into from
Apr 29, 2017
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
15 changes: 14 additions & 1 deletion nipype/interfaces/fsl/tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ def test_mcflirt(setup_flirt):
realcmd = 'mcflirt -in ' + infile + ' -out ' + outfile2
assert frt.cmdline == realcmd


@pytest.mark.skipif(no_fsl(), reason="fsl is not installed")
def test_mcflirt_opt(setup_flirt):
tmpdir, infile, reffile = setup_flirt
_, nme = os.path.split(infile)

opt_map = {
'cost': ('-cost mutualinfo', 'mutualinfo'),
'bins': ('-bins 256', 256),
Expand All @@ -344,6 +350,9 @@ def test_mcflirt(setup_flirt):

for name, settings in list(opt_map.items()):
fnt = fsl.MCFLIRT(in_file=infile, **{name: settings[1]})
outfile = os.path.join(os.getcwd(), nme)
outfile = fnt._gen_fname(outfile, suffix='_mcf')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are always the same, they could go up under _, nme = os.path.split(infile), rather than be in the loop body.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the first line could move, but outfile variable name would need to change because the second outfile has to be generated within the loop.


instr = '-in %s' % (infile)
outstr = '-out %s' % (outfile)
if name in ('init', 'cost', 'dof', 'mean_vol', 'bins'):
Expand All @@ -357,10 +366,14 @@ def test_mcflirt(setup_flirt):
outstr,
settings[0]])


@pytest.mark.skipif(no_fsl(), reason="fsl is not installed")
def test_mcflirt_noinput():
# Test error is raised when missing required args
fnt = fsl.MCFLIRT()
with pytest.raises(ValueError):
with pytest.raises(ValueError) as excinfo:
fnt.run()
assert str(excinfo.value).startswith("MCFLIRT requires a value for input 'in_file'")

# test fnirt

Expand Down