diff --git a/fsl/wrappers/__init__.py b/fsl/wrappers/__init__.py index 2f1d97d6726fa930fecdb9fbf97da1d5280c5ea0..e9a8ecb26e8995f093f3cf51496eb15385997585 100755 --- a/fsl/wrappers/__init__.py +++ b/fsl/wrappers/__init__.py @@ -110,6 +110,7 @@ from fsl.wrappers.fugue import (fugue, from fsl.wrappers.melodic import (melodic, fsl_regfilt) from fsl.wrappers.misc import (fslreorient2std, + fslorient, fslroi, slicer, cluster, diff --git a/fsl/wrappers/misc.py b/fsl/wrappers/misc.py index 9250814830dca73288178360421b383b723e9183..f6c7b172b91f8676dc9f970de7108c705cdfb826 100644 --- a/fsl/wrappers/misc.py +++ b/fsl/wrappers/misc.py @@ -29,6 +29,34 @@ def fslreorient2std(input, output=None): 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.fslwrapper def fslroi(input, output, *args): diff --git a/tests/test_wrappers/test_wrappers.py b/tests/test_wrappers/test_wrappers.py index 9427172a56cb1350d88e0e0161ebd44bd3f38906..1ef475a3fdf2f654c3021d47a62ca13d7f7e6241 100755 --- a/tests/test_wrappers/test_wrappers.py +++ b/tests/test_wrappers/test_wrappers.py @@ -250,6 +250,21 @@ def test_fsl_regfilt(): 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(): with asrt.disabled(), run.dryrun(), mockFSLDIR(bin=('fslreorient2std',)) as fsldir: