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

All the things use @fslwrapper

parent eaa402dc
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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]
......@@ -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
......@@ -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
......@@ -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
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