Skip to content

[ENH] Add ConvertDset interface to AFNI #2337

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 7 commits into from
Jan 19, 2018
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
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Upcoming release (0.14.1)
=========================

* ENH: Add AFNI interface for 3dConvertDset (https://github.com/nipy/nipype/pull/2337)
* MAINT: Cleanup EngineBase (https://github.com/nipy/nipype/pull/2376)
* FIX: Robustly handled outputs of 3dFWHMx across different versions of AFNI (https://github.com/nipy/nipype/pull/2373)
* FIX: Cluster threshold in randomise + change default prefix (https://github.com/nipy/nipype/pull/2369)
Expand Down
11 changes: 6 additions & 5 deletions nipype/interfaces/afni/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
ROIStats, Retroicor, Seg, SkullStrip, TCorr1D, TCorrMap, TCorrelate, TNorm,
TShift, Volreg, Warp, QwarpPlusMinus, Qwarp)
from .svm import (SVMTest, SVMTrain)
from .utils import (ABoverlap, AFNItoNIFTI, Autobox, Axialize, BrickStat,
Bucket, Calc, Cat, CatMatvec, CenterMass, Copy, Dot, Edge3,
Eval, FWHMx, MaskTool, Merge, Notes, NwarpApply, NwarpCat,
OneDToolPy, Refit, Resample, TCat, TCatSubBrick, TStat,
To3D, Unifize, Undump, ZCutUp, GCOR, Zcat, Zeropad)
from .utils import (
ABoverlap, AFNItoNIFTI, Autobox, Axialize, BrickStat, Bucket, Calc, Cat,
CatMatvec, CenterMass, ConvertDset, Copy, Dot, Edge3, Eval, FWHMx,
MaskTool, Merge, Notes, NwarpApply, NwarpCat, OneDToolPy, Refit, Resample,
TCat, TCatSubBrick, TStat, To3D, Unifize, Undump, ZCutUp, GCOR, Zcat,
Zeropad)
from .model import (Deconvolve, Remlfit, Synthesize)
45 changes: 45 additions & 0 deletions nipype/interfaces/afni/tests/test_auto_ConvertDset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from __future__ import unicode_literals
from ..utils import ConvertDset


def test_ConvertDset_inputs():
input_map = dict(args=dict(argstr='%s',
),
environ=dict(nohash=True,
usedefault=True,
),
ignore_exception=dict(deprecated='1.0.0',
nohash=True,
usedefault=True,
),
in_file=dict(argstr='-input %s',
mandatory=True,
position=-2,
),
out_file=dict(argstr='-prefix %s',
position=-1,
),
out_type=dict(argstr='-o_%s',
mandatory=True,
position=0,
),
terminal_output=dict(deprecated='1.0.0',
nohash=True,
),
)
inputs = ConvertDset.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_ConvertDset_outputs():
output_map = dict(out_file=dict(),
)
outputs = ConvertDset.output_spec()

for key, metadata in list(output_map.items()):
for metakey, value in list(metadata.items()):
assert getattr(outputs.traits()[key], metakey) == value
53 changes: 53 additions & 0 deletions nipype/interfaces/afni/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,59 @@ def _list_outputs(self):
return outputs


class ConvertDsetInputSpec(AFNICommandInputSpec):
in_file = File(
desc='input file to ConvertDset',
argstr='-input %s',
position=-2,
mandatory=True,
exists=True)

out_file = File(
desc='output file for ConvertDset',
argstr='-prefix %s',
position=-1,
mandatory=True)

out_type = traits.Enum(
('niml', 'niml_asc', 'niml_bi',
'1D', '1Dp', '1Dpt',
'gii', 'gii_asc', 'gii_b64', 'gii_b64gz'),
desc='output type',
argstr='-o_%s',
mandatory=True,
position=0)


class ConvertDset(AFNICommandBase):
"""Converts a surface dataset from one format to another.

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

Examples
========

>>> from nipype.interfaces import afni
>>> convertdset = afni.ConvertDset()
>>> convertdset.inputs.in_file = 'lh.pial_converted.gii'
>>> convertdset.inputs.out_type = 'niml_asc'
>>> convertdset.inputs.out_file = 'lh.pial_converted.niml.dset'
>>> convertdset.cmdline
'ConvertDset -o_niml_asc -input lh.pial_converted.gii -prefix lh.pial_converted.niml.dset'
>>> res = convertdset.run() # doctest: +SKIP
"""

_cmd = 'ConvertDset'
input_spec = ConvertDsetInputSpec
output_spec = AFNICommandOutputSpec

def _list_outputs(self):
outputs = self.output_spec().get()
outputs['out_file'] = op.abspath(self.inputs.out_file)
return outputs


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