Skip to content
Snippets Groups Projects
Commit 8d1f3fa3 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Merge branch 'master' into 'master'

ENH: wrapper for `fslorient` tool

See merge request fsl/fslpy!315
parents 4ef642f3 91bb5c27
No related branches found
No related tags found
No related merge requests found
Pipeline #12153 passed
...@@ -110,6 +110,7 @@ from fsl.wrappers.fugue import (fugue, ...@@ -110,6 +110,7 @@ from fsl.wrappers.fugue import (fugue,
from fsl.wrappers.melodic import (melodic, from fsl.wrappers.melodic import (melodic,
fsl_regfilt) fsl_regfilt)
from fsl.wrappers.misc import (fslreorient2std, from fsl.wrappers.misc import (fslreorient2std,
fslorient,
fslroi, fslroi,
slicer, slicer,
cluster, cluster,
......
...@@ -29,6 +29,34 @@ def fslreorient2std(input, output=None): ...@@ -29,6 +29,34 @@ def fslreorient2std(input, output=None):
return cmd return cmd
@wutils.fileOrImage('input')
@wutils.fslwrapper
def fslorient(input, **kwargs):
"""Wrapper for the ``fslorient`` tool."""
asrt.assertIsNifti(input)
valmap = {
'getorient' : wutils.SHOW_IF_TRUE,
'getsform' : wutils.SHOW_IF_TRUE,
'getqform' : wutils.SHOW_IF_TRUE,
'getsformcode' : wutils.SHOW_IF_TRUE,
'getqformcode' : wutils.SHOW_IF_TRUE,
'copysform2qform' : wutils.SHOW_IF_TRUE,
'copyqform2sform' : wutils.SHOW_IF_TRUE,
'deleteorient' : wutils.SHOW_IF_TRUE,
'forceradiological' : wutils.SHOW_IF_TRUE,
'forceneurological' : wutils.SHOW_IF_TRUE,
'swaporient' : wutils.SHOW_IF_TRUE,
}
cmd = ['fslorient']
cmd += wutils.applyArgStyle('-', valsep=' ', valmap=valmap, **kwargs)
cmd += [input]
return cmd
@wutils.fileOrImage('input', 'output') @wutils.fileOrImage('input', 'output')
@wutils.fslwrapper @wutils.fslwrapper
def fslroi(input, output, *args): def fslroi(input, output, *args):
......
...@@ -250,6 +250,21 @@ def test_fsl_regfilt(): ...@@ -250,6 +250,21 @@ def test_fsl_regfilt():
assert checkResult(result.stdout[0], *expected) assert checkResult(result.stdout[0], *expected)
def test_fslorient():
with asrt.disabled(), run.dryrun(), mockFSLDIR(bin=('fslorient',)) as fsldir:
fslo = op.join(fsldir, 'bin', 'fslorient')
result = fw.fslorient('input', setsform=(-2, 0, 0, 90, 0, 2, 0, -126, 0, 0, 2, -72, 0, 0, 0, 1))
expected = fslo + ' -setsform -2 0 0 90 0 2 0 -126 0 0 2 -72 0 0 0 1' + ' input'
assert result.stdout[0] == expected
result = fw.fslorient('input', getorient=True)
expected = fslo + ' -getorient' + ' input'
assert result.stdout[0] == expected
result = fw.fslorient('input', setsformcode=1)
expected = fslo + ' -setsformcode 1' + ' input'
assert result.stdout[0] == expected
def test_fslreorient2std(): def test_fslreorient2std():
with asrt.disabled(), run.dryrun(), mockFSLDIR(bin=('fslreorient2std',)) as fsldir: with asrt.disabled(), run.dryrun(), mockFSLDIR(bin=('fslreorient2std',)) as fsldir:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment