Skip to content

Commit 5cc2702

Browse files
authored
Merge pull request #2090 from emdupre/master
ENH Add 3dZcat and 3dZeropad
2 parents d360dde + 32d341d commit 5cc2702

File tree

4 files changed

+272
-1
lines changed

4 files changed

+272
-1
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
from .utils import (AFNItoNIFTI, Autobox, BrickStat, Calc, Copy, Edge3,
2121
Eval, FWHMx,
2222
MaskTool, Merge, Notes, Refit, Resample, TCat, TStat, To3D,
23-
Unifize, ZCutUp, GCOR,)
23+
Unifize, ZCutUp, GCOR, Zcat, Zeropad)
2424
from .model import (Deconvolve, Remlfit)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from __future__ import unicode_literals
3+
from ..preprocess import QwarpPlusMinus
4+
5+
6+
def test_QwarpPlusMinus_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
base_file=dict(argstr='-base %s',
10+
copyfile=False,
11+
mandatory=True,
12+
),
13+
blur=dict(argstr='-blur %s',
14+
),
15+
environ=dict(nohash=True,
16+
usedefault=True,
17+
),
18+
ignore_exception=dict(nohash=True,
19+
usedefault=True,
20+
),
21+
minpatch=dict(argstr='-minpatch %d',
22+
),
23+
nopadWARP=dict(argstr='-nopadWARP',
24+
),
25+
noweight=dict(argstr='-noweight',
26+
),
27+
pblur=dict(argstr='-pblur %s',
28+
),
29+
source_file=dict(argstr='-source %s',
30+
copyfile=False,
31+
mandatory=True,
32+
),
33+
terminal_output=dict(nohash=True,
34+
),
35+
)
36+
inputs = QwarpPlusMinus.input_spec()
37+
38+
for key, metadata in list(input_map.items()):
39+
for metakey, value in list(metadata.items()):
40+
assert getattr(inputs.traits()[key], metakey) == value
41+
42+
43+
def test_QwarpPlusMinus_outputs():
44+
output_map = dict(base_warp=dict(),
45+
source_warp=dict(),
46+
warped_base=dict(),
47+
warped_source=dict(),
48+
)
49+
outputs = QwarpPlusMinus.output_spec()
50+
51+
for key, metadata in list(output_map.items()):
52+
for metakey, value in list(metadata.items()):
53+
assert getattr(outputs.traits()[key], metakey) == value
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from __future__ import unicode_literals
3+
from ..utils import Unifize
4+
5+
6+
def test_Unifize_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
environ=dict(nohash=True,
10+
usedefault=True,
11+
),
12+
epi=dict(argstr='-EPI',
13+
requires=['no_duplo', 't2'],
14+
xor=['gm'],
15+
),
16+
gm=dict(argstr='-GM',
17+
),
18+
ignore_exception=dict(nohash=True,
19+
usedefault=True,
20+
),
21+
in_file=dict(argstr='-input %s',
22+
copyfile=False,
23+
mandatory=True,
24+
position=-1,
25+
),
26+
no_duplo=dict(argstr='-noduplo',
27+
),
28+
out_file=dict(argstr='-prefix %s',
29+
name_source='in_file',
30+
),
31+
outputtype=dict(),
32+
scale_file=dict(argstr='-ssave %s',
33+
),
34+
t2=dict(argstr='-T2',
35+
),
36+
terminal_output=dict(nohash=True,
37+
),
38+
urad=dict(argstr='-Urad %s',
39+
),
40+
)
41+
inputs = Unifize.input_spec()
42+
43+
for key, metadata in list(input_map.items()):
44+
for metakey, value in list(metadata.items()):
45+
assert getattr(inputs.traits()[key], metakey) == value
46+
47+
48+
def test_Unifize_outputs():
49+
output_map = dict(out_file=dict(),
50+
scale_file=dict(),
51+
)
52+
outputs = Unifize.output_spec()
53+
54+
for key, metadata in list(output_map.items()):
55+
for metakey, value in list(metadata.items()):
56+
assert getattr(outputs.traits()[key], metakey) == value

nipype/interfaces/afni/utils.py

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,3 +1534,165 @@ def _run_interface(self, runtime):
15341534

15351535
def _list_outputs(self):
15361536
return {'out': getattr(self, '_gcor')}
1537+
1538+
class ZcatInputSpec(AFNICommandInputSpec):
1539+
in_files = InputMultiPath(
1540+
File(
1541+
desc='input files to 3dZcat',
1542+
exists=True),
1543+
argstr='%s',
1544+
position=-1,
1545+
mandatory=True,
1546+
copyfile=False)
1547+
out_file = File(
1548+
name_template='zcat',
1549+
desc='output dataset prefix name (default \'zcat\')',
1550+
argstr='-prefix %s')
1551+
datum = traits.Enum(
1552+
'byte','short','float',
1553+
argstr='-datum %s',
1554+
desc='specify data type for output. Valid types are \'byte\', '
1555+
'\'short\' and \'float\'.')
1556+
verb = traits.Bool(
1557+
desc='print out some verbositiness as the program proceeds.',
1558+
argstr='-verb')
1559+
fscale = traits.Bool(
1560+
desc='Force scaling of the output to the maximum integer '
1561+
'range. This only has effect if the output datum is '
1562+
'byte or short (either forced or defaulted). This '
1563+
'option is sometimes necessary to eliminate '
1564+
'unpleasant truncation artifacts.',
1565+
argstr='-fscale',
1566+
xor=['nscale'])
1567+
nscale = traits.Bool(
1568+
desc='Don\'t do any scaling on output to byte or short '
1569+
'datasets. This may be especially useful when '
1570+
'operating on mask datasets whose output values '
1571+
'are only 0\'s and 1\'s.',
1572+
argstr='-nscale',
1573+
xor=['fscale'])
1574+
1575+
class Zcat(AFNICommand):
1576+
"""Copies an image of one type to an image of the same
1577+
or different type using 3dZcat command
1578+
1579+
For complete details, see the `3dZcat Documentation.
1580+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dZcat.html>`_
1581+
1582+
Examples
1583+
========
1584+
1585+
>>> from nipype.interfaces import afni
1586+
>>> zcat = afni.Zcat()
1587+
>>> zcat.inputs.in_files = ['functional2.nii', 'functional3.nii']
1588+
>>> zcat.inputs.out_file = 'cat_functional.nii'
1589+
>>> zcat.cmdline # doctest: +ALLOW_UNICODE
1590+
'3dZcat -prefix cat_functional.nii functional2.nii functional3.nii'
1591+
>>> res = zcat.run() # doctest: +SKIP
1592+
"""
1593+
1594+
_cmd = '3dZcat'
1595+
input_spec = ZcatInputSpec
1596+
output_spec = AFNICommandOutputSpec
1597+
1598+
class ZeropadInputSpec(AFNICommandInputSpec):
1599+
in_files = File(
1600+
desc='input dataset',
1601+
argstr='%s',
1602+
position=-1,
1603+
mandatory=True,
1604+
exists=True,
1605+
copyfile=False)
1606+
out_file = File(
1607+
name_template='zeropad',
1608+
desc='output dataset prefix name (default \'zeropad\')',
1609+
argstr='-prefix %s')
1610+
I = traits.Int(
1611+
desc='adds \'n\' planes of zero at the Inferior edge',
1612+
argstr='-I %i',
1613+
xor=['master'])
1614+
S = traits.Int(
1615+
desc='adds \'n\' planes of zero at the Superior edge',
1616+
argstr='-S %i',
1617+
xor=['master'])
1618+
A = traits.Int(
1619+
desc='adds \'n\' planes of zero at the Anterior edge',
1620+
argstr='-A %i',
1621+
xor=['master'])
1622+
P = traits.Int(
1623+
desc='adds \'n\' planes of zero at the Posterior edge',
1624+
argstr='-P %i',
1625+
xor=['master'])
1626+
L = traits.Int(
1627+
desc='adds \'n\' planes of zero at the Left edge',
1628+
argstr='-L %i',
1629+
xor=['master'])
1630+
R = traits.Int(
1631+
desc='adds \'n\' planes of zero at the Right edge',
1632+
argstr='-R %i',
1633+
xor=['master'])
1634+
z = traits.Int(
1635+
desc='adds \'n\' planes of zero on EACH of the '
1636+
'dataset z-axis (slice-direction) faces',
1637+
argstr='-z %i',
1638+
xor=['master'])
1639+
RL = traits.Int(desc='specify that planes should be added or cut '
1640+
'symmetrically to make the resulting volume have'
1641+
'N slices in the right-left direction',
1642+
argstr='-RL %i',
1643+
xor=['master'])
1644+
AP = traits.Int(desc='specify that planes should be added or cut '
1645+
'symmetrically to make the resulting volume have'
1646+
'N slices in the anterior-posterior direction',
1647+
argstr='-AP %i',
1648+
xor=['master'])
1649+
IS = traits.Int(desc='specify that planes should be added or cut '
1650+
'symmetrically to make the resulting volume have'
1651+
'N slices in the inferior-superior direction',
1652+
argstr='-IS %i',
1653+
xor=['master'])
1654+
mm = traits.Bool(desc='pad counts \'n\' are in mm instead of slices, '
1655+
'where each \'n\' is an integer and at least \'n\' '
1656+
'mm of slices will be added/removed; e.g., n = 3 '
1657+
'and slice thickness = 2.5 mm ==> 2 slices added',
1658+
argstr='-mm',
1659+
xor=['master'])
1660+
master = traits.File(desc='match the volume described in dataset '
1661+
'\'mset\', where mset must have the same '
1662+
'orientation and grid spacing as dataset to be '
1663+
'padded. the goal of -master is to make the '
1664+
'output dataset from 3dZeropad match the '
1665+
'spatial \'extents\' of mset by adding or '
1666+
'subtracting slices as needed. You can\'t use '
1667+
'-I,-S,..., or -mm with -master',
1668+
argstr='-master %s',
1669+
xor=['I', 'S', 'A', 'P', 'L', 'R', 'z',
1670+
'RL', 'AP', 'IS', 'mm'])
1671+
1672+
class Zeropad(AFNICommand):
1673+
"""Adds planes of zeros to a dataset (i.e., pads it out).
1674+
1675+
For complete details, see the `3dZeropad Documentation.
1676+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dZeropad.html>`_
1677+
1678+
Examples
1679+
========
1680+
1681+
>>> from nipype.interfaces import afni
1682+
>>> zeropad = afni.Zeropad()
1683+
>>> zeropad.inputs.in_files = 'functional.nii'
1684+
>>> zeropad.inputs.out_file = 'pad_functional.nii'
1685+
>>> zeropad.inputs.I = 10
1686+
>>> zeropad.inputs.S = 10
1687+
>>> zeropad.inputs.A = 10
1688+
>>> zeropad.inputs.P = 10
1689+
>>> zeropad.inputs.R = 10
1690+
>>> zeropad.inputs.L = 10
1691+
>>> zeropad.cmdline # doctest: +ALLOW_UNICODE
1692+
'3dZeropad -A 10 -I 10 -L 10 -P 10 -R 10 -S 10 -prefix pad_functional.nii functional.nii'
1693+
>>> res = zeropad.run() # doctest: +SKIP
1694+
"""
1695+
1696+
_cmd = '3dZeropad'
1697+
input_spec = ZeropadInputSpec
1698+
output_spec = AFNICommandOutputSpec

0 commit comments

Comments
 (0)