Skip to content

Commit 1254589

Browse files
DylanDylan
Dylan
authored and
Dylan
committed
[ENH] Add tcat interface that accepts subbrick selectors
1 parent 0cb9e45 commit 1254589

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
Bucket, Calc, Cat, CatMatvec, Copy, Dot,
2424
Edge3, Eval, FWHMx, MaskTool, Merge, Notes, NwarpApply,
2525
OneDToolPy,
26-
Refit, Resample, TCat, TStat, To3D, Unifize, ZCutUp, GCOR,
26+
Refit, Resample, TCat, TCatSubBrick, TStat, To3D, Unifize, ZCutUp, GCOR,
2727
Zcat, Zeropad)
2828
from .model import (Deconvolve, Remlfit)

nipype/interfaces/afni/utils.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,60 @@ class TCat(AFNICommand):
17481748
input_spec = TCatInputSpec
17491749
output_spec = AFNICommandOutputSpec
17501750

1751+
class TCatSBInputSpec(AFNICommandInputSpec):
1752+
in_files = traits.List(
1753+
traits.Tuple(File(exists=True),Str()),
1754+
desc='List of tuples of file names and subbrick selectors as strings.'
1755+
'Don\'t forget to protect the single quotes in the subbrick selector'
1756+
'so the contents are protected from the command line interpreter.',
1757+
argstr='%s%s ...',
1758+
position=-1,
1759+
mandatory=True,
1760+
copyfile=False)
1761+
out_file = File(
1762+
desc='output image file name',
1763+
argstr='-prefix %s',
1764+
genfile=True)
1765+
rlt = traits.Enum(
1766+
'', '+', '++',
1767+
argstr='-rlt%s',
1768+
desc='Remove linear trends in each voxel time series loaded from each '
1769+
'input dataset, SEPARATELY. Option -rlt removes the least squares '
1770+
'fit of \'a+b*t\' to each voxel time series. Option -rlt+ adds '
1771+
'dataset mean back in. Option -rlt++ adds overall mean of all '
1772+
'dataset timeseries back in.',
1773+
position=1)
1774+
1775+
1776+
class TCatSubBrick(AFNICommand):
1777+
"""Hopefully a temporary function to allow sub-brick selection until
1778+
afni file managment is improved.
1779+
1780+
For complete details, see the `3dTcat Documentation.
1781+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dTcat.html>`_
1782+
1783+
Examples
1784+
========
1785+
1786+
>>> from nipype.interfaces import afni
1787+
>>> tcsb = afni.TCatSubBrick()
1788+
>>> tcsb.inputs.in_files = [('functional.nii', "'{2..$}'"), ('functional2.nii', "'{2..$}'")]
1789+
>>> tcsb.inputs.out_file= 'functional_tcat.nii'
1790+
>>> tcsb.inputs.rlt = '+'
1791+
>>> tcsb.cmdline # doctest: +ALLOW_UNICODE +NORMALIZE_WHITESPACE
1792+
"3dTcat -rlt+ -prefix functional_tcat.nii functional.nii'{2..$}' functional2.nii'{2..$}' "
1793+
>>> res = tcsb.run() # doctest: +SKIP
1794+
1795+
"""
1796+
1797+
_cmd = '3dTcat'
1798+
input_spec = TCatSBInputSpec
1799+
output_spec = AFNICommandOutputSpec
1800+
1801+
def _gen_filename(self, name):
1802+
if name == 'out_file':
1803+
return self._gen_fname(self.inputs.in_files[0][0], suffix='_tcat')
1804+
17511805

17521806
class TStatInputSpec(AFNICommandInputSpec):
17531807
in_file = File(

0 commit comments

Comments
 (0)