Skip to content

Commit c464fc2

Browse files
committed
3dUndump interface
1 parent 4a0bd3d commit c464fc2

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

nipype/interfaces/afni/utils.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,103 @@ class To3D(AFNICommand):
19631963
output_spec = AFNICommandOutputSpec
19641964

19651965

1966+
class UndumpInputSpec(AFNICommandInputSpec):
1967+
in_file = File(
1968+
desc='input file to 3dUndump, whose geometry will determine'
1969+
'the geometry of the output',
1970+
argstr='-master %s',
1971+
position=-1,
1972+
mandatory=True,
1973+
exists=True,
1974+
copyfile=False)
1975+
out_file = File(
1976+
desc='output image file name',
1977+
argstr='-prefix %s',
1978+
name_source='in_file')
1979+
mask_file = File(
1980+
desc='mask image file name. Only voxels that are nonzero in the mask '
1981+
'can be set.',
1982+
argstr='-mask %s')
1983+
datatype = traits.Enum(
1984+
'short', 'float', 'byte',
1985+
desc='set output file datatype',
1986+
argstr='-datum %s')
1987+
default_value = traits.Float(
1988+
desc='default value stored in each input voxel that does not have '
1989+
'a value supplied in the input file',
1990+
argstr='-dval %f')
1991+
fill_value = traits.Float(
1992+
desc='value, used for each voxel in the output dataset that is NOT '
1993+
'listed in the input file',
1994+
argstr='-fval %f')
1995+
coordinates_specification = traits.Enum(
1996+
'ijk', 'xyz',
1997+
desc='Coordinates in the input file as index triples (i, j, k) '
1998+
'or spatial coordinates (x, y, z) in mm',
1999+
argstr='-%s')
2000+
srad = traits.Float(
2001+
desc='radius in mm of the sphere that will be filled about each input '
2002+
'(x,y,z) or (i,j,k) voxel. If the radius is not given, or is 0, '
2003+
'then each input data line sets the value in only one voxel.',
2004+
argstr='-srad -%f')
2005+
srad = traits.Tuple(
2006+
traits.Enum('R', 'L'), traits.Enum('A', 'P'), traits.Enum('I', 'S'),
2007+
desc='radius in mm of the sphere that will be filled about each input '
2008+
'(x,y,z) or (i,j,k) voxel. If the radius is not given, or is 0, '
2009+
'then each input data line sets the value in only one voxel.',
2010+
argstr='-srad -%f')
2011+
head_only = traits.Bool(
2012+
desc='create only the .HEAD file which gets exploited by '
2013+
'the AFNI matlab library function New_HEAD.m',
2014+
argstr='-head_only')
2015+
2016+
2017+
class UndumpOutputSpec(TraitedSpec):
2018+
out_file = File(desc='assembled file', exists=True)
2019+
2020+
2021+
class Undump(AFNICommand):
2022+
"""3dUndump - Assembles a 3D dataset from an ASCII list of coordinates and
2023+
(optionally) values.
2024+
2025+
The input file(s) are ASCII files, with one voxel specification per
2026+
line. A voxel specification is 3 numbers (-ijk or -xyz coordinates),
2027+
with an optional 4th number giving the voxel value. For example:
2028+
2029+
1 2 3
2030+
3 2 1 5
2031+
5.3 6.2 3.7
2032+
// this line illustrates a comment
2033+
2034+
The first line puts a voxel (with value given by '-dval') at point
2035+
(1,2,3). The second line puts a voxel (with value 5) at point (3,2,1).
2036+
The third line puts a voxel (with value given by '-dval') at point
2037+
(5.3,6.2,3.7). If -ijk is in effect, and fractional coordinates
2038+
are given, they will be rounded to the nearest integers; for example,
2039+
the third line would be equivalent to (i,j,k) = (5,6,4).
2040+
2041+
2042+
For complete details, see the `3dUndump Documentation.
2043+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dUndump.html>`_
2044+
2045+
Examples
2046+
========
2047+
2048+
>>> from nipype.interfaces import afni
2049+
>>> unndump = afni.Undump()
2050+
>>> unndump.inputs.in_file = 'structural.nii'
2051+
>>> unndump.inputs.out_file = 'structural_undumped.nii'
2052+
>>> unndump.cmdline # doctest: +ALLOW_UNICODE
2053+
'3dUnifize -prefix structural_unifized.nii -master structural.nii'
2054+
>>> res = unndump.run() # doctest: +SKIP
2055+
2056+
"""
2057+
2058+
_cmd = '3dUndump'
2059+
input_spec = UndumpInputSpec
2060+
output_spec = UndumpOutputSpec
2061+
2062+
19662063
class UnifizeInputSpec(AFNICommandInputSpec):
19672064
in_file = File(
19682065
desc='input file to 3dUnifize',

0 commit comments

Comments
 (0)