From 6eca7accddedf2cc444b4e83749c50d0383169a6 Mon Sep 17 00:00:00 2001
From: Martin Craig <martin.craig@eng.ox.ac.uk>
Date: Thu, 11 Oct 2018 15:18:30 +0100
Subject: [PATCH] Add applytopup and partial fix for input files in topup

---
 fsl/wrappers/eddy.py | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/fsl/wrappers/eddy.py b/fsl/wrappers/eddy.py
index ae5c7bb4f..3419c99d1 100644
--- a/fsl/wrappers/eddy.py
+++ b/fsl/wrappers/eddy.py
@@ -61,8 +61,8 @@ def eddy_cuda(imain, mask, index, acqp, bvecs, bvals, out, **kwargs):
     return cmd
 
 
-@wutils.fileOrImage('imain', 'fout', 'iout')
-@wutils.fileOrArray('datain')
+@wutils.fileOrImage('imain', 'fout', 'iout', outprefix='out')
+@wutils.fileOrArray('datain', outprefix='out')
 @wutils.fslwrapper
 def topup(imain, datain, **kwargs):
     """Wrapper for the ``topup`` command."""
@@ -78,3 +78,25 @@ def topup(imain, datain, **kwargs):
     cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
 
     return cmd
+
+@wutils.fileOrImage('imain', 'out')
+@wutils.fileOrArray('datain')
+@wutils.fslwrapper
+def applytopup(imain, datain, index, **kwargs):
+    """Wrapper for the ``applytopup`` command."""
+
+    valmap = {
+        'verbose' : wutils.SHOW_IF_TRUE
+    }
+
+    asrt.assertFileExists(datain)
+    asrt.assertIsNifti(imain)
+
+    cmd  = [
+        'applytopup', '--imain={}'.format(imain), 
+        '--inindex={}'.format(index), 
+        '--datain={}'.format(datain),
+    ]
+    cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs)
+
+    return cmd
-- 
GitLab