Skip to content

add AFNI interface 3dUndump #2186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nipype/interfaces/afni/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Bucket, Calc, Cat, CatMatvec, Copy, Dot,
Edge3, Eval, FWHMx, MaskTool, Merge, Notes, NwarpApply,
OneDToolPy,
Refit, Resample, TCat, TCatSubBrick, TStat, To3D, Unifize, ZCutUp, GCOR,
Refit, Resample, TCat, TCatSubBrick, TStat, To3D, Unifize,
Undump, ZCutUp, GCOR,
Zcat, Zeropad)
from .model import (Deconvolve, Remlfit)
55 changes: 55 additions & 0 deletions nipype/interfaces/afni/tests/test_auto_Undump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from __future__ import unicode_literals
from ..utils import Undump


def test_Undump_inputs():
input_map = dict(args=dict(argstr='%s',
),
coordinates_specification=dict(argstr='-%s',
),
datatype=dict(argstr='-datum %s',
),
default_value=dict(argstr='-dval %f',
),
environ=dict(nohash=True,
usedefault=True,
),
fill_value=dict(argstr='-fval %f',
),
head_only=dict(argstr='-head_only',
),
ignore_exception=dict(nohash=True,
usedefault=True,
),
in_file=dict(argstr='-master %s',
copyfile=False,
mandatory=True,
position=-1,
),
mask_file=dict(argstr='-mask %s',
),
out_file=dict(argstr='-prefix %s',
name_source='in_file',
),
outputtype=dict(),
srad=dict(argstr='-srad -%f',
),
terminal_output=dict(nohash=True,
),
)
inputs = Undump.input_spec()

for key, metadata in list(input_map.items()):
for metakey, value in list(metadata.items()):
assert getattr(inputs.traits()[key], metakey) == value


def test_Undump_outputs():
output_map = dict(out_file=dict(),
)
outputs = Undump.output_spec()

for key, metadata in list(output_map.items()):
for metakey, value in list(metadata.items()):
assert getattr(outputs.traits()[key], metakey) == value
97 changes: 97 additions & 0 deletions nipype/interfaces/afni/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,103 @@ class To3D(AFNICommand):
output_spec = AFNICommandOutputSpec


class UndumpInputSpec(AFNICommandInputSpec):
in_file = File(
desc='input file to 3dUndump, whose geometry will determine'
'the geometry of the output',
argstr='-master %s',
position=-1,
mandatory=True,
exists=True,
copyfile=False)
out_file = File(
desc='output image file name',
argstr='-prefix %s',
name_source='in_file')
mask_file = File(
desc='mask image file name. Only voxels that are nonzero in the mask '
'can be set.',
argstr='-mask %s')
datatype = traits.Enum(
'short', 'float', 'byte',
desc='set output file datatype',
argstr='-datum %s')
default_value = traits.Float(
desc='default value stored in each input voxel that does not have '
'a value supplied in the input file',
argstr='-dval %f')
fill_value = traits.Float(
desc='value, used for each voxel in the output dataset that is NOT '
'listed in the input file',
argstr='-fval %f')
coordinates_specification = traits.Enum(
'ijk', 'xyz',
desc='Coordinates in the input file as index triples (i, j, k) '
'or spatial coordinates (x, y, z) in mm',
argstr='-%s')
srad = traits.Float(
desc='radius in mm of the sphere that will be filled about each input '
'(x,y,z) or (i,j,k) voxel. If the radius is not given, or is 0, '
'then each input data line sets the value in only one voxel.',
argstr='-srad -%f')
srad = traits.Tuple(
traits.Enum('R', 'L'), traits.Enum('A', 'P'), traits.Enum('I', 'S'),
desc='radius in mm of the sphere that will be filled about each input '
'(x,y,z) or (i,j,k) voxel. If the radius is not given, or is 0, '
'then each input data line sets the value in only one voxel.',
argstr='-srad -%f')
head_only = traits.Bool(
desc='create only the .HEAD file which gets exploited by '
'the AFNI matlab library function New_HEAD.m',
argstr='-head_only')


class UndumpOutputSpec(TraitedSpec):
out_file = File(desc='assembled file', exists=True)


class Undump(AFNICommand):
"""3dUndump - Assembles a 3D dataset from an ASCII list of coordinates and
(optionally) values.

The input file(s) are ASCII files, with one voxel specification per
line. A voxel specification is 3 numbers (-ijk or -xyz coordinates),
with an optional 4th number giving the voxel value. For example:

1 2 3
3 2 1 5
5.3 6.2 3.7
// this line illustrates a comment

The first line puts a voxel (with value given by '-dval') at point
(1,2,3). The second line puts a voxel (with value 5) at point (3,2,1).
The third line puts a voxel (with value given by '-dval') at point
(5.3,6.2,3.7). If -ijk is in effect, and fractional coordinates
are given, they will be rounded to the nearest integers; for example,
the third line would be equivalent to (i,j,k) = (5,6,4).


For complete details, see the `3dUndump Documentation.
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dUndump.html>`_

Examples
========

>>> from nipype.interfaces import afni
>>> unndump = afni.Undump()
>>> unndump.inputs.in_file = 'structural.nii'
>>> unndump.inputs.out_file = 'structural_undumped.nii'
>>> unndump.cmdline # doctest: +ALLOW_UNICODE
'3dUndump -prefix structural_undumped.nii -master structural.nii'
>>> res = unndump.run() # doctest: +SKIP

"""

_cmd = '3dUndump'
input_spec = UndumpInputSpec
output_spec = UndumpOutputSpec


class UnifizeInputSpec(AFNICommandInputSpec):
in_file = File(
desc='input file to 3dUnifize',
Expand Down