From a26d025ee16658d2fe6fec1588d68f85acd72845 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Sun, 4 Mar 2018 10:00:16 +0000
Subject: [PATCH] All the things use @fslwrapper

---
 fsl/wrappers/bet.py      |  7 ++++---
 fsl/wrappers/eddy.py     |  7 ++++---
 fsl/wrappers/flirt.py    | 20 +++++++++-----------
 fsl/wrappers/fnirt.py    | 13 ++++++++-----
 fsl/wrappers/fslmaths.py |  4 ++--
 fsl/wrappers/fugue.py    |  8 +++++---
 fsl/wrappers/melodic.py  |  8 ++++----
 fsl/wrappers/misc.py     | 14 ++++++++------
 8 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/fsl/wrappers/bet.py b/fsl/wrappers/bet.py
index 1eadd23d8..45e7870de 100644
--- a/fsl/wrappers/bet.py
+++ b/fsl/wrappers/bet.py
@@ -11,11 +11,11 @@
 
 
 import fsl.utils.assertions as asrt
-import fsl.utils.run        as run
 from . import wrapperutils  as wutils
 
 
 @wutils.fileOrImage('input', 'output')
+@wutils.fslwrapper
 def bet(input, output, **kwargs):
     """Wrapper for the ``bet`` command.
 
@@ -46,11 +46,12 @@ def bet(input, output, **kwargs):
     cmd  = ['bet', input, output]
     cmd += wutils.applyArgStyle('-', argmap=argmap, valmap=valmap, **kwargs)
 
-    return run.runfsl(*cmd)
+    return cmd
 
 
 @wutils.fileOrImage('input', 'output')
 @wutils.fileOrArray('matrix')
+@wutils.fslwrapper
 def robustfov(input, output=None, **kwargs):
     """Wrapper for the ``robustfov`` command. """
     asrt.assertIsNifti(input)
@@ -66,4 +67,4 @@ def robustfov(input, output=None, **kwargs):
     cmd  = ['robustfov', '-i', input]
     cmd += wutils.applyArgStyle('-', argmap=argmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
diff --git a/fsl/wrappers/eddy.py b/fsl/wrappers/eddy.py
index c5d272ad2..ae5c7bb4f 100644
--- a/fsl/wrappers/eddy.py
+++ b/fsl/wrappers/eddy.py
@@ -18,13 +18,13 @@ estimation and eddy-current distortion correction.
 """
 
 
-import fsl.utils.run        as run
 import fsl.utils.assertions as asrt
 from . import wrapperutils  as wutils
 
 
 @wutils.fileOrImage('imain', 'mask', 'field')
 @wutils.fileOrArray('index', 'acqp', 'bvecs', 'bvals', 'field_mat')
+@wutils.fslwrapper
 def eddy_cuda(imain, mask, index, acqp, bvecs, bvals, out, **kwargs):
     """Wrapper for the ``eddy_cuda`` command."""
 
@@ -58,11 +58,12 @@ def eddy_cuda(imain, mask, index, acqp, bvecs, bvals, out, **kwargs):
                    'out'   : out})
 
     cmd = ['eddy_cuda'] + wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
-    return run.runfsl(cmd)
+    return cmd
 
 
 @wutils.fileOrImage('imain', 'fout', 'iout')
 @wutils.fileOrArray('datain')
+@wutils.fslwrapper
 def topup(imain, datain, **kwargs):
     """Wrapper for the ``topup`` command."""
 
@@ -76,4 +77,4 @@ def topup(imain, datain, **kwargs):
     cmd  = ['topup', '--imain={}'.format(imain), '--datain={}'.format(datain)]
     cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
diff --git a/fsl/wrappers/flirt.py b/fsl/wrappers/flirt.py
index dd4dadbf6..dac853992 100644
--- a/fsl/wrappers/flirt.py
+++ b/fsl/wrappers/flirt.py
@@ -20,14 +20,13 @@ tools.
 """
 
 
-import fsl.utils.run        as run
 import fsl.utils.assertions as asrt
 from . import wrapperutils  as wutils
 
 
-@wutils.required('src', 'ref')
 @wutils.fileOrImage('src', 'ref', 'out', 'wmseg', 'fieldmap', 'fieldmapmask')
 @wutils.fileOrArray('init', 'omat', 'wmcoords', 'wmnorms')
+@wutils.fslwrapper
 def flirt(src, ref, **kwargs):
     """Wrapper for the ``flirt`` command.
 
@@ -57,11 +56,9 @@ def flirt(src, ref, **kwargs):
     cmd  = ['flirt', '-in', src, '-ref', ref]
     cmd += wutils.applyArgStyle('-', argmap=argmap, valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
 
 
-@wutils.fileOrImage('src', 'ref', 'out')
-@wutils.fileOrArray('mat')
 def applyxfm(src, ref, mat, out, interp='spline'):
     """Convenience function which runs ``flirt -applyxfm ...``."""
     return flirt(src,
@@ -72,16 +69,16 @@ def applyxfm(src, ref, mat, out, interp='spline'):
                  interp=interp)
 
 
-@wutils.fileOrArray
+@wutils.fileOrArray()
+@wutils.fslwrapper
 def invxfm(inmat, omat):
     """Use ``convert_xfm`` to invert an affine."""
     asrt.assertFileExists(inmat)
-
-    cmd = 'convert_xfm -omat {} -inverse {}'.format(omat, inmat)
-    return run.runfsl(cmd)
+    return ['convert_xfm', '-omat', omat, '-inverse', inmat]
 
 
 @wutils.fileOrArray('inmat1', 'inmat2', 'outmat')
+@wutils.fslwrapper
 def concatxfm(inmat1, inmat2, outmat):
     """Use ``convert_xfm`` to concatenate two affines."""
 
@@ -94,11 +91,12 @@ def concatxfm(inmat1, inmat2, outmat):
            inmat2,
            inmat1]
 
-    return run.runfsl(cmd)
+    return cmd
 
 
 @wutils.fileOrImage('infile', 'out', 'reffile')
 @wutils.fileOrArray('init')
+@wutils.fslwrapper
 def mcflirt(infile, **kwargs):
     """Wrapper for the ``mcflirt`` command."""
 
@@ -107,4 +105,4 @@ def mcflirt(infile, **kwargs):
     cmd  = ['mcflirt', '-in', infile]
     cmd += wutils.applyArgStyle('-', **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
diff --git a/fsl/wrappers/fnirt.py b/fsl/wrappers/fnirt.py
index 3abcd51c9..bd4573373 100644
--- a/fsl/wrappers/fnirt.py
+++ b/fsl/wrappers/fnirt.py
@@ -19,7 +19,6 @@ non-linear registration of 3D images.
 """
 
 
-import fsl.utils.run        as run
 import fsl.utils.assertions as asrt
 from . import wrapperutils  as wutils
 
@@ -27,6 +26,7 @@ from . import wrapperutils  as wutils
 @wutils.fileOrImage('src', 'ref', 'inwarp', 'cout', 'iout', 'fout', 'jout',
                     'refout', 'refmask', 'inmask')
 @wutils.fileOrArray('aff')
+@wutils.fslwrapper
 def fnirt(src, ref, **kwargs):
     """Wrapper for the ``fnirt`` command."""
 
@@ -35,11 +35,12 @@ def fnirt(src, ref, **kwargs):
     cmd  = ['fnirt', '--in={}'.format(src), '--ref={}'.format(ref)]
     cmd += wutils.applyArgStyle('--=', **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
 
 
 @wutils.fileOrImage('src', 'ref', 'out', 'warp', 'mask')
 @wutils.fileOrArray('premat', 'postmat')
+@wutils.fslwrapper
 def applywarp(src, ref, out, warp, **kwargs):
     """Wrapper for the ``applywarp`` command. """
 
@@ -59,10 +60,11 @@ def applywarp(src, ref, out, warp, **kwargs):
 
     cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
 
 
 @wutils.fileOrImage('warp', 'ref', 'out')
+@wutils.fslwrapper
 def invwarp(warp, ref, out, **kwargs):
     """Wrapper for the ``invwarp`` command."""
 
@@ -83,11 +85,12 @@ def invwarp(warp, ref, out, **kwargs):
 
     cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
 
 
 @wutils.fileOrImage('out', 'ref', 'warp1', 'warp2', 'shiftmap')
 @wutils.fileOrArray('premat', 'midmat', 'postmat')
+@wutils.fslwrapper
 def convertwarp(out, ref, **kwargs):
     """Wrapper for the ``convertwarp`` command."""
 
@@ -105,4 +108,4 @@ def convertwarp(out, ref, **kwargs):
     cmd  = ['convertwarp', '--ref={}'.format(ref), '--out={}'.format(out)]
     cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
diff --git a/fsl/wrappers/fslmaths.py b/fsl/wrappers/fslmaths.py
index 3ad54b784..db5858f04 100644
--- a/fsl/wrappers/fslmaths.py
+++ b/fsl/wrappers/fslmaths.py
@@ -9,7 +9,6 @@ for the ``fslmaths`` command-line tool.
 """
 
 
-import fsl.utils.run       as run
 from . import wrapperutils as wutils
 
 
@@ -155,6 +154,7 @@ class fslmaths(object):
         else:              return output
 
     @wutils.fileOrImage()
+    @wutils.fslwrapper
     def __run(self, *cmd):
         """Run the given ``fslmaths`` command. """
-        return run.runfsl([str(c) for c in cmd])
+        return [str(c) for c in cmd]
diff --git a/fsl/wrappers/fugue.py b/fsl/wrappers/fugue.py
index 7a4cf8e5f..19fdcf94b 100644
--- a/fsl/wrappers/fugue.py
+++ b/fsl/wrappers/fugue.py
@@ -11,12 +11,12 @@ processing and distortion correction.
 """
 
 
-import fsl.utils.run       as run
 from . import wrapperutils as wutils
 
 
 @wutils.fileOrImage('in', 'unwarp', 'warp', 'phasemap', 'savefmap',
                     'loadfmap', 'saveshift', 'loadshift', 'mask')
+@wutils.fslwrapper
 def fugue(**kwargs):
     """Wrapper for the ``fugue`` command."""
 
@@ -39,9 +39,11 @@ def fugue(**kwargs):
 
     cmd = ['fugue'] + wutils.applyArgStyle('--=',  valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
 
 
+@wutils.fileOrImage('input', 'mask', 'sigloss')
+@wutils.fslwrapper
 def sigloss(input, sigloss, **kwargs):
     """Wrapper for the ``sigloss`` command."""
 
@@ -50,4 +52,4 @@ def sigloss(input, sigloss, **kwargs):
     cmd  = ['sigloss', '--in', input, '--sigloss', sigloss]
     cmd += wutils.applyArgStyle('--', valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
diff --git a/fsl/wrappers/melodic.py b/fsl/wrappers/melodic.py
index 16887284d..d95b33fa5 100644
--- a/fsl/wrappers/melodic.py
+++ b/fsl/wrappers/melodic.py
@@ -17,14 +17,13 @@ related utilities.
 """
 
 
-
-import fsl.utils.run        as run
 import fsl.utils.assertions as asrt
 from . import wrapperutils  as wutils
 
 
 @wutils.fileOrArray('mix', 'Tdes', 'Tcon', 'Sdes', 'Scon')
 @wutils.fileOrImage('input', 'mask', 'ICs', 'bgimage')
+@wutils.fslwrapper
 def melodic(input, **kwargs):
     """Multivariate Exploratory Linear Optimised ICA."""
 
@@ -56,11 +55,12 @@ def melodic(input, **kwargs):
     cmd  = ['melodic', '--in', input]
     cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
 
 
 @wutils.fileOrImage('input', 'out', 'mask', 'out_data')
 @wutils.fileOrArray('design', 'out_mix')
+@wutils.fslwrapper
 def fsl_regfilt(input, out, design, **kwargs):
     """Wrapper for the ``fsl_regfilt``command. """
 
@@ -79,4 +79,4 @@ def fsl_regfilt(input, out, design, **kwargs):
             '--design={}'.format(design)]
     cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
diff --git a/fsl/wrappers/misc.py b/fsl/wrappers/misc.py
index 4d912dee2..3b7a0615e 100644
--- a/fsl/wrappers/misc.py
+++ b/fsl/wrappers/misc.py
@@ -10,12 +10,12 @@
 """
 
 
-import fsl.utils.run        as run
 import fsl.utils.assertions as asrt
 from . import wrapperutils  as wutils
 
 
 @wutils.fileOrImage('input', 'output')
+@wutils.fslwrapper
 def fslreorient2std(input, output=None):
     """Wrapper for the ``fsreorient2std`` tool."""
 
@@ -26,10 +26,11 @@ def fslreorient2std(input, output=None):
     if output is not None:
         cmd.append(output)
 
-    return run.runfsl(cmd)
+    return cmd
 
 
 @wutils.fileOrImage('input', 'output')
+@wutils.fslwrapper
 def fslroi(input, output, xmin=None, xsize=None, ymin=None, ysize=None,
            zmin=None, zsize=None, tmin=None, tsize=None):
     """Wrapper for the ``fslroi`` tool."""
@@ -46,10 +47,11 @@ def fslroi(input, output, xmin=None, xsize=None, ymin=None, ysize=None,
     if tmin is not None:
         cmd += [str(tmin), str(tsize)]
 
-    return run.runfsl(cmd)
+    return cmd
 
 
 @wutils.fileOrImage('input', 'input2')
+@wutils.fslwrapper
 def slicer(input, input2=None, label=None, lut=None, intensity=None,
            edgethreshold=None, x=None, y=None, z=None):
     """Wrapper for the ``slicer`` command. """
@@ -73,14 +75,14 @@ def slicer(input, input2=None, label=None, lut=None, intensity=None,
     if z is not None:
         cmd += " -z {0} {1}".format(z[0], z[1])
 
-    return run.runfsl(cmd)
-
+    return cmd
 
 
 @wutils.fileOrImage('input', 'cope', 'oindex', 'othresh', 'olmaxim', 'osize',
                     'omax', 'omean', 'opvals', 'stdvol', 'warpvol',
                     'empiricalNull')
 @wutils.fileOrArray('xfm')
+@wutils.fslwrapper
 def cluster(input, thresh, **kwargs):
     """Wrapper for the ``cluster`` command. """
 
@@ -98,4 +100,4 @@ def cluster(input, thresh, **kwargs):
     cmd  = ['cluster', '--in={}'.format(input), '--thresh={}'.format(thresh)]
     cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
 
-    return run.runfsl(cmd)
+    return cmd
-- 
GitLab