From 506e534a193911cda468564f2ff729c4a293133c Mon Sep 17 00:00:00 2001 From: Christoph Arthofer <christoph.arthofer@ndcn.ox.ac.uk> Date: Tue, 3 Aug 2021 11:58:55 +0100 Subject: [PATCH] ENH: Added wrapper for epi_reg --- fsl/wrappers/__init__.py | 1 + fsl/wrappers/epi_reg.py | 41 ++++++++++++++++++++++++++++ tests/test_wrappers/test_wrappers.py | 8 ++++++ 3 files changed, 50 insertions(+) mode change 100644 => 100755 fsl/wrappers/__init__.py create mode 100755 fsl/wrappers/epi_reg.py mode change 100644 => 100755 tests/test_wrappers/test_wrappers.py diff --git a/fsl/wrappers/__init__.py b/fsl/wrappers/__init__.py old mode 100644 new mode 100755 index 19292be71..7848a07b7 --- a/fsl/wrappers/__init__.py +++ b/fsl/wrappers/__init__.py @@ -110,4 +110,5 @@ from .misc import (fslreorient2std, # noqa slicer, cluster, gps) +from .epi_reg import epi_reg from . import tbss # noqa diff --git a/fsl/wrappers/epi_reg.py b/fsl/wrappers/epi_reg.py new file mode 100755 index 000000000..fe955689a --- /dev/null +++ b/fsl/wrappers/epi_reg.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# +# epi_reg.py - Wrapper for the epi_reg command. +# +# Author: +# +"""This module provides the :func:`epi_reg` function, a wrapper for the FSL +`epi_reg <https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FLIRT/UserGuide#epi_reg>`_ command. +""" + +import fsl.utils.assertions as asrt +from . import wrapperutils as wutils + +@wutils.fileOrImage('epi', 't1', 't1brain', 'fmap', 'fmapmag', 'fmapmagbrain', 'gdc', 'wmseg', 'weight', outprefix='out') +@wutils.fslwrapper +def epi_reg(epi, t1, t1brain, out='epi_reg', **kwargs): + """Wrapper for the ``epi_reg`` command. + + :arg epi: Input EPI image + :arg t1: Input wholehead T1 image + :arg t1brain: Input brain extracted T1 image + :arg out: Output name + """ + asrt.assertIsNifti(epi) + asrt.assertIsNifti(t1) + asrt.assertIsNifti(t1brain) + + valmap = { + 'nofmapreg' : wutils.SHOW_IF_TRUE, + 'noclean' : wutils.SHOW_IF_TRUE, + 'v' : wutils.SHOW_IF_TRUE, + } + + cmd = ['epi_reg', '--epi='+epi, '--t1='+t1, '--t1brain='+t1brain, '--out='+out] + + cmd += wutils.applyArgStyle('--=', + valmap=valmap, + singlechar_args=True, + **kwargs) + + return cmd diff --git a/tests/test_wrappers/test_wrappers.py b/tests/test_wrappers/test_wrappers.py old mode 100644 new mode 100755 index 2c8b9b1aa..5eaea8177 --- a/tests/test_wrappers/test_wrappers.py +++ b/tests/test_wrappers/test_wrappers.py @@ -93,6 +93,14 @@ def test_flirt(): assert checkResult(result.stdout[0], *expected) +def test_epi_reg(): + with asrt.disabled(), run.dryrun(), mockFSLDIR(bin=('epi_reg',)) as fsldir: + epi_reg = op.join(fsldir, 'bin', 'epi_reg') + result = fw.epi_reg('epi', 't1', 't1brain', 'out') + expected = epi_reg + ' --epi=epi --t1=t1 --t1brain=t1brain --out=out' + assert result.stdout[0] == expected + + def test_applyxfm(): with asrt.disabled(), run.dryrun(), mockFSLDIR(bin=('flirt',)) as fsldir: flirt = op.join(fsldir, 'bin', 'flirt') -- GitLab