diff --git a/CHANGES b/CHANGES index c1991d5f2b..3fdacfd639 100644 --- a/CHANGES +++ b/CHANGES @@ -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) diff --git a/nipype/interfaces/afni/__init__.py b/nipype/interfaces/afni/__init__.py index 751f168b1c..9cb519a2a2 100644 --- a/nipype/interfaces/afni/__init__.py +++ b/nipype/interfaces/afni/__init__.py @@ -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) diff --git a/nipype/interfaces/afni/tests/test_auto_ConvertDset.py b/nipype/interfaces/afni/tests/test_auto_ConvertDset.py new file mode 100644 index 0000000000..c6e73f4ecf --- /dev/null +++ b/nipype/interfaces/afni/tests/test_auto_ConvertDset.py @@ -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 diff --git a/nipype/interfaces/afni/utils.py b/nipype/interfaces/afni/utils.py index 65bb734ff7..188ba158c0 100644 --- a/nipype/interfaces/afni/utils.py +++ b/nipype/interfaces/afni/utils.py @@ -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. + `_ + + 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',