diff --git a/CHANGES b/CHANGES index 50337ab634..2a28d40cd9 100644 --- a/CHANGES +++ b/CHANGES @@ -31,6 +31,8 @@ Release 0.12.0-rc1 (April 20, 2016) * ENH: Nipype workflow and interfaces for FreeSurfer's recon-all (https://github.com/nipy/nipype/pull/1326) * FIX: Permit relative path for concatenated_file input to Concatenate() (https://github.com/nipy/nipype/pull/1411) * ENH: Makes ReconAll workflow backwards compatible with FreeSurfer 5.3.0 (https://github.com/nipy/nipype/pull/1434) +* ENH: Added interfaces for AFNI 3dDegreeCentrality, 3dECM, 3dLFCD, 3dClipLevel, 3dmask_tool, and 3dSeg + (https://github.com/nipy/nipype/pull/1460) Release 0.11.0 (September 15, 2015) ============ diff --git a/nipype/interfaces/afni/__init__.py b/nipype/interfaces/afni/__init__.py index 93392d77bb..c7f123c4a1 100644 --- a/nipype/interfaces/afni/__init__.py +++ b/nipype/interfaces/afni/__init__.py @@ -8,9 +8,10 @@ from .base import Info from .preprocess import (To3D, Refit, Resample, TStat, Automask, Volreg, Merge, - ZCutUp, Calc, TShift, Warp, Detrend, Despike, Copy, - Fourier, Allineate, Maskave, SkullStrip, TCat, Fim, - BlurInMask, Autobox, TCorrMap, Bandpass, Retroicor, + ZCutUp, Calc, TShift, Warp, Detrend, Despike, + DegreeCentrality, ECM, LFCD, Copy, Fourier, Allineate, + Maskave, SkullStrip, TCat, ClipLevel, MaskTool, Seg, + Fim, BlurInMask, Autobox, TCorrMap, Bandpass, Retroicor, TCorrelate, TCorr1D, BrickStat, ROIStats, AutoTcorrelate, AFNItoNIFTI, Eval, Means, Hist, FWHMx, OutlierCount, QualityIndex) diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index 599b180401..e65aa95cec 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -507,6 +507,207 @@ class Despike(AFNICommand): output_spec = AFNICommandOutputSpec +class CentralityInputSpec(AFNICommandInputSpec): + """Common input spec class for all centrality-related commmands + """ + + + mask = File(desc='mask file to mask input data', + argstr="-mask %s", + exists=True) + + thresh = traits.Float(desc='threshold to exclude connections where corr <= thresh', + argstr='-thresh %f') + + polort = traits.Int(desc='', argstr='-polort %d') + + autoclip = traits.Bool(desc='Clip off low-intensity regions in the dataset', + argstr='-autoclip') + + automask = traits.Bool(desc='Mask the dataset to target brain-only voxels', + argstr='-automask') + + +class DegreeCentralityInputSpec(CentralityInputSpec): + """DegreeCentrality inputspec + """ + + in_file = File(desc='input file to 3dDegreeCentrality', + argstr='%s', + position=-1, + mandatory=True, + exists=True, + copyfile=False) + + sparsity = traits.Float(desc='only take the top percent of connections', + argstr='-sparsity %f') + + oned_file = traits.Str(desc='output filepath to text dump of correlation matrix', + argstr='-out1D %s', mandatory=False) + + +class DegreeCentralityOutputSpec(AFNICommandOutputSpec): + """DegreeCentrality outputspec + """ + + oned_file = File(desc='The text output of the similarity matrix computed'\ + 'after thresholding with one-dimensional and '\ + 'ijk voxel indices, correlations, image extents, '\ + 'and affine matrix') + + +class DegreeCentrality(AFNICommand): + """Performs degree centrality on a dataset using a given maskfile + via 3dDegreeCentrality + + For complete details, see the `3dDegreeCentrality Documentation. + + + Examples + ======== + + >>> from nipype.interfaces import afni as afni + >>> degree = afni.DegreeCentrality() + >>> degree.inputs.in_file = 'functional.nii' + >>> degree.inputs.mask = 'mask.nii' + >>> degree.inputs.sparsity = 1 # keep the top one percent of connections + >>> degree.inputs.out_file = 'out.nii' + >>> degree.cmdline + '3dDegreeCentrality -mask mask.nii -prefix out.nii -sparsity 1.000000 functional.nii' + >>> res = degree.run() # doctest: +SKIP + """ + + _cmd = '3dDegreeCentrality' + input_spec = DegreeCentralityInputSpec + output_spec = DegreeCentralityOutputSpec + + # Re-define generated inputs + def _list_outputs(self): + # Import packages + import os + + # Update outputs dictionary if oned file is defined + outputs = super(DegreeCentrality, self)._list_outputs() + if self.inputs.oned_file: + outputs['oned_file'] = os.path.abspath(self.inputs.oned_file) + + return outputs + + +class ECMInputSpec(CentralityInputSpec): + """ECM inputspec + """ + + in_file = File(desc='input file to 3dECM', + argstr='%s', + position=-1, + mandatory=True, + exists=True, + copyfile=False) + + sparsity = traits.Float(desc='only take the top percent of connections', + argstr='-sparsity %f') + + full = traits.Bool(desc='Full power method; enables thresholding; '\ + 'automatically selected if -thresh or -sparsity '\ + 'are set', + argstr='-full') + + fecm = traits.Bool(desc='Fast centrality method; substantial speed '\ + 'increase but cannot accomodate thresholding; '\ + 'automatically selected if -thresh or -sparsity '\ + 'are not set', + argstr='-fecm') + + shift = traits.Float(desc='shift correlation coefficients in similarity '\ + 'matrix to enforce non-negativity, s >= 0.0; '\ + 'default = 0.0 for -full, 1.0 for -fecm', + argstr='-shift %f') + + scale = traits.Float(desc='scale correlation coefficients in similarity '\ + 'matrix to after shifting, x >= 0.0; '\ + 'default = 1.0 for -full, 0.5 for -fecm', + argstr='-scale %f') + + eps = traits.Float(desc='sets the stopping criterion for the power '\ + 'iteration; l2|v_old - v_new| < eps*|v_old|; '\ + 'default = 0.001', + argstr='-eps %f') + + max_iter = traits.Int(desc='sets the maximum number of iterations to use '\ + 'in the power iteration; default = 1000', + argstr='-max_iter %d') + + memory = traits.Float(desc='Limit memory consumption on system by setting '\ + 'the amount of GB to limit the algorithm to; '\ + 'default = 2GB', + argstr='-memory %f') + + +class ECM(AFNICommand): + """Performs degree centrality on a dataset using a given maskfile + via the 3dLFCD command + + For complete details, see the `3dECM Documentation. + + + Examples + ======== + + >>> from nipype.interfaces import afni as afni + >>> ecm = afni.ECM() + >>> ecm.inputs.in_file = 'functional.nii' + >>> ecm.inputs.mask = 'mask.nii' + >>> ecm.inputs.sparsity = 0.1 # keep top 0.1% of connections + >>> ecm.inputs.out_file = 'out.nii' + >>> ecm.cmdline + '3dECM -mask mask.nii -prefix out.nii -sparsity 0.100000 functional.nii' + >>> res = ecm.run() # doctest: +SKIP + """ + + _cmd = '3dECM' + input_spec = ECMInputSpec + output_spec = AFNICommandOutputSpec + + +class LFCDInputSpec(CentralityInputSpec): + """LFCD inputspec + """ + + in_file = File(desc='input file to 3dLFCD', + argstr='%s', + position=-1, + mandatory=True, + exists=True, + copyfile=False) + + +class LFCD(AFNICommand): + """Performs degree centrality on a dataset using a given maskfile + via the 3dLFCD command + + For complete details, see the `3dLFCD Documentation. + + + Examples + ======== + + >>> from nipype.interfaces import afni as afni + >>> lfcd = afni.LFCD() + >>> lfcd.inputs.in_file = 'functional.nii' + >>> lfcd.inputs.mask = 'mask.nii' + >>> lfcd.inputs.thresh = 0.8 # keep all connections with corr >= 0.8 + >>> lfcd.inputs.out_file = 'out.nii' + >>> lfcd.cmdline + '3dLFCD -mask mask.nii -prefix out.nii -thresh 0.800000 functional.nii' + >>> res = lfcd.run() # doctest: +SKIP + """ + + _cmd = '3dLFCD' + input_spec = LFCDInputSpec + output_spec = AFNICommandOutputSpec + + class AutomaskInputSpec(AFNICommandInputSpec): in_file = File(desc='input file to 3dAutomask', argstr='%s', @@ -1149,6 +1350,10 @@ def _list_outputs(self): suffix=self.inputs.suffix) else: outputs['out_file'] = os.path.abspath(self.inputs.out_file) + + if isdefined(self.inputs.out_matrix): + outputs['matrix'] = os.path.abspath(os.path.join(os.getcwd(),\ + self.inputs.out_matrix +".aff12.1D")) return outputs def _gen_filename(self, name): @@ -1512,6 +1717,252 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None): return outputs +class ClipLevelInputSpec(CommandLineInputSpec): + in_file = File(desc='input file to 3dClipLevel', + argstr='%s', + position=-1, + mandatory=True, + exists=True) + + mfrac = traits.Float(desc='Use the number ff instead of 0.50 in the algorithm', + argstr='-mfrac %s', + position=2) + + doall = traits.Bool(desc='Apply the algorithm to each sub-brick separately', + argstr='-doall', + position=3, + xor=('grad')) + + grad = traits.File(desc='also compute a \'gradual\' clip level as a function of voxel position, and output that to a dataset', + argstr='-grad %s', + position=3, + xor=('doall')) + + +class ClipLevelOutputSpec(TraitedSpec): + clip_val = traits.Float(desc='output') + + +class ClipLevel(AFNICommandBase): + """Estimates the value at which to clip the anatomical dataset so + that background regions are set to zero. + + For complete details, see the `3dClipLevel Documentation. + `_ + + Examples + ======== + + >>> from nipype.interfaces.afni import preprocess + >>> cliplevel = preprocess.ClipLevel() + >>> cliplevel.inputs.in_file = 'anatomical.nii' + >>> res = cliplevel.run() # doctest: +SKIP + + """ + _cmd = '3dClipLevel' + input_spec = ClipLevelInputSpec + output_spec = ClipLevelOutputSpec + + def aggregate_outputs(self, runtime=None, needed_outputs=None): + + outputs = self._outputs() + + outfile = os.path.join(os.getcwd(), 'stat_result.json') + + if runtime is None: + try: + clip_val = load_json(outfile)['stat'] + except IOError: + return self.run().outputs + else: + clip_val = [] + for line in runtime.stdout.split('\n'): + if line: + values = line.split() + if len(values) > 1: + clip_val.append([float(val) for val in values]) + else: + clip_val.extend([float(val) for val in values]) + + if len(clip_val) == 1: + clip_val = clip_val[0] + save_json(outfile, dict(stat=clip_val)) + outputs.clip_val = clip_val + + return outputs + + +class MaskToolInputSpec(AFNICommandInputSpec): + in_file = File(desc='input file or files to 3dmask_tool', + argstr='-input %s', + position=-1, + mandatory=True, + exists=True, + copyfile=False) + + out_file = File(name_template="%s_mask", desc='output image file name', + argstr='-prefix %s', name_source="in_file") + + count = traits.Bool(desc='Instead of created a binary 0/1 mask dataset, '+ + 'create one with. counts of voxel overlap, i.e '+ + 'each voxel will contain the number of masks ' + + 'that it is set in.', + argstr='-count', + position=2) + + datum = traits.Enum('byte','short','float', + argstr='-datum %s', + desc='specify data type for output. Valid types are '+ + '\'byte\', \'short\' and \'float\'.') + + dilate_inputs = traits.Str(desc='Use this option to dilate and/or erode '+ + 'datasets as they are read. ex. ' + + '\'5 -5\' to dilate and erode 5 times', + argstr='-dilate_inputs %s') + + dilate_results = traits.Str(desc='dilate and/or erode combined mask at ' + + 'the given levels.', + argstr='-dilate_results %s') + + frac = traits.Float(desc='When combining masks (across datasets and ' + + 'sub-bricks), use this option to restrict the ' + + 'result to a certain fraction of the set of ' + + 'volumes', + argstr='-frac %s') + + inter = traits.Bool(desc='intersection, this means -frac 1.0', + argstr='-inter') + + union = traits.Bool(desc='union, this means -frac 0', + argstr='-union') + + fill_holes = traits.Bool(desc='This option can be used to fill holes ' + + 'in the resulting mask, i.e. after all ' + + 'other processing has been done.', + argstr='-fill_holes') + + fill_dirs = traits.Str(desc='fill holes only in the given directions. ' + + 'This option is for use with -fill holes. ' + + 'should be a single string that specifies ' + + '1-3 of the axes using {x,y,z} labels (i.e. '+ + 'dataset axis order), or using the labels ' + + 'in {R,L,A,P,I,S}.', + argstr='-fill_dirs %s', + requires=['fill_holes']) + + +class MaskToolOutputSpec(TraitedSpec): + out_file = File(desc='mask file', + exists=True) + + +class MaskTool(AFNICommand): + """3dmask_tool - for combining/dilating/eroding/filling masks + + For complete details, see the `3dmask_tool Documentation. + `_ + + Examples + ======== + + >>> from nipype.interfaces import afni as afni + >>> automask = afni.Automask() + >>> automask.inputs.in_file = 'functional.nii' + >>> automask.inputs.dilate = 1 + >>> automask.inputs.outputtype = "NIFTI" + >>> automask.cmdline #doctest: +ELLIPSIS + '3dAutomask -apply_prefix functional_masked.nii -dilate 1 -prefix functional_mask.nii functional.nii' + >>> res = automask.run() # doctest: +SKIP + + """ + + _cmd = '3dmask_tool' + input_spec = MaskToolInputSpec + output_spec = MaskToolOutputSpec + + +class SegInputSpec(CommandLineInputSpec): + in_file = File(desc='ANAT is the volume to segment', + argstr='-anat %s', + position=-1, + mandatory=True, + exists=True, + copyfile=True) + + mask = traits.Str(desc='only non-zero voxels in mask are analyzed. mask can either be a dataset or the string \'AUTO\' which would use AFNI\'s automask function to create the mask.', + argstr='-mask %s', + position=-2, + mandatory=True, + exists=True) + + blur_meth = traits.Enum('BFT', 'BIM', + argstr='-blur_meth %s', + desc='set the blurring method for bias field estimation') + + bias_fwhm = traits.Float(desc='The amount of blurring used when estimating the field bias with the Wells method', + argstr='-bias_fwhm %f') + + classes = traits.Str(desc='CLASS_STRING is a semicolon delimited string of class labels', + argstr='-classes %s') + + bmrf = traits.Float(desc='Weighting factor controlling spatial homogeneity of the classifications', + argstr='-bmrf %f') + + bias_classes = traits.Str(desc='A semcolon demlimited string of classes that contribute to the estimation of the bias field', + argstr='-bias_classes %s') + + prefix = traits.Str(desc='the prefix for the output folder containing all output volumes', + argstr='-prefix %s') + + mixfrac = traits.Str(desc='MIXFRAC sets up the volume-wide (within mask) tissue fractions while initializing the segmentation (see IGNORE for exception)', + argstr='-mixfrac %s') + + mixfloor = traits.Float(desc='Set the minimum value for any class\'s mixing fraction', + argstr='-mixfloor %f') + + main_N = traits.Int(desc='Number of iterations to perform.', + argstr='-main_N %d') + + +class Seg(AFNICommandBase): + """3dSeg segments brain volumes into tissue classes. The program allows + for adding a variety of global and voxelwise priors. However for the + moment, only mixing fractions and MRF are documented. + + For complete details, see the `3dSeg Documentation. + + + Examples + ======== + + >>> from nipype.interfaces.afni import preprocess + >>> seg = preprocess.Seg() + >>> seg.inputs.in_file = 'structural.nii' + >>> seg.inputs.mask = 'AUTO' + >>> res = seg.run() # doctest: +SKIP + + """ + + _cmd = '3dSeg' + input_spec = SegInputSpec + output_spec = AFNICommandOutputSpec + + def aggregate_outputs(self, runtime=None, needed_outputs=None): + + import glob + + outputs = self._outputs() + + if isdefined(self.inputs.prefix): + outfile = os.path.join(os.getcwd(), self.inputs.prefix, 'Classes+*.BRIK') + else: + outfile = os.path.join(os.getcwd(), 'Segsy', 'Classes+*.BRIK') + + outputs.out_file = glob.glob(outfile)[0] + + return outputs + + class ROIStatsInputSpec(CommandLineInputSpec): in_file = File(desc='input file to 3dROIstats', argstr='%s', diff --git a/nipype/interfaces/afni/tests/test_auto_ClipLevel.py b/nipype/interfaces/afni/tests/test_auto_ClipLevel.py new file mode 100644 index 0000000000..f6e5ae3e98 --- /dev/null +++ b/nipype/interfaces/afni/tests/test_auto_ClipLevel.py @@ -0,0 +1,47 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..preprocess import ClipLevel + + +def test_ClipLevel_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + doall=dict(argstr='-doall', + position=3, + xor='grad', + ), + environ=dict(nohash=True, + usedefault=True, + ), + grad=dict(argstr='-grad %s', + position=3, + xor='doall', + ), + ignore_exception=dict(nohash=True, + usedefault=True, + ), + in_file=dict(argstr='%s', + mandatory=True, + position=-1, + ), + mfrac=dict(argstr='-mfrac %s', + position=2, + ), + terminal_output=dict(nohash=True, + ), + ) + inputs = ClipLevel.input_spec() + + for key, metadata in list(input_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(inputs.traits()[key], metakey), value + + +def test_ClipLevel_outputs(): + output_map = dict(clip_val=dict(), + ) + outputs = ClipLevel.output_spec() + + for key, metadata in list(output_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(outputs.traits()[key], metakey), value diff --git a/nipype/interfaces/afni/tests/test_auto_DegreeCentrality.py b/nipype/interfaces/afni/tests/test_auto_DegreeCentrality.py new file mode 100644 index 0000000000..36f446cbda --- /dev/null +++ b/nipype/interfaces/afni/tests/test_auto_DegreeCentrality.py @@ -0,0 +1,58 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..preprocess import DegreeCentrality + + +def test_DegreeCentrality_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + autoclip=dict(argstr='-autoclip', + ), + automask=dict(argstr='-automask', + ), + environ=dict(nohash=True, + usedefault=True, + ), + ignore_exception=dict(nohash=True, + usedefault=True, + ), + in_file=dict(argstr='%s', + copyfile=False, + mandatory=True, + position=-1, + ), + mask=dict(argstr='-mask %s', + ), + oned_file=dict(argstr='-out1D %s', + mandatory=False, + ), + out_file=dict(argstr='-prefix %s', + name_source=['in_file'], + name_template='%s_afni', + ), + outputtype=dict(), + polort=dict(argstr='-polort %d', + ), + sparsity=dict(argstr='-sparsity %f', + ), + terminal_output=dict(nohash=True, + ), + thresh=dict(argstr='-thresh %f', + ), + ) + inputs = DegreeCentrality.input_spec() + + for key, metadata in list(input_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(inputs.traits()[key], metakey), value + + +def test_DegreeCentrality_outputs(): + output_map = dict(oned_file=dict(), + out_file=dict(), + ) + outputs = DegreeCentrality.output_spec() + + for key, metadata in list(output_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(outputs.traits()[key], metakey), value diff --git a/nipype/interfaces/afni/tests/test_auto_ECM.py b/nipype/interfaces/afni/tests/test_auto_ECM.py new file mode 100644 index 0000000000..0af69ab986 --- /dev/null +++ b/nipype/interfaces/afni/tests/test_auto_ECM.py @@ -0,0 +1,68 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..preprocess import ECM + + +def test_ECM_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + autoclip=dict(argstr='-autoclip', + ), + automask=dict(argstr='-automask', + ), + environ=dict(nohash=True, + usedefault=True, + ), + eps=dict(argstr='-eps %f', + ), + fecm=dict(argstr='-fecm', + ), + full=dict(argstr='-full', + ), + ignore_exception=dict(nohash=True, + usedefault=True, + ), + in_file=dict(argstr='%s', + copyfile=False, + mandatory=True, + position=-1, + ), + mask=dict(argstr='-mask %s', + ), + max_iter=dict(argstr='-max_iter %d', + ), + memory=dict(argstr='-memory %f', + ), + out_file=dict(argstr='-prefix %s', + name_source=['in_file'], + name_template='%s_afni', + ), + outputtype=dict(), + polort=dict(argstr='-polort %d', + ), + scale=dict(argstr='-scale %f', + ), + shift=dict(argstr='-shift %f', + ), + sparsity=dict(argstr='-sparsity %f', + ), + terminal_output=dict(nohash=True, + ), + thresh=dict(argstr='-thresh %f', + ), + ) + inputs = ECM.input_spec() + + for key, metadata in list(input_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(inputs.traits()[key], metakey), value + + +def test_ECM_outputs(): + output_map = dict(out_file=dict(), + ) + outputs = ECM.output_spec() + + for key, metadata in list(output_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(outputs.traits()[key], metakey), value diff --git a/nipype/interfaces/afni/tests/test_auto_LFCD.py b/nipype/interfaces/afni/tests/test_auto_LFCD.py new file mode 100644 index 0000000000..371bce8b8d --- /dev/null +++ b/nipype/interfaces/afni/tests/test_auto_LFCD.py @@ -0,0 +1,52 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..preprocess import LFCD + + +def test_LFCD_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + autoclip=dict(argstr='-autoclip', + ), + automask=dict(argstr='-automask', + ), + environ=dict(nohash=True, + usedefault=True, + ), + ignore_exception=dict(nohash=True, + usedefault=True, + ), + in_file=dict(argstr='%s', + copyfile=False, + mandatory=True, + position=-1, + ), + mask=dict(argstr='-mask %s', + ), + out_file=dict(argstr='-prefix %s', + name_source=['in_file'], + name_template='%s_afni', + ), + outputtype=dict(), + polort=dict(argstr='-polort %d', + ), + terminal_output=dict(nohash=True, + ), + thresh=dict(argstr='-thresh %f', + ), + ) + inputs = LFCD.input_spec() + + for key, metadata in list(input_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(inputs.traits()[key], metakey), value + + +def test_LFCD_outputs(): + output_map = dict(out_file=dict(), + ) + outputs = LFCD.output_spec() + + for key, metadata in list(output_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(outputs.traits()[key], metakey), value diff --git a/nipype/interfaces/afni/tests/test_auto_MaskTool.py b/nipype/interfaces/afni/tests/test_auto_MaskTool.py new file mode 100644 index 0000000000..005a915ead --- /dev/null +++ b/nipype/interfaces/afni/tests/test_auto_MaskTool.py @@ -0,0 +1,62 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..preprocess import MaskTool + + +def test_MaskTool_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + count=dict(argstr='-count', + position=2, + ), + datum=dict(argstr='-datum %s', + ), + dilate_inputs=dict(argstr='-dilate_inputs %s', + ), + dilate_results=dict(argstr='-dilate_results %s', + ), + environ=dict(nohash=True, + usedefault=True, + ), + fill_dirs=dict(argstr='-fill_dirs %s', + requires=['fill_holes'], + ), + fill_holes=dict(argstr='-fill_holes', + ), + frac=dict(argstr='-frac %s', + ), + ignore_exception=dict(nohash=True, + usedefault=True, + ), + in_file=dict(argstr='-input %s', + copyfile=False, + mandatory=True, + position=-1, + ), + inter=dict(argstr='-inter', + ), + out_file=dict(argstr='-prefix %s', + name_source='in_file', + name_template='%s_mask', + ), + outputtype=dict(), + terminal_output=dict(nohash=True, + ), + union=dict(argstr='-union', + ), + ) + inputs = MaskTool.input_spec() + + for key, metadata in list(input_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(inputs.traits()[key], metakey), value + + +def test_MaskTool_outputs(): + output_map = dict(out_file=dict(), + ) + outputs = MaskTool.output_spec() + + for key, metadata in list(output_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(outputs.traits()[key], metakey), value diff --git a/nipype/interfaces/afni/tests/test_auto_Seg.py b/nipype/interfaces/afni/tests/test_auto_Seg.py new file mode 100644 index 0000000000..3a84f00ced --- /dev/null +++ b/nipype/interfaces/afni/tests/test_auto_Seg.py @@ -0,0 +1,60 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..preprocess import Seg + + +def test_Seg_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + bias_classes=dict(argstr='-bias_classes %s', + ), + bias_fwhm=dict(argstr='-bias_fwhm %f', + ), + blur_meth=dict(argstr='-blur_meth %s', + ), + bmrf=dict(argstr='-bmrf %f', + ), + classes=dict(argstr='-classes %s', + ), + environ=dict(nohash=True, + usedefault=True, + ), + ignore_exception=dict(nohash=True, + usedefault=True, + ), + in_file=dict(argstr='-anat %s', + copyfile=True, + mandatory=True, + position=-1, + ), + main_N=dict(argstr='-main_N %d', + ), + mask=dict(argstr='-mask %s', + exists=True, + mandatory=True, + position=-2, + ), + mixfloor=dict(argstr='-mixfloor %f', + ), + mixfrac=dict(argstr='-mixfrac %s', + ), + prefix=dict(argstr='-prefix %s', + ), + terminal_output=dict(nohash=True, + ), + ) + inputs = Seg.input_spec() + + for key, metadata in list(input_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(inputs.traits()[key], metakey), value + + +def test_Seg_outputs(): + output_map = dict(out_file=dict(), + ) + outputs = Seg.output_spec() + + for key, metadata in list(output_map.items()): + for metakey, value in list(metadata.items()): + yield assert_equal, getattr(outputs.traits()[key], metakey), value diff --git a/nipype/interfaces/io.py b/nipype/interfaces/io.py index 7bc0ff358c..0035971f31 100644 --- a/nipype/interfaces/io.py +++ b/nipype/interfaces/io.py @@ -211,7 +211,7 @@ class DataSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): encrypt_bucket_keys = traits.Bool(desc='Flag indicating whether to use S3 '\ 'server-side AES-256 encryption') # Set this if user wishes to override the bucket with their own - bucket = traits.Str(desc='Boto3 S3 bucket for manual override of bucket') + bucket = traits.Any(desc='Boto3 S3 bucket for manual override of bucket') # Set this if user wishes to have local copy of files as well local_copy = traits.Str(desc='Copy files locally as well as to S3 bucket')