From c24578f75291e6beb8a3a464c277e132296b6ef1 Mon Sep 17 00:00:00 2001 From: Michiel Cottaar <MichielCottaar@protonmail.com> Date: Thu, 23 Jul 2020 11:36:19 +0100 Subject: [PATCH] ENH: add wrapper for gps --- fsl/wrappers/__init__.py | 3 ++- fsl/wrappers/misc.py | 19 +++++++++++++++++++ tests/test_wrappers/test_wrappers.py | 10 +++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/fsl/wrappers/__init__.py b/fsl/wrappers/__init__.py index 87f410cb9..25f5ff9f1 100644 --- a/fsl/wrappers/__init__.py +++ b/fsl/wrappers/__init__.py @@ -107,4 +107,5 @@ from .melodic import (melodic, # noqa from .misc import (fslreorient2std, # noqa fslroi, slicer, - cluster) + cluster, + gps) diff --git a/fsl/wrappers/misc.py b/fsl/wrappers/misc.py index 9c2188828..925081483 100644 --- a/fsl/wrappers/misc.py +++ b/fsl/wrappers/misc.py @@ -85,3 +85,22 @@ def cluster(input, thresh, **kwargs): cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs) return cmd + +@wutils.fileOrArray('out', 'init') +@wutils.fslwrapper +def gps(out, ndir, **kwargs): + """Wrapper of the ``gps`` command + + Usage example to get 128 gradient orientations on the whole sphere:: + + from fsl.wrappers import gps, LOAD + bvecs = gps(LOAD, 128, optws=True)['out'] + """ + valmap = {name: wutils.SHOW_IF_TRUE for name in [ + 'optws', 'report', 'verbose' + ]} + + cmd = ['gps', f'--ndir={ndir}', f'--out={out}'] + cmd += wutils.applyArgStyle('--=', valmap=valmap, **kwargs) + + return cmd diff --git a/tests/test_wrappers/test_wrappers.py b/tests/test_wrappers/test_wrappers.py index 695bedfb3..a75cf2734 100644 --- a/tests/test_wrappers/test_wrappers.py +++ b/tests/test_wrappers/test_wrappers.py @@ -336,7 +336,6 @@ def test_fast(): assert result.stdout[0] == ' '.join(expected) - def test_fsl_anat(): with asrt.disabled(), \ run.dryrun(), \ @@ -349,3 +348,12 @@ def test_fsl_anat(): '-s', '25'] assert result.stdout[0] == ' '.join(expected) + + +def test_gps(): + with asrt.disabled(), run.dryrun(), mockFSLDIR(bin=('gps',)) as fsldir: + gps = op.join(fsldir, 'bin', 'gps') + result = fw.gps('bvecs', 128, optws=True, ranseed=123) + expected = (gps + ' --ndir=128 --out=bvecs', + ('--optws', '--ranseed=123')) + assert checkResult(result.stdout[0], *expected) -- GitLab