From 72131e594acc03ea48367d4ada261d6a84301667 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Thu, 22 Nov 2018 20:59:09 +0000
Subject: [PATCH] DOC,STY: Tweaks to code style, docs, updated authors.

---
 fsl/utils/run.py             | 15 +++++++-------
 fsl/wrappers/bet.py          |  3 ++-
 fsl/wrappers/eddy.py         |  6 ++++--
 fsl/wrappers/fast.py         |  6 +++++-
 fsl/wrappers/fsl_anat.py     |  6 +++++-
 fsl/wrappers/wrapperutils.py | 39 +++++++++++++++++++++++++++---------
 6 files changed, 53 insertions(+), 22 deletions(-)

diff --git a/fsl/utils/run.py b/fsl/utils/run.py
index f469af487..3fb7d979e 100644
--- a/fsl/utils/run.py
+++ b/fsl/utils/run.py
@@ -21,7 +21,6 @@
 
 import               sys
 import               logging
-import               warnings
 import               threading
 import               contextlib
 import               collections
@@ -129,7 +128,7 @@ def run(*args, **kwargs):
     argument.
 
     An exception is raised if the command returns a non-zero exit code, unless
-    the ``ret`` option is set to ``True``.
+    the ``exitcode`` option is set to ``True``.
 
     :arg stdout:   Must be passed as a keyword argument. Defaults to ``True``.
                    If ``True``, standard output is captured and returned.
@@ -162,8 +161,8 @@ def run(*args, **kwargs):
                      - stderr: Optional file-like object to which the command's
                                standard error stream can be forwarded.
 
-                     - cmd:    Optional file-like object to which the command itself 
-                               is logged.
+                     - cmd:    Optional file-like object to which the command
+                               itself is logged.
 
     :returns:      If ``submit`` is provided, the return value of
                    :func:`.fslsub` is returned. Otherwise returns a single
@@ -323,11 +322,11 @@ def _realrun(tee, logStdout, logStderr, logCmd, *args):
 
 
 def runfsl(*args, **kwargs):
-    """Call a FSL command and return its output. 
-    
+    """Call a FSL command and return its output.
+
       This function searches for the command in the following
       locations (ordered by priority):
-      
+
       1. ``FSL_PREFIX``
       2. ``$FSLDEVDIR/bin``
       3. ``$FSLDIR/bin``
@@ -342,7 +341,7 @@ def runfsl(*args, **kwargs):
         prefixes.append(op.join(fslplatform.fsldevdir, 'bin'))
     if fslplatform.fsldir is not None:
         prefixes.append(op.join(fslplatform.fsldir, 'bin'))
-    
+
     if not prefixes:
         raise FSLNotPresent('$FSLDIR is not set - FSL cannot be found!')
 
diff --git a/fsl/wrappers/bet.py b/fsl/wrappers/bet.py
index 31660d122..895f0aa88 100644
--- a/fsl/wrappers/bet.py
+++ b/fsl/wrappers/bet.py
@@ -4,6 +4,7 @@
 #
 # Author: Sean Fitzgibbon <sean.fitzgibbon@ndcn.ox.ac.uk>
 # Author: Paul McCarthy <pauldmccarthy@gmail.com>
+# Author: Martin Craig <martin.craig@eng.ox.ac.uk>
 #
 """This module provides the :func:`bet` function, a wrapper for the FSL
 `BET <https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/BET>`_ command.
@@ -58,7 +59,7 @@ def bet(input, output, **kwargs):
     cmd  = ['bet', input, output]
 
     # The 'centre' argument requires three co-ordinates and can't be passed
-    # as a single value, so needs to be handled separately. Assume it is 
+    # as a single value, so needs to be handled separately. Assume it is
     # passed as a Python sequence
     centre = kwargs.pop("c", None)
     if centre is not None:
diff --git a/fsl/wrappers/eddy.py b/fsl/wrappers/eddy.py
index 3419c99d1..53a90b9ca 100644
--- a/fsl/wrappers/eddy.py
+++ b/fsl/wrappers/eddy.py
@@ -4,6 +4,7 @@
 #
 # Author: Sean Fitzgibbon <sean.fitzgibbon@ndcn.ox.ac.uk>
 # Author: Paul McCarthy <pauldmccarthy@gmail.com>
+# Author: Martin Craig <martin.craig@eng.ox.a.uk>
 #
 """This module provides wrapper functions for the FSL `TOPUP
 <https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/topup>`_ and `EDDY
@@ -15,6 +16,7 @@ estimation and eddy-current distortion correction.
 
    eddy_cuda
    topup
+   applytopup
 """
 
 
@@ -93,8 +95,8 @@ def applytopup(imain, datain, index, **kwargs):
     asrt.assertIsNifti(imain)
 
     cmd  = [
-        'applytopup', '--imain={}'.format(imain), 
-        '--inindex={}'.format(index), 
+        'applytopup', '--imain={}'.format(imain),
+        '--inindex={}'.format(index),
         '--datain={}'.format(datain),
     ]
     cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
diff --git a/fsl/wrappers/fast.py b/fsl/wrappers/fast.py
index b1cd712ac..5dbe2a412 100644
--- a/fsl/wrappers/fast.py
+++ b/fsl/wrappers/fast.py
@@ -45,7 +45,11 @@ def fast(imgs, out='fast', **kwargs):
     }
 
     cmd  = ['fast', '-v', '--out=%s' % out]
-    cmd += wutils.applyArgStyle('--=', valmap=valmap, argmap=argmap, singlechar_args=True, **kwargs)
+    cmd += wutils.applyArgStyle('--=',
+                                valmap=valmap,
+                                argmap=argmap,
+                                singlechar_args=True,
+                                **kwargs)
     cmd += imgs
 
     return cmd
diff --git a/fsl/wrappers/fsl_anat.py b/fsl/wrappers/fsl_anat.py
index a1ea260c1..868dacb70 100644
--- a/fsl/wrappers/fsl_anat.py
+++ b/fsl/wrappers/fsl_anat.py
@@ -46,6 +46,10 @@ def fsl_anat(img, out='fsl_anat', **kwargs):
     if smoothing is not None:
         cmd += ['-s', str(smoothing)]
 
-    cmd += wutils.applyArgStyle('--=', valmap=valmap, argmap=argmap, singlechar_args=True, **kwargs)
+    cmd += wutils.applyArgStyle('--=',
+                                valmap=valmap,
+                                argmap=argmap,
+                                singlechar_args=True,
+                                **kwargs)
 
     return cmd
diff --git a/fsl/wrappers/wrapperutils.py b/fsl/wrappers/wrapperutils.py
index 2bda19793..88db1dc92 100644
--- a/fsl/wrappers/wrapperutils.py
+++ b/fsl/wrappers/wrapperutils.py
@@ -4,6 +4,7 @@
 # functions.
 #
 # Author: Paul McCarthy <pauldmccarthy@gmail.com>
+# Author: Martin Craig <martin.craig@eng.ox.ac.uk>
 #
 """This module contains functions and decorators used by the FSL wrapper
 functions.
@@ -159,7 +160,12 @@ def cmdwrapper(func):
         submit = kwargs.pop('submit', None)
         log    = kwargs.pop('log',    {'tee' : True})
         cmd    = func(*args, **kwargs)
-        return run.run(cmd, stderr=stderr, log=log, submit=submit, stdout=stdout, exitcode=exitcode)
+        return run.run(cmd,
+                       stderr=stderr,
+                       log=log,
+                       submit=submit,
+                       stdout=stdout,
+                       exitcode=exitcode)
     return _update_wrapper(wrapper, func)
 
 
@@ -175,7 +181,12 @@ def fslwrapper(func):
         submit = kwargs.pop('submit', None)
         log    = kwargs.pop('log',    {'tee' : True})
         cmd    = func(*args, **kwargs)
-        return run.runfsl(cmd, stderr=stderr, log=log, submit=submit, stdout=stdout, exitcode=exitcode)
+        return run.runfsl(cmd,
+                          stderr=stderr,
+                          log=log,
+                          submit=submit,
+                          stdout=stdout,
+                          exitcode=exitcode)
     return _update_wrapper(wrapper, func)
 
 
@@ -197,7 +208,12 @@ generated command line arguments.
 """
 
 
-def applyArgStyle(style, valsep=None, argmap=None, valmap=None, singlechar_args=False, **kwargs):
+def applyArgStyle(style,
+                  valsep=None,
+                  argmap=None,
+                  valmap=None,
+                  singlechar_args=False,
+                  **kwargs):
     """Turns the given ``kwargs`` into command line options. This function
     is intended to be used to automatically generate command line options
     from arguments passed into a Python function.
@@ -256,8 +272,9 @@ def applyArgStyle(style, valsep=None, argmap=None, valmap=None, singlechar_args=
                  The argument for any options not specified in the ``valmap``
                  will be converted into strings.
 
-    :arg singlechar_args: If True, single character arguments always take a single
-                          hyphen prefix (e.g. -h) regardless of the style
+    :arg singlechar_args: If True, single character arguments always take a
+                          single hyphen prefix (e.g. -h) regardless of the
+                          style.
 
     :arg kwargs: Arguments to be converted into command-line options.
 
@@ -284,8 +301,10 @@ def applyArgStyle(style, valsep=None, argmap=None, valmap=None, singlechar_args=
     if valmap is None: valmap = {}
 
     def fmtarg(arg):
-        if   style in ('-',  '-=') or (singlechar_args and len(arg) == 1):  arg =  '-{}'.format(arg)
-        elif style in ('--', '--='): arg = '--{}'.format(arg)
+        if   style in ('-',  '-=') or (singlechar_args and len(arg) == 1):
+            arg =  '-{}'.format(arg)
+        elif style in ('--', '--='):
+            arg = '--{}'.format(arg)
         return arg
 
     # always returns a sequence
@@ -1007,9 +1026,11 @@ def fileOrArray(*args, **kwargs):
 
     return decorator
 
+
 def fileOrText(*args, **kwargs):
-    """Decorator which can be used to ensure that any text output (e.g. log file are saved
-    to text files, and output files can be loaded and returned as strings.
+    """Decorator which can be used to ensure that any text output (e.g. log
+    file) are saved to text files, and output files can be loaded and returned
+    as strings.
     """
 
     def prepIn(workdir, name, val):
-- 
GitLab