diff --git a/CHANGES b/CHANGES index 1e47aa4657..3e8023a1db 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ Next release ============ +* ENH: The name_source feature now available for all Interfaces derived from BaseInterface + (https://github.com/nipy/nipype/pull/1240) * FIX: Prevent crash when tvtk is loaded - ETS_TOOLKIT=null (https://github.com/nipy/nipype/pull/973) * ENH: New interfaces in dipy: RESTORE, EstimateResponseSH, CSD and StreamlineTractography (https://github.com/nipy/nipype/pull/1090) diff --git a/nipype/algorithms/icc.py b/nipype/algorithms/icc.py index af61c260b9..b02de49c09 100644 --- a/nipype/algorithms/icc.py +++ b/nipype/algorithms/icc.py @@ -1,36 +1,54 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +""" +Algorithms to compute the Interclass Correlation Coefficient + + Change directory to provide relative paths for doctests + >>> import os + >>> filepath = os.path.dirname( os.path.realpath( __file__ ) ) + >>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data')) + >>> os.chdir(datadir) + +""" + from __future__ import division -from builtins import range +import os +import numpy as np from numpy import ones, kron, mean, eye, hstack, dot, tile from scipy.linalg import pinv -from ..interfaces.base import BaseInterfaceInputSpec, TraitedSpec, \ - BaseInterface, traits, File import nibabel as nb -import numpy as np -import os +from builtins import range +from ..interfaces.base import (traits, File, BaseInterface, BaseInputSpec, + TraitedSpec) -class ICCInputSpec(BaseInterfaceInputSpec): +class ICCInputSpec(BaseInputSpec): subjects_sessions = traits.List(traits.List(File(exists=True)), desc="n subjects m sessions 3D stat files", mandatory=True) mask = File(exists=True, mandatory=True) + icc_map = File('icc_map.nii', desc='name of output ICC map') + session_var_map = File('session_var_map.nii', desc="variance between sessions") + session_F_map = File('session_F_map.nii', desc="F map of sessions") + subject_var_map = File('subject_var_map.nii', desc="variance between subjects") class ICCOutputSpec(TraitedSpec): icc_map = File(exists=True) session_var_map = File(exists=True, desc="variance between sessions") + session_F_map = File(exists=True, desc="variance between sessions") subject_var_map = File(exists=True, desc="variance between subjects") class ICC(BaseInterface): - ''' + """ Calculates Interclass Correlation Coefficient (3,1) as defined in P. E. Shrout & Joseph L. Fleiss (1979). "Intraclass Correlations: Uses in Assessing Rater Reliability". Psychological Bulletin 86 (2): 420-428. This particular implementation is aimed at relaibility (test-retest) studies. - ''' - input_spec = ICCInputSpec - output_spec = ICCOutputSpec + """ + _input_spec = ICCInputSpec + _output_spec = ICCOutputSpec def _run_interface(self, runtime): maskdata = nb.load(self.inputs.mask).get_data() @@ -44,48 +62,46 @@ def _run_interface(self, runtime): session_var = np.zeros(session_datas[0][0].shape) subject_var = np.zeros(session_datas[0][0].shape) - for x in range(icc.shape[0]): - Y = all_data[x, :, :] - icc[x], subject_var[x], session_var[x], session_F[x], _, _ = ICC_rep_anova(Y) + for i in range(icc.shape[0]): + data = all_data[i, :, :] + icc[i], subject_var[i], session_var[i], session_F[i], _, _ = ICC_rep_anova(data) nim = nb.load(self.inputs.subjects_sessions[0][0]) new_data = np.zeros(nim.shape) new_data[maskdata] = icc.reshape(-1,) new_img = nb.Nifti1Image(new_data, nim.affine, nim.header) - nb.save(new_img, 'icc_map.nii') + nb.save(new_img, self.inputs.icc_map) new_data = np.zeros(nim.shape) new_data[maskdata] = session_var.reshape(-1,) new_img = nb.Nifti1Image(new_data, nim.affine, nim.header) - nb.save(new_img, 'session_var_map.nii') + nb.save(new_img, self.inputs.session_var_map) new_data = np.zeros(nim.shape) new_data[maskdata] = subject_var.reshape(-1,) new_img = nb.Nifti1Image(new_data, nim.affine, nim.header) - nb.save(new_img, 'subject_var_map.nii') + nb.save(new_img, self.inputs.subject_var_map.nii) + new_data = np.zeros(nim.shape) + new_data[maskdata] = session_F.reshape(-1,) + new_img = nb.Nifti1Image(new_data, nim.affine, nim.header) + nb.save(new_img, self.inputs.session_F_map) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['icc_map'] = os.path.abspath('icc_map.nii') - outputs['sessions_F_map'] = os.path.abspath('sessions_F_map.nii') - outputs['session_var_map'] = os.path.abspath('session_var_map.nii') - outputs['subject_var_map'] = os.path.abspath('subject_var_map.nii') - return outputs - -def ICC_rep_anova(Y): - ''' - the data Y are entered as a 'table' ie subjects are in rows and repeated +def ICC_rep_anova(data): + """ + the data (Y) are entered as a 'table' ie subjects are in rows and repeated measures in columns One Sample Repeated measure ANOVA - Y = XB + E with X = [FaTor / Subjects] - ''' + .. math:: + + Y = XB + E with X = [FaTor / Subjects] + """ - [nb_subjects, nb_conditions] = Y.shape + [nb_subjects, nb_conditions] = data.shape dfc = nb_conditions - 1 dfe = (nb_subjects - 1) * dfc dfr = nb_subjects - 1 @@ -94,8 +110,8 @@ def ICC_rep_anova(Y): # ------------------------------------ # Sum Square Total - mean_Y = mean(Y) - SST = ((Y - mean_Y) ** 2).sum() + mean_Y = mean(data) + SST = ((data - mean_Y) ** 2).sum() # create the design matrix for the different levels x = kron(eye(nb_conditions), ones((nb_subjects, 1))) # sessions @@ -103,16 +119,16 @@ def ICC_rep_anova(Y): X = hstack([x, x0]) # Sum Square Error - predicted_Y = dot(dot(dot(X, pinv(dot(X.T, X))), X.T), Y.flatten('F')) - residuals = Y.flatten('F') - predicted_Y + predicted_Y = dot(dot(dot(X, pinv(dot(X.T, X))), X.T), data.flatten('F')) + residuals = data.flatten('F') - predicted_Y SSE = (residuals ** 2).sum() - residuals.shape = Y.shape + residuals.shape = data.shape MSE = SSE / dfe # Sum square session effect - between colums/sessions - SSC = ((mean(Y, 0) - mean_Y) ** 2).sum() * nb_subjects + SSC = ((mean(data, 0) - mean_Y) ** 2).sum() * nb_subjects MSC = SSC / dfc / nb_subjects session_effect_F = MSC / MSE diff --git a/nipype/algorithms/mesh.py b/nipype/algorithms/mesh.py index 9e18a96b90..2d022a750a 100644 --- a/nipype/algorithms/mesh.py +++ b/nipype/algorithms/mesh.py @@ -21,10 +21,11 @@ from .. import logging from ..external.six import string_types -from ..interfaces.base import (BaseInterface, traits, TraitedSpec, File, - BaseInterfaceInputSpec) +from ..interfaces.base import (traits, File, GenFile, BaseInterface, BaseInputSpec, + TraitedSpec) from ..interfaces.vtkbase import tvtk from ..interfaces import vtkbase as VTKInfo + IFLOGGER = logging.getLogger('interface') @@ -39,16 +40,15 @@ def __init__(self, **inputs): super(TVTKBaseInterface, self).__init__(**inputs) -class WarpPointsInputSpec(BaseInterfaceInputSpec): +class WarpPointsInputSpec(BaseInputSpec): points = File(exists=True, mandatory=True, desc='file containing the point set') warp = File(exists=True, mandatory=True, desc='dense deformation field to be applied') interp = traits.Enum('cubic', 'nearest', 'linear', usedefault=True, mandatory=True, desc='interpolation') - out_points = File(name_source='points', name_template='%s_warped', - output_name='out_points', keep_extension=True, - desc='the warped point set') + out_points = GenFile(template='{points}_warped', keep_extension=True, + desc='the warped point set') class WarpPointsOutputSpec(TraitedSpec): @@ -72,22 +72,8 @@ class WarpPoints(TVTKBaseInterface): res = wp.run() """ - input_spec = WarpPointsInputSpec - output_spec = WarpPointsOutputSpec - - def _gen_fname(self, in_file, suffix='generated', ext=None): - fname, fext = op.splitext(op.basename(in_file)) - - if fext == '.gz': - fname, fext2 = op.splitext(fname) - fext = fext2 + fext - - if ext is None: - ext = fext - - if ext[0] == '.': - ext = ext[1:] - return op.abspath('%s_%s.%s' % (fname, suffix, ext)) + _input_spec = WarpPointsInputSpec + _output_spec = WarpPointsOutputSpec def _run_interface(self, runtime): import nibabel as nb @@ -122,19 +108,14 @@ def _run_interface(self, runtime): newpoints = [p + d for p, d in zip(points, disps)] mesh.points = newpoints w = tvtk.PolyDataWriter() + VTKInfo.configure_input_data(w, mesh) - w.file_name = self._gen_fname(self.inputs.points, suffix='warped', ext='.vtk') + w.file_name = self.inputs.out_points w.write() return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_points'] = self._gen_fname(self.inputs.points, suffix='warped', - ext='.vtk') - return outputs - -class ComputeMeshWarpInputSpec(BaseInterfaceInputSpec): +class ComputeMeshWarpInputSpec(BaseInputSpec): surface1 = File(exists=True, mandatory=True, desc=('Reference surface (vtk format) to which compute ' 'distance.')) @@ -184,8 +165,8 @@ class ComputeMeshWarp(TVTKBaseInterface): """ - input_spec = ComputeMeshWarpInputSpec - output_spec = ComputeMeshWarpOutputSpec + _input_spec = ComputeMeshWarpInputSpec + _output_spec = ComputeMeshWarpOutputSpec def _triangle_area(self, A, B, C): A = np.array(A) @@ -248,18 +229,15 @@ def _run_interface(self, runtime): VTKInfo.configure_input_data(writer, out_mesh) writer.write() - self._distance = np.average(errvector, weights=weights) - return runtime + _distance = np.average(errvector, weights=weights) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - outputs['out_warp'] = op.abspath(self.inputs.out_warp) - outputs['distance'] = self._distance - return outputs + self.outputs.out_file = op.abspath(self.inputs.out_file) + self.outputs.out_warp = op.abspath(self.inputs.out_warp) + self.outputs.distance = _distance + return runtime -class MeshWarpMathsInputSpec(BaseInterfaceInputSpec): +class MeshWarpMathsInputSpec(BaseInputSpec): in_surf = File(exists=True, mandatory=True, desc=('Input surface in vtk format, with associated warp ' 'field as point data (ie. from ComputeMeshWarp')) @@ -273,18 +251,16 @@ class MeshWarpMathsInputSpec(BaseInterfaceInputSpec): operation = traits.Enum('sum', 'sub', 'mul', 'div', usedefault=True, desc='operation to be performed') - out_warp = File('warp_maths.vtk', usedefault=True, - desc='vtk file based on in_surf and warpings mapping it ' - 'to out_file') - out_file = File('warped_surf.vtk', usedefault=True, + out_warp = GenFile(template='{in_surf}_warping', keep_extension=True, + desc='vtk file based on in_surf and warpings mapping it to out_file') + out_file = File(template='{in_surf}_warped', keep_extension=True, desc='vtk with surface warped') class MeshWarpMathsOutputSpec(TraitedSpec): out_warp = File(exists=True, desc=('vtk file with the vertex-wise ' 'mapping of surface1 to surface2')) - out_file = File(exists=True, - desc='vtk with surface warped') + out_file = File(exists=True, desc='vtk with surface warped') class MeshWarpMaths(TVTKBaseInterface): @@ -309,8 +285,8 @@ class MeshWarpMaths(TVTKBaseInterface): """ - input_spec = MeshWarpMathsInputSpec - output_spec = MeshWarpMathsOutputSpec + _input_spec = MeshWarpMathsInputSpec + _output_spec = MeshWarpMathsOutputSpec def _run_interface(self, runtime): r1 = tvtk.PolyDataReader(file_name=self.inputs.in_surf) @@ -370,12 +346,6 @@ def _run_interface(self, runtime): writer.write() return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - outputs['out_warp'] = op.abspath(self.inputs.out_warp) - return outputs - class P2PDistance(ComputeMeshWarp): """ diff --git a/nipype/algorithms/metrics.py b/nipype/algorithms/metrics.py index 25ace5f012..95d2db82bf 100644 --- a/nipype/algorithms/metrics.py +++ b/nipype/algorithms/metrics.py @@ -1,6 +1,6 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: -''' +""" Image assessment algorithms. Typical overlap and error computation measures to evaluate results from other processing units. @@ -10,7 +10,7 @@ >>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data')) >>> os.chdir(datadir) -''' +""" from __future__ import division from builtins import zip from builtins import range @@ -27,13 +27,13 @@ from .. import logging from ..utils.misc import package_check -from ..interfaces.base import (BaseInterface, traits, TraitedSpec, File, - InputMultiPath, - BaseInterfaceInputSpec, isdefined) +from ..interfaces.base import (traits, File, GenFile, isdefined, BaseInputSpec, + TraitedSpec, InputMultiPath, BaseInterface) + iflogger = logging.getLogger('interface') -class DistanceInputSpec(BaseInterfaceInputSpec): +class DistanceInputSpec(BaseInputSpec): volume1 = File(exists=True, mandatory=True, desc="Has to have the same dimensions as volume2.") volume2 = File( @@ -67,8 +67,8 @@ class DistanceOutputSpec(TraitedSpec): class Distance(BaseInterface): """Calculates distance between two volumes. """ - input_spec = DistanceInputSpec - output_spec = DistanceOutputSpec + _input_spec = DistanceInputSpec + _output_spec = DistanceOutputSpec _hist_filename = "hist.pdf" @@ -186,34 +186,30 @@ def _run_interface(self, runtime): nii2 = nb.load(self.inputs.volume2, mmap=False) if self.inputs.method == "eucl_min": - self._distance, self._point1, self._point2 = self._eucl_min( + _distance, _point1, _point2 = self._eucl_min( nii1, nii2) elif self.inputs.method == "eucl_cog": - self._distance = self._eucl_cog(nii1, nii2) + _distance = self._eucl_cog(nii1, nii2) elif self.inputs.method == "eucl_mean": - self._distance = self._eucl_mean(nii1, nii2) + _distance = self._eucl_mean(nii1, nii2) elif self.inputs.method == "eucl_wmean": - self._distance = self._eucl_mean(nii1, nii2, weighted=True) + _distance = self._eucl_mean(nii1, nii2, weighted=True) elif self.inputs.method == "eucl_max": - self._distance = self._eucl_max(nii1, nii2) - - return runtime + _distance = self._eucl_max(nii1, nii2) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['distance'] = self._distance + self.outputs.distance = _distance if self.inputs.method == "eucl_min": - outputs['point1'] = self._point1 - outputs['point2'] = self._point2 + self.outputs.point1 = _point1 + self.outputs.point2 = _point2 elif self.inputs.method in ["eucl_mean", "eucl_wmean"]: - outputs['histogram'] = os.path.abspath(self._hist_filename) - return outputs + self.outputs.histogram = os.path.abspath(self._hist_filename) + return runtime -class OverlapInputSpec(BaseInterfaceInputSpec): +class OverlapInputSpec(BaseInputSpec): volume1 = File(exists=True, mandatory=True, desc='Has to have the same dimensions as volume2.') volume2 = File(exists=True, mandatory=True, @@ -268,8 +264,8 @@ class Overlap(BaseInterface): >>> res = overlap.run() # doctest: +SKIP """ - input_spec = OverlapInputSpec - output_spec = OverlapOutputSpec + _input_spec = OverlapInputSpec + _output_spec = OverlapOutputSpec def _bool_vec_dissimilarity(self, booldata1, booldata2, method): methods = {'dice': dice, 'jaccard': jaccard} @@ -317,9 +313,9 @@ def _run_interface(self, runtime): volumes1.append(scale * len(data1[data1 == l])) volumes2.append(scale * len(data2[data2 == l])) - results = dict(jaccard=[], dice=[]) - results['jaccard'] = np.array(res) - results['dice'] = 2.0 * results['jaccard'] / (results['jaccard'] + 1.0) + _ove_rois = dict(jaccard=[], dice=[]) + _ove_rois['jaccard'] = np.array(res) + _ove_rois['dice'] = 2.0 * _ove_rois['jaccard'] / (_ove_rois['jaccard'] + 1.0) weights = np.ones((len(volumes1),), dtype=np.float32) if self.inputs.weighting != 'none': @@ -334,32 +330,24 @@ def _run_interface(self, runtime): nb.save(nb.Nifti1Image(both_data, nii1.affine, nii1.header), self.inputs.out_file) - self._labels = labels - self._ove_rois = results - self._vol_rois = (np.array(volumes1) - + _vol_rois = (np.array(volumes1) - np.array(volumes2)) / np.array(volumes1) - self._dice = round(np.sum(weights * results['dice']), 5) - self._jaccard = round(np.sum(weights * results['jaccard']), 5) - self._volume = np.sum(weights * self._vol_rois) - + _dice = round(np.sum(weights * _ove_rois['dice']), 5) + _jaccard = round(np.sum(weights * _ove_rois['jaccard']), 5) + _volume = np.sum(weights * _vol_rois) + self.outputs.labels = labels + self.outputs.jaccard = _jaccard + self.outputs.dice = _dice + self.outputs.volume_difference = _volume + self.outputs.roi_ji = _ove_rois['jaccard'].tolist() + self.outputs.roi_di = _ove_rois['dice'].tolist() + self.outputs.roi_voldiff = _vol_rois.tolist() + self.outputs.diff_file = os.path.abspath(self.inputs.out_file) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['labels'] = self._labels - outputs['jaccard'] = self._jaccard - outputs['dice'] = self._dice - outputs['volume_difference'] = self._volume - - outputs['roi_ji'] = self._ove_rois['jaccard'].tolist() - outputs['roi_di'] = self._ove_rois['dice'].tolist() - outputs['roi_voldiff'] = self._vol_rois.tolist() - outputs['diff_file'] = os.path.abspath(self.inputs.out_file) - return outputs - -class FuzzyOverlapInputSpec(BaseInterfaceInputSpec): +class FuzzyOverlapInputSpec(BaseInputSpec): in_ref = InputMultiPath(File(exists=True), mandatory=True, desc='Reference image. Requires the same dimensions as in_tst.') in_tst = InputMultiPath(File(exists=True), mandatory=True, @@ -402,8 +390,8 @@ class FuzzyOverlap(BaseInterface): >>> res = overlap.run() # doctest: +SKIP """ - input_spec = FuzzyOverlapInputSpec - output_spec = FuzzyOverlapOutputSpec + _input_spec = FuzzyOverlapInputSpec + _output_spec = FuzzyOverlapOutputSpec def _run_interface(self, runtime): ncomp = len(self.inputs.in_ref) @@ -422,7 +410,7 @@ def _run_interface(self, runtime): # img_ref[:][msk>0] = img_ref[:][msk>0] / (np.sum( img_ref, axis=0 ))[msk>0] # img_tst[tst_msk>0] = img_tst[tst_msk>0] / np.sum( img_tst, axis=0 )[tst_msk>0] - self._jaccards = [] + _jaccards = [] volumes = [] diff_im = np.zeros(img_ref.shape) @@ -431,11 +419,11 @@ def _run_interface(self, runtime): num = np.minimum(ref_comp, tst_comp) ddr = np.maximum(ref_comp, tst_comp) diff_comp[ddr > 0] += 1.0 - (num[ddr > 0] / ddr[ddr > 0]) - self._jaccards.append(np.sum(num) / np.sum(ddr)) + _jaccards.append(np.sum(num) / np.sum(ddr)) volumes.append(np.sum(ref_comp)) - self._dices = 2.0 * (np.array(self._jaccards) / - (np.array(self._jaccards) + 1.0)) + _dices = 2.0 * (np.array(_jaccards) / + (np.array(_jaccards) + 1.0)) if self.inputs.weighting != "none": weights = 1.0 / np.array(volumes) @@ -444,8 +432,8 @@ def _run_interface(self, runtime): weights = weights / np.sum(weights) - setattr(self, '_jaccard', np.sum(weights * self._jaccards)) - setattr(self, '_dice', np.sum(weights * self._dices)) + setattr(self, '_jaccard', np.sum(weights * _jaccards)) + setattr(self, '_dice', np.sum(weights * _dices)) diff = np.zeros(diff_im[0].shape) @@ -457,20 +445,16 @@ def _run_interface(self, runtime): nb.load(self.inputs.in_ref[0]).header), self.inputs.out_file) - return runtime - - def _list_outputs(self): - outputs = self._outputs().get() for method in ("dice", "jaccard"): - outputs[method] = getattr(self, '_' + method) - # outputs['volume_difference'] = self._volume - outputs['diff_file'] = os.path.abspath(self.inputs.out_file) - outputs['class_fji'] = np.array(self._jaccards).astype(float).tolist() - outputs['class_fdi'] = self._dices.astype(float).tolist() - return outputs + setattr(self.outputs, method, getattr(self, '_' + method)) + # self.outputs.volume_difference = _volume + self.outputs.diff_file = os.path.abspath(self.inputs.out_file) + self.outputs.class_fji = np.array(_jaccards).astype(float).tolist() + self.outputs.class_fdi = _dices.astype(float).tolist() + return runtime -class ErrorMapInputSpec(BaseInterfaceInputSpec): +class ErrorMapInputSpec(BaseInputSpec): in_ref = File(exists=True, mandatory=True, desc="Reference image. Requires the same dimensions as in_tst.") in_tst = File(exists=True, mandatory=True, @@ -479,7 +463,8 @@ class ErrorMapInputSpec(BaseInterfaceInputSpec): metric = traits.Enum("sqeuclidean", "euclidean", desc='error map metric (as implemented in scipy cdist)', usedefault=True, mandatory=True) - out_map = File(desc="Name for the output file") + out_map = GenFile(template='{in_tst}_errormap', keep_extension=True, + desc="Name for the output file") class ErrorMapOutputSpec(TraitedSpec): @@ -498,8 +483,8 @@ class ErrorMap(BaseInterface): >>> errormap.inputs.in_tst = 'cont2.nii' >>> res = errormap.run() # doctest: +SKIP """ - input_spec = ErrorMapInputSpec - output_spec = ErrorMapOutputSpec + _input_spec = ErrorMapInputSpec + _output_spec = ErrorMapOutputSpec _out_file = '' def _run_interface(self, runtime): @@ -547,7 +532,7 @@ def _run_interface(self, runtime): errvectorexp[msk_idxs] = errvector # Get averaged error - self._distance = np.average(errvector) # Only average the masked voxels + _distance = np.average(errvector) # Only average the masked voxels errmap = errvectorexp.reshape(mapshape) @@ -555,29 +540,13 @@ def _run_interface(self, runtime): hdr.set_data_dtype(np.float32) hdr['data_type'] = 16 hdr.set_data_shape(mapshape) - - if not isdefined(self.inputs.out_map): - fname, ext = op.splitext(op.basename(self.inputs.in_tst)) - if ext == '.gz': - fname, ext2 = op.splitext(fname) - ext = ext2 + ext - self._out_file = op.abspath(fname + "_errmap" + ext) - else: - self._out_file = self.inputs.out_map - nb.Nifti1Image(errmap.astype(np.float32), nii_ref.affine, - hdr).to_filename(self._out_file) - + hdr).to_filename(self.inputs.out_map) + self.outputs.distance = _distance return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_map'] = self._out_file - outputs['distance'] = self._distance - return outputs - -class SimilarityInputSpec(BaseInterfaceInputSpec): +class SimilarityInputSpec(BaseInputSpec): volume1 = File(exists=True, desc="3D/4D volume", mandatory=True) volume2 = File(exists=True, desc="3D/4D volume", mandatory=True) mask1 = File(exists=True, desc="3D volume") @@ -619,8 +588,8 @@ class Similarity(BaseInterface): >>> res = similarity.run() # doctest: +SKIP """ - input_spec = SimilarityInputSpec - output_spec = SimilarityOutputSpec + _input_spec = SimilarityInputSpec + _output_spec = SimilarityOutputSpec _have_nipy = True def __init__(self, **inputs): @@ -662,7 +631,7 @@ def _run_interface(self, runtime): else: mask2 = None - self._similarity = [] + _similarity = [] for ts1, ts2 in zip(vols1, vols2): histreg = HistogramRegistration(from_img=ts1, @@ -670,11 +639,8 @@ def _run_interface(self, runtime): similarity=self.inputs.metric, from_mask=mask1, to_mask=mask2) - self._similarity.append(histreg.eval(Affine())) + _similarity.append(histreg.eval(Affine())) + self.outputs.similarity = _similarity return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['similarity'] = self._similarity - return outputs diff --git a/nipype/algorithms/misc.py b/nipype/algorithms/misc.py index 1aea8cdbae..6154d6e859 100644 --- a/nipype/algorithms/misc.py +++ b/nipype/algorithms/misc.py @@ -1,6 +1,6 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: -''' +""" Miscellaneous algorithms Change directory to provide relative paths for doctests @@ -9,7 +9,7 @@ >>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data')) >>> os.chdir(datadir) -''' +""" from __future__ import print_function from __future__ import absolute_import from __future__ import division @@ -28,39 +28,36 @@ import itertools import scipy.stats as stats -from nipype import logging +from . import metrics as nam +from ..utils.filemanip import fname_presuffix, split_filename +from ..interfaces.base import (traits, File, GenFile, GenMultiFile, isdefined, Undefined, + BaseInputSpec, TraitedSpec, InputMultiPath, + OutputMultiPath, DynamicTraitedSpec, BaseInterface) -import warnings -from . import metrics as nam -from ..interfaces.base import (BaseInterface, traits, TraitedSpec, File, - InputMultiPath, OutputMultiPath, - BaseInterfaceInputSpec, isdefined, - DynamicTraitedSpec, Undefined) -from nipype.utils.filemanip import fname_presuffix, split_filename -iflogger = logging.getLogger('interface') +from .. import logging +IFLOGGER = logging.getLogger('interface') -class PickAtlasInputSpec(BaseInterfaceInputSpec): +class PickAtlasInputSpec(BaseInputSpec): atlas = File(exists=True, desc="Location of the atlas that will be used.", mandatory=True) labels = traits.Either( traits.Int, traits.List(traits.Int), desc=("Labels of regions that will be included in the mask. Must be\ compatible with the atlas used."), - mandatory=True - ) + mandatory=True) hemi = traits.Enum( 'both', 'left', 'right', desc="Restrict the mask to only one hemisphere: left or right", - usedefault=True - ) + usedefault=True) dilation_size = traits.Int( usedefault=True, - desc="Defines how much the mask will be dilated (expanded in 3D)." - ) - output_file = File(desc="Where to store the output mask.") - + desc="Defines how much the mask will be dilated (expanded in 3D).") + output_file = File(deprecated=True, new_name='mask_file', + desc="Where to store the output mask.") + mask_file = GenFile(ns='atlas', template='%s_mask', + desc="Where to store the output mask.") class PickAtlasOutputSpec(TraitedSpec): mask_file = File(exists=True, desc="output mask file") @@ -71,13 +68,12 @@ class PickAtlas(BaseInterface): and left right masking (assuming the atlas is properly aligned). """ - input_spec = PickAtlasInputSpec - output_spec = PickAtlasOutputSpec + _input_spec = PickAtlasInputSpec + _output_spec = PickAtlasOutputSpec def _run_interface(self, runtime): nim = self._get_brodmann_area() - nb.save(nim, self._gen_output_filename()) - + nb.save(nim, self.inputs.out_mask) return runtime def _gen_output_filename(self): @@ -113,35 +109,28 @@ def _get_brodmann_area(self): return nb.Nifti1Image(newdata, nii.affine, nii.header) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['mask_file'] = self._gen_output_filename() - return outputs - -class SimpleThresholdInputSpec(BaseInterfaceInputSpec): - volumes = InputMultiPath( - File(exists=True), desc='volumes to be thresholded', mandatory=True) - threshold = traits.Float( - desc='volumes to be thresholdedeverything below this value will be set\ - to zero', - mandatory=True - ) +class SimpleThresholdInputSpec(BaseInputSpec): + volumes = InputMultiPath(File(exists=True), mandatory=True, + desc='volumes to be thresholded') + threshold = traits.Float(mandatory=True, desc='volumes to be thresholdedeverything below ' + 'this value will be set to zero') + thresholded_volumes = GenMultiFile(template='{volumes}_thresholded', keep_extension=True, + desc="thresholded volumes") class SimpleThresholdOutputSpec(TraitedSpec): - thresholded_volumes = OutputMultiPath( - File(exists=True), desc="thresholded volumes") + thresholded_volumes = OutputMultiPath(File(exists=True), desc="thresholded volumes") class SimpleThreshold(BaseInterface): """Applies a threshold to input volumes """ - input_spec = SimpleThresholdInputSpec - output_spec = SimpleThresholdOutputSpec + _input_spec = SimpleThresholdInputSpec + _output_spec = SimpleThresholdOutputSpec def _run_interface(self, runtime): - for fname in self.inputs.volumes: + for fname, out_name in zip(self.inputs.volumes, self.inputs.thresholded_volumes): img = nb.load(fname) data = np.array(img.get_data()) @@ -151,92 +140,60 @@ def _run_interface(self, runtime): thresholded_map[active_map] = data[active_map] new_img = nb.Nifti1Image(thresholded_map, img.affine, img.header) - _, base, _ = split_filename(fname) - nb.save(new_img, base + '_thresholded.nii') + nb.save(new_img, out_name) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs["thresholded_volumes"] = [] - for fname in self.inputs.volumes: - _, base, _ = split_filename(fname) - outputs["thresholded_volumes"].append( - os.path.abspath(base + '_thresholded.nii')) - return outputs - -class ModifyAffineInputSpec(BaseInterfaceInputSpec): +class ModifyAffineInputSpec(BaseInputSpec): volumes = InputMultiPath( - File(exists=True), - desc='volumes which affine matrices will be modified', - mandatory=True - ) + File(exists=True), mandatory=True, + desc='volumes which affine matrices will be modified') transformation_matrix = traits.Array( - value=np.eye(4), - shape=(4, 4), - desc="transformation matrix that will be left multiplied by the\ - affine matrix", - usedefault=True - ) + value=np.eye(4), shape=(4, 4), usedefault=True, + desc='transformation matrix that will be left multiplied by the affine matrix') + transformed_volumes = GenMultiFile(template='{volumes}_transformed', keep_extension=True, + desc='output transformed files') class ModifyAffineOutputSpec(TraitedSpec): - transformed_volumes = OutputMultiPath(File(exist=True)) + transformed_volumes = OutputMultiPath(File(exist=True), desc='output transformed files') class ModifyAffine(BaseInterface): """Left multiplies the affine matrix with a specified values. Saves the volume as a nifti file. """ - input_spec = ModifyAffineInputSpec - output_spec = ModifyAffineOutputSpec - - def _gen_output_filename(self, name): - _, base, _ = split_filename(name) - return os.path.abspath(base + "_transformed.nii") + _input_spec = ModifyAffineInputSpec + _output_spec = ModifyAffineOutputSpec def _run_interface(self, runtime): - for fname in self.inputs.volumes: + for fname, out_name in zip(self.inputs.volumes, self.inputs.transformed_volumes): img = nb.load(fname) - affine = img.affine affine = np.dot(self.inputs.transformation_matrix, affine) - - nb.save(nb.Nifti1Image(img.get_data(), affine, img.header), - self._gen_output_filename(fname)) - + nb.save(nb.Nifti1Image(img.get_data(), affine, img.header), out_name) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['transformed_volumes'] = [] - for fname in self.inputs.volumes: - outputs['transformed_volumes'].append( - self._gen_output_filename(fname)) - return outputs - -class CreateNiftiInputSpec(BaseInterfaceInputSpec): +class CreateNiftiInputSpec(BaseInputSpec): data_file = File(exists=True, mandatory=True, desc="ANALYZE img file") header_file = File( exists=True, mandatory=True, desc="corresponding ANALYZE hdr file") affine = traits.Array(desc="affine transformation array") + nifti_file = GenFile(ns='data_file', template='%s_nifti.nii', + keep_extension=False, desc='output nifti file') class CreateNiftiOutputSpec(TraitedSpec): - nifti_file = File(exists=True) + nifti_file = File(exists=True, desc='output nifti file') class CreateNifti(BaseInterface): """Creates a nifti volume """ - input_spec = CreateNiftiInputSpec - output_spec = CreateNiftiOutputSpec - - def _gen_output_file_name(self): - _, base, _ = split_filename(self.inputs.data_file) - return os.path.abspath(base + ".nii") + _input_spec = CreateNiftiInputSpec + _output_spec = CreateNiftiOutputSpec def _run_interface(self, runtime): hdr = nb.AnalyzeHeader.from_fileobj( @@ -249,28 +206,23 @@ def _run_interface(self, runtime): data = hdr.data_from_fileobj(open(self.inputs.data_file, 'rb')) img = nb.Nifti1Image(data, affine, hdr) - nb.save(img, self._gen_output_file_name()) - + nb.save(img, self.inputs.nifti_file) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['nifti_file'] = self._gen_output_file_name() - return outputs - -class TSNRInputSpec(BaseInterfaceInputSpec): +class TSNRInputSpec(BaseInputSpec): in_file = InputMultiPath(File(exists=True), mandatory=True, desc='realigned 4D file or a list of 3D files') regress_poly = traits.Range(low=1, desc='Remove polynomials') - tsnr_file = File('tsnr.nii.gz', usedefault=True, hash_files=False, - desc='output tSNR file') - mean_file = File('mean.nii.gz', usedefault=True, hash_files=False, - desc='output mean file') - stddev_file = File('stdev.nii.gz', usedefault=True, hash_files=False, - desc='output tSNR file') - detrended_file = File('detrend.nii.gz', usedefault=True, hash_files=False, - desc='input file after detrending') + tsnr_file = GenFile(ns='in_file', template='%s_tsnr', + hash_files=False, desc='output tSNR file') + mean_file = GenFile(ns='in_file', template='%s_mean', + hash_files=False, desc='output mean file') + stddev_file = GenFile(ns='in_file', template='%s_stdev', + hash_files=False, desc='output std deviation file') + detrended_file = GenFile( + ns='in_file', template='%s_detrend', hash_files=False, + desc='input file after detrending') class TSNROutputSpec(TraitedSpec): @@ -293,8 +245,8 @@ class TSNR(BaseInterface): >>> res = tsnr.run() # doctest: +SKIP """ - input_spec = TSNRInputSpec - output_spec = TSNROutputSpec + _input_spec = TSNRInputSpec + _output_spec = TSNROutputSpec def _run_interface(self, runtime): img = nb.load(self.inputs.in_file[0]) @@ -333,19 +285,13 @@ def _run_interface(self, runtime): nb.save(img, op.abspath(self.inputs.mean_file)) img = nb.Nifti1Image(stddevimg, img.get_affine(), header) nb.save(img, op.abspath(self.inputs.stddev_file)) - return runtime - def _list_outputs(self): - outputs = self._outputs().get() - for k in ['tsnr_file', 'mean_file', 'stddev_file']: - outputs[k] = op.abspath(getattr(self.inputs, k)) - - if isdefined(self.inputs.regress_poly): - outputs['detrended_file'] = op.abspath(self.inputs.detrended_file) - return outputs + if not isdefined(self.inputs.regress_poly): + self.outputs.detrended_file = Undefined + return runtime -class GunzipInputSpec(BaseInterfaceInputSpec): +class GunzipInputSpec(BaseInputSpec): in_file = File(exists=True, mandatory=True) @@ -354,51 +300,25 @@ class GunzipOutputSpec(TraitedSpec): class Gunzip(BaseInterface): - """Gunzip wrapper - """ - input_spec = GunzipInputSpec - output_spec = GunzipOutputSpec - - def _gen_output_file_name(self): - _, base, ext = split_filename(self.inputs.in_file) - if ext[-2:].lower() == ".gz": - ext = ext[:-3] - return os.path.abspath(base + ext[:-3]) + """Gunzip wrapper""" + _input_spec = GunzipInputSpec + _output_spec = GunzipOutputSpec def _run_interface(self, runtime): import gzip - in_file = gzip.open(self.inputs.in_file, 'rb') - out_file = open(self._gen_output_file_name(), 'wb') - out_file.write(in_file.read()) - out_file.close() - in_file.close() - return runtime - - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = self._gen_output_file_name() - return outputs - - -def replaceext(in_list, ext): - out_list = list() - for filename in in_list: - path, name, _ = split_filename(op.abspath(filename)) - out_name = op.join(path, name) + ext - out_list.append(out_name) - return out_list + _, fname, ext = split_filename(self.inputs.in_file) + out_file = fname + ext + if not ext.endswith('.gz'): + IFLOGGER.warn('File does not have .gz extension.') + else: + out_file = out_file[:-3] -def matlab2csv(in_array, name, reshape): - output_array = np.asarray(in_array) - if reshape: - if len(np.shape(output_array)) > 1: - output_array = np.reshape(output_array, ( - np.shape(output_array)[0] * np.shape(output_array)[1], 1)) - iflogger.info(np.shape(output_array)) - output_name = op.abspath(name + '.csv') - np.savetxt(output_name, output_array, delimiter=',') - return output_name + with gzip.open(self.inputs.in_file, 'rb') as in_file: + with open(out_file, 'wb') as ofile: + ofile.write(in_file.read()) + self.outputs.out_file = out_file + return runtime class Matlab2CSVInputSpec(TraitedSpec): @@ -432,8 +352,8 @@ class Matlab2CSV(BaseInterface): >>> mat2csv.inputs.in_file = 'cmatrix.mat' >>> mat2csv.run() # doctest: +SKIP """ - input_spec = Matlab2CSVInputSpec - output_spec = Matlab2CSVOutputSpec + _input_spec = Matlab2CSVInputSpec + _output_spec = Matlab2CSVOutputSpec def _run_interface(self, runtime): in_dict = sio.loadmat(op.abspath(self.inputs.in_file)) @@ -449,14 +369,14 @@ def _run_interface(self, runtime): if isinstance(in_dict[key][0], np.ndarray): saved_variables.append(key) else: - iflogger.info('One of the keys in the input file, {k}, is not a Numpy array'.format(k=key)) + IFLOGGER.info('One of the keys in the input file, {k}, is not a Numpy array'.format(k=key)) if len(saved_variables) > 1: - iflogger.info( + IFLOGGER.info( '{N} variables found:'.format(N=len(saved_variables))) - iflogger.info(saved_variables) + IFLOGGER.info(saved_variables) for variable in saved_variables: - iflogger.info( + IFLOGGER.info( '...Converting {var} - type {ty} - to\ CSV'.format(var=variable, ty=type(in_dict[variable])) ) @@ -465,17 +385,18 @@ def _run_interface(self, runtime): elif len(saved_variables) == 1: _, name, _ = split_filename(self.inputs.in_file) variable = saved_variables[0] - iflogger.info('Single variable found {var}, type {ty}:'.format( + IFLOGGER.info('Single variable found {var}, type {ty}:'.format( var=variable, ty=type(in_dict[variable]))) - iflogger.info('...Converting {var} to CSV from {f}'.format( + IFLOGGER.info('...Converting {var} to CSV from {f}'.format( var=variable, f=self.inputs.in_file)) matlab2csv(in_dict[variable], name, self.inputs.reshape_matrix) else: - iflogger.error('No values in the MATLAB file?!') + IFLOGGER.error('No values in the MATLAB file?!') return runtime - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + super(Matlab2CSV, self)._post_run() + in_dict = sio.loadmat(op.abspath(self.inputs.in_file)) saved_variables = list() for key in list(in_dict.keys()): @@ -483,104 +404,16 @@ def _list_outputs(self): if isinstance(in_dict[key][0], np.ndarray): saved_variables.append(key) else: - iflogger.error('One of the keys in the input file, {k}, is\ + IFLOGGER.error('One of the keys in the input file, {k}, is\ not a Numpy array'.format(k=key)) if len(saved_variables) > 1: - outputs['csv_files'] = replaceext(saved_variables, '.csv') + self.outputs.csv_files = replaceext(saved_variables, '.csv') elif len(saved_variables) == 1: _, name, ext = split_filename(self.inputs.in_file) - outputs['csv_files'] = op.abspath(name + '.csv') + self.outputs.csv_files = op.abspath(name + '.csv') else: - iflogger.error('No values in the MATLAB file?!') - return outputs - - -def merge_csvs(in_list): - for idx, in_file in enumerate(in_list): - try: - in_array = np.loadtxt(in_file, delimiter=',') - except ValueError as ex: - try: - in_array = np.loadtxt(in_file, delimiter=',', skiprows=1) - except ValueError as ex: - first = open(in_file, 'r') - header_line = first.readline() - header_list = header_line.split(',') - n_cols = len(header_list) - try: - in_array = np.loadtxt( - in_file, delimiter=',', skiprows=1, - usecols=list(range(1, n_cols)) - ) - except ValueError as ex: - in_array = np.loadtxt( - in_file, delimiter=',', skiprows=1, usecols=list(range(1, n_cols - 1))) - if idx == 0: - out_array = in_array - else: - out_array = np.dstack((out_array, in_array)) - out_array = np.squeeze(out_array) - iflogger.info('Final output array shape:') - iflogger.info(np.shape(out_array)) - return out_array - - -def remove_identical_paths(in_files): - import os.path as op - from ..utils.filemanip import split_filename - if len(in_files) > 1: - out_names = list() - commonprefix = op.commonprefix(in_files) - lastslash = commonprefix.rfind('/') - commonpath = commonprefix[0:(lastslash + 1)] - for fileidx, in_file in enumerate(in_files): - path, name, ext = split_filename(in_file) - in_file = op.join(path, name) - name = in_file.replace(commonpath, '') - name = name.replace('_subject_id_', '') - out_names.append(name) - else: - path, name, ext = split_filename(in_files[0]) - out_names = [name] - return out_names - - -def maketypelist(rowheadings, shape, extraheadingBool, extraheading): - typelist = [] - if rowheadings: - typelist.append(('heading', 'a40')) - if len(shape) > 1: - for idx in range(1, (min(shape) + 1)): - typelist.append((str(idx), float)) - else: - for idx in range(1, (shape[0] + 1)): - typelist.append((str(idx), float)) - if extraheadingBool: - typelist.append((extraheading, 'a40')) - iflogger.info(typelist) - return typelist - - -def makefmtlist(output_array, typelist, rowheadingsBool, - shape, extraheadingBool): - fmtlist = [] - if rowheadingsBool: - fmtlist.append('%s') - if len(shape) > 1: - output = np.zeros(max(shape), typelist) - for idx in range(1, min(shape) + 1): - output[str(idx)] = output_array[:, idx - 1] - fmtlist.append('%f') - else: - output = np.zeros(1, typelist) - for idx in range(1, len(output_array) + 1): - output[str(idx)] = output_array[idx - 1] - fmtlist.append('%f') - if extraheadingBool: - fmtlist.append('%s') - fmt = ','.join(fmtlist) - return fmt, output + IFLOGGER.error('No values in the MATLAB file?!') class MergeCSVFilesInputSpec(TraitedSpec): @@ -627,8 +460,8 @@ class MergeCSVFiles(BaseInterface): >>> mat2csv.inputs.column_headings = ['degree','clustering'] >>> mat2csv.run() # doctest: +SKIP """ - input_spec = MergeCSVFilesInputSpec - output_spec = MergeCSVFilesOutputSpec + _input_spec = MergeCSVFilesInputSpec + _output_spec = MergeCSVFilesOutputSpec def _run_interface(self, runtime): extraheadingBool = False @@ -638,41 +471,41 @@ def _run_interface(self, runtime): This block defines the column headings. """ if isdefined(self.inputs.column_headings): - iflogger.info('Column headings have been provided:') + IFLOGGER.info('Column headings have been provided:') headings = self.inputs.column_headings else: - iflogger.info( + IFLOGGER.info( 'Column headings not provided! Pulled from input filenames:') headings = remove_identical_paths(self.inputs.in_files) if isdefined(self.inputs.extra_field): if isdefined(self.inputs.extra_column_heading): extraheading = self.inputs.extra_column_heading - iflogger.info('Extra column heading provided: {col}'.format( + IFLOGGER.info('Extra column heading provided: {col}'.format( col=extraheading)) else: extraheading = 'type' - iflogger.info( + IFLOGGER.info( 'Extra column heading was not defined. Using "type"') headings.append(extraheading) extraheadingBool = True if len(self.inputs.in_files) == 1: - iflogger.warn('Only one file input!') + IFLOGGER.warn('Only one file input!') if isdefined(self.inputs.row_headings): - iflogger.info('Row headings have been provided. Adding "labels"\ + IFLOGGER.info('Row headings have been provided. Adding "labels"\ column header.') prefix = '"{p}","'.format(p=self.inputs.row_heading_title) csv_headings = prefix + '","'.join(itertools.chain( headings)) + '"\n' rowheadingsBool = True else: - iflogger.info('Row headings have not been provided.') + IFLOGGER.info('Row headings have not been provided.') csv_headings = '"' + '","'.join(itertools.chain(headings)) + '"\n' - iflogger.info('Final Headings:') - iflogger.info(csv_headings) + IFLOGGER.info('Final Headings:') + IFLOGGER.info(csv_headings) """ Next we merge the arrays and define the output text file @@ -710,29 +543,20 @@ def _run_interface(self, runtime): mx = 1 for idx in range(0, mx): extrafieldlist.append(self.inputs.extra_field) - iflogger.info(len(extrafieldlist)) + IFLOGGER.info(len(extrafieldlist)) output[extraheading] = extrafieldlist - iflogger.info(output) - iflogger.info(fmt) + IFLOGGER.info(output) + IFLOGGER.info(fmt) np.savetxt(file_handle, output, fmt, delimiter=',') file_handle.close() return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - _, name, ext = split_filename(self.inputs.out_file) - if not ext == '.csv': - ext = '.csv' - out_file = op.abspath(name + ext) - outputs['csv_file'] = out_file - return outputs - class AddCSVColumnInputSpec(TraitedSpec): in_file = File(exists=True, mandatory=True, desc='Input comma-separated value (CSV) files') - out_file = File('extra_heading.csv', usedefault=True, - desc='Output filename for merged CSV file') + out_file = GenFile(ns='in_file', template='%s_col_added', output_name='csv_file', + desc='Output filename for merged CSV file') extra_column_heading = traits.Str( desc='New heading to add for the added field.') extra_field = traits.Str( @@ -757,41 +581,25 @@ class AddCSVColumn(BaseInterface): >>> addcol.inputs.extra_field = 'male' >>> addcol.run() # doctest: +SKIP """ - input_spec = AddCSVColumnInputSpec - output_spec = AddCSVColumnOutputSpec + _input_spec = AddCSVColumnInputSpec + _output_spec = AddCSVColumnOutputSpec def _run_interface(self, runtime): - in_file = open(self.inputs.in_file, 'r') - _, name, ext = split_filename(self.inputs.out_file) - if not ext == '.csv': - ext = '.csv' - out_file = op.abspath(name + ext) - - out_file = open(out_file, 'w') - firstline = in_file.readline() - firstline = firstline.replace('\n', '') - new_firstline = firstline + ',"' + \ - self.inputs.extra_column_heading + '"\n' - out_file.write(new_firstline) - for line in in_file: - new_line = line.replace('\n', '') - new_line = new_line + ',' + self.inputs.extra_field + '\n' - out_file.write(new_line) + with open(self.inputs.in_file, 'r') as in_file: + firstline = in_file.readline() + firstline = firstline.replace('\n', '') + new_firstline = firstline + ',"' + self.inputs.extra_column_heading + '"\n' + with open(self.inputs.out_file, 'w') as out_file: + out_file.write(new_firstline) + for line in in_file: + new_line = line.replace('\n', '') + new_line = new_line + ',' + self.inputs.extra_field + '\n' + out_file.write(new_line) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - _, name, ext = split_filename(self.inputs.out_file) - if not ext == '.csv': - ext = '.csv' - out_file = op.abspath(name + ext) - outputs['csv_file'] = out_file - return outputs - -class AddCSVRowInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): - in_file = traits.File(mandatory=True, - desc='Input comma-separated value (CSV) files') +class AddCSVRowInputSpec(DynamicTraitedSpec, BaseInputSpec): + in_file = File(mandatory=True, desc='Input comma-separated value (CSV) files') _outputs = traits.Dict(traits.Any, value={}, usedefault=True) def __setattr__(self, key, value): @@ -801,7 +609,7 @@ def __setattr__(self, key, value): self._outputs[key] = value else: if key in self._outputs: - self._outputs[key] = value + self.outputs[key] = value super(AddCSVRowInputSpec, self).__setattr__(key, value) @@ -834,8 +642,8 @@ class AddCSVRow(BaseInterface): >>> addrow.inputs.list_of_values = [ 0.4, 0.7, 0.3 ] >>> addrow.run() # doctest: +SKIP """ - input_spec = AddCSVRowInputSpec - output_spec = AddCSVRowOutputSpec + _input_spec = AddCSVRowInputSpec + _output_spec = AddCSVRowOutputSpec def __init__(self, infields=None, force_run=True, **kwargs): super(AddCSVRow, self).__init__(**kwargs) @@ -865,9 +673,8 @@ def _run_interface(self, runtime): import lockfile as pl self._have_lock = True except ImportError: - from warnings import warn - warn(('Python module lockfile was not found: AddCSVRow will not be' - ' thread-safe in multi-processor execution')) + IFLOGGER.warn('Python module lockfile was not found: AddCSVRow will not be' + ' thread-safe in multi-processor execution') input_dict = {} for key, val in list(self.inputs._outputs.items()): @@ -906,13 +713,9 @@ def _run_interface(self, runtime): # df = pd.concat([formerdf, df], ignore_index=True) # df.to_csv(fh) + self.outputs.csv_file = op.abspath(self.inputs.in_file) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['csv_file'] = self.inputs.in_file - return outputs - def _outputs(self): return self._add_output_traits(super(AddCSVRow, self)._outputs()) @@ -922,13 +725,10 @@ def _add_output_traits(self, base): class CalculateNormalizedMomentsInputSpec(TraitedSpec): timeseries_file = File( - exists=True, mandatory=True, - desc='Text file with timeseries in columns and timepoints in rows,\ - whitespace separated') - moment = traits.Int( - mandatory=True, - desc="Define which moment should be calculated, 3 for skewness, 4 for\ - kurtosis.") + exists=True, mandatory=True, desc='Text file with timeseries in columns and timepoints' + ' in rows, whitespace separated') + moment = traits.Int(mandatory=True, desc='Define which moment should be calculated, 3 for ' + 'skewness, 4 for kurtosis.') class CalculateNormalizedMomentsOutputSpec(TraitedSpec): @@ -947,49 +747,28 @@ class CalculateNormalizedMoments(BaseInterface): >>> skew.inputs.timeseries_file = 'timeseries.txt' >>> skew.run() # doctest: +SKIP """ - input_spec = CalculateNormalizedMomentsInputSpec - output_spec = CalculateNormalizedMomentsOutputSpec + _input_spec = CalculateNormalizedMomentsInputSpec + _output_spec = CalculateNormalizedMomentsOutputSpec def _run_interface(self, runtime): - - self._moments = calc_moments( + self.outputs.skewness = calc_moments( self.inputs.timeseries_file, self.inputs.moment) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['skewness'] = self._moments - return outputs - - -def calc_moments(timeseries_file, moment): - """Returns nth moment (3 for skewness, 4 for kurtosis) of timeseries - (list of values; one per timeseries). - - Keyword arguments: - timeseries_file -- text file with white space separated timepoints in rows - - """ - timeseries = np.genfromtxt(timeseries_file) - - m2 = stats.moment(timeseries, 2, axis=0) - m3 = stats.moment(timeseries, moment, axis=0) - zero = (m2 == 0) - return np.where(zero, 0, m3 / m2 ** (moment / 2.0)) - class AddNoiseInputSpec(TraitedSpec): in_file = File(exists=True, mandatory=True, desc='input image that will be corrupted with noise') - in_mask = File(exists=True, desc=('input mask, voxels outside this mask ' - 'will be considered background')) + in_mask = File(exists=True, desc='input mask, voxels outside this mask ' + 'will be considered background') snr = traits.Float(10.0, desc='desired output SNR in dB', usedefault=True) dist = traits.Enum('normal', 'rician', usedefault=True, mandatory=True, - desc=('desired noise distribution')) + desc='desired noise distribution') bg_dist = traits.Enum('normal', 'rayleigh', usedefault=True, mandatory=True, - desc=('desired noise distribution, currently ' - 'only normal is implemented')) - out_file = File(desc='desired output filename') + desc='desired noise distribution, currently ' + 'only normal is implemented') + out_file = GenFile(ns=['in_file', 'snr'], template='%s_SNR%.02f', + keep_extension=True, desc='desired output filename') class AddNoiseOutputSpec(TraitedSpec): @@ -1011,8 +790,8 @@ class AddNoise(BaseInterface): >>> noise.run() # doctest: +SKIP """ - input_spec = AddNoiseInputSpec - output_spec = AddNoiseOutputSpec + _input_spec = AddNoiseInputSpec + _output_spec = AddNoiseOutputSpec def _run_interface(self, runtime): in_image = nb.load(self.inputs.in_file) @@ -1027,23 +806,9 @@ def _run_interface(self, runtime): result = self.gen_noise(in_data, mask=in_mask, snr_db=snr, dist=self.inputs.dist, bg_dist=self.inputs.bg_dist) res_im = nb.Nifti1Image(result, in_image.affine, in_image.header) - res_im.to_filename(self._gen_output_filename()) + res_im.to_filename(self.inputs.out_file) return runtime - def _gen_output_filename(self): - if not isdefined(self.inputs.out_file): - _, base, ext = split_filename(self.inputs.in_file) - out_file = os.path.abspath('%s_SNR%03.2f%s' % (base, self.inputs.snr, ext)) - else: - out_file = self.inputs.out_file - - return out_file - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self._gen_output_filename() - return outputs - def gen_noise(self, image, mask=None, snr_db=10.0, dist='normal', bg_dist='normal'): """ Generates a copy of an image with a certain amount of @@ -1091,13 +856,13 @@ def gen_noise(self, image, mask=None, snr_db=10.0, dist='normal', bg_dist='norma class NormalizeProbabilityMapSetInputSpec(TraitedSpec): in_files = InputMultiPath(File(exists=True, mandatory=True, desc='The tpms to be normalized')) - in_mask = File(exists=True, - desc='Masked voxels must sum up 1.0, 0.0 otherwise.') + out_files = GenMultiFile(template='{in_files}_norm', keep_extension=True, + desc="normalized maps") + in_mask = File(exists=True, desc='Masked voxels must sum up 1.0, 0.0 otherwise.') class NormalizeProbabilityMapSetOutputSpec(TraitedSpec): - out_files = OutputMultiPath(File(exists=True), - desc="normalized maps") + out_files = OutputMultiPath(File(exists=True), desc="normalized maps") class NormalizeProbabilityMapSet(BaseInterface): @@ -1117,8 +882,8 @@ class NormalizeProbabilityMapSet(BaseInterface): >>> normalize.inputs.in_mask = 'tpms_msk.nii.gz' >>> normalize.run() # doctest: +SKIP """ - input_spec = NormalizeProbabilityMapSetInputSpec - output_spec = NormalizeProbabilityMapSetOutputSpec + _input_spec = NormalizeProbabilityMapSetInputSpec + _output_spec = NormalizeProbabilityMapSetOutputSpec def _run_interface(self, runtime): mask = None @@ -1126,15 +891,9 @@ def _run_interface(self, runtime): if isdefined(self.inputs.in_mask): mask = self.inputs.in_mask - self._out_filenames = normalize_tpms(self.inputs.in_files, mask) + normalize_tpms(self.inputs.in_files, mask, self.inputs.out_files) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_files'] = self._out_filenames - return outputs - - class SplitROIsInputSpec(TraitedSpec): in_file = File(exists=True, mandatory=True, desc='file to be splitted') @@ -1163,31 +922,24 @@ class SplitROIs(BaseInterface): >>> rois.run() # doctest: +SKIP """ - input_spec = SplitROIsInputSpec - output_spec = SplitROIsOutputSpec + _input_spec = SplitROIsInputSpec + _output_spec = SplitROIsOutputSpec def _run_interface(self, runtime): mask = None roisize = None - self._outnames = {} if isdefined(self.inputs.in_mask): mask = self.inputs.in_mask if isdefined(self.inputs.roi_size): roisize = self.inputs.roi_size - res = split_rois(self.inputs.in_file, - mask, roisize) - self._outnames['out_files'] = res[0] - self._outnames['out_masks'] = res[1] - self._outnames['out_index'] = res[2] - return runtime + res = split_rois(self.inputs.in_file, mask, roisize) + self.outputs.out_files = res[0] + self.outputs.out_masks = res[1] + self.outputs.out_index = res[2] - def _list_outputs(self): - outputs = self.output_spec().get() - for k, v in self._outnames.items(): - outputs[k] = v - return outputs + return runtime class MergeROIsInputSpec(TraitedSpec): @@ -1218,21 +970,138 @@ class MergeROIs(BaseInterface): >>> rois.run() # doctest: +SKIP """ - input_spec = MergeROIsInputSpec - output_spec = MergeROIsOutputSpec + _input_spec = MergeROIsInputSpec + _output_spec = MergeROIsOutputSpec def _run_interface(self, runtime): - res = merge_rois(self.inputs.in_files, - self.inputs.in_index, - self.inputs.in_reference) - self._merged = res + self.outputs.merged_file = merge_rois( + self.inputs.in_files, self.inputs.in_index, self.inputs.in_reference) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['merged_file'] = self._merged - return outputs +# Helper functions ------------------------------------------------------ + +def replaceext(in_list, ext): + out_list = list() + for filename in in_list: + path, name, _ = split_filename(op.abspath(filename)) + out_name = op.join(path, name) + ext + out_list.append(out_name) + return out_list + + +def matlab2csv(in_array, name, reshape): + output_array = np.asarray(in_array) + if reshape: + if len(np.shape(output_array)) > 1: + output_array = np.reshape(output_array, ( + np.shape(output_array)[0] * np.shape(output_array)[1], 1)) + IFLOGGER.info(np.shape(output_array)) + output_name = op.abspath(name + '.csv') + np.savetxt(output_name, output_array, delimiter=',') + return output_name + +def merge_csvs(in_list): + for idx, in_file in enumerate(in_list): + try: + in_array = np.loadtxt(in_file, delimiter=',') + except ValueError as ex: + try: + in_array = np.loadtxt(in_file, delimiter=',', skiprows=1) + except ValueError as ex: + first = open(in_file, 'r') + header_line = first.readline() + header_list = header_line.split(',') + n_cols = len(header_list) + try: + in_array = np.loadtxt( + in_file, delimiter=',', skiprows=1, + usecols=list(range(1, n_cols)) + ) + except ValueError as ex: + in_array = np.loadtxt( + in_file, delimiter=',', skiprows=1, usecols=list(range(1, n_cols - 1))) + if idx == 0: + out_array = in_array + else: + out_array = np.dstack((out_array, in_array)) + out_array = np.squeeze(out_array) + IFLOGGER.info('Final output array shape:') + IFLOGGER.info(np.shape(out_array)) + return out_array + + +def remove_identical_paths(in_files): + import os.path as op + from ..utils.filemanip import split_filename + if len(in_files) > 1: + out_names = list() + commonprefix = op.commonprefix(in_files) + lastslash = commonprefix.rfind('/') + commonpath = commonprefix[0:(lastslash + 1)] + for fileidx, in_file in enumerate(in_files): + path, name, ext = split_filename(in_file) + in_file = op.join(path, name) + name = in_file.replace(commonpath, '') + name = name.replace('_subject_id_', '') + out_names.append(name) + else: + path, name, ext = split_filename(in_files[0]) + out_names = [name] + return out_names + + +def maketypelist(rowheadings, shape, extraheadingBool, extraheading): + typelist = [] + if rowheadings: + typelist.append(('heading', 'a40')) + if len(shape) > 1: + for idx in range(1, (min(shape) + 1)): + typelist.append((str(idx), float)) + else: + for idx in range(1, (shape[0] + 1)): + typelist.append((str(idx), float)) + if extraheadingBool: + typelist.append((extraheading, 'a40')) + IFLOGGER.info(typelist) + return typelist + + +def makefmtlist(output_array, typelist, rowheadingsBool, + shape, extraheadingBool): + fmtlist = [] + if rowheadingsBool: + fmtlist.append('%s') + if len(shape) > 1: + output = np.zeros(max(shape), typelist) + for idx in range(1, min(shape) + 1): + output[str(idx)] = output_array[:, idx - 1] + fmtlist.append('%f') + else: + output = np.zeros(1, typelist) + for idx in range(1, len(output_array) + 1): + output[str(idx)] = output_array[idx - 1] + fmtlist.append('%f') + if extraheadingBool: + fmtlist.append('%s') + fmt = ','.join(fmtlist) + return fmt, output + + +def calc_moments(timeseries_file, moment): + """Returns nth moment (3 for skewness, 4 for kurtosis) of timeseries + (list of values; one per timeseries). + + Keyword arguments: + timeseries_file -- text file with white space separated timepoints in rows + + """ + timeseries = np.genfromtxt(timeseries_file) + + m2 = stats.moment(timeseries, 2, axis=0) + m3 = stats.moment(timeseries, moment, axis=0) + zero = (m2 == 0) + return np.where(zero, 0, m3 / m2 ** (moment / 2.0)) def normalize_tpms(in_files, in_mask=None, out_files=[]): """ @@ -1369,8 +1238,7 @@ def split_rois(in_file, mask=None, roishape=None): return out_files, out_mask, out_idxs -def merge_rois(in_files, in_idxs, in_ref, - dtype=None, out_file=None): +def merge_rois(in_files, in_idxs, in_ref, dtype=None, out_file=None): """ Re-builds an image resulting from a parallelized processing """ @@ -1389,7 +1257,7 @@ def merge_rois(in_files, in_idxs, in_ref, # to avoid memory errors if op.splitext(in_ref)[1] == '.gz': try: - iflogger.info('uncompress %i' % in_ref) + IFLOGGER.info('uncompress %i' % in_ref) sp.check_call(['gunzip', in_ref], stdout=sp.PIPE, shell=True) in_ref = op.splitext(in_ref)[0] except: @@ -1468,10 +1336,9 @@ class Distance(nam.Distance): Use :py:class:`nipype.algorithms.metrics.Distance` instead. """ def __init__(self, **inputs): - super(nam.Distance, self).__init__(**inputs) - warnings.warn(("This interface has been deprecated since 0.10.0," - " please use nipype.algorithms.metrics.Distance"), - DeprecationWarning) + super(Distance, self).__init__(**inputs) + IFLOGGER.warn("This interface has been deprecated since 0.10.0," + " please use nipype.algorithms.metrics.Distance") class Overlap(nam.Overlap): @@ -1481,10 +1348,9 @@ class Overlap(nam.Overlap): Use :py:class:`nipype.algorithms.metrics.Overlap` instead. """ def __init__(self, **inputs): - super(nam.Overlap, self).__init__(**inputs) - warnings.warn(("This interface has been deprecated since 0.10.0," - " please use nipype.algorithms.metrics.Overlap"), - DeprecationWarning) + super(Overlap, self).__init__(**inputs) + IFLOGGER.warn("This interface has been deprecated since 0.10.0," + " please use nipype.algorithms.metrics.Overlap") class FuzzyOverlap(nam.FuzzyOverlap): @@ -1495,7 +1361,6 @@ class FuzzyOverlap(nam.FuzzyOverlap): Use :py:class:`nipype.algorithms.metrics.FuzzyOverlap` instead. """ def __init__(self, **inputs): - super(nam.FuzzyOverlap, self).__init__(**inputs) - warnings.warn(("This interface has been deprecated since 0.10.0," - " please use nipype.algorithms.metrics.FuzzyOverlap"), - DeprecationWarning) + super(FuzzyOverlap, self).__init__(**inputs) + IFLOGGER.warn("This interface has been deprecated since 0.10.0," + " please use nipype.algorithms.metrics.FuzzyOverlap") diff --git a/nipype/algorithms/modelgen.py b/nipype/algorithms/modelgen.py index 93aaeb042c..96101df591 100644 --- a/nipype/algorithms/modelgen.py +++ b/nipype/algorithms/modelgen.py @@ -29,9 +29,10 @@ from scipy.special import gammaln from ..external.six import string_types -from ..interfaces.base import (BaseInterface, TraitedSpec, InputMultiPath, - traits, File, Bunch, BaseInterfaceInputSpec, - isdefined) + +from ..interfaces.base import (traits, File, isdefined, Undefined, BaseInputSpec, + TraitedSpec, InputMultiPath, BaseInterface, Bunch) + from ..utils.filemanip import filename_to_list from .. import config, logging iflogger = logging.getLogger('interface') @@ -175,7 +176,7 @@ def gen_info(run_event_files): return info -class SpecifyModelInputSpec(BaseInterfaceInputSpec): +class SpecifyModelInputSpec(BaseInputSpec): subject_info = InputMultiPath(Bunch, mandatory=True, xor=['subject_info', 'event_files'], desc=("Bunch or List(Bunch) subject specific condition information. " @@ -280,8 +281,8 @@ class SpecifyModel(BaseInterface): >>> s.inputs.subject_info = info """ - input_spec = SpecifyModelInputSpec - output_spec = SpecifyModelOutputSpec + _input_spec = SpecifyModelInputSpec + _output_spec = SpecifyModelOutputSpec def _generate_standard_design(self, infolist, functional_runs=None, @@ -406,15 +407,10 @@ def _run_interface(self, runtime): """ self._sessioninfo = None self._generate_design() - return runtime - - def _list_outputs(self): - outputs = self._outputs().get() if not hasattr(self, '_sessinfo'): self._generate_design() - outputs['session_info'] = self._sessinfo - - return outputs + self.outputs.session_info = self._sessinfo + return runtime class SpecifySPMModelInputSpec(SpecifyModelInputSpec): @@ -450,7 +446,7 @@ class SpecifySPMModel(SpecifyModel): """ - input_spec = SpecifySPMModelInputSpec + _input_spec = SpecifySPMModelInputSpec def _concatenate_info(self, infolist): nscans = [] @@ -571,11 +567,12 @@ class SpecifySparseModelInputSpec(SpecifyModelInputSpec): desc="Create a temporal derivative in addition to regular regressor") scale_regressors = traits.Bool(True, desc="Scale regressors by the peak", usedefault=True) - scan_onset = traits.Float(0.0, - desc="Start of scanning relative to onset of run in secs", + scan_onset = traits.Float(0.0, desc="Start of scanning relative to onset of run in secs", usedefault=True) - save_plot = traits.Bool(desc=('save plot of sparse design calculation ' - '(Requires matplotlib)')) + save_plot = traits.Bool(False, usedefault=True, desc='save plot of sparse design ' + 'calculation (Requires matplotlib)') + sparse_png_file = File('sparse.png', desc='PNG file showing sparse design') + sparse_svg_file = File('sparse.svg', desc='SVG file showing sparse design') class SpecifySparseModelOutputSpec(SpecifyModelOutputSpec): @@ -611,8 +608,8 @@ class SpecifySparseModel(SpecifyModel): >>> s.inputs.subject_info = info """ - input_spec = SpecifySparseModelInputSpec - output_spec = SpecifySparseModelOutputSpec + _input_spec = SpecifySparseModelInputSpec + _output_spec = SpecifySparseModelOutputSpec def _gen_regress(self, i_onsets, i_durations, i_amplitudes, nscans): """Generates a regressor for a sparse/clustered-sparse acquisition @@ -802,12 +799,9 @@ def _generate_design(self, infolist=None): sparselist = self._generate_clustered_design(infolist) super(SpecifySparseModel, self)._generate_design(infolist=sparselist) - def _list_outputs(self): - outputs = self._outputs().get() - if not hasattr(self, '_sessinfo'): - self._generate_design() - outputs['session_info'] = self._sessinfo - if isdefined(self.inputs.save_plot) and self.inputs.save_plot: - outputs['sparse_png_file'] = os.path.join(os.getcwd(), 'sparse.png') - outputs['sparse_svg_file'] = os.path.join(os.getcwd(), 'sparse.svg') - return outputs + def _post_run(self): + super(SpecifySparseModel,self)._post_run() + # Unset non-used variables + if not self.inputs.save_plot: + self.outputs.sparse_png_file = Undefined + self.outputs.sparse_svg_file = Undefined diff --git a/nipype/algorithms/rapidart.py b/nipype/algorithms/rapidart.py index 06ad009d50..3a08f61c50 100644 --- a/nipype/algorithms/rapidart.py +++ b/nipype/algorithms/rapidart.py @@ -30,130 +30,17 @@ import scipy.io as sio from ..external.six import string_types -from ..interfaces.base import (BaseInterface, traits, InputMultiPath, - OutputMultiPath, TraitedSpec, File, - BaseInterfaceInputSpec, isdefined) + from ..utils.filemanip import filename_to_list, save_json, split_filename from ..utils.misc import find_indices +from ..interfaces.base import (traits, File, GenMultiFile, isdefined, BaseInputSpec, + TraitedSpec, InputMultiPath, OutputMultiPath, BaseInterface) + from .. import logging, config iflogger = logging.getLogger('interface') -def _get_affine_matrix(params, source): - """Return affine matrix given a set of translation and rotation parameters - - params : np.array (upto 12 long) in native package format - source : the package that generated the parameters - supports SPM, AFNI, FSFAST, FSL, NIPY - """ - if source == 'FSL': - params = params[[3, 4, 5, 0, 1, 2]] - elif source in ('AFNI', 'FSFAST'): - params = params[np.asarray([4, 5, 3, 1, 2, 0]) + (len(params) > 6)] - params[3:] = params[3:] * np.pi / 180. - if source == 'NIPY': - # nipy does not store typical euler angles, use nipy to convert - from nipy.algorithms.registration import to_matrix44 - return to_matrix44(params) - # process for FSL, SPM, AFNI and FSFAST - rotfunc = lambda x: np.array([[np.cos(x), np.sin(x)], - [-np.sin(x), np.cos(x)]]) - q = np.array([0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0]) - if len(params) < 12: - params = np.hstack((params, q[len(params):])) - params.shape = (len(params),) - # Translation - T = np.eye(4) - T[0:3, -1] = params[0:3] - # Rotation - Rx = np.eye(4) - Rx[1:3, 1:3] = rotfunc(params[3]) - Ry = np.eye(4) - Ry[(0, 0, 2, 2), (0, 2, 0, 2)] = rotfunc(params[4]).ravel() - Rz = np.eye(4) - Rz[0:2, 0:2] = rotfunc(params[5]) - # Scaling - S = np.eye(4) - S[0:3, 0:3] = np.diag(params[6:9]) - # Shear - Sh = np.eye(4) - Sh[(0, 0, 1), (1, 2, 2)] = params[9:12] - if source in ('AFNI', 'FSFAST'): - return np.dot(T, np.dot(Ry, np.dot(Rx, np.dot(Rz, np.dot(S, Sh))))) - return np.dot(T, np.dot(Rx, np.dot(Ry, np.dot(Rz, np.dot(S, Sh))))) - - -def _calc_norm(mc, use_differences, source, brain_pts=None): - """Calculates the maximum overall displacement of the midpoints - of the faces of a cube due to translation and rotation. - - Parameters - ---------- - mc : motion parameter estimates - [3 translation, 3 rotation (radians)] - use_differences : boolean - brain_pts : [4 x n_points] of coordinates - - Returns - ------- - - norm : at each time point - displacement : euclidean distance (mm) of displacement at each coordinate - - """ - - if brain_pts is None: - respos = np.diag([70, 70, 75]) - resneg = np.diag([-70, -110, -45]) - all_pts = np.vstack((np.hstack((respos, resneg)), np.ones((1, 6)))) - displacement = None - else: - all_pts = brain_pts - n_pts = all_pts.size - all_pts.shape[1] - newpos = np.zeros((mc.shape[0], n_pts)) - if brain_pts is not None: - displacement = np.zeros((mc.shape[0], int(n_pts / 3))) - for i in range(mc.shape[0]): - affine = _get_affine_matrix(mc[i, :], source) - newpos[i, :] = np.dot(affine, - all_pts)[0:3, :].ravel() - if brain_pts is not None: - displacement[i, :] = \ - np.sqrt(np.sum(np.power(np.reshape(newpos[i, :], - (3, all_pts.shape[1])) - - all_pts[0:3, :], - 2), - axis=0)) - # np.savez('displacement.npz', newpos=newpos, pts=all_pts) - normdata = np.zeros(mc.shape[0]) - if use_differences: - newpos = np.concatenate((np.zeros((1, n_pts)), - np.diff(newpos, n=1, axis=0)), axis=0) - for i in range(newpos.shape[0]): - normdata[i] = \ - np.max(np.sqrt(np.sum(np.reshape(np.power(np.abs(newpos[i, :]), 2), - (3, all_pts.shape[1])), axis=0))) - else: - newpos = np.abs(signal.detrend(newpos, axis=0, type='constant')) - normdata = np.sqrt(np.mean(np.power(newpos, 2), axis=1)) - return normdata, displacement - - -def _nanmean(a, axis=None): - """Return the mean excluding items that are nan - - >>> a = [1, 2, np.nan] - >>> _nanmean(a) - 1.5 - - """ - if axis: - return np.nansum(a, axis) / np.sum(1 - np.isnan(a), axis) - else: - return np.nansum(a) / np.sum(1 - np.isnan(a)) - - -class ArtifactDetectInputSpec(BaseInterfaceInputSpec): +class ArtifactDetectInputSpec(BaseInputSpec): realigned_files = InputMultiPath(File(exists=True), desc="Names of realigned functional data files", mandatory=True) @@ -264,8 +151,8 @@ class ArtifactDetect(BaseInterface): >>> ad.run() # doctest: +SKIP """ - input_spec = ArtifactDetectInputSpec - output_spec = ArtifactDetectOutputSpec + _input_spec = ArtifactDetectInputSpec + _output_spec = ArtifactDetectOutputSpec def __init__(self, **inputs): super(ArtifactDetect, self).__init__(**inputs) @@ -304,34 +191,6 @@ def _get_output_filenames(self, motionfile, output_dir): return (artifactfile, intensityfile, statsfile, normfile, plotfile, displacementfile, maskfile) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['outlier_files'] = [] - outputs['intensity_files'] = [] - outputs['statistic_files'] = [] - outputs['mask_files'] = [] - if isdefined(self.inputs.use_norm) and self.inputs.use_norm: - outputs['norm_files'] = [] - if self.inputs.bound_by_brainmask: - outputs['displacement_files'] = [] - if isdefined(self.inputs.save_plot) and self.inputs.save_plot: - outputs['plot_files'] = [] - for i, f in enumerate(filename_to_list(self.inputs.realigned_files)): - (outlierfile, intensityfile, statsfile, normfile, plotfile, - displacementfile, maskfile) = \ - self._get_output_filenames(f, os.getcwd()) - outputs['outlier_files'].insert(i, outlierfile) - outputs['intensity_files'].insert(i, intensityfile) - outputs['statistic_files'].insert(i, statsfile) - outputs['mask_files'].insert(i, maskfile) - if isdefined(self.inputs.use_norm) and self.inputs.use_norm: - outputs['norm_files'].insert(i, normfile) - if self.inputs.bound_by_brainmask: - outputs['displacement_files'].insert(i, displacementfile) - if isdefined(self.inputs.save_plot) and self.inputs.save_plot: - outputs['plot_files'].insert(i, plotfile) - return outputs - def _plot_outliers_with_wave(self, wave, outliers, name): import matplotlib.pyplot as plt plt.plot(wave) @@ -539,24 +398,50 @@ def _run_interface(self, runtime): for i, imgf in enumerate(funcfilelist): self._detect_outliers_core(imgf, motparamlist[i], i, cwd=os.getcwd()) + + self.outputs.outlier_files = [] + self.outputs.intensity_files = [] + self.outputs.statistic_files = [] + self.outputs.mask_files = [] + if isdefined(self.inputs.use_norm) and self.inputs.use_norm: + self.outputs.norm_files = [] + if self.inputs.bound_by_brainmask: + self.outputs.displacement_files = [] + if isdefined(self.inputs.save_plot) and self.inputs.save_plot: + self.outputs.plot_files = [] + for i, f in enumerate(filename_to_list(self.inputs.realigned_files)): + (outlierfile, intensityfile, statsfile, normfile, plotfile, + displacementfile, maskfile) = \ + self._get_output_filenames(f, os.getcwd()) + self.outputs.outlier_files.insert(i, outlierfile) + self.outputs.intensity_files.insert(i, intensityfile) + self.outputs.statistic_files.insert(i, statsfile) + self.outputs.mask_files.insert(i, maskfile) + if isdefined(self.inputs.use_norm) and self.inputs.use_norm: + self.outputs.norm_files.insert(i, normfile) + if self.inputs.bound_by_brainmask: + self.outputs.displacement_files.insert(i, displacementfile) + if isdefined(self.inputs.save_plot) and self.inputs.save_plot: + self.outputs.plot_files.insert(i, plotfile) return runtime -class StimCorrInputSpec(BaseInterfaceInputSpec): - realignment_parameters = InputMultiPath(File(exists=True), mandatory=True, - desc=('Names of realignment parameters corresponding to the functional ' - 'data files')) +class StimCorrInputSpec(BaseInputSpec): + realignment_parameters = InputMultiPath( + File(exists=True), mandatory=True, + desc='Names of realignment parameters corresponding to the functional data files') intensity_values = InputMultiPath(File(exists=True), mandatory=True, desc='Name of file containing intensity values') spm_mat_file = File(exists=True, mandatory=True, desc='SPM mat file (use pre-estimate SPM.mat file)') - concatenated_design = traits.Bool(mandatory=True, - desc='state if the design matrix contains concatenated sessions') - + concatenated_design = traits.Bool( + mandatory=True, desc='state if the design matrix contains concatenated sessions') + stimcorr_files = GenMultiFile(template='qa.{realignment_parameters}_stimcorr.txt', + keep_extension=False, desc='List of files containing correlation values') class StimCorrOutputSpec(TraitedSpec): - stimcorr_files = OutputMultiPath(File(exists=True), - desc='List of files containing correlation values') + stimcorr_files = OutputMultiPath( + File(exists=True), desc='List of files containing correlation values') class StimulusCorrelation(BaseInterface): @@ -581,32 +466,14 @@ class StimulusCorrelation(BaseInterface): """ - input_spec = StimCorrInputSpec - output_spec = StimCorrOutputSpec - - def _get_output_filenames(self, motionfile, output_dir): - """Generate output files based on motion filenames - - Parameters - ---------- - motionfile: file/string - Filename for motion parameter file - output_dir: string - output directory in which the files will be generated - """ - (_, filename) = os.path.split(motionfile) - (filename, _) = os.path.splitext(filename) - corrfile = os.path.join(output_dir, ''.join(('qa.', filename, - '_stimcorr.txt'))) - return corrfile + _input_spec = StimCorrInputSpec + _output_spec = StimCorrOutputSpec - def _stimcorr_core(self, motionfile, intensityfile, designmatrix, cwd=None): + def _stimcorr_core(self, motionfile, intensityfile, corrfile, designmatrix): """ Core routine for determining stimulus correlation """ - if not cwd: - cwd = os.getcwd() # read in motion parameters mc_in = np.loadtxt(motionfile) g_in = np.loadtxt(intensityfile) @@ -615,7 +482,6 @@ def _stimcorr_core(self, motionfile, intensityfile, designmatrix, cwd=None): mccol = mc_in.shape[1] concat_matrix = np.hstack((np.hstack((designmatrix, mc_in)), g_in)) cm = np.corrcoef(concat_matrix, rowvar=0) - corrfile = self._get_output_filenames(motionfile, cwd) # write output to outputfile file = open(corrfile, 'w') file.write("Stats for:\n") @@ -665,14 +531,122 @@ def _run_interface(self, runtime): nrows.append(mc_in.shape[0]) matrix = self._get_spm_submatrix(spmmat, sessidx, rows) self._stimcorr_core(motparamlist[i], intensityfiles[i], + self.inputs.stimcorr_files[i], matrix, os.getcwd()) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - files = [] - for i, f in enumerate(self.inputs.realignment_parameters): - files.insert(i, self._get_output_filenames(f, os.getcwd())) - if files: - outputs['stimcorr_files'] = files - return outputs + +# Helper functions ----------------------------------------------------------------- + +def _get_affine_matrix(params, source): + """Return affine matrix given a set of translation and rotation parameters + + params : np.array (upto 12 long) in native package format + source : the package that generated the parameters + supports SPM, AFNI, FSFAST, FSL, NIPY + """ + if source == 'FSL': + params = params[[3, 4, 5, 0, 1, 2]] + elif source in ('AFNI', 'FSFAST'): + params = params[np.asarray([4, 5, 3, 1, 2, 0]) + (len(params) > 6)] + params[3:] = params[3:] * np.pi / 180. + if source == 'NIPY': + # nipy does not store typical euler angles, use nipy to convert + from nipy.algorithms.registration import to_matrix44 + return to_matrix44(params) + # process for FSL, SPM, AFNI and FSFAST + rotfunc = lambda x: np.array([[np.cos(x), np.sin(x)], + [-np.sin(x), np.cos(x)]]) + q = np.array([0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0]) + if len(params) < 12: + params = np.hstack((params, q[len(params):])) + params.shape = (len(params),) + # Translation + T = np.eye(4) + T[0:3, -1] = params[0:3] + # Rotation + Rx = np.eye(4) + Rx[1:3, 1:3] = rotfunc(params[3]) + Ry = np.eye(4) + Ry[(0, 0, 2, 2), (0, 2, 0, 2)] = rotfunc(params[4]).ravel() + Rz = np.eye(4) + Rz[0:2, 0:2] = rotfunc(params[5]) + # Scaling + S = np.eye(4) + S[0:3, 0:3] = np.diag(params[6:9]) + # Shear + Sh = np.eye(4) + Sh[(0, 0, 1), (1, 2, 2)] = params[9:12] + if source in ('AFNI', 'FSFAST'): + return np.dot(T, np.dot(Ry, np.dot(Rx, np.dot(Rz, np.dot(S, Sh))))) + return np.dot(T, np.dot(Rx, np.dot(Ry, np.dot(Rz, np.dot(S, Sh))))) + + +def _calc_norm(mc, use_differences, source, brain_pts=None): + """Calculates the maximum overall displacement of the midpoints + of the faces of a cube due to translation and rotation. + + Parameters + ---------- + mc : motion parameter estimates + [3 translation, 3 rotation (radians)] + use_differences : boolean + brain_pts : [4 x n_points] of coordinates + + Returns + ------- + + norm : at each time point + displacement : euclidean distance (mm) of displacement at each coordinate + + """ + + if brain_pts is None: + respos = np.diag([70, 70, 75]) + resneg = np.diag([-70, -110, -45]) + all_pts = np.vstack((np.hstack((respos, resneg)), np.ones((1, 6)))) + displacement = None + else: + all_pts = brain_pts + n_pts = all_pts.size - all_pts.shape[1] + newpos = np.zeros((mc.shape[0], n_pts)) + if brain_pts is not None: + displacement = np.zeros((mc.shape[0], int(n_pts / 3))) + for i in range(mc.shape[0]): + affine = _get_affine_matrix(mc[i, :], source) + newpos[i, :] = np.dot(affine, + all_pts)[0:3, :].ravel() + if brain_pts is not None: + displacement[i, :] = \ + np.sqrt(np.sum(np.power(np.reshape(newpos[i, :], + (3, all_pts.shape[1])) - + all_pts[0:3, :], + 2), + axis=0)) + # np.savez('displacement.npz', newpos=newpos, pts=all_pts) + normdata = np.zeros(mc.shape[0]) + if use_differences: + newpos = np.concatenate((np.zeros((1, n_pts)), + np.diff(newpos, n=1, axis=0)), axis=0) + for i in range(newpos.shape[0]): + normdata[i] = \ + np.max(np.sqrt(np.sum(np.reshape(np.power(np.abs(newpos[i, :]), 2), + (3, all_pts.shape[1])), axis=0))) + else: + newpos = np.abs(signal.detrend(newpos, axis=0, type='constant')) + normdata = np.sqrt(np.mean(np.power(newpos, 2), axis=1)) + return normdata, displacement + + +def _nanmean(a, axis=None): + """Return the mean excluding items that are nan + + >>> a = [1, 2, np.nan] + >>> _nanmean(a) + 1.5 + + """ + if axis: + return np.nansum(a, axis) / np.sum(1 - np.isnan(a), axis) + else: + return np.nansum(a) / np.sum(1 - np.isnan(a)) diff --git a/nipype/algorithms/tests/test_auto_AddCSVColumn.py b/nipype/algorithms/tests/test_auto_AddCSVColumn.py index 89a52b8abe..0a00920bb5 100644 --- a/nipype/algorithms/tests/test_auto_AddCSVColumn.py +++ b/nipype/algorithms/tests/test_auto_AddCSVColumn.py @@ -8,10 +8,11 @@ def test_AddCSVColumn_inputs(): extra_field=dict(), in_file=dict(mandatory=True, ), - out_file=dict(usedefault=True, + out_file=dict(ns='in_file', + output_name='csv_file', ), ) - inputs = AddCSVColumn.input_spec() + inputs = AddCSVColumn._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -21,7 +22,7 @@ def test_AddCSVColumn_inputs(): def test_AddCSVColumn_outputs(): output_map = dict(csv_file=dict(), ) - outputs = AddCSVColumn.output_spec() + outputs = AddCSVColumn._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_AddCSVRow.py b/nipype/algorithms/tests/test_auto_AddCSVRow.py index eaac3370c9..22bc79a238 100644 --- a/nipype/algorithms/tests/test_auto_AddCSVRow.py +++ b/nipype/algorithms/tests/test_auto_AddCSVRow.py @@ -6,13 +6,10 @@ def test_AddCSVRow_inputs(): input_map = dict(_outputs=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(mandatory=True, ), ) - inputs = AddCSVRow.input_spec() + inputs = AddCSVRow._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -22,7 +19,7 @@ def test_AddCSVRow_inputs(): def test_AddCSVRow_outputs(): output_map = dict(csv_file=dict(), ) - outputs = AddCSVRow.output_spec() + outputs = AddCSVRow._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_AddNoise.py b/nipype/algorithms/tests/test_auto_AddNoise.py index 50aa563ce0..7b50767d6f 100644 --- a/nipype/algorithms/tests/test_auto_AddNoise.py +++ b/nipype/algorithms/tests/test_auto_AddNoise.py @@ -13,11 +13,13 @@ def test_AddNoise_inputs(): in_file=dict(mandatory=True, ), in_mask=dict(), - out_file=dict(), + out_file=dict(keep_extension=True, + ns=['in_file', 'snr'], + ), snr=dict(usedefault=True, ), ) - inputs = AddNoise.input_spec() + inputs = AddNoise._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -27,7 +29,7 @@ def test_AddNoise_inputs(): def test_AddNoise_outputs(): output_map = dict(out_file=dict(), ) - outputs = AddNoise.output_spec() + outputs = AddNoise._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_ArtifactDetect.py b/nipype/algorithms/tests/test_auto_ArtifactDetect.py index 961b7dd2d0..59b369ce82 100644 --- a/nipype/algorithms/tests/test_auto_ArtifactDetect.py +++ b/nipype/algorithms/tests/test_auto_ArtifactDetect.py @@ -8,9 +8,6 @@ def test_ArtifactDetect_inputs(): ), global_threshold=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), intersect_mask=dict(), mask_file=dict(), mask_threshold=dict(), @@ -45,7 +42,7 @@ def test_ArtifactDetect_inputs(): zintensity_threshold=dict(mandatory=True, ), ) - inputs = ArtifactDetect.input_spec() + inputs = ArtifactDetect._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -61,7 +58,7 @@ def test_ArtifactDetect_outputs(): plot_files=dict(), statistic_files=dict(), ) - outputs = ArtifactDetect.output_spec() + outputs = ArtifactDetect._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_CalculateNormalizedMoments.py b/nipype/algorithms/tests/test_auto_CalculateNormalizedMoments.py index 62a7b67b0c..e7cc5d3a58 100644 --- a/nipype/algorithms/tests/test_auto_CalculateNormalizedMoments.py +++ b/nipype/algorithms/tests/test_auto_CalculateNormalizedMoments.py @@ -9,7 +9,7 @@ def test_CalculateNormalizedMoments_inputs(): timeseries_file=dict(mandatory=True, ), ) - inputs = CalculateNormalizedMoments.input_spec() + inputs = CalculateNormalizedMoments._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -19,7 +19,7 @@ def test_CalculateNormalizedMoments_inputs(): def test_CalculateNormalizedMoments_outputs(): output_map = dict(moments=dict(), ) - outputs = CalculateNormalizedMoments.output_spec() + outputs = CalculateNormalizedMoments._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_ComputeMeshWarp.py b/nipype/algorithms/tests/test_auto_ComputeMeshWarp.py index e0a2d5f85c..1a6503c24a 100644 --- a/nipype/algorithms/tests/test_auto_ComputeMeshWarp.py +++ b/nipype/algorithms/tests/test_auto_ComputeMeshWarp.py @@ -4,10 +4,7 @@ def test_ComputeMeshWarp_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - metric=dict(usedefault=True, + input_map = dict(metric=dict(usedefault=True, ), out_file=dict(usedefault=True, ), @@ -20,7 +17,7 @@ def test_ComputeMeshWarp_inputs(): weighting=dict(usedefault=True, ), ) - inputs = ComputeMeshWarp.input_spec() + inputs = ComputeMeshWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +29,7 @@ def test_ComputeMeshWarp_outputs(): out_file=dict(), out_warp=dict(), ) - outputs = ComputeMeshWarp.output_spec() + outputs = ComputeMeshWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_CreateNifti.py b/nipype/algorithms/tests/test_auto_CreateNifti.py index 0e12142783..aa5a78206b 100644 --- a/nipype/algorithms/tests/test_auto_CreateNifti.py +++ b/nipype/algorithms/tests/test_auto_CreateNifti.py @@ -9,11 +9,11 @@ def test_CreateNifti_inputs(): ), header_file=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, + nifti_file=dict(keep_extension=False, + ns='data_file', ), ) - inputs = CreateNifti.input_spec() + inputs = CreateNifti._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -23,7 +23,7 @@ def test_CreateNifti_inputs(): def test_CreateNifti_outputs(): output_map = dict(nifti_file=dict(), ) - outputs = CreateNifti.output_spec() + outputs = CreateNifti._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_Distance.py b/nipype/algorithms/tests/test_auto_Distance.py index 4e5da64ba9..98e224ca8a 100644 --- a/nipype/algorithms/tests/test_auto_Distance.py +++ b/nipype/algorithms/tests/test_auto_Distance.py @@ -4,10 +4,7 @@ def test_Distance_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - mask_volume=dict(), + input_map = dict(mask_volume=dict(), method=dict(usedefault=True, ), volume1=dict(mandatory=True, @@ -15,7 +12,7 @@ def test_Distance_inputs(): volume2=dict(mandatory=True, ), ) - inputs = Distance.input_spec() + inputs = Distance._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +25,7 @@ def test_Distance_outputs(): point1=dict(), point2=dict(), ) - outputs = Distance.output_spec() + outputs = Distance._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_ErrorMap.py b/nipype/algorithms/tests/test_auto_ErrorMap.py index 69484529dd..6d2fcb98dd 100644 --- a/nipype/algorithms/tests/test_auto_ErrorMap.py +++ b/nipype/algorithms/tests/test_auto_ErrorMap.py @@ -4,10 +4,7 @@ def test_ErrorMap_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - in_ref=dict(mandatory=True, + input_map = dict(in_ref=dict(mandatory=True, ), in_tst=dict(mandatory=True, ), @@ -15,9 +12,10 @@ def test_ErrorMap_inputs(): metric=dict(mandatory=True, usedefault=True, ), - out_map=dict(), + out_map=dict(keep_extension=True, + ), ) - inputs = ErrorMap.input_spec() + inputs = ErrorMap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +26,7 @@ def test_ErrorMap_outputs(): output_map = dict(distance=dict(), out_map=dict(), ) - outputs = ErrorMap.output_spec() + outputs = ErrorMap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_FuzzyOverlap.py b/nipype/algorithms/tests/test_auto_FuzzyOverlap.py index dbc0c02474..9356670157 100644 --- a/nipype/algorithms/tests/test_auto_FuzzyOverlap.py +++ b/nipype/algorithms/tests/test_auto_FuzzyOverlap.py @@ -4,10 +4,7 @@ def test_FuzzyOverlap_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - in_ref=dict(mandatory=True, + input_map = dict(in_ref=dict(mandatory=True, ), in_tst=dict(mandatory=True, ), @@ -16,7 +13,7 @@ def test_FuzzyOverlap_inputs(): weighting=dict(usedefault=True, ), ) - inputs = FuzzyOverlap.input_spec() + inputs = FuzzyOverlap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -30,7 +27,7 @@ def test_FuzzyOverlap_outputs(): diff_file=dict(), jaccard=dict(), ) - outputs = FuzzyOverlap.output_spec() + outputs = FuzzyOverlap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_Gunzip.py b/nipype/algorithms/tests/test_auto_Gunzip.py index b77e6dfbd5..663f3906d0 100644 --- a/nipype/algorithms/tests/test_auto_Gunzip.py +++ b/nipype/algorithms/tests/test_auto_Gunzip.py @@ -4,13 +4,14 @@ def test_Gunzip_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, + input_map = dict(in_file=dict(mandatory=True, ), - in_file=dict(mandatory=True, + out_file=dict(keep_extension=False, + name_remove='.gz', + ns='in_file', ), ) - inputs = Gunzip.input_spec() + inputs = Gunzip._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -20,7 +21,7 @@ def test_Gunzip_inputs(): def test_Gunzip_outputs(): output_map = dict(out_file=dict(), ) - outputs = Gunzip.output_spec() + outputs = Gunzip._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_ICC.py b/nipype/algorithms/tests/test_auto_ICC.py index 76b70b3369..7671b85d96 100644 --- a/nipype/algorithms/tests/test_auto_ICC.py +++ b/nipype/algorithms/tests/test_auto_ICC.py @@ -4,15 +4,16 @@ def test_ICC_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), + input_map = dict(icc_map=dict(), mask=dict(mandatory=True, ), + session_F_map=dict(), + session_var_map=dict(), + subject_var_map=dict(), subjects_sessions=dict(mandatory=True, ), ) - inputs = ICC.input_spec() + inputs = ICC._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -21,10 +22,11 @@ def test_ICC_inputs(): def test_ICC_outputs(): output_map = dict(icc_map=dict(), + session_F_map=dict(), session_var_map=dict(), subject_var_map=dict(), ) - outputs = ICC.output_spec() + outputs = ICC._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_Matlab2CSV.py b/nipype/algorithms/tests/test_auto_Matlab2CSV.py index 1382385dc3..79664ea725 100644 --- a/nipype/algorithms/tests/test_auto_Matlab2CSV.py +++ b/nipype/algorithms/tests/test_auto_Matlab2CSV.py @@ -9,7 +9,7 @@ def test_Matlab2CSV_inputs(): reshape_matrix=dict(usedefault=True, ), ) - inputs = Matlab2CSV.input_spec() + inputs = Matlab2CSV._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -19,7 +19,7 @@ def test_Matlab2CSV_inputs(): def test_Matlab2CSV_outputs(): output_map = dict(csv_files=dict(), ) - outputs = Matlab2CSV.output_spec() + outputs = Matlab2CSV._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_MergeCSVFiles.py b/nipype/algorithms/tests/test_auto_MergeCSVFiles.py index 4d2d896db3..5b8530f627 100644 --- a/nipype/algorithms/tests/test_auto_MergeCSVFiles.py +++ b/nipype/algorithms/tests/test_auto_MergeCSVFiles.py @@ -15,7 +15,7 @@ def test_MergeCSVFiles_inputs(): ), row_headings=dict(), ) - inputs = MergeCSVFiles.input_spec() + inputs = MergeCSVFiles._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -25,7 +25,7 @@ def test_MergeCSVFiles_inputs(): def test_MergeCSVFiles_outputs(): output_map = dict(csv_file=dict(), ) - outputs = MergeCSVFiles.output_spec() + outputs = MergeCSVFiles._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_MergeROIs.py b/nipype/algorithms/tests/test_auto_MergeROIs.py index 83eed3a4d4..46564d63d5 100644 --- a/nipype/algorithms/tests/test_auto_MergeROIs.py +++ b/nipype/algorithms/tests/test_auto_MergeROIs.py @@ -8,7 +8,7 @@ def test_MergeROIs_inputs(): in_index=dict(), in_reference=dict(), ) - inputs = MergeROIs.input_spec() + inputs = MergeROIs._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -18,7 +18,7 @@ def test_MergeROIs_inputs(): def test_MergeROIs_outputs(): output_map = dict(merged_file=dict(), ) - outputs = MergeROIs.output_spec() + outputs = MergeROIs._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_MeshWarpMaths.py b/nipype/algorithms/tests/test_auto_MeshWarpMaths.py index dfd4c5bd63..77b25ae6b2 100644 --- a/nipype/algorithms/tests/test_auto_MeshWarpMaths.py +++ b/nipype/algorithms/tests/test_auto_MeshWarpMaths.py @@ -5,21 +5,19 @@ def test_MeshWarpMaths_inputs(): input_map = dict(float_trait=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_surf=dict(mandatory=True, ), operation=dict(usedefault=True, ), operator=dict(mandatory=True, ), - out_file=dict(usedefault=True, + out_file=dict(keep_extension=True, + template='{in_surf}_warped', ), - out_warp=dict(usedefault=True, + out_warp=dict(keep_extension=True, ), ) - inputs = MeshWarpMaths.input_spec() + inputs = MeshWarpMaths._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -30,7 +28,7 @@ def test_MeshWarpMaths_outputs(): output_map = dict(out_file=dict(), out_warp=dict(), ) - outputs = MeshWarpMaths.output_spec() + outputs = MeshWarpMaths._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_ModifyAffine.py b/nipype/algorithms/tests/test_auto_ModifyAffine.py index fb8c5ca876..584dffdfca 100644 --- a/nipype/algorithms/tests/test_auto_ModifyAffine.py +++ b/nipype/algorithms/tests/test_auto_ModifyAffine.py @@ -4,15 +4,13 @@ def test_ModifyAffine_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - transformation_matrix=dict(usedefault=True, + input_map = dict(transformation_matrix=dict(usedefault=True, ), + transformed_volumes=dict(), volumes=dict(mandatory=True, ), ) - inputs = ModifyAffine.input_spec() + inputs = ModifyAffine._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -22,7 +20,7 @@ def test_ModifyAffine_inputs(): def test_ModifyAffine_outputs(): output_map = dict(transformed_volumes=dict(), ) - outputs = ModifyAffine.output_spec() + outputs = ModifyAffine._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_NormalizeProbabilityMapSet.py b/nipype/algorithms/tests/test_auto_NormalizeProbabilityMapSet.py index c2595baa72..09812d3e44 100644 --- a/nipype/algorithms/tests/test_auto_NormalizeProbabilityMapSet.py +++ b/nipype/algorithms/tests/test_auto_NormalizeProbabilityMapSet.py @@ -6,8 +6,9 @@ def test_NormalizeProbabilityMapSet_inputs(): input_map = dict(in_files=dict(), in_mask=dict(), + out_files=dict(), ) - inputs = NormalizeProbabilityMapSet.input_spec() + inputs = NormalizeProbabilityMapSet._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -17,7 +18,7 @@ def test_NormalizeProbabilityMapSet_inputs(): def test_NormalizeProbabilityMapSet_outputs(): output_map = dict(out_files=dict(), ) - outputs = NormalizeProbabilityMapSet.output_spec() + outputs = NormalizeProbabilityMapSet._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_Overlap.py b/nipype/algorithms/tests/test_auto_Overlap.py index a5a3874bd1..d313cd9698 100644 --- a/nipype/algorithms/tests/test_auto_Overlap.py +++ b/nipype/algorithms/tests/test_auto_Overlap.py @@ -7,9 +7,6 @@ def test_Overlap_inputs(): input_map = dict(bg_overlap=dict(mandatory=True, usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), mask_volume=dict(), out_file=dict(usedefault=True, ), @@ -23,7 +20,7 @@ def test_Overlap_inputs(): weighting=dict(usedefault=True, ), ) - inputs = Overlap.input_spec() + inputs = Overlap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +37,7 @@ def test_Overlap_outputs(): roi_voldiff=dict(), volume_difference=dict(), ) - outputs = Overlap.output_spec() + outputs = Overlap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_P2PDistance.py b/nipype/algorithms/tests/test_auto_P2PDistance.py index 0a30a382c9..59b8753ae2 100644 --- a/nipype/algorithms/tests/test_auto_P2PDistance.py +++ b/nipype/algorithms/tests/test_auto_P2PDistance.py @@ -4,10 +4,7 @@ def test_P2PDistance_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - metric=dict(usedefault=True, + input_map = dict(metric=dict(usedefault=True, ), out_file=dict(usedefault=True, ), @@ -20,7 +17,7 @@ def test_P2PDistance_inputs(): weighting=dict(usedefault=True, ), ) - inputs = P2PDistance.input_spec() + inputs = P2PDistance._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +29,7 @@ def test_P2PDistance_outputs(): out_file=dict(), out_warp=dict(), ) - outputs = P2PDistance.output_spec() + outputs = P2PDistance._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_PickAtlas.py b/nipype/algorithms/tests/test_auto_PickAtlas.py index 27aaac7d41..2a3f7d3453 100644 --- a/nipype/algorithms/tests/test_auto_PickAtlas.py +++ b/nipype/algorithms/tests/test_auto_PickAtlas.py @@ -10,14 +10,15 @@ def test_PickAtlas_inputs(): ), hemi=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), labels=dict(mandatory=True, ), - output_file=dict(), + mask_file=dict(ns='atlas', + ), + output_file=dict(deprecated=True, + new_name='mask_file', + ), ) - inputs = PickAtlas.input_spec() + inputs = PickAtlas._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -27,7 +28,7 @@ def test_PickAtlas_inputs(): def test_PickAtlas_outputs(): output_map = dict(mask_file=dict(), ) - outputs = PickAtlas.output_spec() + outputs = PickAtlas._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_Similarity.py b/nipype/algorithms/tests/test_auto_Similarity.py index 109933677c..2e79106ee5 100644 --- a/nipype/algorithms/tests/test_auto_Similarity.py +++ b/nipype/algorithms/tests/test_auto_Similarity.py @@ -4,10 +4,7 @@ def test_Similarity_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - mask1=dict(), + input_map = dict(mask1=dict(), mask2=dict(), metric=dict(usedefault=True, ), @@ -16,7 +13,7 @@ def test_Similarity_inputs(): volume2=dict(mandatory=True, ), ) - inputs = Similarity.input_spec() + inputs = Similarity._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -26,7 +23,7 @@ def test_Similarity_inputs(): def test_Similarity_outputs(): output_map = dict(similarity=dict(), ) - outputs = Similarity.output_spec() + outputs = Similarity._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_SimpleThreshold.py b/nipype/algorithms/tests/test_auto_SimpleThreshold.py index ff46592c11..2b3f99aea2 100644 --- a/nipype/algorithms/tests/test_auto_SimpleThreshold.py +++ b/nipype/algorithms/tests/test_auto_SimpleThreshold.py @@ -4,15 +4,13 @@ def test_SimpleThreshold_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - threshold=dict(mandatory=True, + input_map = dict(threshold=dict(mandatory=True, ), + thresholded_volumes=dict(), volumes=dict(mandatory=True, ), ) - inputs = SimpleThreshold.input_spec() + inputs = SimpleThreshold._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -22,7 +20,7 @@ def test_SimpleThreshold_inputs(): def test_SimpleThreshold_outputs(): output_map = dict(thresholded_volumes=dict(), ) - outputs = SimpleThreshold.output_spec() + outputs = SimpleThreshold._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_SpecifyModel.py b/nipype/algorithms/tests/test_auto_SpecifyModel.py index 69a528c3c2..b35a8c2de7 100644 --- a/nipype/algorithms/tests/test_auto_SpecifyModel.py +++ b/nipype/algorithms/tests/test_auto_SpecifyModel.py @@ -12,9 +12,6 @@ def test_SpecifyModel_inputs(): ), high_pass_filter_cutoff=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_units=dict(mandatory=True, ), outlier_files=dict(copyfile=False, @@ -27,7 +24,7 @@ def test_SpecifyModel_inputs(): time_repetition=dict(mandatory=True, ), ) - inputs = SpecifyModel.input_spec() + inputs = SpecifyModel._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +34,7 @@ def test_SpecifyModel_inputs(): def test_SpecifyModel_outputs(): output_map = dict(session_info=dict(), ) - outputs = SpecifyModel.output_spec() + outputs = SpecifyModel._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_SpecifySPMModel.py b/nipype/algorithms/tests/test_auto_SpecifySPMModel.py index 19ccaa9ba5..5aca7f6798 100644 --- a/nipype/algorithms/tests/test_auto_SpecifySPMModel.py +++ b/nipype/algorithms/tests/test_auto_SpecifySPMModel.py @@ -14,9 +14,6 @@ def test_SpecifySPMModel_inputs(): ), high_pass_filter_cutoff=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_units=dict(mandatory=True, ), outlier_files=dict(copyfile=False, @@ -31,7 +28,7 @@ def test_SpecifySPMModel_inputs(): time_repetition=dict(mandatory=True, ), ) - inputs = SpecifySPMModel.input_spec() + inputs = SpecifySPMModel._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +38,7 @@ def test_SpecifySPMModel_inputs(): def test_SpecifySPMModel_outputs(): output_map = dict(session_info=dict(), ) - outputs = SpecifySPMModel.output_spec() + outputs = SpecifySPMModel._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_SpecifySparseModel.py b/nipype/algorithms/tests/test_auto_SpecifySparseModel.py index aa641facf7..010392edd8 100644 --- a/nipype/algorithms/tests/test_auto_SpecifySparseModel.py +++ b/nipype/algorithms/tests/test_auto_SpecifySparseModel.py @@ -12,9 +12,6 @@ def test_SpecifySparseModel_inputs(): ), high_pass_filter_cutoff=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_units=dict(mandatory=True, ), model_hrf=dict(), @@ -22,11 +19,14 @@ def test_SpecifySparseModel_inputs(): ), realignment_parameters=dict(copyfile=False, ), - save_plot=dict(), + save_plot=dict(usedefault=True, + ), scale_regressors=dict(usedefault=True, ), scan_onset=dict(usedefault=True, ), + sparse_png_file=dict(), + sparse_svg_file=dict(), stimuli_as_impulses=dict(usedefault=True, ), subject_info=dict(mandatory=True, @@ -41,7 +41,7 @@ def test_SpecifySparseModel_inputs(): volumes_in_cluster=dict(usedefault=True, ), ) - inputs = SpecifySparseModel.input_spec() + inputs = SpecifySparseModel._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +53,7 @@ def test_SpecifySparseModel_outputs(): sparse_png_file=dict(), sparse_svg_file=dict(), ) - outputs = SpecifySparseModel.output_spec() + outputs = SpecifySparseModel._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_SplitROIs.py b/nipype/algorithms/tests/test_auto_SplitROIs.py index cd23a51468..80e45a9e54 100644 --- a/nipype/algorithms/tests/test_auto_SplitROIs.py +++ b/nipype/algorithms/tests/test_auto_SplitROIs.py @@ -9,7 +9,7 @@ def test_SplitROIs_inputs(): in_mask=dict(), roi_size=dict(), ) - inputs = SplitROIs.input_spec() + inputs = SplitROIs._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -21,7 +21,7 @@ def test_SplitROIs_outputs(): out_index=dict(), out_masks=dict(), ) - outputs = SplitROIs.output_spec() + outputs = SplitROIs._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_StimulusCorrelation.py b/nipype/algorithms/tests/test_auto_StimulusCorrelation.py index f1b786aa8e..bf1937103c 100644 --- a/nipype/algorithms/tests/test_auto_StimulusCorrelation.py +++ b/nipype/algorithms/tests/test_auto_StimulusCorrelation.py @@ -6,17 +6,15 @@ def test_StimulusCorrelation_inputs(): input_map = dict(concatenated_design=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), intensity_values=dict(mandatory=True, ), realignment_parameters=dict(mandatory=True, ), spm_mat_file=dict(mandatory=True, ), + stimcorr_files=dict(), ) - inputs = StimulusCorrelation.input_spec() + inputs = StimulusCorrelation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -26,7 +24,7 @@ def test_StimulusCorrelation_inputs(): def test_StimulusCorrelation_outputs(): output_map = dict(stimcorr_files=dict(), ) - outputs = StimulusCorrelation.output_spec() + outputs = StimulusCorrelation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_TSNR.py b/nipype/algorithms/tests/test_auto_TSNR.py index 4bc6693b20..42f3e19722 100644 --- a/nipype/algorithms/tests/test_auto_TSNR.py +++ b/nipype/algorithms/tests/test_auto_TSNR.py @@ -5,25 +5,22 @@ def test_TSNR_inputs(): input_map = dict(detrended_file=dict(hash_files=False, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, + ns='in_file', ), in_file=dict(mandatory=True, ), mean_file=dict(hash_files=False, - usedefault=True, + ns='in_file', ), regress_poly=dict(), stddev_file=dict(hash_files=False, - usedefault=True, + ns='in_file', ), tsnr_file=dict(hash_files=False, - usedefault=True, + ns='in_file', ), ) - inputs = TSNR.input_spec() + inputs = TSNR._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +33,7 @@ def test_TSNR_outputs(): stddev_file=dict(), tsnr_file=dict(), ) - outputs = TSNR.output_spec() + outputs = TSNR._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_auto_TVTKBaseInterface.py b/nipype/algorithms/tests/test_auto_TVTKBaseInterface.py index 3dd8ac6d2a..d246493911 100644 --- a/nipype/algorithms/tests/test_auto_TVTKBaseInterface.py +++ b/nipype/algorithms/tests/test_auto_TVTKBaseInterface.py @@ -4,13 +4,18 @@ def test_TVTKBaseInterface_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - ) - inputs = TVTKBaseInterface.input_spec() + input_map = dict() + inputs = TVTKBaseInterface._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_TVTKBaseInterface_outputs(): + output_map = dict() + outputs = TVTKBaseInterface._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/algorithms/tests/test_auto_WarpPoints.py b/nipype/algorithms/tests/test_auto_WarpPoints.py index 741b9f0c60..5b985f0509 100644 --- a/nipype/algorithms/tests/test_auto_WarpPoints.py +++ b/nipype/algorithms/tests/test_auto_WarpPoints.py @@ -4,23 +4,17 @@ def test_WarpPoints_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - interp=dict(mandatory=True, + input_map = dict(interp=dict(mandatory=True, usedefault=True, ), out_points=dict(keep_extension=True, - name_source='points', - name_template='%s_warped', - output_name='out_points', ), points=dict(mandatory=True, ), warp=dict(mandatory=True, ), ) - inputs = WarpPoints.input_spec() + inputs = WarpPoints._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -30,7 +24,7 @@ def test_WarpPoints_inputs(): def test_WarpPoints_outputs(): output_map = dict(out_points=dict(), ) - outputs = WarpPoints.output_spec() + outputs = WarpPoints._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/algorithms/tests/test_errormap.py b/nipype/algorithms/tests/test_errormap.py index 361646add0..7c58fac2e0 100644 --- a/nipype/algorithms/tests/test_errormap.py +++ b/nipype/algorithms/tests/test_errormap.py @@ -12,6 +12,7 @@ def test_errormap(): tempdir = mkdtemp() + os.chdir(tempdir) # Single-Spectual # Make two fake 2*2*2 voxel volumes volume1 = np.array([[[2.0, 8.0], [1.0, 2.0]], [[1.0, 9.0], [0.0, 3.0]]]) # John von Neumann's birthday diff --git a/nipype/algorithms/tests/test_rapidart.py b/nipype/algorithms/tests/test_rapidart.py index 1ba6414e29..4edd4e8b10 100644 --- a/nipype/algorithms/tests/test_rapidart.py +++ b/nipype/algorithms/tests/test_rapidart.py @@ -16,19 +16,20 @@ def test_ad_init(): yield assert_false, ad.inputs.use_differences[1] -def test_ad_output_filenames(): - ad = ra.ArtifactDetect() - outputdir = '/tmp' - f = 'motion.nii' - (outlierfile, intensityfile, statsfile, normfile, plotfile, - displacementfile, maskfile) = ad._get_output_filenames(f, outputdir) - yield assert_equal, outlierfile, '/tmp/art.motion_outliers.txt' - yield assert_equal, intensityfile, '/tmp/global_intensity.motion.txt' - yield assert_equal, statsfile, '/tmp/stats.motion.txt' - yield assert_equal, normfile, '/tmp/norm.motion.txt' - yield assert_equal, plotfile, '/tmp/plot.motion.png' - yield assert_equal, displacementfile, '/tmp/disp.motion.nii' - yield assert_equal, maskfile, '/tmp/mask.motion.nii' +# def test_ad_output_filenames(): + # TODO: rewrite this test + # ad = ra.ArtifactDetect() + # outputdir = '/tmp' + # f = 'motion.nii' + # (outlierfile, intensityfile, statsfile, normfile, plotfile, + # displacementfile, maskfile) = ad.inputs. + # yield assert_equal, outlierfile, '/tmp/art.motion_outliers.txt' + # yield assert_equal, intensityfile, '/tmp/global_intensity.motion.txt' + # yield assert_equal, statsfile, '/tmp/stats.motion.txt' + # yield assert_equal, normfile, '/tmp/norm.motion.txt' + # yield assert_equal, plotfile, '/tmp/plot.motion.png' + # yield assert_equal, displacementfile, '/tmp/disp.motion.nii' + # yield assert_equal, maskfile, '/tmp/mask.motion.nii' def test_ad_get_affine_matrix(): @@ -79,11 +80,3 @@ def test_sc_populate_inputs(): spm_mat_file=None, concatenated_design=None) yield assert_equal, set(sc.inputs.__dict__.keys()), set(inputs.__dict__.keys()) - - -def test_sc_output_filenames(): - sc = ra.StimulusCorrelation() - outputdir = '/tmp' - f = 'motion.nii' - corrfile = sc._get_output_filenames(f, outputdir) - yield assert_equal, corrfile, '/tmp/qa.motion_stimcorr.txt' diff --git a/nipype/external/portalocker.py b/nipype/external/portalocker.py index 40b12b3cf3..2b7e60e2a5 100644 --- a/nipype/external/portalocker.py +++ b/nipype/external/portalocker.py @@ -1,6 +1,6 @@ # portalocker.py - Cross-platform (posix/nt) API for flock-style file locking. # Requires python 1.5.2 or better. -'''Cross-platform (posix/nt) API for flock-style file locking. +"""Cross-platform (posix/nt) API for flock-style file locking. Synopsis: @@ -47,7 +47,7 @@ Lowell Alleman Version: $Id: portalocker.py 5474 2008-05-16 20:53:50Z lowell $ -''' +""" from __future__ import print_function from __future__ import absolute_import diff --git a/nipype/fixes/numpy/testing/noseclasses.py b/nipype/fixes/numpy/testing/noseclasses.py index 9f69dc33db..aaa7350eda 100644 --- a/nipype/fixes/numpy/testing/noseclasses.py +++ b/nipype/fixes/numpy/testing/noseclasses.py @@ -304,16 +304,16 @@ def configure(self, options, config): class KnownFailureTest(Exception): - '''Raise this exception to mark a test as a known failing test.''' + """Raise this exception to mark a test as a known failing test.""" pass class KnownFailure(ErrorClassPlugin): - '''Plugin that installs a KNOWNFAIL error class for the + """Plugin that installs a KNOWNFAIL error class for the KnownFailureClass exception. When KnownFailureTest is raised, the exception will be logged in the knownfail attribute of the result, 'K' or 'KNOWNFAIL' (verbose) will be output, and the - exception will not be counted as an error or failure.''' + exception will not be counted as an error or failure.""" enabled = True knownfail = ErrorClass(KnownFailureTest, label='KNOWNFAIL', diff --git a/nipype/fixes/numpy/testing/nosetester.py b/nipype/fixes/numpy/testing/nosetester.py index 22c8d1a5ef..2a5c92333b 100644 --- a/nipype/fixes/numpy/testing/nosetester.py +++ b/nipype/fixes/numpy/testing/nosetester.py @@ -126,7 +126,7 @@ class NoseTester(object): 'swig_ext'] def __init__(self, package=None): - ''' Test class init + """ Test class init Parameters ---------- @@ -134,7 +134,7 @@ def __init__(self, package=None): If string, gives full path to package If None, extract calling module path Default is None - ''' + """ package_name = None if package is None: f = sys._getframe(1) @@ -158,7 +158,7 @@ def __init__(self, package=None): self.package_name = package_name def _test_argv(self, label, verbose, extra_argv): - ''' Generate argv for nosetest command + """ Generate argv for nosetest command Parameters ---------- @@ -173,7 +173,7 @@ def _test_argv(self, label, verbose, extra_argv): ------- argv : list command line arguments that will be passed to nose - ''' + """ argv = [__file__, self.package_path, '-s'] if label and label != 'full': if not isinstance(label, string_types): diff --git a/nipype/interfaces/__init__.py b/nipype/interfaces/__init__.py index c9ff7936ba..4ef022803f 100644 --- a/nipype/interfaces/__init__.py +++ b/nipype/interfaces/__init__.py @@ -9,5 +9,6 @@ from __future__ import absolute_import __docformat__ = 'restructuredtext' +from . import base from .io import DataGrabber, DataSink, SelectFiles from .utility import IdentityInterface, Rename, Function, Select, Merge diff --git a/nipype/interfaces/afni/base.py b/nipype/interfaces/afni/base.py index ffe9f230b5..f470fdce12 100644 --- a/nipype/interfaces/afni/base.py +++ b/nipype/interfaces/afni/base.py @@ -3,25 +3,19 @@ """Provide interface to AFNI commands.""" import os -from sys import platform from builtins import object from ... import logging -from ...utils.filemanip import split_filename -from ..base import ( - CommandLine, traits, CommandLineInputSpec, isdefined, File, TraitedSpec) +from ...external.six import string_types +from ..base import traits, File, CommandLine, CommandLineInputSpec, TraitedSpec # Use nipype's logging system IFLOGGER = logging.getLogger('interface') +AFNI_FTYPES = {'NIFTI': '.nii', 'AFNI': '', 'NIFTI_GZ': '.nii.gz'} class Info(object): - """Handle afni output type and version information. - """ - __outputtype = 'AFNI' - ftypes = {'NIFTI': '.nii', - 'AFNI': '', - 'NIFTI_GZ': '.nii.gz'} + """Handle afni output type and version information. """ @staticmethod def version(): @@ -47,67 +41,30 @@ def version(): # If afni_vcheck is not present, return None IFLOGGER.warn('afni_vcheck executable not found.') return None - except RuntimeError as e: + except RuntimeError as err: # If AFNI is outdated, afni_vcheck throws error. # Show new version, but parse current anyways. - currv = str(e).split('\n')[4].split('=', 1)[1].strip() - nextv = str(e).split('\n')[6].split('=', 1)[1].strip() + currv = str(err).split('\n')[4].split('=', 1)[1].strip() + nextv = str(err).split('\n')[6].split('=', 1)[1].strip() IFLOGGER.warn( - 'AFNI is outdated, detected version %s and %s is available.' % (currv, nextv)) + 'AFNI is outdated, detected version %s and %s is available.', currv, nextv) if currv.startswith('AFNI_'): currv = currv[5:] - v = currv.split('.') + version = currv.split('.') try: - v = [int(n) for n in v] + version = [int(n) for n in version] except ValueError: return currv - return tuple(v) - - @classmethod - def outputtype_to_ext(cls, outputtype): - """Get the file extension for the given output type. - - Parameters - ---------- - outputtype : {'NIFTI', 'NIFTI_GZ', 'AFNI'} - String specifying the output type. - - Returns - ------- - extension : str - The file extension for the output type. - """ - - try: - return cls.ftypes[outputtype] - except KeyError: - msg = 'Invalid AFNIOUTPUTTYPE: ', outputtype - raise KeyError(msg) - - @classmethod - def outputtype(cls): - """AFNI has no environment variables, - Output filetypes get set in command line calls - Nipype uses AFNI as default - - - Returns - ------- - None - """ - # warn(('AFNI has no environment variable that sets filetype ' - # 'Nipype uses NIFTI_GZ as default')) - return 'AFNI' + return tuple(version) @staticmethod def standard_image(img_name): - '''Grab an image from the standard location. + """Grab an image from the standard location. - Could be made more fancy to allow for more relocatability''' - clout = CommandLine('which afni', - terminal_output='allatonce').run() + Could be made more fancy to allow for more relocatability""" + clout = CommandLine('which afni', terminal_output='allatonce').run() if clout.runtime.returncode is not 0: return None @@ -121,80 +78,41 @@ class AFNICommandBase(CommandLine): A base class to fix a linking problem in OSX and afni. See http://afni.nimh.nih.gov/afni/community/board/read.php?1,145346,145347#msg-145347 """ + version_major = traits.Int(0, desc='AFNI version major') + + def _default_version(self): + version = '' + if not no_afni(): + version += Info.version() + + if isinstance(version, string_types): + return '.'.join(version) + return version + + def _default_version_major(self): + try: + return int(self.version.split('.')[0]) + except ValueError: + return 0 + + def _run_interface(self, runtime): - if platform == 'darwin': + if runtime.platform == 'darwin': runtime.environ['DYLD_FALLBACK_LIBRARY_PATH'] = '/usr/local/afni/' return super(AFNICommandBase, self)._run_interface(runtime) class AFNICommandInputSpec(CommandLineInputSpec): - outputtype = traits.Enum('AFNI', list(Info.ftypes.keys()), - desc='AFNI output filetype') - out_file = File(name_template="%s_afni", desc='output image file name', - argstr='-prefix %s', - name_source=["in_file"]) - + output_type = traits.Trait('AFNI', AFNI_FTYPES, usedefault=True, + desc='AFNI output filetype') class AFNICommandOutputSpec(TraitedSpec): - out_file = File(desc='output file', - exists=True) + out_file = File(exists=True, desc='output file') class AFNICommand(AFNICommandBase): """Shared options for several AFNI commands """ - input_spec = AFNICommandInputSpec - _outputtype = None - - def __init__(self, **inputs): - super(AFNICommand, self).__init__(**inputs) - self.inputs.on_trait_change(self._output_update, 'outputtype') - - if self._outputtype is None: - self._outputtype = Info.outputtype() - - if not isdefined(self.inputs.outputtype): - self.inputs.outputtype = self._outputtype - else: - self._output_update() - - def _output_update(self): - """ i think? updates class private attribute based on instance input - in fsl also updates ENVIRON variable....not valid in afni - as it uses no environment variables - """ - self._outputtype = self.inputs.outputtype - - @classmethod - def set_default_output_type(cls, outputtype): - """Set the default output type for AFNI classes. - - This method is used to set the default output type for all afni - subclasses. However, setting this will not update the output - type for any existing instances. For these, assign the - .inputs.outputtype. - """ - - if outputtype in Info.ftypes: - cls._outputtype = outputtype - else: - raise AttributeError('Invalid AFNI outputtype: %s' % outputtype) - - def _overload_extension(self, value, name=None): - path, base, _ = split_filename(value) - return os.path.join(path, base + Info.outputtype_to_ext(self.inputs.outputtype)) - - def _list_outputs(self): - outputs = super(AFNICommand, self)._list_outputs() - metadata = dict(name_source=lambda t: t is not None) - out_names = list(self.inputs.traits(**metadata).keys()) - if out_names: - for name in out_names: - if outputs[name]: - _, _, ext = split_filename(outputs[name]) - if ext == "": - outputs[name] = outputs[name] + "+orig.BRIK" - return outputs - + _input_spec = AFNICommandInputSpec def no_afni(): """ Checks if AFNI is available """ diff --git a/nipype/interfaces/afni/preprocess.py b/nipype/interfaces/afni/preprocess.py index c88fa02506..49d8545abc 100644 --- a/nipype/interfaces/afni/preprocess.py +++ b/nipype/interfaces/afni/preprocess.py @@ -14,18 +14,21 @@ import re import numpy as np -from .base import (AFNICommandBase, AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec, - Info, no_afni) -from ..base import CommandLineInputSpec -from ..base import (Directory, TraitedSpec, - traits, isdefined, File, InputMultiPath, Undefined) +from ..base import (traits, isdefined, Undefined, + CommandLineInputSpec, TraitedSpec) +from ..base.traits_extension import Directory, File, GenFile, InputMultiPath + +from .base import (AFNICommandBase, AFNICommand, AFNICommandInputSpec, + AFNICommandOutputSpec, Info, no_afni) from ...external.six import string_types from ...utils.filemanip import (load_json, save_json, split_filename) class To3DInputSpec(AFNICommandInputSpec): - out_file = File(name_template="%s", desc='output image file name', - argstr='-prefix %s', name_source=["in_folder"]) + prefix = traits.Str('afni_to3d', usedefault='true', argstr='-prefix %s', + desc='output files prefix') + out_file = GenFile(template='{prefix}{output_type_}', keep_extension=False, + desc='output image file name') in_folder = Directory(desc='folder with DICOM images to convert', argstr='%s/*.dcm', position=-1, @@ -53,6 +56,7 @@ class To3DInputSpec(AFNICommandInputSpec): class To3D(AFNICommand): + """Create a 3D dataset from 2D image files using AFNI to3d command For complete details, see the `to3d Documentation @@ -68,59 +72,40 @@ class To3D(AFNICommand): >>> To3D.inputs.out_file = 'dicomdir.nii' >>> To3D.inputs.filetype = "anat" >>> To3D.cmdline #doctest: +ELLIPSIS - 'to3d -datum float -anat -prefix dicomdir.nii ./*.dcm' + 'to3d -datum float -anat -prefix afni_to3d ./*.dcm' >>> res = To3D.run() #doctest: +SKIP """ _cmd = 'to3d' - input_spec = To3DInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = To3DInputSpec + _output_spec = AFNICommandOutputSpec class TShiftInputSpec(AFNICommandInputSpec): - in_file = File(desc='input file to 3dTShift', - argstr='%s', - position=-1, - mandatory=True, - exists=True, - copyfile=False) - - out_file = File(name_template="%s_tshift", desc='output image file name', - argstr='-prefix %s', name_source="in_file") - - tr = traits.Str(desc='manually set the TR' + - 'You can attach suffix "s" for seconds or "ms" for milliseconds.', - argstr='-TR %s') - - tzero = traits.Float(desc='align each slice to given time offset', - argstr='-tzero %s', - xor=['tslice']) - - tslice = traits.Int(desc='align each slice to time offset of given slice', - argstr='-slice %s', - xor=['tzero']) - + in_file = File(desc='input file to 3dTShift', argstr='%s', position=-1, mandatory=True, + exists=True, copyfile=False) + prefix = GenFile(template='{in_file}_tshift', keep_extension=False, argstr='-prefix %s', + desc='output files prefix') + tr = traits.Str(argstr='-TR %s', desc='manually set the TR You can attach suffix "s" for ' + 'seconds or "ms" for milliseconds.') + tzero = traits.Float(argstr='-tzero %s', xor=['tslice'], + desc='align each slice to given time offset') + tslice = traits.Int(argstr='-slice %s', xor=['tzero'], + desc='align each slice to time offset of given slice') ignore = traits.Int(desc='ignore the first set of points specified', argstr='-ignore %s') - - interp = traits.Enum(('Fourier', 'linear', 'cubic', 'quintic', 'heptic'), - desc='different interpolation methods (see 3dTShift for details)' + - ' default = Fourier', argstr='-%s') - - tpattern = traits.Str(desc='use specified slice time pattern rather than one in header', - argstr='-tpattern %s') - - rlt = traits.Bool(desc='Before shifting, remove the mean and linear trend', - argstr="-rlt") - - rltplus = traits.Bool(desc='Before shifting,' + - ' remove the mean and linear trend and ' + - 'later put back the mean', - argstr="-rlt+") - + interp = traits.Enum('Fourier', 'linear', 'cubic', 'quintic', 'heptic', argstr='-%s', + desc='different interpolation methods (see 3dTShift for details)') + tpattern = traits.Str(argstr='-tpattern %s', + desc='use specified slice time pattern rather than one in header') + rlt = traits.Bool(argstr="-rlt", desc='Before shifting, remove the mean and linear trend') + rltplus = traits.Bool(argstr="-rlt+", desc='Before shifting, remove the mean and linear trend' + ' and later put back the mean') + out_file = GenFile(template='{prefix}{output_type_}', desc='output image file name') class TShift(AFNICommand): + """Shifts voxel time series from input so that seperate slices are aligned to the same temporal origin @@ -143,43 +128,29 @@ class TShift(AFNICommand): """ _cmd = '3dTshift' - input_spec = TShiftInputSpec - output_spec = AFNICommandOutputSpec - - -class RefitInputSpec(CommandLineInputSpec): - in_file = File(desc='input file to 3drefit', - argstr='%s', - position=-1, - mandatory=True, - exists=True, - copyfile=True) - - deoblique = traits.Bool(desc='replace current transformation' + - ' matrix with cardinal matrix', - argstr='-deoblique') - - xorigin = traits.Str(desc='x distance for edge voxel offset', - argstr='-xorigin %s') - - yorigin = traits.Str(desc='y distance for edge voxel offset', - argstr='-yorigin %s') - zorigin = traits.Str(desc='z distance for edge voxel offset', - argstr='-zorigin %s') - - xdel = traits.Float(desc='new x voxel dimension in mm', - argstr='-xdel %f') - - ydel = traits.Float(desc='new y voxel dimension in mm', - argstr='-ydel %f') - - zdel = traits.Float(desc='new z voxel dimension in mm', - argstr='-zdel %f') - - space = traits.Enum('TLRC', 'MNI', 'ORIG', - argstr='-space %s', - desc='Associates the dataset with a specific' + - ' template type, e.g. TLRC, MNI, ORIG') + _input_spec = TShiftInputSpec + _output_spec = AFNICommandOutputSpec + + +class RefitInputSpec(AFNICommandInputSpec): + in_file = File(argstr='%s', position=-1, mandatory=True, exists=True, + copyfile=True, desc='input file to 3drefit') + out_file = GenFile(template='{in_file}{output_type_}', desc='output file') + deoblique = traits.Bool( + False, usedefault=True, argstr='-deoblique', + desc='replace current transformation matrix with cardinal matrix') + xorigin = traits.Str(argstr='-xorigin %s', desc='x distance for edge voxel offset') + yorigin = traits.Str(argstr='-yorigin %s', desc='y distance for edge voxel offset') + zorigin = traits.Str(argstr='-zorigin %s', desc='z distance for edge voxel offset') + xdel = traits.Float(argstr='-xdel %f', desc='new x voxel dimension in mm') + ydel = traits.Float(argstr='-ydel %f', desc='new y voxel dimension in mm') + zdel = traits.Float(argstr='-zdel %f', desc='new z voxel dimension in mm') + space = traits.Enum( + 'TLRC', 'MNI', 'ORIG', argstr='-space %s', + desc='Associates the dataset with a specific template type, e.g. TLRC, MNI, ORIG') + +class RefitOutputSpec(TraitedSpec): + out_file = File(exists=True, desc='output file') class Refit(AFNICommandBase): @@ -197,62 +168,39 @@ class Refit(AFNICommandBase): >>> refit.inputs.deoblique = True >>> refit.cmdline '3drefit -deoblique structural.nii' - >>> res = refit.run() # doctest: +SKIP + >>> res = refit.run(dry_run=True) """ _cmd = '3drefit' - input_spec = RefitInputSpec - output_spec = AFNICommandOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs["out_file"] = os.path.abspath(self.inputs.in_file) - return outputs + _input_spec = RefitInputSpec + _output_spec = RefitOutputSpec class WarpInputSpec(AFNICommandInputSpec): - - in_file = File(desc='input file to 3dWarp', - argstr='%s', - position=-1, - mandatory=True, - exists=True, - copyfile=False) - - out_file = File(name_template="%s_warp", desc='output image file name', - argstr='-prefix %s', name_source="in_file") - + in_file = File(argstr='%s', position=-1, mandatory=True, exists=True, copyfile=False, + desc='input file to 3dWarp') + prefix = GenFile(template='{in_file}_warp', keep_extension=False, argstr='-prefix %s', + desc='output files prefix') + out_file = GenFile(template="{prefix}{output_type_}", desc='output image file name') tta2mni = traits.Bool(desc='transform dataset from Talairach to MNI152', argstr='-tta2mni') - mni2tta = traits.Bool(desc='transform dataset from MNI152 to Talaraich', argstr='-mni2tta') - matparent = File(desc="apply transformation from 3dWarpDrive", - argstr="-matparent %s", - exists=True) - + argstr="-matparent %s", exists=True) deoblique = traits.Bool(desc='transform dataset from oblique to cardinal', argstr='-deoblique') - - interp = traits.Enum(('linear', 'cubic', 'NN', 'quintic'), - desc='spatial interpolation methods [default = linear]', - argstr='-%s') - - gridset = File(desc="copy grid of specified dataset", - argstr="-gridset %s", - exists=True) - - newgrid = traits.Float(desc="specify grid of this size (mm)", - argstr="-newgrid %f") - - zpad = traits.Int(desc="pad input dataset with N planes" + - " of zero on all sides.", + interp = traits.Enum('linear', 'cubic', 'NN', 'quintic', argstr='-%s', + desc='spatial interpolation methods [default = linear]') + gridset = File(desc="copy grid of specified dataset", argstr="-gridset %s", exists=True) + newgrid = traits.Float(desc="specify grid of this size (mm)", argstr="-newgrid %f") + zpad = traits.Int(desc="pad input dataset with N planes of zero on all sides.", argstr="-zpad %d") class Warp(AFNICommand): + """Use 3dWarp for spatially transforming a dataset For complete details, see the `3dWarp Documentation. @@ -265,52 +213,42 @@ class Warp(AFNICommand): >>> warp = afni.Warp() >>> warp.inputs.in_file = 'structural.nii' >>> warp.inputs.deoblique = True - >>> warp.inputs.out_file = "trans.nii.gz" >>> warp.cmdline - '3dWarp -deoblique -prefix trans.nii.gz structural.nii' + '3dWarp -deoblique -prefix structural_warp structural.nii' >>> warp_2 = afni.Warp() >>> warp_2.inputs.in_file = 'structural.nii' >>> warp_2.inputs.newgrid = 1.0 - >>> warp_2.inputs.out_file = "trans.nii.gz" >>> warp_2.cmdline - '3dWarp -newgrid 1.000000 -prefix trans.nii.gz structural.nii' + '3dWarp -newgrid 1.000000 -prefix structural_warp structural.nii' """ _cmd = '3dWarp' - input_spec = WarpInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = WarpInputSpec + _output_spec = AFNICommandOutputSpec class ResampleInputSpec(AFNICommandInputSpec): - - in_file = File(desc='input file to 3dresample', - argstr='-inset %s', - position=-1, - mandatory=True, - exists=True, - copyfile=False) - - out_file = File(name_template="%s_resample", desc='output image file name', - argstr='-prefix %s', name_source="in_file") - - orientation = traits.Str(desc='new orientation code', - argstr='-orient %s') - - resample_mode = traits.Enum('NN', 'Li', 'Cu', 'Bk', - argstr='-rmode %s', - desc="resampling method from set {'NN', 'Li', 'Cu', 'Bk'}. These are for 'Nearest Neighbor', 'Linear', 'Cubic' and 'Blocky' interpolation, respectively. Default is NN.") - - voxel_size = traits.Tuple(*[traits.Float()] * 3, - argstr='-dxyz %f %f %f', + in_file = File(argstr='-inset %s', position=-1, mandatory=True, exists=True, copyfile=False, + desc='input file to 3dresample') + prefix = GenFile(template='{in_file}_resample', keep_extension=False, argstr='-prefix %s', + desc='output files prefix') + out_file = GenFile(template="{prefix}{output_type_}", keep_extension=False, + desc='output image file name') + orientation = traits.Str(desc='new orientation code', argstr='-orient %s') + resample_mode = traits.Enum( + 'NN', 'Li', 'Cu', 'Bk', argstr='-rmode %s', + desc="resampling method from set {'NN', 'Li', 'Cu', 'Bk'}. These are for 'Nearest " + "Neighbor', 'Linear', 'Cubic' and 'Blocky' interpolation, respectively.") + voxel_size = traits.Tuple(*[traits.Float()] * 3, argstr='-dxyz %f %f %f', desc="resample to new dx, dy and dz") - master = traits.File(argstr='-master %s', desc='align dataset grid to a reference file') class Resample(AFNICommand): + """Resample or reorient an image using AFNI 3dresample command For complete details, see the `3dresample Documentation. @@ -323,46 +261,36 @@ class Resample(AFNICommand): >>> resample = afni.Resample() >>> resample.inputs.in_file = 'functional.nii' >>> resample.inputs.orientation= 'RPI' - >>> resample.inputs.outputtype = "NIFTI" + >>> resample.inputs.output_type = "NIFTI" >>> resample.cmdline - '3dresample -orient RPI -prefix functional_resample.nii -inset functional.nii' - >>> res = resample.run() # doctest: +SKIP + '3dresample -orient RPI -prefix functional_resample -inset functional.nii' + >>> res = resample.run(dry_run=True) """ _cmd = '3dresample' - input_spec = ResampleInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = ResampleInputSpec + _output_spec = AFNICommandOutputSpec class AutoTcorrelateInputSpec(AFNICommandInputSpec): - in_file = File(desc='timeseries x space (volume or surface) file', - argstr='%s', - position=-1, - mandatory=True, - exists=True, - copyfile=False) - - polort = traits.Int( - desc='Remove polynomical trend of order m or -1 for no detrending', - argstr="-polort %d") - eta2 = traits.Bool(desc='eta^2 similarity', - argstr="-eta2") - mask = File(exists=True, desc="mask of voxels", - argstr="-mask %s") - mask_only_targets = traits.Bool(desc="use mask only on targets voxels", - argstr="-mask_only_targets", - xor=['mask_source']) - mask_source = File(exists=True, - desc="mask for source voxels", - argstr="-mask_source %s", - xor=['mask_only_targets']) - - out_file = File(name_template="%s_similarity_matrix.1D", desc='output image file name', - argstr='-prefix %s', name_source="in_file") + in_file = File(argstr='%s', position=-1, mandatory=True, exists=True, copyfile=False, + desc='timeseries x space (volume or surface) file') + polort = traits.Int(argstr="-polort %d", + desc='Remove polynomical trend of order m or -1 for no detrending') + eta2 = traits.Bool(desc='eta^2 similarity', argstr="-eta2") + mask = File(exists=True, desc="mask of voxels", argstr="-mask %s") + mask_only_targets = traits.Bool( + False, usedefault=True, argstr="-mask_only_targets", xor=['mask_source'], + desc="use mask only on targets voxels") + mask_source = File(exists=True, argstr="-mask_source %s", xor=['mask_only_targets'], + desc="mask for source voxels") + out_file = GenFile(template="{in_file}_similarity_matrix.1D", argstr='-prefix %s', + keep_extension=False, desc='output image file name') class AutoTcorrelate(AFNICommand): + """Computes the correlation coefficient between the time series of each pair of voxels in the input dataset, and stores the output into a new anatomical bucket dataset [scaled to shorts to save memory space]. @@ -379,38 +307,26 @@ class AutoTcorrelate(AFNICommand): >>> corr.inputs.mask_only_targets = True >>> corr.cmdline # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE '3dAutoTcorrelate -eta2 -mask mask.nii -mask_only_targets -prefix functional_similarity_matrix.1D -polort -1 functional.nii' - >>> res = corr.run() # doctest: +SKIP + >>> res = corr.run(dry_run=True) """ - input_spec = AutoTcorrelateInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = AutoTcorrelateInputSpec + _output_spec = AFNICommandOutputSpec _cmd = '3dAutoTcorrelate' - def _overload_extension(self, value, name=None): - path, base, ext = split_filename(value) - if ext.lower() not in [".1d", ".nii.gz", ".nii"]: - ext = ext + ".1D" - return os.path.join(path, base + ext) - class TStatInputSpec(AFNICommandInputSpec): - in_file = File(desc='input file to 3dTstat', - argstr='%s', - position=-1, - mandatory=True, - exists=True, - copyfile=False) - - out_file = File(name_template="%s_tstat", desc='output image file name', - argstr='-prefix %s', name_source="in_file") - - mask = File(desc='mask file', - argstr='-mask %s', - exists=True) - options = traits.Str(desc='selected statistical output', - argstr='%s') + in_file = File(argstr='%s', position=-1, mandatory=True, exists=True, copyfile=False, + desc='input file to 3dTstat') + prefix = GenFile(template='{in_file}_tstat', keep_extension=False, argstr='-prefix %s', + desc='output files prefix') + out_file = GenFile(template="{prefix}{output_type_}", keep_extension=False, + desc='output image file name') + mask = File(desc='mask file', argstr='-mask %s', exists=True) + options = traits.Str(desc='selected statistical output', argstr='%s') class TStat(AFNICommand): + """Compute voxel-wise statistics using AFNI 3dTstat command For complete details, see the `3dTstat Documentation. @@ -425,29 +341,27 @@ class TStat(AFNICommand): >>> tstat.inputs.args= '-mean' >>> tstat.inputs.out_file = "stats" >>> tstat.cmdline - '3dTstat -mean -prefix stats functional.nii' - >>> res = tstat.run() # doctest: +SKIP + '3dTstat -mean -prefix functional_tstat functional.nii' + >>> res = tstat.run(dry_run=True) """ _cmd = '3dTstat' - input_spec = TStatInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = TStatInputSpec + _output_spec = AFNICommandOutputSpec class DetrendInputSpec(AFNICommandInputSpec): - in_file = File(desc='input file to 3dDetrend', - argstr='%s', - position=-1, - mandatory=True, - exists=True, - copyfile=False) - - out_file = File(name_template="%s_detrend", desc='output image file name', - argstr='-prefix %s', name_source="in_file") + in_file = File(argstr='%s', position=-1, mandatory=True, exists=True, copyfile=False, + desc='input file to 3dDetrend') + prefix = GenFile(template='{in_file}_detrend', keep_extension=False, argstr='-prefix %s', + desc='output files prefix') + out_file = GenFile(template="{prefix}{output_type_}", keep_extension=False, + desc='output image file name') class Detrend(AFNICommand): + """This program removes components from voxel time series using linear least squares @@ -461,31 +375,29 @@ class Detrend(AFNICommand): >>> detrend = afni.Detrend() >>> detrend.inputs.in_file = 'functional.nii' >>> detrend.inputs.args = '-polort 2' - >>> detrend.inputs.outputtype = "AFNI" + >>> detrend.inputs.output_type = "AFNI" >>> detrend.cmdline '3dDetrend -polort 2 -prefix functional_detrend functional.nii' - >>> res = detrend.run() # doctest: +SKIP + >>> res = detrend.run(dry_run=True) """ _cmd = '3dDetrend' - input_spec = DetrendInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = DetrendInputSpec + _output_spec = AFNICommandOutputSpec class DespikeInputSpec(AFNICommandInputSpec): - in_file = File(desc='input file to 3dDespike', - argstr='%s', - position=-1, - mandatory=True, - exists=True, - copyfile=False) - - out_file = File(name_template="%s_despike", desc='output image file name', - argstr='-prefix %s', name_source="in_file") + in_file = File(argstr='%s', position=-1, mandatory=True, exists=True, copyfile=False, + desc='input file to 3dDespike') + prefix = GenFile(template='{in_file}_despike', keep_extension=False, argstr='-prefix %s', + desc='output files prefix') + out_file = GenFile(template="{prefix}{output_type_}", keep_extension=False, + desc='output image file name') class Despike(AFNICommand): + """Removes 'spikes' from the 3D+time input dataset For complete details, see the `3dDespike Documentation. @@ -499,51 +411,40 @@ class Despike(AFNICommand): >>> despike.inputs.in_file = 'functional.nii' >>> despike.cmdline '3dDespike -prefix functional_despike functional.nii' - >>> res = despike.run() # doctest: +SKIP + >>> res = despike.run(dry_run=True) """ _cmd = '3dDespike' - input_spec = DespikeInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = DespikeInputSpec + _output_spec = AFNICommandOutputSpec class AutomaskInputSpec(AFNICommandInputSpec): - in_file = File(desc='input file to 3dAutomask', - argstr='%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") - - brain_file = File(name_template="%s_masked", - desc="output file from 3dAutomask", - argstr='-apply_prefix %s', - name_source="in_file") - - clfrac = traits.Float(desc='sets the clip level fraction' + - ' (must be 0.1-0.9). ' + - 'A small value will tend to make the mask larger [default = 0.5].', - argstr="-clfrac %s") - - dilate = traits.Int(desc='dilate the mask outwards', - argstr="-dilate %s") - - erode = traits.Int(desc='erode the mask inwards', - argstr="-erode %s") - + in_file = File(argstr='%s', position=-1, mandatory=True, exists=True, copyfile=False, + desc='input file to 3dAutomask',) + prefix = GenFile(template="{in_file}_mask", argstr='-prefix %s', + desc='prefix for output images') + apply_prefix = GenFile(template="{in_file}_masked", argstr='-apply_prefix %s', + desc="output file from 3dAutomask") + clfrac = traits.Range(low=0.1, high=0.9, argstr='-clfrac %.2f', + desc='sets the clip level fraction. A small value will tend ' + 'to make the mask larger [default = 0.5].') + dilate = traits.Int(argstr="-dilate %s", desc='dilate the mask outwards') + erode = traits.Int(argstr="-erode %s", desc='erode the mask inwards') + + # Automatically generated output names + out_file = GenFile(template="{prefix}{output_type_}", desc='output image file name') + brain_file = GenFile(template="{apply_prefix}{output_type_}", + desc="output file from 3dAutomask") class AutomaskOutputSpec(TraitedSpec): - out_file = File(desc='mask file', - exists=True) - - brain_file = File(desc='brain file (skull stripped)', exists=True) + out_file = File(exists=True, desc='mask file') + brain_file = File(exists=True, desc='brain file (skull stripped)') class Automask(AFNICommand): + """Create a brain-only mask of the image using AFNI 3dAutomask command For complete details, see the `3dAutomask Documentation. @@ -556,64 +457,57 @@ class Automask(AFNICommand): >>> automask = afni.Automask() >>> automask.inputs.in_file = 'functional.nii' >>> automask.inputs.dilate = 1 - >>> automask.inputs.outputtype = "NIFTI" + >>> automask.inputs.output_type = "NIFTI" >>> automask.cmdline #doctest: +ELLIPSIS - '3dAutomask -apply_prefix functional_masked.nii -dilate 1 -prefix functional_mask.nii functional.nii' - >>> res = automask.run() # doctest: +SKIP + '3dAutomask -apply_prefix functional_masked -dilate 1 -prefix functional_mask functional.nii' + >>> res = automask.run(dry_run=True) + >>> res.outputs.get_traitsfree() + {'out_file': 'functional_mask.nii', 'brain_file': 'functional_masked.nii'} """ _cmd = '3dAutomask' - input_spec = AutomaskInputSpec - output_spec = AutomaskOutputSpec + _input_spec = AutomaskInputSpec + _output_spec = AutomaskOutputSpec class VolregInputSpec(AFNICommandInputSpec): - - in_file = File(desc='input file to 3dvolreg', - argstr='%s', - position=-1, - mandatory=True, - exists=True, - copyfile=False) - out_file = File(name_template="%s_volreg", desc='output image file name', - argstr='-prefix %s', name_source="in_file") - basefile = File(desc='base file for registration', - argstr='-base %s', - position=-6, - exists=True) - zpad = traits.Int(desc='Zeropad around the edges' + - ' by \'n\' voxels during rotations', - argstr='-zpad %d', - position=-5) - md1d_file = File(name_template='%s_md.1D', desc='max displacement output file', - argstr='-maxdisp1D %s', name_source="in_file", - keep_extension=True, position=-4) - oned_file = File(name_template='%s.1D', desc='1D movement parameters output file', - argstr='-1Dfile %s', - name_source="in_file", - keep_extension=True) + in_file = File(argstr='%s', position=-1, mandatory=True, exists=True, copyfile=False, + desc='input file to 3dvolreg') + prefix = GenFile(template="{in_file}_volreg", argstr='-prefix %s', + desc='output image file name') + basefile = File(argstr='-base %s', position=-6, exists=True, + desc='base file for registration') + zpad = traits.Int(argstr='-zpad %d', position=-5, + desc='Zeropad around the edges by \'n\' voxels during rotations') verbose = traits.Bool(desc='more detailed description of the process', argstr='-verbose') timeshift = traits.Bool(desc='time shift to mean slice time offset', argstr='-tshift 0') copyorigin = traits.Bool(desc='copy base file origin coords to output', argstr='-twodup') - oned_matrix_save = File(name_template='%s.aff12.1D', - desc='Save the matrix transformation', - argstr='-1Dmatrix_save %s', - keep_extension=True, - name_source="in_file") + + # Outputs + out_file = GenFile(template="{in_file}_volreg{output_type_}", + desc='output image file name') + md1d_file = GenFile(template='{in_file}_md.1D', argstr='-maxdisp1D %s', keep_extension=False, + position=-4, desc='max displacement output file') + oned_file = GenFile(template='{in_file}.1D', argstr='-1Dfile %s', keep_extension=False, + desc='1D movement parameters output file') + oned_matrix_save = GenFile(template='{in_file}.aff12.1D', argstr='-1Dmatrix_save %s', + keep_extension=False, desc='Save the matrix transformation') class VolregOutputSpec(TraitedSpec): - out_file = File(desc='registered file', exists=True) - md1d_file = File(desc='max displacement info file', exists=True) - oned_file = File(desc='movement parameters info file', exists=True) - oned_matrix_save = File(desc='matrix transformation from base to input', exists=True) + out_file = File(exists=True, desc='registered file') + md1d_file = File(exists=True, desc='max displacement info file') + oned_file = File(exists=True, desc='movement parameters info file') + oned_matrix_save = File( + desc='matrix transformation from base to input', exists=True) class Volreg(AFNICommand): + """Register input volumes to a base volume using AFNI 3dvolreg command For complete details, see the `3dvolreg Documentation. @@ -627,16 +521,16 @@ class Volreg(AFNICommand): >>> volreg.inputs.in_file = 'functional.nii' >>> volreg.inputs.args = '-Fourier -twopass' >>> volreg.inputs.zpad = 4 - >>> volreg.inputs.outputtype = "NIFTI" + >>> volreg.inputs.output_type = "NIFTI" >>> volreg.cmdline #doctest: +ELLIPSIS - '3dvolreg -Fourier -twopass -1Dfile functional.1D -1Dmatrix_save functional.aff12.1D -prefix functional_volreg.nii -zpad 4 -maxdisp1D functional_md.1D functional.nii' - >>> res = volreg.run() # doctest: +SKIP + '3dvolreg -Fourier -twopass -1Dfile functional.1D -1Dmatrix_save functional.aff12.1D -prefix functional_volreg -zpad 4 -maxdisp1D functional_md.1D functional.nii' + >>> res = volreg.run(dry_run=True) """ _cmd = '3dvolreg' - input_spec = VolregInputSpec - output_spec = VolregOutputSpec + _input_spec = VolregInputSpec + _output_spec = VolregOutputSpec class MergeInputSpec(AFNICommandInputSpec): @@ -646,8 +540,8 @@ class MergeInputSpec(AFNICommandInputSpec): position=-1, mandatory=True, copyfile=False) - out_file = File(name_template="%s_merge", desc='output image file name', - argstr='-prefix %s', name_source="in_file") + out_file = GenFile(template="{in_file}_merge", argstr='-prefix %s', + desc='output image file name') doall = traits.Bool(desc='apply options to all sub-bricks in dataset', argstr='-doall') blurfwhm = traits.Int(desc='FWHM blur value (mm)', @@ -656,6 +550,7 @@ class MergeInputSpec(AFNICommandInputSpec): class Merge(AFNICommand): + """Merge or edit volumes using AFNI 3dmerge command For complete details, see the `3dmerge Documentation. @@ -670,27 +565,25 @@ class Merge(AFNICommand): >>> merge.inputs.blurfwhm = 4 >>> merge.inputs.doall = True >>> merge.inputs.out_file = 'e7.nii' - >>> res = merge.run() # doctest: +SKIP + >>> res = merge.run(dry_run=True) """ _cmd = '3dmerge' - input_spec = MergeInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = MergeInputSpec + _output_spec = AFNICommandOutputSpec class CopyInputSpec(AFNICommandInputSpec): - in_file = File(desc='input file to 3dcopy', - argstr='%s', - position=-2, - mandatory=True, - exists=True, - copyfile=False) - out_file = File(name_template="%s_copy", desc='output image file name', - argstr='%s', position=-1, name_source="in_file") + in_file = File(desc='input file to 3dcopy', argstr='%s', position=-2, mandatory=True, + exists=True, copyfile=False) + out_file = GenFile( + template='{in_file}_copy{output_type_}', position=-1, + argstr='%s', desc='output image file name') class Copy(AFNICommand): + """Copies an image of one type to an image of the same or different type using 3dcopy command @@ -707,25 +600,28 @@ class Copy(AFNICommand): '3dcopy functional.nii functional_copy' >>> from copy import deepcopy - >>> copy3d_2 = deepcopy(copy3d) - >>> copy3d_2.inputs.outputtype = 'NIFTI' + >>> copy3d_2 = afni.Copy() + >>> copy3d_2.inputs.in_file = 'functional.nii' + >>> copy3d_2.inputs.output_type = 'NIFTI' >>> copy3d_2.cmdline '3dcopy functional.nii functional_copy.nii' - >>> copy3d_3 = deepcopy(copy3d) - >>> copy3d_3.inputs.outputtype = 'NIFTI_GZ' + >>> copy3d_3 = afni.Copy() + >>> copy3d_3.inputs.in_file = 'functional.nii' + >>> copy3d_3.inputs.output_type = 'NIFTI_GZ' >>> copy3d_3.cmdline '3dcopy functional.nii functional_copy.nii.gz' - >>> copy3d_4 = deepcopy(copy3d) + >>> copy3d_4 = afni.Copy() + >>> copy3d_4.inputs.in_file = 'functional.nii' >>> copy3d_4.inputs.out_file = 'new_func.nii' >>> copy3d_4.cmdline '3dcopy functional.nii new_func.nii' """ _cmd = '3dcopy' - input_spec = CopyInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = CopyInputSpec + _output_spec = AFNICommandOutputSpec class FourierInputSpec(AFNICommandInputSpec): @@ -748,6 +644,7 @@ class FourierInputSpec(AFNICommandInputSpec): class Fourier(AFNICommand): + """Program to lowpass and/or highpass each voxel time series in a dataset, via the FFT @@ -763,13 +660,13 @@ class Fourier(AFNICommand): >>> fourier.inputs.args = '-retrend' >>> fourier.inputs.highpass = 0.005 >>> fourier.inputs.lowpass = 0.1 - >>> res = fourier.run() # doctest: +SKIP + >>> res = fourier.run(dry_run=True) """ _cmd = '3dFourier' - input_spec = FourierInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = FourierInputSpec + _output_spec = AFNICommandOutputSpec class BandpassInputSpec(AFNICommandInputSpec): @@ -858,6 +755,7 @@ class BandpassInputSpec(AFNICommandInputSpec): class Bandpass(AFNICommand): + """Program to lowpass and/or highpass each voxel time series in a dataset, offering more/different options than Fourier @@ -873,13 +771,13 @@ class Bandpass(AFNICommand): >>> bandpass.inputs.in_file = example_data('functional.nii') >>> bandpass.inputs.highpass = 0.005 >>> bandpass.inputs.lowpass = 0.1 - >>> res = bandpass.run() # doctest: +SKIP + >>> res = bandpass.run(dry_run=True) """ _cmd = '3dBandpass' - input_spec = BandpassInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = BandpassInputSpec + _output_spec = AFNICommandOutputSpec class ZCutUpInputSpec(AFNICommandInputSpec): @@ -896,6 +794,7 @@ class ZCutUpInputSpec(AFNICommandInputSpec): class ZCutUp(AFNICommand): + """Cut z-slices from a volume using AFNI 3dZcutup command For complete details, see the `3dZcutup Documentation. @@ -909,13 +808,13 @@ class ZCutUp(AFNICommand): >>> zcutup.inputs.in_file = 'functional.nii' >>> zcutup.inputs.out_file = 'functional_zcutup.nii' >>> zcutup.inputs.keep= '0 10' - >>> res = zcutup.run() # doctest: +SKIP + >>> res = zcutup.run(dry_run=True) """ _cmd = '3dZcutup' - input_spec = ZCutUpInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = ZCutUpInputSpec + _output_spec = AFNICommandOutputSpec class AllineateInputSpec(AFNICommandInputSpec): @@ -934,7 +833,8 @@ class AllineateInputSpec(AFNICommandInputSpec): desc='output file from 3dAllineate', argstr='-prefix %s', position=-2, - name_source='%s_allineate', + name_source='in_file', + name_template='%s_allineate', genfile=True) out_param_file = File( @@ -1110,12 +1010,20 @@ class AllineateInputSpec(AFNICommandInputSpec): desc='To fix non-linear warp dependency along directions.') + def _format_arg(self, name, trait_spec, value): + if name == 'nwarp_fixmot' or name == 'nwarp_fixdep': + arg = ' '.join([trait_spec.argstr % v for v in value]) + return arg + return super(AllineateInputSpec, self)._format_arg(name, trait_spec, value) + + class AllineateOutputSpec(TraitedSpec): out_file = File(desc='output image file name') matrix = File(desc='matrix to align input file') class Allineate(AFNICommand): + """Program to align one dataset (the 'source') to a base dataset For complete details, see the `3dAllineate Documentation. @@ -1129,44 +1037,21 @@ class Allineate(AFNICommand): >>> allineate.inputs.in_file = 'functional.nii' >>> allineate.inputs.out_file= 'functional_allineate.nii' >>> allineate.inputs.in_matrix= 'cmatrix.mat' - >>> res = allineate.run() # doctest: +SKIP + >>> res = allineate.run(dry_run=True) """ _cmd = '3dAllineate' - input_spec = AllineateInputSpec - output_spec = AllineateOutputSpec - - def _format_arg(self, name, trait_spec, value): - if name == 'nwarp_fixmot' or name == 'nwarp_fixdep': - arg = ' '.join([trait_spec.argstr % v for v in value]) - return arg - return super(Allineate, self)._format_arg(name, trait_spec, value) - - def _list_outputs(self): - outputs = self.output_spec().get() - if not isdefined(self.inputs.out_file): - outputs['out_file'] = self._gen_filename(self.inputs.in_file, - suffix=self.inputs.suffix) - else: - outputs['out_file'] = os.path.abspath(self.inputs.out_file) - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._list_outputs()[name] + _input_spec = AllineateInputSpec + _output_spec = AllineateOutputSpec class MaskaveInputSpec(AFNICommandInputSpec): - in_file = File(desc='input file to 3dmaskave', - argstr='%s', - position=-2, - mandatory=True, - exists=True, - copyfile=False) - out_file = File(name_template="%s_maskave.1D", desc='output image file name', - keep_extension=True, - argstr="> %s", name_source="in_file", position=-1) + in_file = File(argstr='%s', position=-2, mandatory=True, exists=True, + copyfile=False, desc='input file to 3dmaskave') + out_file = GenFile( + template="{in_file}_maskave.1D", keep_extension=False, argstr="> %s", position=-1, + desc='output image file name',) mask = File(desc='matrix to align input file', argstr='-mask %s', position=1, @@ -1177,6 +1062,7 @@ class MaskaveInputSpec(AFNICommandInputSpec): class Maskave(AFNICommand): + """Computes average of all voxels in the input dataset which satisfy the criterion in the options list @@ -1193,13 +1079,13 @@ class Maskave(AFNICommand): >>> maskave.inputs.quiet= True >>> maskave.cmdline #doctest: +ELLIPSIS '3dmaskave -mask seed_mask.nii -quiet functional.nii > functional_maskave.1D' - >>> res = maskave.run() # doctest: +SKIP + >>> res = maskave.run(dry_run=True) """ _cmd = '3dmaskave' - input_spec = MaskaveInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = MaskaveInputSpec + _output_spec = AFNICommandOutputSpec class SkullStripInputSpec(AFNICommandInputSpec): @@ -1214,6 +1100,7 @@ class SkullStripInputSpec(AFNICommandInputSpec): class SkullStrip(AFNICommand): + """A program to extract the brain from surrounding tissue from MRI T1-weighted images @@ -1227,22 +1114,19 @@ class SkullStrip(AFNICommand): >>> skullstrip = afni.SkullStrip() >>> skullstrip.inputs.in_file = 'functional.nii' >>> skullstrip.inputs.args = '-o_ply' - >>> res = skullstrip.run() # doctest: +SKIP + >>> res = skullstrip.run(dry_run=True) """ _cmd = '3dSkullStrip' - _redirect_x = True - input_spec = SkullStripInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = SkullStripInputSpec + _output_spec = AFNICommandOutputSpec + redirect_x = True def __init__(self, **inputs): super(SkullStrip, self).__init__(**inputs) - if not no_afni(): - v = Info.version() - - # As of AFNI 16.0.00, redirect_x is not needed - if isinstance(v[0], int) and v[0] > 15: - self._redirect_x = False + # As of AFNI 16.0.00, redirect_x is not needed + if self.version_major > 15: + self.redirect_x = False class TCatInputSpec(AFNICommandInputSpec): @@ -1259,6 +1143,7 @@ class TCatInputSpec(AFNICommandInputSpec): class TCat(AFNICommand): + """Concatenate sub-bricks from input datasets into one big 3D+time dataset @@ -1273,13 +1158,13 @@ class TCat(AFNICommand): >>> tcat.inputs.in_files = ['functional.nii', 'functional2.nii'] >>> tcat.inputs.out_file= 'functional_tcat.nii' >>> tcat.inputs.rlt = '+' - >>> res = tcat.run() # doctest: +SKIP + >>> res = tcat.run(dry_run=True) """ _cmd = '3dTcat' - input_spec = TCatInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = TCatInputSpec + _output_spec = AFNICommandOutputSpec class FimInputSpec(AFNICommandInputSpec): @@ -1303,6 +1188,7 @@ class FimInputSpec(AFNICommandInputSpec): class Fim(AFNICommand): + """Program to calculate the cross-correlation of an ideal reference waveform with the measured FMRI time series for each voxel @@ -1320,13 +1206,13 @@ class Fim(AFNICommand): >>> fim.inputs.out_file = 'functional_corr.nii' >>> fim.inputs.out = 'Correlation' >>> fim.inputs.fim_thr = 0.0009 - >>> res = fim.run() # doctest: +SKIP + >>> res = fim.run(dry_run=True) """ _cmd = '3dfim+' - input_spec = FimInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = FimInputSpec + _output_spec = AFNICommandOutputSpec class TCorrelateInputSpec(AFNICommandInputSpec): @@ -1353,6 +1239,7 @@ class TCorrelateInputSpec(AFNICommandInputSpec): class TCorrelate(AFNICommand): + """Computes the correlation coefficient between corresponding voxel time series in two input 3D+time datasets 'xset' and 'yset' @@ -1366,35 +1253,26 @@ class TCorrelate(AFNICommand): >>> tcorrelate = afni.TCorrelate() >>> tcorrelate.inputs.xset= 'u_rc1s1_Template.nii' >>> tcorrelate.inputs.yset = 'u_rc1s2_Template.nii' - >>> tcorrelate.inputs.out_file = 'functional_tcorrelate.nii.gz' >>> tcorrelate.inputs.polort = -1 >>> tcorrelate.inputs.pearson = True - >>> res = tcarrelate.run() # doctest: +SKIP + >>> res = tcorrelate.run(dry_run=True) """ _cmd = '3dTcorrelate' - input_spec = TCorrelateInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = TCorrelateInputSpec + _output_spec = AFNICommandOutputSpec class TCorr1DInputSpec(AFNICommandInputSpec): - xset = File(desc='3d+time dataset input', - argstr=' %s', - position=-2, - mandatory=True, - exists=True, - copyfile=False) - y_1d = File(desc='1D time series file input', - argstr=' %s', - position=-1, - mandatory=True, - exists=True) - out_file = File(desc='output filename prefix', - name_template='%s_correlation.nii.gz', - argstr='-prefix %s', - name_source='xset', - keep_extension=True) + xset = File(argstr='%s', position=-2, mandatory=True, exists=True, + copyfile=False, desc='3d+time dataset input') + prefix = GenFile(template='{xset}_correlation', keep_extension=False, + argstr='-prefix %s', desc='output files prefix') + y_1d = File(argstr='%s', position=-1, mandatory=True, exists=True, + desc='1D time series file input') + out_file = File(name_template='{prefix}{output_type_}', keep_extension=False, + desc='output filename prefix') pearson = traits.Bool(desc='Correlation is the normal' + ' Pearson correlation coefficient', argstr=' -pearson', @@ -1423,6 +1301,7 @@ class TCorr1DOutputSpec(TraitedSpec): class TCorr1D(AFNICommand): + """Computes the correlation coefficient between each voxel time series in the input 3D+time dataset. For complete details, see the `3dTcorr1D Documentation. @@ -1433,30 +1312,22 @@ class TCorr1D(AFNICommand): >>> tcorr1D.inputs.xset= 'u_rc1s1_Template.nii' >>> tcorr1D.inputs.y_1d = 'seed.1D' >>> tcorr1D.cmdline - '3dTcorr1D -prefix u_rc1s1_Template_correlation.nii.gz u_rc1s1_Template.nii seed.1D' - >>> res = tcorr1D.run() # doctest: +SKIP + '3dTcorr1D -prefix u_rc1s1_Template_correlation u_rc1s1_Template.nii seed.1D' + >>> res = tcorr1D.run(dry_run=True) """ _cmd = '3dTcorr1D' - input_spec = TCorr1DInputSpec - output_spec = TCorr1DOutputSpec + _input_spec = TCorr1DInputSpec + _output_spec = TCorr1DOutputSpec class BrickStatInputSpec(AFNICommandInputSpec): - in_file = File(desc='input file to 3dmaskave', - argstr='%s', - position=-1, - mandatory=True, - exists=True) - - mask = File(desc='-mask dset = use dset as mask to include/exclude voxels', - argstr='-mask %s', - position=2, - exists=True) - - min = traits.Bool(desc='print the minimum value in dataset', - argstr='-min', - position=1) + in_file = File(argstr='%s', position=-1, mandatory=True, exists=True, + desc='input file to 3dmaskave') + mask = File(argstr='-mask %s', position=2, exists=True, + desc='-mask dset = use dset as mask to include/exclude voxels') + min = traits.Bool(argstr='-min', position=1, + desc='print the minimum value in dataset') class BrickStatOutputSpec(TraitedSpec): @@ -1464,6 +1335,7 @@ class BrickStatOutputSpec(TraitedSpec): class BrickStat(AFNICommand): + """Compute maximum and/or minimum voxel values of an input dataset For complete details, see the `3dBrickStat Documentation. @@ -1477,12 +1349,12 @@ class BrickStat(AFNICommand): >>> brickstat.inputs.in_file = 'functional.nii' >>> brickstat.inputs.mask = 'skeleton_mask.nii.gz' >>> brickstat.inputs.min = True - >>> res = brickstat.run() # doctest: +SKIP + >>> res = brickstat.run(dry_run=True) """ _cmd = '3dBrickStat' - input_spec = BrickStatInputSpec - output_spec = BrickStatOutputSpec + _input_spec = BrickStatInputSpec + _output_spec = BrickStatOutputSpec def aggregate_outputs(self, runtime=None, needed_outputs=None): @@ -1510,7 +1382,6 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None): save_json(outfile, dict(stat=min_val)) outputs.min_val = min_val - return outputs class ROIStatsInputSpec(CommandLineInputSpec): @@ -1560,12 +1431,12 @@ class ROIStats(AFNICommandBase): >>> roistats.inputs.in_file = 'functional.nii' >>> roistats.inputs.mask = 'skeleton_mask.nii.gz' >>> roistats.inputs.quiet=True - >>> res = roistats.run() # doctest: +SKIP + >>> res = roistats.run(dry_run=True) """ _cmd = '3dROIstats' - input_spec = ROIStatsInputSpec - output_spec = ROIStatsOutputSpec + _input_spec = ROIStatsInputSpec + _output_spec = ROIStatsOutputSpec def aggregate_outputs(self, runtime=None, needed_outputs=None): outputs = self._outputs() @@ -1575,7 +1446,6 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None): f.close() outputs.stats = os.path.abspath(output_filename) - return outputs class CalcInputSpec(AFNICommandInputSpec): @@ -1596,8 +1466,20 @@ class CalcInputSpec(AFNICommandInputSpec): single_idx = traits.Int(desc='volume index for in_file_a') other = File(desc='other options', argstr='') + def _format_arg(self, name, trait_spec, value): + if name == 'in_file_a': + arg = trait_spec.argstr % value + if isdefined(self.start_idx): + arg += '[%d..%d]' % (self.start_idx, + self.stop_idx) + if isdefined(self.single_idx): + arg += '[%d]' % (self.single_idx) + return arg + return super(CalcInputSpec, self)._format_arg(name, trait_spec, value) + class Calc(AFNICommand): + """This program does voxel-by-voxel arithmetic on 3D datasets For complete details, see the `3dcalc Documentation. @@ -1612,32 +1494,15 @@ class Calc(AFNICommand): >>> calc.inputs.in_file_b = 'functional2.nii' >>> calc.inputs.expr='a*b' >>> calc.inputs.out_file = 'functional_calc.nii.gz' - >>> calc.inputs.outputtype = "NIFTI" + >>> calc.inputs.output_type = "NIFTI" >>> calc.cmdline #doctest: +ELLIPSIS '3dcalc -a functional.nii -b functional2.nii -expr "a*b" -prefix functional_calc.nii.gz' """ _cmd = '3dcalc' - input_spec = CalcInputSpec - output_spec = AFNICommandOutputSpec - - def _format_arg(self, name, trait_spec, value): - if name == 'in_file_a': - arg = trait_spec.argstr % value - if isdefined(self.inputs.start_idx): - arg += '[%d..%d]' % (self.inputs.start_idx, - self.inputs.stop_idx) - if isdefined(self.inputs.single_idx): - arg += '[%d]' % (self.inputs.single_idx) - return arg - return super(Calc, self)._format_arg(name, trait_spec, value) - - def _parse_inputs(self, skip=None): - """Skip the arguments without argstr metadata - """ - return super(Calc, self)._parse_inputs( - skip=('start_idx', 'stop_idx', 'other')) + _input_spec = CalcInputSpec + _output_spec = AFNICommandOutputSpec class BlurInMaskInputSpec(AFNICommandInputSpec): @@ -1648,8 +1513,10 @@ class BlurInMaskInputSpec(AFNICommandInputSpec): mandatory=True, exists=True, copyfile=False) - out_file = File(name_template='%s_blur', desc='output to the file', argstr='-prefix %s', - name_source='in_file', position=-1) + prefix = GenFile(template='{in_file}_blur', keep_extension=False, argstr='-prefix %s', + desc='output files prefix') + out_file = GenFile(template='{prefix}{output_type_}', keep_extension=False, + desc='output to the file') mask = File( desc='Mask dataset, if desired. Blurring will occur only within the mask. Voxels NOT in the mask will be set to zero in the output.', argstr='-mask %s') @@ -1673,6 +1540,7 @@ class BlurInMaskInputSpec(AFNICommandInputSpec): class BlurInMask(AFNICommand): + """ Blurs a dataset spatially inside a mask. That's all. Experimental. For complete details, see the `3dBlurInMask Documentation. @@ -1693,12 +1561,13 @@ class BlurInMask(AFNICommand): """ _cmd = '3dBlurInMask' - input_spec = BlurInMaskInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = BlurInMaskInputSpec + _output_spec = AFNICommandOutputSpec class TCorrMapInputSpec(AFNICommandInputSpec): - in_file = File(exists=True, argstr='-input %s', mandatory=True, copyfile=False) + in_file = File( + exists=True, argstr='-input %s', mandatory=True, copyfile=False) seeds = File(exists=True, argstr='-seed %s', xor=('seeds_width')) mask = File(exists=True, argstr='-mask %s') automask = traits.Bool(argstr='-automask') @@ -1749,9 +1618,19 @@ class TCorrMapInputSpec(AFNICommandInputSpec): histogram = File( name_source='in_file', argstr='-Hist %d %s', suffix='_hist') + def _format_arg(self, name, trait_spec, value): + if name in self._thresh_opts: + return trait_spec.argstr % self.thresholds + [value] + elif name in self._expr_opts: + return trait_spec.argstr % (self.expr, value) + elif name == 'histogram': + return trait_spec.argstr % (self.histogram_bin_numbers, + value) + else: + return super(TCorrMapInputSpec, self)._format_arg(name, trait_spec, value) -class TCorrMapOutputSpec(TraitedSpec): +class TCorrMapOutputSpec(TraitedSpec): mean_file = File() zmean = File() qmean = File() @@ -1768,6 +1647,7 @@ class TCorrMapOutputSpec(TraitedSpec): class TCorrMap(AFNICommand): + """ For each voxel time series, computes the correlation between it and all other voxels, and combines this set of values into the output dataset(s) in some way. @@ -1788,20 +1668,10 @@ class TCorrMap(AFNICommand): """ _cmd = '3dTcorrMap' - input_spec = TCorrMapInputSpec - output_spec = TCorrMapOutputSpec + _input_spec = TCorrMapInputSpec + _output_spec = TCorrMapOutputSpec _additional_metadata = ['suffix'] - def _format_arg(self, name, trait_spec, value): - if name in self.inputs._thresh_opts: - return trait_spec.argstr % self.inputs.thresholds + [value] - elif name in self.inputs._expr_opts: - return trait_spec.argstr % (self.inputs.expr, value) - elif name == 'histogram': - return trait_spec.argstr % (self.inputs.histogram_bin_numbers, - value) - else: - return super(TCorrMap, self)._format_arg(name, trait_spec, value) class AutoboxInputSpec(AFNICommandInputSpec): @@ -1831,6 +1701,7 @@ class AutoboxOuputSpec(TraitedSpec): # out_file not mandatory class Autobox(AFNICommand): + """ Computes size of a box that fits around the volume. Also can be used to crop the volume to that box. @@ -1849,8 +1720,8 @@ class Autobox(AFNICommand): """ _cmd = '3dAutobox' - input_spec = AutoboxInputSpec - output_spec = AutoboxOuputSpec + _input_spec = AutoboxInputSpec + _output_spec = AutoboxOuputSpec def aggregate_outputs(self, runtime=None, needed_outputs=None): outputs = self._outputs() @@ -1863,7 +1734,6 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None): d[k] = int(d[k]) outputs.set(**d) outputs.set(out_file=self._gen_filename('out_file')) - return outputs def _gen_filename(self, name): if name == 'out_file' and (not isdefined(self.inputs.out_file)): @@ -1878,7 +1748,8 @@ class RetroicorInputSpec(AFNICommandInputSpec): mandatory=True, exists=True, copyfile=False) - out_file = File(desc='output image file name', argstr='-prefix %s', mandatory=True, position=1) + out_file = File( + desc='output image file name', argstr='-prefix %s', mandatory=True, position=1) card = File(desc='1D cardiac data file for cardiac correction', argstr='-card %s', position=-2, @@ -1905,6 +1776,7 @@ class RetroicorInputSpec(AFNICommandInputSpec): class Retroicor(AFNICommand): + """Performs Retrospective Image Correction for physiological motion effects, using a slightly modified version of the RETROICOR algorithm @@ -1936,8 +1808,8 @@ class Retroicor(AFNICommand): """ _cmd = '3dretroicor' - input_spec = RetroicorInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = RetroicorInputSpec + _output_spec = AFNICommandOutputSpec class AFNItoNIFTIInputSpec(AFNICommandInputSpec): @@ -1948,11 +1820,12 @@ class AFNItoNIFTIInputSpec(AFNICommandInputSpec): exists=True, copyfile=False) out_file = File(name_template="%s.nii", desc='output image file name', - argstr='-prefix %s', name_source="in_file") + argstr='-prefix %s', name_source="in_file", keep_extension=False) hash_files = False class AFNItoNIFTI(AFNICommand): + """Changes AFNI format files to NIFTI format using 3dAFNItoNIFTI see AFNI Documentation: @@ -1971,17 +1844,8 @@ class AFNItoNIFTI(AFNICommand): """ _cmd = '3dAFNItoNIFTI' - input_spec = AFNItoNIFTIInputSpec - output_spec = AFNICommandOutputSpec - - def _overload_extension(self, value): - path, base, ext = split_filename(value) - if ext.lower() not in [".1d", ".nii.gz", ".1D"]: - ext = ext + ".nii" - return os.path.join(path, base + ext) - - def _gen_filename(self, name): - return os.path.abspath(super(AFNItoNIFTI, self)._gen_filename(name)) + _input_spec = AFNItoNIFTIInputSpec + _output_spec = AFNICommandOutputSpec class EvalInputSpec(AFNICommandInputSpec): @@ -2004,8 +1868,26 @@ class EvalInputSpec(AFNICommandInputSpec): single_idx = traits.Int(desc='volume index for in_file_a') other = File(desc='other options', argstr='') + def _format_arg(self, name, trait_spec, value): + if name == 'in_file_a': + arg = trait_spec.argstr % value + if isdefined(self.start_idx): + arg += '[%d..%d]' % (self.start_idx, + self.stop_idx) + if isdefined(self.single_idx): + arg += '[%d]' % (self.single_idx) + return arg + return super(EvalInputSpec, self)._format_arg(name, trait_spec, value) + + def parse_args(self, skip=None): + """Skip the arguments without argstr metadata + """ + return super(EvalInputSpec, self).parse_args( + skip=('start_idx', 'stop_idx', 'out1D', 'other')) + class Eval(AFNICommand): + """Evaluates an expression that may include columns of data from one or more text files see AFNI Documentation: @@ -2026,25 +1908,8 @@ class Eval(AFNICommand): """ _cmd = '1deval' - input_spec = EvalInputSpec - output_spec = AFNICommandOutputSpec - - def _format_arg(self, name, trait_spec, value): - if name == 'in_file_a': - arg = trait_spec.argstr % value - if isdefined(self.inputs.start_idx): - arg += '[%d..%d]' % (self.inputs.start_idx, - self.inputs.stop_idx) - if isdefined(self.inputs.single_idx): - arg += '[%d]' % (self.inputs.single_idx) - return arg - return super(Eval, self)._format_arg(name, trait_spec, value) - - def _parse_inputs(self, skip=None): - """Skip the arguments without argstr metadata - """ - return super(Eval, self)._parse_inputs( - skip=('start_idx', 'stop_idx', 'out1D', 'other')) + _input_spec = EvalInputSpec + _output_spec = AFNICommandOutputSpec class MeansInputSpec(AFNICommandInputSpec): @@ -2064,12 +1929,15 @@ class MeansInputSpec(AFNICommandInputSpec): std_dev = traits.Bool(desc='calculate std dev', argstr='-stdev') sqr = traits.Bool(desc='mean square instead of value', argstr='-sqr') summ = traits.Bool(desc='take sum, (not average)', argstr='-sum') - count = traits.Bool(desc='compute count of non-zero voxels', argstr='-count') - mask_inter = traits.Bool(desc='create intersection mask', argstr='-mask_inter') + count = traits.Bool( + desc='compute count of non-zero voxels', argstr='-count') + mask_inter = traits.Bool( + desc='create intersection mask', argstr='-mask_inter') mask_union = traits.Bool(desc='create union mask', argstr='-mask_union') class Means(AFNICommand): + """Takes the voxel-by-voxel mean of all input datasets using 3dMean see AFNI Documentation: @@ -2088,17 +1956,20 @@ class Means(AFNICommand): """ _cmd = '3dMean' - input_spec = MeansInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = MeansInputSpec + _output_spec = AFNICommandOutputSpec class HistInputSpec(CommandLineInputSpec): in_file = File( desc='input file to 3dHist', argstr='-input %s', position=1, mandatory=True, exists=True, copyfile=False) - out_file = File( - desc='Write histogram to niml file with this prefix', name_template='%s_hist', - keep_extension=False, argstr='-prefix %s', name_source=['in_file']) + prefix = GenFile( + template='{in_file}_hist', keep_extension=False, argstr='-prefix %s', + desc='Write histogram to niml file with this prefix') + out_file = GenFile( + template='{prefix}.niml.hist', keep_extension=False, + desc='Write histogram to niml file with this prefix') showhist = traits.Bool(False, usedefault=True, desc='write a text visual histogram', argstr='-showhist') out_show = File( @@ -2110,8 +1981,15 @@ class HistInputSpec(CommandLineInputSpec): min_value = traits.Float(argstr='-min %f', desc='minimum intensity value') bin_width = traits.Float(argstr='-binwidth %f', desc='bin width') + def parse_args(self, skip=None): + if not self.showhist: + if skip is None: + skip = [] + skip += ['out_show'] + return super(HistInputSpec, self).parse_args(skip=skip) + class HistOutputSpec(TraitedSpec): - out_file = File(desc='output file', exists=True) + out_file = File(desc='output file') out_show = File(desc='output visual histogram') @@ -2130,46 +2008,34 @@ class Hist(AFNICommandBase): >>> hist.inputs.in_file = 'functional.nii' >>> hist.cmdline '3dHist -input functional.nii -prefix functional_hist' - >>> res = hist.run() # doctest: +SKIP + >>> res = hist.run(dry_run=True) """ _cmd = '3dHist' - input_spec = HistInputSpec - output_spec = HistOutputSpec - _redirect_x = True + _input_spec = HistInputSpec + _output_spec = HistOutputSpec + redirect_x = True def __init__(self, **inputs): super(Hist, self).__init__(**inputs) - if not no_afni(): - version = Info.version() - - # As of AFNI 16.0.00, redirect_x is not needed - if isinstance(version[0], int) and version[0] > 15: - self._redirect_x = False - - def _parse_inputs(self, skip=None): - if not self.inputs.showhist: - if skip is None: - skip = [] - skip += ['out_show'] - return super(Hist, self)._parse_inputs(skip=skip) + # As of AFNI 16.0.00, redirect_x is not needed + if self.version_major > 15: + self.redirect_x = False - def _list_outputs(self): - outputs = super(Hist, self)._list_outputs() - outputs['out_file'] += '.niml.hist' + def _post_run(self): if not self.inputs.showhist: - outputs['out_show'] = Undefined - return outputs + self.outputs.out_show = Undefined class FWHMxInputSpec(CommandLineInputSpec): in_file = File(desc='input dataset', argstr='-input %s', mandatory=True, exists=True) - out_file = File(argstr='> %s', name_source='in_file', name_template='%s_fwhmx.out', - position=-1, keep_extension=False, desc='output file') - out_subbricks = File(argstr='-out %s', name_source='in_file', name_template='%s_subbricks.out', - keep_extension=False, desc='output file listing the subbricks FWHM') + out_file = GenFile(argstr='> %s', template='{in_file}_fwhmx.out', position=-1, + keep_extension=False, desc='output file') + out_subbricks = GenFile( + argstr='-out %s', template='{in_file}_subbricks.out', + keep_extension=False, desc='output file listing the subbricks FWHM') mask = File(desc='use only voxels that are nonzero in mask', argstr='-mask %s', exists=True) automask = traits.Bool(False, usedefault=True, argstr='-automask', desc='compute a mask from THIS dataset, a la 3dAutomask') @@ -2197,8 +2063,48 @@ class FWHMxInputSpec(CommandLineInputSpec): combine = traits.Bool(argstr='-combine', desc='combine the final measurements along each axis') compat = traits.Bool(argstr='-compat', desc='be compatible with the older 3dFWHM') acf = traits.Either( - traits.Bool(), File(), traits.Tuple(File(exists=True), traits.Float()), - default=False, usedefault=True, argstr='-acf', desc='computes the spatial autocorrelation') + traits.Bool(), File(), traits.Tuple(File(exists=True), traits.Float()), default=False, + usedefault=True, argstr='-acf', desc='computes the spatial autocorrelation') + + def parse_args(self, skip=None): + if not self.detrend: + if skip is None: + skip = [] + skip += ['out_detrend'] + return super(FWHMxInputSpec, self).parse_args(skip=skip) + + def arg_used(self, name): + return self._format_arg(name) is None + + def _format_arg(self, name, trait_spec=None, value=None): + if trait_spec is None: + trait_spec = self.traits()[name] + + if value is None: + value = getattr(self, name) + + if name == 'detrend': + if isinstance(value, bool): + if value: + return trait_spec.argstr + else: + return None + elif isinstance(value, int): + return trait_spec.argstr + ' %d' % value + + if name == 'acf': + if value is None: + return None + if isinstance(value, bool): + if value: + return trait_spec.argstr + else: + return None + elif isinstance(value, tuple): + return trait_spec.argstr + ' %s %f' % value + elif isinstance(value, string_types): + return trait_spec.argstr + ' ' + value + return super(FWHMxInputSpec, self)._format_arg(name, trait_spec, value) class FWHMxOutputSpec(TraitedSpec): @@ -2315,60 +2221,29 @@ class FWHMx(AFNICommandBase): """ _cmd = '3dFWHMx' - input_spec = FWHMxInputSpec - output_spec = FWHMxOutputSpec - _acf = True + _input_spec = FWHMxInputSpec + _output_spec = FWHMxOutputSpec - def _parse_inputs(self, skip=None): - if not self.inputs.detrend: - if skip is None: - skip = [] - skip += ['out_detrend'] - return super(FWHMx, self)._parse_inputs(skip=skip) - - def _format_arg(self, name, trait_spec, value): - if name == 'detrend': - if isinstance(value, bool): - if value: - return trait_spec.argstr - else: - return None - elif isinstance(value, int): - return trait_spec.argstr + ' %d' % value - - if name == 'acf': - if isinstance(value, bool): - if value: - return trait_spec.argstr - else: - self._acf = False - return None - elif isinstance(value, tuple): - return trait_spec.argstr + ' %s %f' % value - elif isinstance(value, string_types): - return trait_spec.argstr + ' ' + value - return super(FWHMx, self)._format_arg(name, trait_spec, value) - - def _list_outputs(self): - outputs = super(FWHMx, self)._list_outputs() + def _post_run(self): + super(FWHMx, self)._post_run() if self.inputs.detrend: fname, ext = op.splitext(self.inputs.in_file) if '.gz' in ext: _, ext2 = op.splitext(fname) ext = ext2 + ext - outputs['out_detrend'] += ext + self.outputs.out_detrend += ext else: - outputs['out_detrend'] = Undefined + self.outputs.out_detrend = Undefined - sout = np.loadtxt(outputs['out_file']) #pylint: disable=E1101 - if self._acf: - outputs['acf_param'] = tuple(sout[1]) + sout = np.loadtxt(self.outputs.out_file) #pylint: disable=E1101 + if self.inputs.arg_used('acf'): + self.outputs.acf_param = tuple(sout[1]) sout = tuple(sout[0]) - outputs['out_acf'] = op.abspath('3dFWHMx.1D') + self.outputs.out_acf = op.abspath('3dFWHMx.1D') if isinstance(self.inputs.acf, string_types): - outputs['out_acf'] = op.abspath(self.inputs.acf) + self.outputs.out_acf = op.abspath(self.inputs.acf) + + self.outputs.fwhm = tuple(sout) - outputs['fwhm'] = tuple(sout) - return outputs diff --git a/nipype/interfaces/afni/svm.py b/nipype/interfaces/afni/svm.py index c2bb335d32..6f9c69d4e3 100644 --- a/nipype/interfaces/afni/svm.py +++ b/nipype/interfaces/afni/svm.py @@ -8,21 +8,14 @@ >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data')) >>> os.chdir(datadir) """ -import warnings -import os -import re +from ..base import traits, File, TraitedSpec +from .base import AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec -from ..base import (Directory, TraitedSpec, - traits, isdefined, File, InputMultiPath, Undefined) -from ...utils.filemanip import (load_json, save_json, split_filename) -from nipype.utils.filemanip import fname_presuffix -from .base import AFNICommand, AFNICommandInputSpec,\ - AFNICommandOutputSpec -from nipype.interfaces.base import CommandLineInputSpec, CommandLine,\ - OutputMultiPath +from ... import logging -warn = warnings.warn +IFLOGGER = logging.getLogger('interface') +warn = IFLOGGER.warn class SVMTrainInputSpec(AFNICommandInputSpec): @@ -100,8 +93,8 @@ class SVMTrain(AFNICommand): """ _cmd = '3dsvm' - input_spec = SVMTrainInputSpec - output_spec = SVMTrainOutputSpec + _input_spec = SVMTrainInputSpec + _output_spec = SVMTrainOutputSpec _additional_metadata = ['suffix'] def _format_arg(self, name, trait_spec, value): @@ -153,5 +146,5 @@ class SVMTest(AFNICommand): """ _cmd = '3dsvm' - input_spec = SVMTestInputSpec - output_spec = AFNICommandOutputSpec + _input_spec = SVMTestInputSpec + _output_spec = AFNICommandOutputSpec diff --git a/nipype/interfaces/afni/tests/test_auto_AFNICommand.py b/nipype/interfaces/afni/tests/test_auto_AFNICommand.py index f822168eb8..a00c44d21e 100644 --- a/nipype/interfaces/afni/tests/test_auto_AFNICommand.py +++ b/nipype/interfaces/afni/tests/test_auto_AFNICommand.py @@ -6,23 +6,20 @@ def test_AFNICommand_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - out_file=dict(argstr='-prefix %s', - name_source=['in_file'], - name_template='%s_afni', - ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = AFNICommand.input_spec() + inputs = AFNICommand._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_AFNICommand_outputs(): + output_map = dict() + outputs = AFNICommand._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_AFNICommandBase.py b/nipype/interfaces/afni/tests/test_auto_AFNICommandBase.py index 9052c5345a..3ea9bac7cc 100644 --- a/nipype/interfaces/afni/tests/test_auto_AFNICommandBase.py +++ b/nipype/interfaces/afni/tests/test_auto_AFNICommandBase.py @@ -6,18 +6,18 @@ def test_AFNICommandBase_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - terminal_output=dict(nohash=True, - ), ) - inputs = AFNICommandBase.input_spec() + inputs = AFNICommandBase._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_AFNICommandBase_outputs(): + output_map = dict() + outputs = AFNICommandBase._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_AFNItoNIFTI.py b/nipype/interfaces/afni/tests/test_auto_AFNItoNIFTI.py index 1e46cccd56..25d85c0ff0 100644 --- a/nipype/interfaces/afni/tests/test_auto_AFNItoNIFTI.py +++ b/nipype/interfaces/afni/tests/test_auto_AFNItoNIFTI.py @@ -6,26 +6,20 @@ def test_AFNItoNIFTI_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, position=-1, ), out_file=dict(argstr='-prefix %s', + keep_extension=False, name_source='in_file', name_template='%s.nii', ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = AFNItoNIFTI.input_spec() + inputs = AFNItoNIFTI._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +29,7 @@ def test_AFNItoNIFTI_inputs(): def test_AFNItoNIFTI_outputs(): output_map = dict(out_file=dict(), ) - outputs = AFNItoNIFTI.output_spec() + outputs = AFNItoNIFTI._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Allineate.py b/nipype/interfaces/afni/tests/test_auto_Allineate.py index 27a1cc5dae..63c3b02ddf 100644 --- a/nipype/interfaces/afni/tests/test_auto_Allineate.py +++ b/nipype/interfaces/afni/tests/test_auto_Allineate.py @@ -20,18 +20,12 @@ def test_Allineate_inputs(): ), cost=dict(argstr='-cost %s', ), - environ=dict(nohash=True, - usedefault=True, - ), epi=dict(argstr='-EPI', ), final_interpolation=dict(argstr='-final %s', ), fine_blur=dict(argstr='-fineblur %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-source %s', copyfile=False, mandatory=True, @@ -64,7 +58,8 @@ def test_Allineate_inputs(): ), out_file=dict(argstr='-prefix %s', genfile=True, - name_source='%s_allineate', + name_source='in_file', + name_template='%s_allineate', position=-2, ), out_matrix=dict(argstr='-1Dmatrix_save %s', @@ -73,7 +68,8 @@ def test_Allineate_inputs(): ), out_weight_file=dict(argstr='-wtprefix %s', ), - outputtype=dict(), + output_type=dict(usedefault=True, + ), reference=dict(argstr='-base %s', ), replacebase=dict(argstr='-replacebase', @@ -84,8 +80,6 @@ def test_Allineate_inputs(): ), source_mask=dict(argstr='-source_mask %s', ), - terminal_output=dict(nohash=True, - ), two_best=dict(argstr='-twobest %d', ), two_blur=dict(argstr='-twoblur', @@ -105,7 +99,7 @@ def test_Allineate_inputs(): zclip=dict(argstr='-zclip', ), ) - inputs = Allineate.input_spec() + inputs = Allineate._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -116,7 +110,7 @@ def test_Allineate_outputs(): output_map = dict(matrix=dict(), out_file=dict(), ) - outputs = Allineate.output_spec() + outputs = Allineate._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_AutoTcorrelate.py b/nipype/interfaces/afni/tests/test_auto_AutoTcorrelate.py index 0591a7eb7f..679a195115 100644 --- a/nipype/interfaces/afni/tests/test_auto_AutoTcorrelate.py +++ b/nipype/interfaces/afni/tests/test_auto_AutoTcorrelate.py @@ -6,14 +6,8 @@ def test_AutoTcorrelate_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), eta2=dict(argstr='-eta2', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, @@ -22,22 +16,21 @@ def test_AutoTcorrelate_inputs(): mask=dict(argstr='-mask %s', ), mask_only_targets=dict(argstr='-mask_only_targets', + usedefault=True, xor=['mask_source'], ), mask_source=dict(argstr='-mask_source %s', xor=['mask_only_targets'], ), out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_similarity_matrix.1D', + keep_extension=False, ), - outputtype=dict(), - polort=dict(argstr='-polort %d', + output_type=dict(usedefault=True, ), - terminal_output=dict(nohash=True, + polort=dict(argstr='-polort %d', ), ) - inputs = AutoTcorrelate.input_spec() + inputs = AutoTcorrelate._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +40,7 @@ def test_AutoTcorrelate_inputs(): def test_AutoTcorrelate_outputs(): output_map = dict(out_file=dict(), ) - outputs = AutoTcorrelate.output_spec() + outputs = AutoTcorrelate._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Autobox.py b/nipype/interfaces/afni/tests/test_auto_Autobox.py index 3a23e751a3..c3c37c8519 100644 --- a/nipype/interfaces/afni/tests/test_auto_Autobox.py +++ b/nipype/interfaces/afni/tests/test_auto_Autobox.py @@ -6,12 +6,6 @@ def test_Autobox_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-input %s', copyfile=False, mandatory=True, @@ -21,13 +15,12 @@ def test_Autobox_inputs(): out_file=dict(argstr='-prefix %s', name_source='in_file', ), - outputtype=dict(), - padding=dict(argstr='-npad %d', + output_type=dict(usedefault=True, ), - terminal_output=dict(nohash=True, + padding=dict(argstr='-npad %d', ), ) - inputs = Autobox.input_spec() + inputs = Autobox._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +36,7 @@ def test_Autobox_outputs(): z_max=dict(), z_min=dict(), ) - outputs = Autobox.output_spec() + outputs = Autobox._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Automask.py b/nipype/interfaces/afni/tests/test_auto_Automask.py index 5ee4b08162..1fb32bd509 100644 --- a/nipype/interfaces/afni/tests/test_auto_Automask.py +++ b/nipype/interfaces/afni/tests/test_auto_Automask.py @@ -4,38 +4,29 @@ def test_Automask_inputs(): - input_map = dict(args=dict(argstr='%s', + input_map = dict(apply_prefix=dict(argstr='-apply_prefix %s', ), - brain_file=dict(argstr='-apply_prefix %s', - name_source='in_file', - name_template='%s_masked', + args=dict(argstr='%s', ), - clfrac=dict(argstr='-clfrac %s', + brain_file=dict(), + clfrac=dict(argstr='-clfrac %.2f', ), dilate=dict(argstr='-dilate %s', ), - environ=dict(nohash=True, - usedefault=True, - ), erode=dict(argstr='-erode %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, position=-1, ), - out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_mask', + out_file=dict(), + output_type=dict(usedefault=True, ), - outputtype=dict(), - terminal_output=dict(nohash=True, + prefix=dict(argstr='-prefix %s', ), ) - inputs = Automask.input_spec() + inputs = Automask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +37,7 @@ def test_Automask_outputs(): output_map = dict(brain_file=dict(), out_file=dict(), ) - outputs = Automask.output_spec() + outputs = Automask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Bandpass.py b/nipype/interfaces/afni/tests/test_auto_Bandpass.py index 519d8fd501..a56d3e8e04 100644 --- a/nipype/interfaces/afni/tests/test_auto_Bandpass.py +++ b/nipype/interfaces/afni/tests/test_auto_Bandpass.py @@ -12,16 +12,10 @@ def test_Bandpass_inputs(): ), despike=dict(argstr='-despike', ), - environ=dict(nohash=True, - usedefault=True, - ), highpass=dict(argstr='%f', mandatory=True, position=-3, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, @@ -54,13 +48,12 @@ def test_Bandpass_inputs(): name_template='%s_bp', position=1, ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), tr=dict(argstr='-dt %f', ), ) - inputs = Bandpass.input_spec() + inputs = Bandpass._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -70,7 +63,7 @@ def test_Bandpass_inputs(): def test_Bandpass_outputs(): output_map = dict(out_file=dict(), ) - outputs = Bandpass.output_spec() + outputs = Bandpass._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_BlurInMask.py b/nipype/interfaces/afni/tests/test_auto_BlurInMask.py index 276cf8a81f..cef0743f2e 100644 --- a/nipype/interfaces/afni/tests/test_auto_BlurInMask.py +++ b/nipype/interfaces/afni/tests/test_auto_BlurInMask.py @@ -8,17 +8,11 @@ def test_BlurInMask_inputs(): ), automask=dict(argstr='-automask', ), - environ=dict(nohash=True, - usedefault=True, - ), float_out=dict(argstr='-float', ), fwhm=dict(argstr='-FWHM %f', mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-input %s', copyfile=False, mandatory=True, @@ -31,18 +25,17 @@ def test_BlurInMask_inputs(): options=dict(argstr='%s', position=2, ), - out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_blur', - position=-1, + out_file=dict(keep_extension=False, ), - outputtype=dict(), - preserve=dict(argstr='-preserve', + output_type=dict(usedefault=True, ), - terminal_output=dict(nohash=True, + prefix=dict(argstr='-prefix %s', + keep_extension=False, + ), + preserve=dict(argstr='-preserve', ), ) - inputs = BlurInMask.input_spec() + inputs = BlurInMask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +45,7 @@ def test_BlurInMask_inputs(): def test_BlurInMask_outputs(): output_map = dict(out_file=dict(), ) - outputs = BlurInMask.output_spec() + outputs = BlurInMask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_BrickStat.py b/nipype/interfaces/afni/tests/test_auto_BrickStat.py index 0c47101656..25a35d64b2 100644 --- a/nipype/interfaces/afni/tests/test_auto_BrickStat.py +++ b/nipype/interfaces/afni/tests/test_auto_BrickStat.py @@ -6,12 +6,6 @@ def test_BrickStat_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-1, @@ -22,15 +16,10 @@ def test_BrickStat_inputs(): min=dict(argstr='-min', position=1, ), - out_file=dict(argstr='-prefix %s', - name_source=['in_file'], - name_template='%s_afni', - ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = BrickStat.input_spec() + inputs = BrickStat._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +29,7 @@ def test_BrickStat_inputs(): def test_BrickStat_outputs(): output_map = dict(min_val=dict(), ) - outputs = BrickStat.output_spec() + outputs = BrickStat._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Calc.py b/nipype/interfaces/afni/tests/test_auto_Calc.py index c15431a5a8..da849bc858 100644 --- a/nipype/interfaces/afni/tests/test_auto_Calc.py +++ b/nipype/interfaces/afni/tests/test_auto_Calc.py @@ -6,16 +6,10 @@ def test_Calc_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), expr=dict(argstr='-expr "%s"', mandatory=True, position=3, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file_a=dict(argstr='-a %s', mandatory=True, position=0, @@ -32,16 +26,15 @@ def test_Calc_inputs(): name_source='in_file_a', name_template='%s_calc', ), - outputtype=dict(), + output_type=dict(usedefault=True, + ), single_idx=dict(), start_idx=dict(requires=['stop_idx'], ), stop_idx=dict(requires=['start_idx'], ), - terminal_output=dict(nohash=True, - ), ) - inputs = Calc.input_spec() + inputs = Calc._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -51,7 +44,7 @@ def test_Calc_inputs(): def test_Calc_outputs(): output_map = dict(out_file=dict(), ) - outputs = Calc.output_spec() + outputs = Calc._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Copy.py b/nipype/interfaces/afni/tests/test_auto_Copy.py index fffc9267d1..5ab15a44c5 100644 --- a/nipype/interfaces/afni/tests/test_auto_Copy.py +++ b/nipype/interfaces/afni/tests/test_auto_Copy.py @@ -6,27 +6,18 @@ def test_Copy_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, position=-2, ), out_file=dict(argstr='%s', - name_source='in_file', - name_template='%s_copy', position=-1, ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = Copy.input_spec() + inputs = Copy._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +27,7 @@ def test_Copy_inputs(): def test_Copy_outputs(): output_map = dict(out_file=dict(), ) - outputs = Copy.output_spec() + outputs = Copy._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Despike.py b/nipype/interfaces/afni/tests/test_auto_Despike.py index 0e8c5876f9..c2782e4dc1 100644 --- a/nipype/interfaces/afni/tests/test_auto_Despike.py +++ b/nipype/interfaces/afni/tests/test_auto_Despike.py @@ -6,26 +6,20 @@ def test_Despike_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, position=-1, ), - out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_despike', + out_file=dict(keep_extension=False, + ), + output_type=dict(usedefault=True, ), - outputtype=dict(), - terminal_output=dict(nohash=True, + prefix=dict(argstr='-prefix %s', + keep_extension=False, ), ) - inputs = Despike.input_spec() + inputs = Despike._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +29,7 @@ def test_Despike_inputs(): def test_Despike_outputs(): output_map = dict(out_file=dict(), ) - outputs = Despike.output_spec() + outputs = Despike._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Detrend.py b/nipype/interfaces/afni/tests/test_auto_Detrend.py index 2fd8bf3d6f..9646a319bf 100644 --- a/nipype/interfaces/afni/tests/test_auto_Detrend.py +++ b/nipype/interfaces/afni/tests/test_auto_Detrend.py @@ -6,26 +6,20 @@ def test_Detrend_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, position=-1, ), - out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_detrend', + out_file=dict(keep_extension=False, + ), + output_type=dict(usedefault=True, ), - outputtype=dict(), - terminal_output=dict(nohash=True, + prefix=dict(argstr='-prefix %s', + keep_extension=False, ), ) - inputs = Detrend.input_spec() + inputs = Detrend._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +29,7 @@ def test_Detrend_inputs(): def test_Detrend_outputs(): output_map = dict(out_file=dict(), ) - outputs = Detrend.output_spec() + outputs = Detrend._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Eval.py b/nipype/interfaces/afni/tests/test_auto_Eval.py index 0ca8e85bc0..942d52fcc6 100644 --- a/nipype/interfaces/afni/tests/test_auto_Eval.py +++ b/nipype/interfaces/afni/tests/test_auto_Eval.py @@ -6,16 +6,10 @@ def test_Eval_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), expr=dict(argstr='-expr "%s"', mandatory=True, position=3, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file_a=dict(argstr='-a %s', mandatory=True, position=0, @@ -34,16 +28,15 @@ def test_Eval_inputs(): name_source='in_file_a', name_template='%s_calc', ), - outputtype=dict(), + output_type=dict(usedefault=True, + ), single_idx=dict(), start_idx=dict(requires=['stop_idx'], ), stop_idx=dict(requires=['start_idx'], ), - terminal_output=dict(nohash=True, - ), ) - inputs = Eval.input_spec() + inputs = Eval._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +46,7 @@ def test_Eval_inputs(): def test_Eval_outputs(): output_map = dict(out_file=dict(), ) - outputs = Eval.output_spec() + outputs = Eval._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_FWHMx.py b/nipype/interfaces/afni/tests/test_auto_FWHMx.py index f35aa66b62..c55296d87e 100644 --- a/nipype/interfaces/afni/tests/test_auto_FWHMx.py +++ b/nipype/interfaces/afni/tests/test_auto_FWHMx.py @@ -26,15 +26,9 @@ def test_FWHMx_inputs(): usedefault=True, xor=['demed'], ), - environ=dict(nohash=True, - usedefault=True, - ), geom=dict(argstr='-geom', xor=['arith'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-input %s', mandatory=True, ), @@ -47,21 +41,15 @@ def test_FWHMx_inputs(): ), out_file=dict(argstr='> %s', keep_extension=False, - name_source='in_file', - name_template='%s_fwhmx.out', position=-1, ), out_subbricks=dict(argstr='-out %s', keep_extension=False, - name_source='in_file', - name_template='%s_subbricks.out', - ), - terminal_output=dict(nohash=True, ), unif=dict(argstr='-unif', ), ) - inputs = FWHMx.input_spec() + inputs = FWHMx._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -76,7 +64,7 @@ def test_FWHMx_outputs(): out_file=dict(), out_subbricks=dict(), ) - outputs = FWHMx.output_spec() + outputs = FWHMx._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Fim.py b/nipype/interfaces/afni/tests/test_auto_Fim.py index 60aa963b28..c385b9a928 100644 --- a/nipype/interfaces/afni/tests/test_auto_Fim.py +++ b/nipype/interfaces/afni/tests/test_auto_Fim.py @@ -6,9 +6,6 @@ def test_Fim_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fim_thr=dict(argstr='-fim_thr %f', position=3, ), @@ -16,9 +13,6 @@ def test_Fim_inputs(): mandatory=True, position=2, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr=' -input %s', copyfile=False, mandatory=True, @@ -31,11 +25,10 @@ def test_Fim_inputs(): name_source='in_file', name_template='%s_fim', ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = Fim.input_spec() + inputs = Fim._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +38,7 @@ def test_Fim_inputs(): def test_Fim_outputs(): output_map = dict(out_file=dict(), ) - outputs = Fim.output_spec() + outputs = Fim._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Fourier.py b/nipype/interfaces/afni/tests/test_auto_Fourier.py index 0bc9e03b6c..8b7b86a033 100644 --- a/nipype/interfaces/afni/tests/test_auto_Fourier.py +++ b/nipype/interfaces/afni/tests/test_auto_Fourier.py @@ -6,16 +6,10 @@ def test_Fourier_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), highpass=dict(argstr='-highpass %f', mandatory=True, position=1, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, @@ -29,11 +23,10 @@ def test_Fourier_inputs(): name_source='in_file', name_template='%s_fourier', ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = Fourier.input_spec() + inputs = Fourier._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +36,7 @@ def test_Fourier_inputs(): def test_Fourier_outputs(): output_map = dict(out_file=dict(), ) - outputs = Fourier.output_spec() + outputs = Fourier._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Hist.py b/nipype/interfaces/afni/tests/test_auto_Hist.py index 0024e5f186..e65f7f0416 100644 --- a/nipype/interfaces/afni/tests/test_auto_Hist.py +++ b/nipype/interfaces/afni/tests/test_auto_Hist.py @@ -8,12 +8,6 @@ def test_Hist_inputs(): ), bin_width=dict(argstr='-binwidth %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-input %s', copyfile=False, mandatory=True, @@ -27,10 +21,7 @@ def test_Hist_inputs(): ), nbin=dict(argstr='-nbin %d', ), - out_file=dict(argstr='-prefix %s', - keep_extension=False, - name_source=['in_file'], - name_template='%s_hist', + out_file=dict(keep_extension=False, ), out_show=dict(argstr='> %s', keep_extension=False, @@ -38,13 +29,14 @@ def test_Hist_inputs(): name_template='%s_hist.out', position=-1, ), + prefix=dict(argstr='-prefix %s', + keep_extension=False, + ), showhist=dict(argstr='-showhist', usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Hist.input_spec() + inputs = Hist._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_Hist_outputs(): output_map = dict(out_file=dict(), out_show=dict(), ) - outputs = Hist.output_spec() + outputs = Hist._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Maskave.py b/nipype/interfaces/afni/tests/test_auto_Maskave.py index dbff513cc8..df21b9422e 100644 --- a/nipype/interfaces/afni/tests/test_auto_Maskave.py +++ b/nipype/interfaces/afni/tests/test_auto_Maskave.py @@ -6,12 +6,6 @@ def test_Maskave_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, @@ -21,19 +15,16 @@ def test_Maskave_inputs(): position=1, ), out_file=dict(argstr='> %s', - keep_extension=True, - name_source='in_file', - name_template='%s_maskave.1D', + keep_extension=False, position=-1, ), - outputtype=dict(), + output_type=dict(usedefault=True, + ), quiet=dict(argstr='-quiet', position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Maskave.input_spec() + inputs = Maskave._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +34,7 @@ def test_Maskave_inputs(): def test_Maskave_outputs(): output_map = dict(out_file=dict(), ) - outputs = Maskave.output_spec() + outputs = Maskave._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Means.py b/nipype/interfaces/afni/tests/test_auto_Means.py index de764464b5..f18d796c5f 100644 --- a/nipype/interfaces/afni/tests/test_auto_Means.py +++ b/nipype/interfaces/afni/tests/test_auto_Means.py @@ -8,12 +8,6 @@ def test_Means_inputs(): ), count=dict(argstr='-count', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file_a=dict(argstr='%s', mandatory=True, position=0, @@ -31,7 +25,8 @@ def test_Means_inputs(): name_source='in_file_a', name_template='%s_mean', ), - outputtype=dict(), + output_type=dict(usedefault=True, + ), scale=dict(argstr='-%sscale', ), sqr=dict(argstr='-sqr', @@ -40,10 +35,8 @@ def test_Means_inputs(): ), summ=dict(argstr='-sum', ), - terminal_output=dict(nohash=True, - ), ) - inputs = Means.input_spec() + inputs = Means._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +46,7 @@ def test_Means_inputs(): def test_Means_outputs(): output_map = dict(out_file=dict(), ) - outputs = Means.output_spec() + outputs = Means._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Merge.py b/nipype/interfaces/afni/tests/test_auto_Merge.py index 9851b90b9c..961e422f85 100644 --- a/nipype/interfaces/afni/tests/test_auto_Merge.py +++ b/nipype/interfaces/afni/tests/test_auto_Merge.py @@ -11,26 +11,17 @@ def test_Merge_inputs(): ), doall=dict(argstr='-doall', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='%s', copyfile=False, mandatory=True, position=-1, ), out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_merge', ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = Merge.input_spec() + inputs = Merge._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +31,7 @@ def test_Merge_inputs(): def test_Merge_outputs(): output_map = dict(out_file=dict(), ) - outputs = Merge.output_spec() + outputs = Merge._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_ROIStats.py b/nipype/interfaces/afni/tests/test_auto_ROIStats.py index 447b5000f6..fa1df6d87f 100644 --- a/nipype/interfaces/afni/tests/test_auto_ROIStats.py +++ b/nipype/interfaces/afni/tests/test_auto_ROIStats.py @@ -6,12 +6,6 @@ def test_ROIStats_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-1, @@ -30,7 +24,7 @@ def test_ROIStats_inputs(): usedefault=True, ), ) - inputs = ROIStats.input_spec() + inputs = ROIStats._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +34,7 @@ def test_ROIStats_inputs(): def test_ROIStats_outputs(): output_map = dict(stats=dict(), ) - outputs = ROIStats.output_spec() + outputs = ROIStats._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Refit.py b/nipype/interfaces/afni/tests/test_auto_Refit.py index 124655276a..b4447f0dd1 100644 --- a/nipype/interfaces/afni/tests/test_auto_Refit.py +++ b/nipype/interfaces/afni/tests/test_auto_Refit.py @@ -7,11 +7,6 @@ def test_Refit_inputs(): input_map = dict(args=dict(argstr='%s', ), deoblique=dict(argstr='-deoblique', - ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, usedefault=True, ), in_file=dict(argstr='%s', @@ -19,9 +14,10 @@ def test_Refit_inputs(): mandatory=True, position=-1, ), - space=dict(argstr='-space %s', + out_file=dict(), + output_type=dict(usedefault=True, ), - terminal_output=dict(nohash=True, + space=dict(argstr='-space %s', ), xdel=dict(argstr='-xdel %f', ), @@ -36,7 +32,7 @@ def test_Refit_inputs(): zorigin=dict(argstr='-zorigin %s', ), ) - inputs = Refit.input_spec() + inputs = Refit._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +42,7 @@ def test_Refit_inputs(): def test_Refit_outputs(): output_map = dict(out_file=dict(), ) - outputs = Refit.output_spec() + outputs = Refit._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Resample.py b/nipype/interfaces/afni/tests/test_auto_Resample.py index 8aa40f92ee..2b0bdfe3d7 100644 --- a/nipype/interfaces/afni/tests/test_auto_Resample.py +++ b/nipype/interfaces/afni/tests/test_auto_Resample.py @@ -6,12 +6,6 @@ def test_Resample_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inset %s', copyfile=False, mandatory=True, @@ -21,19 +15,19 @@ def test_Resample_inputs(): ), orientation=dict(argstr='-orient %s', ), - out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_resample', + out_file=dict(keep_extension=False, ), - outputtype=dict(), - resample_mode=dict(argstr='-rmode %s', + output_type=dict(usedefault=True, ), - terminal_output=dict(nohash=True, + prefix=dict(argstr='-prefix %s', + keep_extension=False, + ), + resample_mode=dict(argstr='-rmode %s', ), voxel_size=dict(argstr='-dxyz %f %f %f', ), ) - inputs = Resample.input_spec() + inputs = Resample._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +37,7 @@ def test_Resample_inputs(): def test_Resample_outputs(): output_map = dict(out_file=dict(), ) - outputs = Resample.output_spec() + outputs = Resample._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Retroicor.py b/nipype/interfaces/afni/tests/test_auto_Retroicor.py index 2d5fb74175..3a304b243a 100644 --- a/nipype/interfaces/afni/tests/test_auto_Retroicor.py +++ b/nipype/interfaces/afni/tests/test_auto_Retroicor.py @@ -13,12 +13,6 @@ def test_Retroicor_inputs(): hash_files=False, position=-6, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, @@ -31,7 +25,8 @@ def test_Retroicor_inputs(): mandatory=True, position=1, ), - outputtype=dict(), + output_type=dict(usedefault=True, + ), resp=dict(argstr='-resp %s', position=-3, ), @@ -39,13 +34,11 @@ def test_Retroicor_inputs(): hash_files=False, position=-7, ), - terminal_output=dict(nohash=True, - ), threshold=dict(argstr='-threshold %d', position=-4, ), ) - inputs = Retroicor.input_spec() + inputs = Retroicor._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +48,7 @@ def test_Retroicor_inputs(): def test_Retroicor_outputs(): output_map = dict(out_file=dict(), ) - outputs = Retroicor.output_spec() + outputs = Retroicor._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_SVMTest.py b/nipype/interfaces/afni/tests/test_auto_SVMTest.py index a1566c59f7..c5363f9b9c 100644 --- a/nipype/interfaces/afni/tests/test_auto_SVMTest.py +++ b/nipype/interfaces/afni/tests/test_auto_SVMTest.py @@ -8,12 +8,6 @@ def test_SVMTest_inputs(): ), classout=dict(argstr='-classout', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-testvol %s', mandatory=True, ), @@ -31,13 +25,12 @@ def test_SVMTest_inputs(): out_file=dict(argstr='-predictions %s', name_template='%s_predictions', ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), testlabels=dict(argstr='-testlabels %s', ), ) - inputs = SVMTest.input_spec() + inputs = SVMTest._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +40,7 @@ def test_SVMTest_inputs(): def test_SVMTest_outputs(): output_map = dict(out_file=dict(), ) - outputs = SVMTest.output_spec() + outputs = SVMTest._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_SVMTrain.py b/nipype/interfaces/afni/tests/test_auto_SVMTrain.py index eb13dcb531..e858e24f94 100644 --- a/nipype/interfaces/afni/tests/test_auto_SVMTrain.py +++ b/nipype/interfaces/afni/tests/test_auto_SVMTrain.py @@ -13,12 +13,6 @@ def test_SVMTrain_inputs(): ), censor=dict(argstr='-censor %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-trainvol %s', copyfile=False, mandatory=True, @@ -45,8 +39,7 @@ def test_SVMTrain_inputs(): name_template='%s_vectors', suffix='_bucket', ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), trainlabels=dict(argstr='-trainlabels %s', ), @@ -56,7 +49,7 @@ def test_SVMTrain_inputs(): w_out=dict(argstr='-wout', ), ) - inputs = SVMTrain.input_spec() + inputs = SVMTrain._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -68,7 +61,7 @@ def test_SVMTrain_outputs(): model=dict(), out_file=dict(), ) - outputs = SVMTrain.output_spec() + outputs = SVMTrain._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_SkullStrip.py b/nipype/interfaces/afni/tests/test_auto_SkullStrip.py index 12449c331f..f291120518 100644 --- a/nipype/interfaces/afni/tests/test_auto_SkullStrip.py +++ b/nipype/interfaces/afni/tests/test_auto_SkullStrip.py @@ -6,12 +6,6 @@ def test_SkullStrip_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-input %s', copyfile=False, mandatory=True, @@ -21,11 +15,10 @@ def test_SkullStrip_inputs(): name_source='in_file', name_template='%s_skullstrip', ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = SkullStrip.input_spec() + inputs = SkullStrip._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +28,7 @@ def test_SkullStrip_inputs(): def test_SkullStrip_outputs(): output_map = dict(out_file=dict(), ) - outputs = SkullStrip.output_spec() + outputs = SkullStrip._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_TCat.py b/nipype/interfaces/afni/tests/test_auto_TCat.py index ce1e8fbaac..6b526a4134 100644 --- a/nipype/interfaces/afni/tests/test_auto_TCat.py +++ b/nipype/interfaces/afni/tests/test_auto_TCat.py @@ -6,12 +6,6 @@ def test_TCat_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr=' %s', copyfile=False, mandatory=True, @@ -21,14 +15,13 @@ def test_TCat_inputs(): name_source='in_files', name_template='%s_tcat', ), - outputtype=dict(), + output_type=dict(usedefault=True, + ), rlt=dict(argstr='-rlt%s', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = TCat.input_spec() + inputs = TCat._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +31,7 @@ def test_TCat_inputs(): def test_TCat_outputs(): output_map = dict(out_file=dict(), ) - outputs = TCat.output_spec() + outputs = TCat._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_TCorr1D.py b/nipype/interfaces/afni/tests/test_auto_TCorr1D.py index 96ebdbe3a6..6479e5c684 100644 --- a/nipype/interfaces/afni/tests/test_auto_TCorr1D.py +++ b/nipype/interfaces/afni/tests/test_auto_TCorr1D.py @@ -6,26 +6,22 @@ def test_TCorr1D_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), ktaub=dict(argstr=' -ktaub', position=1, xor=['pearson', 'spearman', 'quadrant'], ), - out_file=dict(argstr='-prefix %s', - keep_extension=True, - name_source='xset', - name_template='%s_correlation.nii.gz', + out_file=dict(keep_extension=False, + name_template='{prefix}{output_type_}', + ), + output_type=dict(usedefault=True, ), - outputtype=dict(), pearson=dict(argstr=' -pearson', position=1, xor=['spearman', 'quadrant', 'ktaub'], ), + prefix=dict(argstr='-prefix %s', + keep_extension=False, + ), quadrant=dict(argstr=' -quadrant', position=1, xor=['pearson', 'spearman', 'ktaub'], @@ -34,19 +30,17 @@ def test_TCorr1D_inputs(): position=1, xor=['pearson', 'quadrant', 'ktaub'], ), - terminal_output=dict(nohash=True, - ), - xset=dict(argstr=' %s', + xset=dict(argstr='%s', copyfile=False, mandatory=True, position=-2, ), - y_1d=dict(argstr=' %s', + y_1d=dict(argstr='%s', mandatory=True, position=-1, ), ) - inputs = TCorr1D.input_spec() + inputs = TCorr1D._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -56,7 +50,7 @@ def test_TCorr1D_inputs(): def test_TCorr1D_outputs(): output_map = dict(out_file=dict(), ) - outputs = TCorr1D.output_spec() + outputs = TCorr1D._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_TCorrMap.py b/nipype/interfaces/afni/tests/test_auto_TCorrMap.py index 15c98d2aac..c9f0a1bfae 100644 --- a/nipype/interfaces/afni/tests/test_auto_TCorrMap.py +++ b/nipype/interfaces/afni/tests/test_auto_TCorrMap.py @@ -33,18 +33,12 @@ def test_TCorrMap_inputs(): correlation_maps_masked=dict(argstr='-CorrMask %s', name_source='in_file', ), - environ=dict(nohash=True, - usedefault=True, - ), expr=dict(), histogram=dict(argstr='-Hist %d %s', name_source='in_file', suffix='_hist', ), histogram_bin_numbers=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-input %s', copyfile=False, mandatory=True, @@ -55,11 +49,8 @@ def test_TCorrMap_inputs(): name_source='in_file', suffix='_mean', ), - out_file=dict(argstr='-prefix %s', - name_source=['in_file'], - name_template='%s_afni', + output_type=dict(usedefault=True, ), - outputtype=dict(), pmean=dict(argstr='-Pmean %s', name_source='in_file', suffix='_pmean', @@ -83,8 +74,6 @@ def test_TCorrMap_inputs(): suffix='_sexpr', xor=('average_expr', 'average_expr_nonzero', 'sum_expr'), ), - terminal_output=dict(nohash=True, - ), thresholds=dict(), var_absolute_threshold=dict(argstr='-VarThresh %f %f %f %s', name_source='in_file', @@ -101,7 +90,7 @@ def test_TCorrMap_inputs(): suffix='_zmean', ), ) - inputs = TCorrMap.input_spec() + inputs = TCorrMap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -123,7 +112,7 @@ def test_TCorrMap_outputs(): var_absolute_threshold_normalize=dict(), zmean=dict(), ) - outputs = TCorrMap.output_spec() + outputs = TCorrMap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_TCorrelate.py b/nipype/interfaces/afni/tests/test_auto_TCorrelate.py index 4a5d68f9e9..bce8dfaa54 100644 --- a/nipype/interfaces/afni/tests/test_auto_TCorrelate.py +++ b/nipype/interfaces/afni/tests/test_auto_TCorrelate.py @@ -6,25 +6,18 @@ def test_TCorrelate_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), out_file=dict(argstr='-prefix %s', name_source='xset', name_template='%s_tcorr', ), - outputtype=dict(), + output_type=dict(usedefault=True, + ), pearson=dict(argstr='-pearson', position=1, ), polort=dict(argstr='-polort %d', position=2, ), - terminal_output=dict(nohash=True, - ), xset=dict(argstr=' %s', copyfile=False, mandatory=True, @@ -36,7 +29,7 @@ def test_TCorrelate_inputs(): position=-1, ), ) - inputs = TCorrelate.input_spec() + inputs = TCorrelate._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +39,7 @@ def test_TCorrelate_inputs(): def test_TCorrelate_outputs(): output_map = dict(out_file=dict(), ) - outputs = TCorrelate.output_spec() + outputs = TCorrelate._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_TShift.py b/nipype/interfaces/afni/tests/test_auto_TShift.py index a67893c811..1e6f254d4c 100644 --- a/nipype/interfaces/afni/tests/test_auto_TShift.py +++ b/nipype/interfaces/afni/tests/test_auto_TShift.py @@ -6,14 +6,8 @@ def test_TShift_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), ignore=dict(argstr='-ignore %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, @@ -21,17 +15,16 @@ def test_TShift_inputs(): ), interp=dict(argstr='-%s', ), - out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_tshift', + out_file=dict(), + output_type=dict(usedefault=True, + ), + prefix=dict(argstr='-prefix %s', + keep_extension=False, ), - outputtype=dict(), rlt=dict(argstr='-rlt', ), rltplus=dict(argstr='-rlt+', ), - terminal_output=dict(nohash=True, - ), tpattern=dict(argstr='-tpattern %s', ), tr=dict(argstr='-TR %s', @@ -43,7 +36,7 @@ def test_TShift_inputs(): xor=['tslice'], ), ) - inputs = TShift.input_spec() + inputs = TShift._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +46,7 @@ def test_TShift_inputs(): def test_TShift_outputs(): output_map = dict(out_file=dict(), ) - outputs = TShift.output_spec() + outputs = TShift._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_TStat.py b/nipype/interfaces/afni/tests/test_auto_TStat.py index f7a60ca78c..349628e661 100644 --- a/nipype/interfaces/afni/tests/test_auto_TStat.py +++ b/nipype/interfaces/afni/tests/test_auto_TStat.py @@ -6,12 +6,6 @@ def test_TStat_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, @@ -21,15 +15,15 @@ def test_TStat_inputs(): ), options=dict(argstr='%s', ), - out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_tstat', + out_file=dict(keep_extension=False, + ), + output_type=dict(usedefault=True, ), - outputtype=dict(), - terminal_output=dict(nohash=True, + prefix=dict(argstr='-prefix %s', + keep_extension=False, ), ) - inputs = TStat.input_spec() + inputs = TStat._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +33,7 @@ def test_TStat_inputs(): def test_TStat_outputs(): output_map = dict(out_file=dict(), ) - outputs = TStat.output_spec() + outputs = TStat._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_To3D.py b/nipype/interfaces/afni/tests/test_auto_To3D.py index 4357ee96da..55f7f71acc 100644 --- a/nipype/interfaces/afni/tests/test_auto_To3D.py +++ b/nipype/interfaces/afni/tests/test_auto_To3D.py @@ -10,31 +10,25 @@ def test_To3D_inputs(): ), datatype=dict(argstr='-datum %s', ), - environ=dict(nohash=True, - usedefault=True, - ), filetype=dict(argstr='-%s', ), funcparams=dict(argstr='-time:zt %s alt+z2', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_folder=dict(argstr='%s/*.dcm', mandatory=True, position=-1, ), - out_file=dict(argstr='-prefix %s', - name_source=['in_folder'], - name_template='%s', + out_file=dict(keep_extension=False, ), - outputtype=dict(), - skipoutliers=dict(argstr='-skip_outliers', + output_type=dict(usedefault=True, ), - terminal_output=dict(nohash=True, + prefix=dict(argstr='-prefix %s', + usedefault='true', + ), + skipoutliers=dict(argstr='-skip_outliers', ), ) - inputs = To3D.input_spec() + inputs = To3D._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +38,7 @@ def test_To3D_inputs(): def test_To3D_outputs(): output_map = dict(out_file=dict(), ) - outputs = To3D.output_spec() + outputs = To3D._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Volreg.py b/nipype/interfaces/afni/tests/test_auto_Volreg.py index f97afe6366..80cb42f1dd 100644 --- a/nipype/interfaces/afni/tests/test_auto_Volreg.py +++ b/nipype/interfaces/afni/tests/test_auto_Volreg.py @@ -11,39 +11,25 @@ def test_Volreg_inputs(): ), copyorigin=dict(argstr='-twodup', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, position=-1, ), md1d_file=dict(argstr='-maxdisp1D %s', - keep_extension=True, - name_source='in_file', - name_template='%s_md.1D', + keep_extension=False, position=-4, ), oned_file=dict(argstr='-1Dfile %s', - keep_extension=True, - name_source='in_file', - name_template='%s.1D', + keep_extension=False, ), oned_matrix_save=dict(argstr='-1Dmatrix_save %s', - keep_extension=True, - name_source='in_file', - name_template='%s.aff12.1D', + keep_extension=False, ), - out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_volreg', + out_file=dict(), + output_type=dict(usedefault=True, ), - outputtype=dict(), - terminal_output=dict(nohash=True, + prefix=dict(argstr='-prefix %s', ), timeshift=dict(argstr='-tshift 0', ), @@ -53,7 +39,7 @@ def test_Volreg_inputs(): position=-5, ), ) - inputs = Volreg.input_spec() + inputs = Volreg._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -66,7 +52,7 @@ def test_Volreg_outputs(): oned_matrix_save=dict(), out_file=dict(), ) - outputs = Volreg.output_spec() + outputs = Volreg._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_Warp.py b/nipype/interfaces/afni/tests/test_auto_Warp.py index c749d7fade..bbf9d4a429 100644 --- a/nipype/interfaces/afni/tests/test_auto_Warp.py +++ b/nipype/interfaces/afni/tests/test_auto_Warp.py @@ -8,14 +8,8 @@ def test_Warp_inputs(): ), deoblique=dict(argstr='-deoblique', ), - environ=dict(nohash=True, - usedefault=True, - ), gridset=dict(argstr='-gridset %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, @@ -29,19 +23,18 @@ def test_Warp_inputs(): ), newgrid=dict(argstr='-newgrid %f', ), - out_file=dict(argstr='-prefix %s', - name_source='in_file', - name_template='%s_warp', + out_file=dict(), + output_type=dict(usedefault=True, ), - outputtype=dict(), - terminal_output=dict(nohash=True, + prefix=dict(argstr='-prefix %s', + keep_extension=False, ), tta2mni=dict(argstr='-tta2mni', ), zpad=dict(argstr='-zpad %d', ), ) - inputs = Warp.input_spec() + inputs = Warp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -51,7 +44,7 @@ def test_Warp_inputs(): def test_Warp_outputs(): output_map = dict(out_file=dict(), ) - outputs = Warp.output_spec() + outputs = Warp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/afni/tests/test_auto_ZCutUp.py b/nipype/interfaces/afni/tests/test_auto_ZCutUp.py index f3ede54b3e..e913a5f234 100644 --- a/nipype/interfaces/afni/tests/test_auto_ZCutUp.py +++ b/nipype/interfaces/afni/tests/test_auto_ZCutUp.py @@ -6,12 +6,6 @@ def test_ZCutUp_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', copyfile=False, mandatory=True, @@ -23,11 +17,10 @@ def test_ZCutUp_inputs(): name_source='in_file', name_template='%s_zcupup', ), - outputtype=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = ZCutUp.input_spec() + inputs = ZCutUp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +30,7 @@ def test_ZCutUp_inputs(): def test_ZCutUp_outputs(): output_map = dict(out_file=dict(), ) - outputs = ZCutUp.output_spec() + outputs = ZCutUp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/base.py b/nipype/interfaces/ants/base.py index 20fab05881..87eeca6e72 100644 --- a/nipype/interfaces/ants/base.py +++ b/nipype/interfaces/ants/base.py @@ -33,11 +33,17 @@ class ANTSCommandInputSpec(CommandLineInputSpec): nohash=True, desc="Number of ITK threads to use") + @staticmethod + def _format_xarray(val): + """ Convenience method for converting input arrays [1,2,3] to commandline format '1x2x3' """ + return 'x'.join([str(x) for x in val]) + + class ANTSCommand(CommandLine): """Base class for ANTS interfaces """ - input_spec = ANTSCommandInputSpec + _input_spec = ANTSCommandInputSpec _num_threads = LOCAL_DEFAULT_NUMBER_OF_THREADS def __init__(self, **inputs): @@ -61,19 +67,14 @@ def _num_threads_update(self): # (i.e. respect SGE $NSLOTS or environmental variables of threads, or # user environmental settings) if (self.inputs.num_threads == -1): - if (ALT_ITKv4_THREAD_LIMIT_VARIABLE in self.inputs.environ): - del self.inputs.environ[ALT_ITKv4_THREAD_LIMIT_VARIABLE] - if (PREFERED_ITKv4_THREAD_LIMIT_VARIABLE in self.inputs.environ): - del self.inputs.environ[PREFERED_ITKv4_THREAD_LIMIT_VARIABLE] + if (ALT_ITKv4_THREAD_LIMIT_VARIABLE in self.environ): + del self.environ[ALT_ITKv4_THREAD_LIMIT_VARIABLE] + if (PREFERED_ITKv4_THREAD_LIMIT_VARIABLE in self.environ): + del self.environ[PREFERED_ITKv4_THREAD_LIMIT_VARIABLE] else: - self.inputs.environ.update({PREFERED_ITKv4_THREAD_LIMIT_VARIABLE: + self.environ.update({PREFERED_ITKv4_THREAD_LIMIT_VARIABLE: '%s' % self.inputs.num_threads}) - @staticmethod - def _format_xarray(val): - """ Convenience method for converting input arrays [1,2,3] to commandline format '1x2x3' """ - return 'x'.join([str(x) for x in val]) - @classmethod def set_default_num_threads(cls, num_threads): """Set the default number of threads for ITK calls diff --git a/nipype/interfaces/ants/legacy.py b/nipype/interfaces/ants/legacy.py index b68e0f7ed8..1a15bfc801 100644 --- a/nipype/interfaces/ants/legacy.py +++ b/nipype/interfaces/ants/legacy.py @@ -92,35 +92,33 @@ class antsIntroduction(ANTSCommand): """ _cmd = 'antsIntroduction.sh' - input_spec = antsIntroductionInputSpec - output_spec = antsIntroductionOutputSpec + _input_spec = antsIntroductionInputSpec + _output_spec = antsIntroductionOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): transmodel = self.inputs.transformation_model # When transform is set as 'RI'/'RA', wrap fields should not be expected # The default transformation is GR, which outputs the wrap fields if not isdefined(transmodel) or (isdefined(transmodel) and transmodel not in ['RI', 'RA']): - outputs['warp_field'] = os.path.join(os.getcwd(), + self.outputs.warp_field = os.path.join(os.getcwd(), self.inputs.out_prefix + 'Warp.nii.gz') - outputs['inverse_warp_field'] = os.path.join(os.getcwd(), + self.outputs.inverse_warp_field = os.path.join(os.getcwd(), self.inputs.out_prefix + 'InverseWarp.nii.gz') - outputs['affine_transformation'] = os.path.join(os.getcwd(), + self.outputs.affine_transformation = os.path.join(os.getcwd(), self.inputs.out_prefix + 'Affine.txt') - outputs['input_file'] = os.path.join(os.getcwd(), + self.outputs.input_file = os.path.join(os.getcwd(), self.inputs.out_prefix + 'repaired.nii.gz') - outputs['output_file'] = os.path.join(os.getcwd(), + self.outputs.output_file = os.path.join(os.getcwd(), self.inputs.out_prefix + 'deformed.nii.gz') - return outputs - + # How do we make a pass through so that GenWarpFields is just an alias for antsIntroduction ? @@ -210,8 +208,8 @@ class buildtemplateparallel(ANTSCommand): """ _cmd = 'buildtemplateparallel.sh' - input_spec = buildtemplateparallelInputSpec - output_spec = buildtemplateparallelOutputSpec + _input_spec = buildtemplateparallelInputSpec + _output_spec = buildtemplateparallelOutputSpec def _format_arg(self, opt, spec, val): if opt == 'num_cores': @@ -227,9 +225,8 @@ def _format_arg(self, opt, spec, val): return start + ' '.join(name for name in val) return super(buildtemplateparallel, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['template_files'] = [] + def _post_run(self): + self.outputs.template_files = [] for i in range(len(glob(os.path.realpath('*iteration*')))): temp = os.path.realpath('%s_iteration_%d/%stemplate.nii.gz' % (self.inputs.transformation_model, @@ -247,15 +244,15 @@ def _list_outputs(self): self.inputs.out_prefix, i)) - outputs['template_files'].append(os.path.realpath(file_)) - outputs['final_template_file'] = \ + self.outputs.template_files.append(os.path.realpath(file_)) + self.outputs.final_template_file = \ os.path.realpath('%stemplate.nii.gz' % self.inputs.out_prefix) - outputs['subject_outfiles'] = [] + self.outputs.subject_outfiles = [] for filename in self.inputs.in_files: _, base, _ = split_filename(filename) temp = glob(os.path.realpath('%s%s*' % (self.inputs.out_prefix, base))) for file_ in temp: - outputs['subject_outfiles'].append(file_) - return outputs + self.outputs.subject_outfiles.append(file_) + \ No newline at end of file diff --git a/nipype/interfaces/ants/registration.py b/nipype/interfaces/ants/registration.py index 89af092a33..2095256e2b 100644 --- a/nipype/interfaces/ants/registration.py +++ b/nipype/interfaces/ants/registration.py @@ -85,77 +85,49 @@ class ANTSInputSpec(ANTSCommandInputSpec): traits.Int(), argstr='--number-of-affine-iterations %s', sep='x') -class ANTSOutputSpec(TraitedSpec): - affine_transform = File(exists=True, desc='Affine transform file') - warp_transform = File(exists=True, desc='Warping deformation field') - inverse_warp_transform = File( - exists=True, desc='Inverse warping deformation field') - metaheader = File(exists=True, desc='VTK metaheader .mhd file') - metaheader_raw = File(exists=True, desc='VTK metaheader .raw file') - - -class ANTS(ANTSCommand): - - """ - - - Examples - -------- - - >>> from nipype.interfaces.ants import ANTS - >>> ants = ANTS() - >>> ants.inputs.dimension = 3 - >>> ants.inputs.output_transform_prefix = 'MY' - >>> ants.inputs.metric = ['CC'] - >>> ants.inputs.fixed_image = ['T1.nii'] - >>> ants.inputs.moving_image = ['resting.nii'] - >>> ants.inputs.metric_weight = [1.0] - >>> ants.inputs.radius = [5] - >>> ants.inputs.transformation_model = 'SyN' - >>> ants.inputs.gradient_step_length = 0.25 - >>> ants.inputs.number_of_iterations = [50, 35, 15] - >>> ants.inputs.use_histogram_matching = True - >>> ants.inputs.mi_option = [32, 16000] - >>> ants.inputs.regularization = 'Gauss' - >>> ants.inputs.regularization_gradient_field_sigma = 3 - >>> ants.inputs.regularization_deformation_field_sigma = 0 - >>> ants.inputs.number_of_affine_iterations = [10000,10000,10000,10000,10000] - >>> ants.cmdline - 'ANTS 3 --MI-option 32x16000 --image-metric CC[ T1.nii, resting.nii, 1, 5 ] --number-of-affine-iterations \ -10000x10000x10000x10000x10000 --number-of-iterations 50x35x15 --output-naming MY --regularization Gauss[3.0,0.0] \ ---transformation-model SyN[0.25] --use-Histogram-Matching 1' - """ - _cmd = 'ANTS' - input_spec = ANTSInputSpec - output_spec = ANTSOutputSpec + def _format_arg(self, opt, spec, val): + if opt == 'moving_image': + return self._image_metric_constructor() + elif opt == 'transformation_model': + return self._transformation_constructor() + elif opt == 'regularization': + return self._regularization_constructor() + elif opt == 'affine_gradient_descent_option': + return self._affine_gradient_descent_option_constructor() + elif opt == 'use_histogram_matching': + if self.use_histogram_matching: + return '--use-Histogram-Matching 1' + else: + return '--use-Histogram-Matching 0' + return super(ANTSInputSpec, self)._format_arg(opt, spec, val) def _image_metric_constructor(self): retval = [] intensity_based = ['CC', 'MI', 'SMI', 'PR', 'SSD', 'MSQ'] point_set_based = ['PSE', 'JTB'] - for ii in range(len(self.inputs.moving_image)): - if self.inputs.metric[ii] in intensity_based: + for ii in range(len(self.moving_image)): + if self.metric[ii] in intensity_based: retval.append( - '--image-metric %s[ %s, %s, %g, %d ]' % (self.inputs.metric[ii], - self.inputs.fixed_image[ + '--image-metric %s[ %s, %s, %g, %d ]' % (self.metric[ii], + self.fixed_image[ ii], - self.inputs.moving_image[ + self.moving_image[ ii], - self.inputs.metric_weight[ + self.metric_weight[ ii], - self.inputs.radius[ii])) - elif self.inputs.metric[ii] == point_set_based: + self.radius[ii])) + elif self.metric[ii] == point_set_based: pass - # retval.append('--image-metric %s[%s, %s, ...'.format(self.inputs.metric[ii], - # self.inputs.fixed_image[ii], self.inputs.moving_image[ii], ...)) + # retval.append('--image-metric %s[%s, %s, ...'.format(self.metric[ii], + # self.fixed_image[ii], self.moving_image[ii], ...)) return ' '.join(retval) def _transformation_constructor(self): - model = self.inputs.transformation_model - step_length = self.inputs.gradient_step_length - time_step = self.inputs.number_of_time_steps - delta_time = self.inputs.delta_time - symmetry_type = self.inputs.symmetry_type + model = self.transformation_model + step_length = self.gradient_step_length + time_step = self.number_of_time_steps + delta_time = self.delta_time + symmetry_type = self.symmetry_type retval = ['--transformation-model %s' % model] parameters = [] for elem in (step_length, time_step, delta_time, symmetry_type): @@ -170,12 +142,12 @@ def _transformation_constructor(self): return ''.join(retval) def _regularization_constructor(self): - return '--regularization {0}[{1},{2}]'.format(self.inputs.regularization, - self.inputs.regularization_gradient_field_sigma, - self.inputs.regularization_deformation_field_sigma) + return '--regularization {0}[{1},{2}]'.format(self.regularization, + self.regularization_gradient_field_sigma, + self.regularization_deformation_field_sigma) def _affine_gradient_descent_option_constructor(self): - values = self.inputs.affine_gradient_descent_option + values = self.affine_gradient_descent_option defaults = [0.1, 0.5, 1.e-4, 1.e-4] for ii in range(len(defaults)): try: @@ -186,33 +158,55 @@ def _affine_gradient_descent_option_constructor(self): retval = ['--affine-gradient-descent-option', parameters] return ' '.join(retval) - def _format_arg(self, opt, spec, val): - if opt == 'moving_image': - return self._image_metric_constructor() - elif opt == 'transformation_model': - return self._transformation_constructor() - elif opt == 'regularization': - return self._regularization_constructor() - elif opt == 'affine_gradient_descent_option': - return self._affine_gradient_descent_option_constructor() - elif opt == 'use_histogram_matching': - if self.inputs.use_histogram_matching: - return '--use-Histogram-Matching 1' - else: - return '--use-Histogram-Matching 0' - return super(ANTS, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['affine_transform'] = os.path.abspath( - self.inputs.output_transform_prefix + 'Affine.txt') - outputs['warp_transform'] = os.path.abspath( - self.inputs.output_transform_prefix + 'Warp.nii.gz') - outputs['inverse_warp_transform'] = os.path.abspath( - self.inputs.output_transform_prefix + 'InverseWarp.nii.gz') - # outputs['metaheader'] = os.path.abspath(self.inputs.output_transform_prefix + 'velocity.mhd') - # outputs['metaheader_raw'] = os.path.abspath(self.inputs.output_transform_prefix + 'velocity.raw') - return outputs +class ANTSOutputSpec(TraitedSpec): + affine_transform = File( + name_source='output_transform_prefix', name_template='%sAffine.txt', + keep_extension=False, desc='Affine transform file') + warp_transform = File( + name_source='output_transform_prefix', name_template='%sWarp.nii.gz', + keep_extension=False, desc='Warping deformation field') + inverse_warp_transform = File( + name_source='output_transform_prefix', name_template='%sInverseWarp.nii.gz', + keep_extension=False, desc='Inverse warping deformation field') + metaheader = File(exists=True, desc='VTK metaheader .mhd file') + metaheader_raw = File(exists=True, desc='VTK metaheader .raw file') + + +class ANTS(ANTSCommand): + + """ + + + Examples + -------- + + >>> from nipype.interfaces.ants import ANTS + >>> ants = ANTS() + >>> ants.inputs.dimension = 3 + >>> ants.inputs.output_transform_prefix = 'MY' + >>> ants.inputs.metric = ['CC'] + >>> ants.inputs.fixed_image = ['T1.nii'] + >>> ants.inputs.moving_image = ['resting.nii'] + >>> ants.inputs.metric_weight = [1.0] + >>> ants.inputs.radius = [5] + >>> ants.inputs.transformation_model = 'SyN' + >>> ants.inputs.gradient_step_length = 0.25 + >>> ants.inputs.number_of_iterations = [50, 35, 15] + >>> ants.inputs.use_histogram_matching = True + >>> ants.inputs.mi_option = [32, 16000] + >>> ants.inputs.regularization = 'Gauss' + >>> ants.inputs.regularization_gradient_field_sigma = 3 + >>> ants.inputs.regularization_deformation_field_sigma = 0 + >>> ants.inputs.number_of_affine_iterations = [10000,10000,10000,10000,10000] + >>> ants.cmdline + 'ANTS 3 --MI-option 32x16000 --image-metric CC[ T1.nii, resting.nii, 1, 5 ] --number-of-affine-iterations \ +10000x10000x10000x10000x10000 --number-of-iterations 50x35x15 --output-naming MY --regularization Gauss[3.0,0.0] \ +--transformation-model SyN[0.25] --use-Histogram-Matching 1' + """ + _cmd = 'ANTS' + _input_spec = ANTSInputSpec + _output_spec = ANTSOutputSpec class RegistrationInputSpec(ANTSCommandInputSpec): @@ -380,6 +374,254 @@ class RegistrationInputSpec(ANTSCommandInputSpec): low=0.0, high=1.0, value=0.0, argstr='%s', usedefault=True, desc="The Lower quantile to clip image ranges") + def parse_args(self, skip=None): + if skip is None: + skip = [] + + if (isdefined(self.winsorize_upper_quantile) and + isdefined(self.winsorize_lower_quantile)): + skip += ['winsorize_upper_quantile'] + return super(RegistrationInputSpec, self).parse_args(skip) + + def _format_arg(self, opt, spec, val): + if opt == 'fixed_image_mask': + if isdefined(self.moving_image_mask): + return '--masks [ %s, %s ]' % (self.fixed_image_mask, + self.moving_image_mask) + else: + return '--masks %s' % self.fixed_image_mask + elif opt == 'transforms': + return self._format_registration() + elif opt == 'initial_moving_transform': + try: + do_invert_transform = int(self.invert_initial_moving_transform) + except ValueError: + do_invert_transform = 0 # Just do the default behavior + return '--initial-moving-transform [ %s, %d ]' % (self.initial_moving_transform, + do_invert_transform) + elif opt == 'initial_moving_transform_com': + try: + do_center_of_mass_init = int(self.initial_moving_transform_com) + except ValueError: + do_center_of_mass_init = 0 # Just do the default behavior + return '--initial-moving-transform [ %s, %s, %d ]' % (self.fixed_image[0], + self.moving_image[0], + do_center_of_mass_init) + elif opt == 'interpolation': + if self.interpolation in ['BSpline', 'MultiLabel', 'Gaussian'] and \ + isdefined(self.interpolation_parameters): + return '--interpolation %s[ %s ]' % (self.interpolation, + ', '.join([str(param) + for param in self.interpolation_parameters])) + else: + return '--interpolation %s' % self.interpolation + elif opt == 'output_transform_prefix': + out_filename = self._get_outputfilenames(inverse=False) + inv_out_filename = self._get_outputfilenames(inverse=True) + if out_filename and inv_out_filename: + return '--output [ %s, %s, %s ]' % (self.output_transform_prefix, + out_filename, + inv_out_filename) + elif out_filename: + return '--output [ %s, %s ]' % (self.output_transform_prefix, + out_filename) + else: + return '--output %s' % self.output_transform_prefix + elif opt == 'winsorize_upper_quantile' or opt == 'winsorize_lower_quantile': + return self._format_winsorize_image_intensities() + + # This feature was removed from recent versions of antsRegistration due to corrupt outputs. + # elif opt == 'collapse_linear_transforms_to_fixed_image_header': + # return self._formatCollapseLinearTransformsToFixedImageHeader() + return super(RegistrationInputSpec, self)._format_arg(opt, spec, val) + + + def _format_metric(self, index): + """ + Format the antsRegistration -m metric argument(s). + + Parameters + ---------- + index: the stage index + """ + # The metric name input for the current stage. + name_input = self.metric[index] + # The stage-specific input dictionary. + stage_inputs = dict( + fixed_image=self.fixed_image[0], + moving_image=self.moving_image[0], + metric=name_input, + weight=self.metric_weight[index], + radius_or_bins=self.radius_or_number_of_bins[index], + optional=self.radius_or_number_of_bins[index] + ) + # The optional sampling strategy and percentage. + if isdefined(self.sampling_strategy) and self.sampling_strategy: + sampling_strategy = self.sampling_strategy[index] + if sampling_strategy: + stage_inputs['sampling_strategy'] = sampling_strategy + if isdefined(self.sampling_percentage) and self.sampling_percentage: + sampling_percentage = self.sampling_percentage[index] + if sampling_percentage: + stage_inputs['sampling_percentage'] = sampling_percentage + + # Make a list of metric specifications, one per -m command line + # argument for the current stage. + # If there are multiple inputs for this stage, then convert the + # dictionary of list inputs into a list of metric specifications. + # Otherwise, make a singleton list of the metric specification + # from the non-list inputs. + if isinstance(name_input, list): + items = list(stage_inputs.items()) + indexes = list(range(0, len(name_input))) + specs = list() + for i in indexes: + temp = dict([(k, v[i]) for k, v in items]) + if len(self.fixed_image) == 1: + temp["fixed_image"] = self.fixed_image[0] + else: + temp["fixed_image"] = self.fixed_image[i] + + if len(self.moving_image) == 1: + temp["moving_image"] = self.moving_image[0] + else: + temp["moving_image"] = self.moving_image[i] + + specs.append(temp) + else: + specs = [stage_inputs] + + # Format the --metric command line metric arguments, one per + # specification. + return [self._format_metric_argument(**spec) for spec in specs] + + @staticmethod + def _format_metric_argument(**kwargs): + retval = '%s[ %s, %s, %g, %d' % (kwargs['metric'], + kwargs['fixed_image'], + kwargs['moving_image'], + kwargs['weight'], + kwargs['radius_or_bins']) + + # The optional sampling strategy. + if 'sampling_strategy' in kwargs: + sampling_strategy = kwargs['sampling_strategy'] + elif 'sampling_percentage' in kwargs: + # The sampling percentage is specified but not the + # sampling strategy. Use the default strategy. + sampling_strategy = Registration.DEF_SAMPLING_STRATEGY + else: + sampling_strategy = None + # Format the optional sampling arguments. + if sampling_strategy: + retval += ', %s' % sampling_strategy + if 'sampling_percentage' in kwargs: + retval += ', %g' % kwargs['sampling_percentage'] + + retval += ' ]' + + return retval + + def _format_transform(self, index): + retval = [] + retval.append('%s[ ' % self.transforms[index]) + parameters = ', '.join([str( + element) for element in self.transform_parameters[index]]) + retval.append('%s' % parameters) + retval.append(' ]') + return "".join(retval) + + def _format_registration(self): + retval = [] + for ii in range(len(self.transforms)): + retval.append('--transform %s' % (self._format_transform(ii))) + for metric in self._format_metric(ii): + retval.append('--metric %s' % metric) + retval.append('--convergence %s' % self._format_convergence(ii)) + if isdefined(self.sigma_units): + retval.append('--smoothing-sigmas %s%s' % + (self._format_xarray(self.smoothing_sigmas[ii]), + self.sigma_units[ii])) + else: + retval.append('--smoothing-sigmas %s' % + self._format_xarray(self.smoothing_sigmas[ii])) + retval.append('--shrink-factors %s' % + self._format_xarray(self.shrink_factors[ii])) + if isdefined(self.use_estimate_learning_rate_once): + retval.append('--use-estimate-learning-rate-once %d' % + self.use_estimate_learning_rate_once[ii]) + if isdefined(self.use_histogram_matching): + # use_histogram_matching is either a common flag for all transforms + # or a list of transform-specific flags + if isinstance(self.use_histogram_matching, bool): + histval = self.use_histogram_matching + else: + histval = self.use_histogram_matching[ii] + retval.append('--use-histogram-matching %d' % histval) + return " ".join(retval) + + def _get_outputfilenames(self, inverse=False): + output_filename = None + if not inverse: + if isdefined(self.output_warped_image) and \ + self.output_warped_image: + output_filename = self.output_warped_image + if isinstance(output_filename, bool): + output_filename = '%s_Warped.nii.gz' % self.output_transform_prefix + else: + output_filename = output_filename + return output_filename + inv_output_filename = None + if isdefined(self.output_inverse_warped_image) and \ + self.output_inverse_warped_image: + inv_output_filename = self.output_inverse_warped_image + if isinstance(inv_output_filename, bool): + inv_output_filename = '%s_InverseWarped.nii.gz' % self.output_transform_prefix + else: + inv_output_filename = inv_output_filename + return inv_output_filename + + def _format_convergence(self, ii): + convergence_iter = self._format_xarray(self.number_of_iterations[ii]) + if len(self.convergence_threshold) > ii: + convergence_value = self.convergence_threshold[ii] + else: + convergence_value = self.convergence_threshold[0] + if len(self.convergence_window_size) > ii: + convergence_ws = self.convergence_window_size[ii] + else: + convergence_ws = self.convergence_window_size[0] + return '[ %s, %g, %d ]' % (convergence_iter, convergence_value, convergence_ws) + + def _format_winsorize_image_intensities(self): + if not self.winsorize_upper_quantile > self.winsorize_lower_quantile: + raise RuntimeError("Upper bound MUST be more than lower bound: %g > %g" + % (self.winsorize_upper_quantile, self.winsorize_lower_quantile)) + return '--winsorize-image-intensities [ %s, %s ]' % (self.winsorize_lower_quantile, + self.winsorize_upper_quantile) + + + def _output_filenames(self, prefix, count, transform, inverse=False): + self.low_dimensional_transform_map = {'Rigid': 'Rigid.mat', + 'Affine': 'Affine.mat', + 'GenericAffine': 'GenericAffine.mat', + 'CompositeAffine': 'Affine.mat', + 'Similarity': 'Similarity.mat', + 'Translation': 'Translation.mat', + 'BSpline': 'BSpline.txt', + 'Initial': 'DerivedInitialMovingTranslation.mat'} + if transform in list(self.low_dimensional_transform_map.keys()): + suffix = self.low_dimensional_transform_map[transform] + inverse_mode = inverse + else: + inverse_mode = False # These are not analytically invertable + if inverse: + suffix = 'InverseWarp.nii.gz' + else: + suffix = 'Warp.nii.gz' + return '%s%d%s' % (prefix, count, suffix), inverse_mode + + class RegistrationOutputSpec(TraitedSpec): forward_transforms = traits.List( File(exists=True), desc='List of output transforms for forward registration') @@ -440,7 +682,7 @@ class Registration(ANTSCommand): --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --transform SyN[ 0.25, 3.0, 0.0 ] \ --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --convergence [ 100x50x30, 1e-09, 20 ] \ --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 \ ---use-histogram-matching 1 --winsorize-image-intensities [ 0.025, 1.0 ] --write-composite-transform 1' +--use-histogram-matching 1 --winsorize-image-intensities [ 0.025, 1.0 ] --write-composite-transform 1' >>> reg1.run() # doctest: +SKIP >>> reg2 = copy.deepcopy(reg) @@ -453,7 +695,7 @@ class Registration(ANTSCommand): --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --transform SyN[ 0.25, 3.0, 0.0 ] \ --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --convergence [ 100x50x30, 1e-09, 20 ] \ --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 \ ---use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 0.975 ] --write-composite-transform 1' +--use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 0.975 ] --write-composite-transform 1' >>> reg3 = copy.deepcopy(reg) >>> reg3.inputs.winsorize_lower_quantile = 0.025 @@ -466,7 +708,7 @@ class Registration(ANTSCommand): --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --transform SyN[ 0.25, 3.0, 0.0 ] \ --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --convergence [ 100x50x30, 1e-09, 20 ] \ --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 \ ---use-histogram-matching 1 --winsorize-image-intensities [ 0.025, 0.975 ] --write-composite-transform 1' +--use-histogram-matching 1 --winsorize-image-intensities [ 0.025, 0.975 ] --write-composite-transform 1' >>> reg3a = copy.deepcopy(reg) >>> reg3a.inputs.float = True @@ -478,7 +720,7 @@ class Registration(ANTSCommand): --smoothing-sigmas 1.0x0.0vox --shrink-factors 2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 \ --transform SyN[ 0.25, 3.0, 0.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] \ --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 \ ---use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ +--use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ --write-composite-transform 1' >>> reg3b = copy.deepcopy(reg) @@ -491,7 +733,7 @@ class Registration(ANTSCommand): --smoothing-sigmas 1.0x0.0vox --shrink-factors 2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 \ --transform SyN[ 0.25, 3.0, 0.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] \ --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 \ ---use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ +--use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ --write-composite-transform 1' >>> # Test collapse transforms flag @@ -500,8 +742,7 @@ class Registration(ANTSCommand): >>> reg4.inputs.restore_state = 'trans.mat' >>> reg4.inputs.initialize_transforms_per_stage = True >>> reg4.inputs.collapse_output_transforms = True - >>> outputs = reg4._list_outputs() - >>> pprint.pprint(outputs) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + >>> pprint.pprint(reg4.outputs) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE {'composite_transform': '.../nipype/testing/data/output_Composite.h5', 'forward_invert_flags': [], 'forward_transforms': [], @@ -519,14 +760,14 @@ class Registration(ANTSCommand): --smoothing-sigmas 1.0x0.0vox --shrink-factors 2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 \ --transform SyN[ 0.25, 3.0, 0.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] \ --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 \ ---use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ +--use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ --write-composite-transform 1' >>> # Test collapse transforms flag >>> reg4b = copy.deepcopy(reg4) >>> reg4b.inputs.write_composite_transform = False >>> outputs = reg4b._list_outputs() - >>> pprint.pprint(outputs) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + >>> pprint.pprint(reg4b.outputs) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE {'composite_transform': , 'forward_invert_flags': [False, False], 'forward_transforms': ['.../nipype/testing/data/output_0GenericAffine.mat', @@ -547,7 +788,7 @@ class Registration(ANTSCommand): --smoothing-sigmas 1.0x0.0vox --shrink-factors 2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 \ --transform SyN[ 0.25, 3.0, 0.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] \ --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 \ ---use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ +--use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ --write-composite-transform 0' >>> # Test multiple metrics per stage @@ -568,7 +809,7 @@ class Registration(ANTSCommand): --metric Mattes[ fixed1.nii, moving1.nii, 0.5, 32, None, 0.05 ] \ --metric CC[ fixed1.nii, moving1.nii, 0.5, 4, None, 0.1 ] --convergence [ 100x50x30, 1e-09, 20 ] \ --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 \ ---use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1' +--use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1' >>> # Test multiple inputs >>> reg6 = copy.deepcopy(reg5) @@ -583,7 +824,7 @@ class Registration(ANTSCommand): --metric Mattes[ fixed1.nii, moving1.nii, 0.5, 32, None, 0.05 ] \ --metric CC[ fixed2.nii, moving2.nii, 0.5, 4, None, 0.1 ] --convergence [ 100x50x30, 1e-09, 20 ] \ --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 \ ---use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1' +--use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1' >>> # Test Interpolation Parameters (BSpline) >>> reg7a = copy.deepcopy(reg) @@ -597,7 +838,7 @@ class Registration(ANTSCommand): --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --transform SyN[ 0.25, 3.0, 0.0 ] \ --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --convergence [ 100x50x30, 1e-09, 20 ] \ --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 \ ---use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1' +--use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1' >>> # Test Interpolation Parameters (MultiLabel/Gaussian) >>> reg7b = copy.deepcopy(reg) @@ -611,7 +852,7 @@ class Registration(ANTSCommand): --smoothing-sigmas 1.0x0.0vox --shrink-factors 2x1 --use-estimate-learning-rate-once 1 --use-histogram-matching 1 \ --transform SyN[ 0.25, 3.0, 0.0 ] --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] \ --convergence [ 100x50x30, 1e-09, 20 ] --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 \ ---use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ +--use-estimate-learning-rate-once 1 --use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] \ --write-composite-transform 1' >>> # Test Extended Transform Parameters @@ -626,263 +867,21 @@ class Registration(ANTSCommand): --use-estimate-learning-rate-once 1 --use-histogram-matching 1 --transform BSplineSyN[ 0.25, 26, 0, 3 ] \ --metric Mattes[ fixed1.nii, moving1.nii, 1, 32 ] --convergence [ 100x50x30, 1e-09, 20 ] \ --smoothing-sigmas 2.0x1.0x0.0vox --shrink-factors 3x2x1 --use-estimate-learning-rate-once 1 \ ---use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1' +--use-histogram-matching 1 --winsorize-image-intensities [ 0.0, 1.0 ] --write-composite-transform 1' """ DEF_SAMPLING_STRATEGY = 'None' """The default sampling strategy argument.""" _cmd = 'antsRegistration' - input_spec = RegistrationInputSpec - output_spec = RegistrationOutputSpec - _quantilesDone = False + _input_spec = RegistrationInputSpec + _output_spec = RegistrationOutputSpec _linear_transform_names = ['Rigid', 'Affine', 'Translation', 'CompositeAffine', 'Similarity'] - def _format_metric(self, index): - """ - Format the antsRegistration -m metric argument(s). - - Parameters - ---------- - index: the stage index - """ - # The metric name input for the current stage. - name_input = self.inputs.metric[index] - # The stage-specific input dictionary. - stage_inputs = dict( - fixed_image=self.inputs.fixed_image[0], - moving_image=self.inputs.moving_image[0], - metric=name_input, - weight=self.inputs.metric_weight[index], - radius_or_bins=self.inputs.radius_or_number_of_bins[index], - optional=self.inputs.radius_or_number_of_bins[index] - ) - # The optional sampling strategy and percentage. - if isdefined(self.inputs.sampling_strategy) and self.inputs.sampling_strategy: - sampling_strategy = self.inputs.sampling_strategy[index] - if sampling_strategy: - stage_inputs['sampling_strategy'] = sampling_strategy - if isdefined(self.inputs.sampling_percentage) and self.inputs.sampling_percentage: - sampling_percentage = self.inputs.sampling_percentage[index] - if sampling_percentage: - stage_inputs['sampling_percentage'] = sampling_percentage - - # Make a list of metric specifications, one per -m command line - # argument for the current stage. - # If there are multiple inputs for this stage, then convert the - # dictionary of list inputs into a list of metric specifications. - # Otherwise, make a singleton list of the metric specification - # from the non-list inputs. - if isinstance(name_input, list): - items = list(stage_inputs.items()) - indexes = list(range(0, len(name_input))) - specs = list() - for i in indexes: - temp = dict([(k, v[i]) for k, v in items]) - if len(self.inputs.fixed_image) == 1: - temp["fixed_image"] = self.inputs.fixed_image[0] - else: - temp["fixed_image"] = self.inputs.fixed_image[i] - - if len(self.inputs.moving_image) == 1: - temp["moving_image"] = self.inputs.moving_image[0] - else: - temp["moving_image"] = self.inputs.moving_image[i] - - specs.append(temp) - else: - specs = [stage_inputs] - - # Format the --metric command line metric arguments, one per - # specification. - return [self._format_metric_argument(**spec) for spec in specs] - - @staticmethod - def _format_metric_argument(**kwargs): - retval = '%s[ %s, %s, %g, %d' % (kwargs['metric'], - kwargs['fixed_image'], - kwargs['moving_image'], - kwargs['weight'], - kwargs['radius_or_bins']) - - # The optional sampling strategy. - if 'sampling_strategy' in kwargs: - sampling_strategy = kwargs['sampling_strategy'] - elif 'sampling_percentage' in kwargs: - # The sampling percentage is specified but not the - # sampling strategy. Use the default strategy. - sampling_strategy = Registration.DEF_SAMPLING_STRATEGY - else: - sampling_strategy = None - # Format the optional sampling arguments. - if sampling_strategy: - retval += ', %s' % sampling_strategy - if 'sampling_percentage' in kwargs: - retval += ', %g' % kwargs['sampling_percentage'] - - retval += ' ]' - - return retval - - def _format_transform(self, index): - retval = [] - retval.append('%s[ ' % self.inputs.transforms[index]) - parameters = ', '.join([str( - element) for element in self.inputs.transform_parameters[index]]) - retval.append('%s' % parameters) - retval.append(' ]') - return "".join(retval) - - def _format_registration(self): - retval = [] - for ii in range(len(self.inputs.transforms)): - retval.append('--transform %s' % (self._format_transform(ii))) - for metric in self._format_metric(ii): - retval.append('--metric %s' % metric) - retval.append('--convergence %s' % self._format_convergence(ii)) - if isdefined(self.inputs.sigma_units): - retval.append('--smoothing-sigmas %s%s' % - (self._format_xarray(self.inputs.smoothing_sigmas[ii]), - self.inputs.sigma_units[ii])) - else: - retval.append('--smoothing-sigmas %s' % - self._format_xarray(self.inputs.smoothing_sigmas[ii])) - retval.append('--shrink-factors %s' % - self._format_xarray(self.inputs.shrink_factors[ii])) - if isdefined(self.inputs.use_estimate_learning_rate_once): - retval.append('--use-estimate-learning-rate-once %d' % - self.inputs.use_estimate_learning_rate_once[ii]) - if isdefined(self.inputs.use_histogram_matching): - # use_histogram_matching is either a common flag for all transforms - # or a list of transform-specific flags - if isinstance(self.inputs.use_histogram_matching, bool): - histval = self.inputs.use_histogram_matching - else: - histval = self.inputs.use_histogram_matching[ii] - retval.append('--use-histogram-matching %d' % histval) - return " ".join(retval) - - def _get_outputfilenames(self, inverse=False): - output_filename = None - if not inverse: - if isdefined(self.inputs.output_warped_image) and \ - self.inputs.output_warped_image: - output_filename = self.inputs.output_warped_image - if isinstance(output_filename, bool): - output_filename = '%s_Warped.nii.gz' % self.inputs.output_transform_prefix - else: - output_filename = output_filename - return output_filename - inv_output_filename = None - if isdefined(self.inputs.output_inverse_warped_image) and \ - self.inputs.output_inverse_warped_image: - inv_output_filename = self.inputs.output_inverse_warped_image - if isinstance(inv_output_filename, bool): - inv_output_filename = '%s_InverseWarped.nii.gz' % self.inputs.output_transform_prefix - else: - inv_output_filename = inv_output_filename - return inv_output_filename - - def _format_convergence(self, ii): - convergence_iter = self._format_xarray(self.inputs.number_of_iterations[ii]) - if len(self.inputs.convergence_threshold) > ii: - convergence_value = self.inputs.convergence_threshold[ii] - else: - convergence_value = self.inputs.convergence_threshold[0] - if len(self.inputs.convergence_window_size) > ii: - convergence_ws = self.inputs.convergence_window_size[ii] - else: - convergence_ws = self.inputs.convergence_window_size[0] - return '[ %s, %g, %d ]' % (convergence_iter, convergence_value, convergence_ws) - - def _format_winsorize_image_intensities(self): - if not self.inputs.winsorize_upper_quantile > self.inputs.winsorize_lower_quantile: - raise RuntimeError("Upper bound MUST be more than lower bound: %g > %g" - % (self.inputs.winsorize_upper_quantile, self.inputs.winsorize_lower_quantile)) - self._quantilesDone = True - return '--winsorize-image-intensities [ %s, %s ]' % (self.inputs.winsorize_lower_quantile, - self.inputs.winsorize_upper_quantile) - - def _format_arg(self, opt, spec, val): - if opt == 'fixed_image_mask': - if isdefined(self.inputs.moving_image_mask): - return '--masks [ %s, %s ]' % (self.inputs.fixed_image_mask, - self.inputs.moving_image_mask) - else: - return '--masks %s' % self.inputs.fixed_image_mask - elif opt == 'transforms': - return self._format_registration() - elif opt == 'initial_moving_transform': - try: - do_invert_transform = int(self.inputs.invert_initial_moving_transform) - except ValueError: - do_invert_transform = 0 # Just do the default behavior - return '--initial-moving-transform [ %s, %d ]' % (self.inputs.initial_moving_transform, - do_invert_transform) - elif opt == 'initial_moving_transform_com': - try: - do_center_of_mass_init = int(self.inputs.initial_moving_transform_com) - except ValueError: - do_center_of_mass_init = 0 # Just do the default behavior - return '--initial-moving-transform [ %s, %s, %d ]' % (self.inputs.fixed_image[0], - self.inputs.moving_image[0], - do_center_of_mass_init) - elif opt == 'interpolation': - if self.inputs.interpolation in ['BSpline', 'MultiLabel', 'Gaussian'] and \ - isdefined(self.inputs.interpolation_parameters): - return '--interpolation %s[ %s ]' % (self.inputs.interpolation, - ', '.join([str(param) - for param in self.inputs.interpolation_parameters])) - else: - return '--interpolation %s' % self.inputs.interpolation - elif opt == 'output_transform_prefix': - out_filename = self._get_outputfilenames(inverse=False) - inv_out_filename = self._get_outputfilenames(inverse=True) - if out_filename and inv_out_filename: - return '--output [ %s, %s, %s ]' % (self.inputs.output_transform_prefix, - out_filename, - inv_out_filename) - elif out_filename: - return '--output [ %s, %s ]' % (self.inputs.output_transform_prefix, - out_filename) - else: - return '--output %s' % self.inputs.output_transform_prefix - elif opt == 'winsorize_upper_quantile' or opt == 'winsorize_lower_quantile': - if not self._quantilesDone: - return self._format_winsorize_image_intensities() - else: - self._quantilesDone = False - return '' # Must return something for argstr! - # This feature was removed from recent versions of antsRegistration due to corrupt outputs. - # elif opt == 'collapse_linear_transforms_to_fixed_image_header': - # return self._formatCollapseLinearTransformsToFixedImageHeader() - return super(Registration, self)._format_arg(opt, spec, val) - - def _output_filenames(self, prefix, count, transform, inverse=False): - self.low_dimensional_transform_map = {'Rigid': 'Rigid.mat', - 'Affine': 'Affine.mat', - 'GenericAffine': 'GenericAffine.mat', - 'CompositeAffine': 'Affine.mat', - 'Similarity': 'Similarity.mat', - 'Translation': 'Translation.mat', - 'BSpline': 'BSpline.txt', - 'Initial': 'DerivedInitialMovingTranslation.mat'} - if transform in list(self.low_dimensional_transform_map.keys()): - suffix = self.low_dimensional_transform_map[transform] - inverse_mode = inverse - else: - inverse_mode = False # These are not analytically invertable - if inverse: - suffix = 'InverseWarp.nii.gz' - else: - suffix = 'Warp.nii.gz' - return '%s%d%s' % (prefix, count, suffix), inverse_mode - - def _list_outputs(self): - outputs = self._outputs().get() - outputs['forward_transforms'] = [] - outputs['forward_invert_flags'] = [] - outputs['reverse_transforms'] = [] - outputs['reverse_invert_flags'] = [] + def _post_run(self): + self.outputs.forward_transforms = [] + self.outputs.forward_invert_flags = [] + self.outputs.reverse_transforms = [] + self.outputs.reverse_invert_flags = [] # invert_initial_moving_transform should be always defined, even if # there's no initial transform @@ -892,18 +891,18 @@ def _list_outputs(self): if self.inputs.write_composite_transform: filename = self.inputs.output_transform_prefix + 'Composite.h5' - outputs['composite_transform'] = os.path.abspath(filename) + self.outputs.composite_transform = os.path.abspath(filename) filename = self.inputs.output_transform_prefix + \ 'InverseComposite.h5' - outputs['inverse_composite_transform'] = os.path.abspath(filename) + self.outputs.inverse_composite_transform = os.path.abspath(filename) else: # If composite transforms are written, then individuals are not written (as of 2014-10-26 if not self.inputs.collapse_output_transforms: transform_count = 0 if isdefined(self.inputs.initial_moving_transform): - outputs['forward_transforms'].append(self.inputs.initial_moving_transform) - outputs['forward_invert_flags'].append(invert_initial_moving_transform) - outputs['reverse_transforms'].insert(0, self.inputs.initial_moving_transform) - outputs['reverse_invert_flags'].insert(0, not invert_initial_moving_transform) # Prepend + self.outputs.forward_transforms.append(self.inputs.initial_moving_transform) + self.outputs.forward_invert_flags.append(invert_initial_moving_transform) + self.outputs.reverse_transforms.insert(0, self.inputs.initial_moving_transform) + self.outputs.reverse_invert_flags.insert(0, not invert_initial_moving_transform) # Prepend transform_count += 1 elif isdefined(self.inputs.initial_moving_transform_com): forward_filename, forward_inversemode = self._output_filenames( @@ -915,11 +914,11 @@ def _list_outputs(self): transform_count, 'Initial', True) - outputs['forward_transforms'].append(os.path.abspath(forward_filename)) - outputs['forward_invert_flags'].append(False) - outputs['reverse_transforms'].insert(0, + self.outputs.forward_transforms.append(os.path.abspath(forward_filename)) + self.outputs.forward_invert_flags.append(False) + self.outputs.reverse_transforms.insert(0, os.path.abspath(reverse_filename)) - outputs['reverse_invert_flags'].insert(0, True) + self.outputs.reverse_invert_flags.insert(0, True) transform_count += 1 for count in range(len(self.inputs.transforms)): @@ -929,10 +928,10 @@ def _list_outputs(self): reverse_filename, reverse_inversemode = self._output_filenames( self.inputs.output_transform_prefix, transform_count, self.inputs.transforms[count], True) - outputs['forward_transforms'].append(os.path.abspath(forward_filename)) - outputs['forward_invert_flags'].append(forward_inversemode) - outputs['reverse_transforms'].insert(0, os.path.abspath(reverse_filename)) - outputs['reverse_invert_flags'].insert(0, reverse_inversemode) + self.outputs.forward_transforms.append(os.path.abspath(forward_filename)) + self.outputs.forward_invert_flags.append(forward_inversemode) + self.outputs.reverse_transforms.insert(0, os.path.abspath(reverse_filename)) + self.outputs.reverse_invert_flags.insert(0, reverse_inversemode) transform_count += 1 else: transform_count = 0 @@ -960,18 +959,18 @@ def _list_outputs(self): transform_count, transform, inverse=True) - outputs['forward_transforms'].append(os.path.abspath(forward_filename)) - outputs['forward_invert_flags'].append(forward_inversemode) - outputs['reverse_transforms'].append(os.path.abspath(reverse_filename)) - outputs['reverse_invert_flags'].append(reverse_inversemode) + self.outputs.forward_transforms.append(os.path.abspath(forward_filename)) + self.outputs.forward_invert_flags.append(forward_inversemode) + self.outputs.reverse_transforms.append(os.path.abspath(reverse_filename)) + self.outputs.reverse_invert_flags.append(reverse_inversemode) transform_count += 1 out_filename = self._get_outputfilenames(inverse=False) inv_out_filename = self._get_outputfilenames(inverse=True) if out_filename: - outputs['warped_image'] = os.path.abspath(out_filename) + self.outputs.warped_image = os.path.abspath(out_filename) if inv_out_filename: - outputs['inverse_warped_image'] = os.path.abspath(inv_out_filename) + self.outputs.inverse_warped_image = os.path.abspath(inv_out_filename) if len(self.inputs.save_state): - outputs['save_state'] = os.path.abspath(self.inputs.save_state) - return outputs + self.outputs.save_state = os.path.abspath(self.inputs.save_state) + diff --git a/nipype/interfaces/ants/resampling.py b/nipype/interfaces/ants/resampling.py index 6191324771..a67f034856 100644 --- a/nipype/interfaces/ants/resampling.py +++ b/nipype/interfaces/ants/resampling.py @@ -18,12 +18,14 @@ class WarpTimeSeriesImageMultiTransformInputSpec(ANTSCommandInputSpec): dimension = traits.Enum(4, 3, argstr='%d', usedefault=True, desc='image dimension (3 or 4)', position=1) - input_image = File(argstr='%s', mandatory=True, copyfile=True, - desc=('image to apply transformation to (generally a ' - 'coregistered functional)')) - out_postfix = traits.Str('_wtsimt', argstr='%s', usedefault=True, - desc=('Postfix that is prepended to all output ' - 'files (default = _wtsimt)')) + input_image = File( + argstr='%s', mandatory=True, copyfile=True, + desc='image to apply transformation to (generally a coregistered functional)') + output_image = File(name_source='input_image', name_template='%s_wtsimt', argstr='%s', + keep_extension=True, desc='filename of output warped image') + out_postfix = traits.Str( + '_wtsimt', argstr='%s', deprecated=True, new_name='output_image', + desc='Postfix that is prepended to all output files (default = _wtsimt)') reference_image = File(argstr='-R %s', xor=['tightest_box'], desc='reference image space that you wish to warp INTO') tightest_box = traits.Bool(argstr='--tightest-bounding-box', @@ -46,6 +48,20 @@ class WarpTimeSeriesImageMultiTransformInputSpec(ANTSCommandInputSpec): 'E.g.: [1,4,5] inverts the 1st, 4th, and 5th Affines ' 'found in transformation_series')) + def _format_arg(self, opt, spec, val): + if opt == 'transformation_series': + series = [] + affine_counter = 0 + for transformation in val: + if 'Affine' in transformation and \ + isdefined(self.invert_affine): + affine_counter += 1 + if affine_counter in self.invert_affine: + series += ['-i'], + series += [transformation] + return ' '.join(series) + return super( + WarpTimeSeriesImageMultiTransformInputSpec, self)._format_arg(opt, spec, val) class WarpTimeSeriesImageMultiTransformOutputSpec(TraitedSpec): output_image = File(exists=True, desc='Warped image') @@ -69,35 +85,8 @@ class WarpTimeSeriesImageMultiTransform(ANTSCommand): """ _cmd = 'WarpTimeSeriesImageMultiTransform' - input_spec = WarpTimeSeriesImageMultiTransformInputSpec - output_spec = WarpTimeSeriesImageMultiTransformOutputSpec - - def _format_arg(self, opt, spec, val): - if opt == 'out_postfix': - _, name, ext = split_filename( - os.path.abspath(self.inputs.input_image)) - return name + val + ext - if opt == 'transformation_series': - series = [] - affine_counter = 0 - for transformation in val: - if 'Affine' in transformation and \ - isdefined(self.inputs.invert_affine): - affine_counter += 1 - if affine_counter in self.inputs.invert_affine: - series += ['-i'], - series += [transformation] - return ' '.join(series) - return super(WarpTimeSeriesImageMultiTransform, self)._format_arg(opt, spec, val) - - def _list_outputs(self): - outputs = self._outputs().get() - _, name, ext = split_filename(os.path.abspath(self.inputs.input_image)) - outputs['output_image'] = os.path.join(os.getcwd(), - ''.join((name, - self.inputs.out_postfix, - ext))) - return outputs + _input_spec = WarpTimeSeriesImageMultiTransformInputSpec + _output_spec = WarpTimeSeriesImageMultiTransformOutputSpec def _run_interface(self, runtime, correct_return_codes=[0]): runtime = super(WarpTimeSeriesImageMultiTransform, self)._run_interface(runtime, correct_return_codes=[0, 1]) @@ -112,11 +101,12 @@ class WarpImageMultiTransformInputSpec(ANTSCommandInputSpec): input_image = File(argstr='%s', mandatory=True, desc=('image to apply transformation to (generally a ' 'coregistered functional)'), position=2) - output_image = File(genfile=True, hash_files=False, argstr='%s', - desc='name of the output warped image', position=3, xor=['out_postfix']) - out_postfix = File("_wimt", usedefault=True, hash_files=False, - desc=('Postfix that is prepended to all output ' - 'files (default = _wimt)'), xor=['output_image']) + output_image = File(name_source='input_image', name_template='%s_wimt', argstr='%s', + keep_extension=True, desc='filename of output warped image') + out_postfix = File( + "_wimt", usedefault=True, hash_files=False, deprecated=True, new_name='output_image', + desc=('Postfix that is prepended to all output files (default = _wimt)'), + xor=['output_image']) reference_image = File(argstr='-R %s', xor=['tightest_box'], desc='reference image space that you wish to warp INTO') tightest_box = traits.Bool(argstr='--tightest-bounding-box', @@ -142,6 +132,20 @@ class WarpImageMultiTransformInputSpec(ANTSCommandInputSpec): 'transformations are distinguished ' 'from warp fields by the word "affine" included in their filenames.')) + def _format_arg(self, opt, spec, val): + if opt == 'transformation_series': + series = [] + affine_counter = 0 + for transformation in val: + if "affine" in transformation.lower() and \ + isdefined(self.invert_affine): + affine_counter += 1 + if affine_counter in self.invert_affine: + series += '-i', + series += [transformation] + return ' '.join(series) + return super(WarpImageMultiTransformInputSpec, self)._format_arg(opt, spec, val) + class WarpImageMultiTransformOutputSpec(TraitedSpec): output_image = File(exists=True, desc='Warped image') @@ -175,38 +179,8 @@ class WarpImageMultiTransform(ANTSCommand): """ _cmd = 'WarpImageMultiTransform' - input_spec = WarpImageMultiTransformInputSpec - output_spec = WarpImageMultiTransformOutputSpec - - def _gen_filename(self, name): - if name == 'output_image': - _, name, ext = split_filename( - os.path.abspath(self.inputs.input_image)) - return ''.join((name, self.inputs.out_postfix, ext)) - return None - - def _format_arg(self, opt, spec, val): - if opt == 'transformation_series': - series = [] - affine_counter = 0 - for transformation in val: - if "affine" in transformation.lower() and \ - isdefined(self.inputs.invert_affine): - affine_counter += 1 - if affine_counter in self.inputs.invert_affine: - series += '-i', - series += [transformation] - return ' '.join(series) - return super(WarpImageMultiTransform, self)._format_arg(opt, spec, val) - - def _list_outputs(self): - outputs = self._outputs().get() - if isdefined(self.inputs.output_image): - outputs['output_image'] = os.path.abspath(self.inputs.output_image) - else: - outputs['output_image'] = os.path.abspath( - self._gen_filename('output_image')) - return outputs + _input_spec = WarpImageMultiTransformInputSpec + _output_spec = WarpImageMultiTransformOutputSpec class ApplyTransformsInputSpec(ANTSCommandInputSpec): @@ -224,8 +198,8 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec): desc=('image to apply transformation to (generally a ' 'coregistered functional)'), exists=True) - output_image = traits.Str(argstr='--output %s', desc='output file name', - genfile=True, hash_files=False) + output_image = File(name_source='input_image', name_template='%s_warped', keep_extension=True, + argstr='--output %s', desc='output file name', hash_files=False) out_postfix = traits.Str("_trans", usedefault=True, desc=('Postfix that is appended to all output ' 'files (default = _trans)')) @@ -250,10 +224,46 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec): File(exists=True), argstr='%s', mandatory=True, desc='transform files: will be applied in reverse order. For example, the last specified transform will be applied first') invert_transform_flags = InputMultiPath(traits.Bool()) default_value = traits.Float(0.0, argstr='--default-value %g', usedefault=True) - print_out_composite_warp_file = traits.Bool(False, requires=["output_image"], - desc='output a composite warp file instead of a transformed image') + print_out_composite_warp_file = traits.Bool( + False, usedefault=True, desc='output a composite warp file instead of a transformed image') float = traits.Bool(argstr='--float %d', default=False, desc='Use float instead of double for computations.') + def _get_transform_filenames(self): + retval = [] + for ii in range(len(self.transforms)): + if isdefined(self.invert_transform_flags): + if len(self.transforms) == len(self.invert_transform_flags): + invert_code = 1 if self.invert_transform_flags[ + ii] else 0 + retval.append("--transform [ %s, %d ]" % + (self.transforms[ii], invert_code)) + else: + raise Exception(("ERROR: The useInverse list must have the same number " + "of entries as the transformsFileName list.")) + else: + retval.append("--transform %s" % self.transforms[ii]) + return " ".join(retval) + + def _format_arg(self, opt, spec, val): + retval = super(ApplyTransformsInputSpec, self)._format_arg(opt, spec, val) + + if opt == "output_image": + if self.print_out_composite_warp_file: + modval = super(ApplyTransformsInputSpec, + self)._format_arg('print_out_composite_warp_file') + return '--output [ ' + retval[6:] + ', ' + modval + ' ]' + elif opt == "transforms": + return self._get_transform_filenames() + elif opt == 'interpolation': + if self.interpolation in ['BSpline', 'MultiLabel', 'Gaussian'] and \ + isdefined(self.interpolation_parameters): + return '--interpolation %s[ %s ]' % (self.interpolation, + ', '.join([str(param) + for param in self.interpolation_parameters])) + else: + return '--interpolation %s' % self.interpolation + return retval + class ApplyTransformsOutputSpec(TraitedSpec): output_image = File(exists=True, desc='Warped image') @@ -299,61 +309,8 @@ class ApplyTransforms(ANTSCommand): """ _cmd = 'antsApplyTransforms' - input_spec = ApplyTransformsInputSpec - output_spec = ApplyTransformsOutputSpec - - def _gen_filename(self, name): - if name == 'output_image': - output = self.inputs.output_image - if not isdefined(output): - _, name, ext = split_filename(self.inputs.input_image) - output = name + self.inputs.out_postfix + ext - return output - return None - - def _get_transform_filenames(self): - retval = [] - for ii in range(len(self.inputs.transforms)): - if isdefined(self.inputs.invert_transform_flags): - if len(self.inputs.transforms) == len(self.inputs.invert_transform_flags): - invert_code = 1 if self.inputs.invert_transform_flags[ - ii] else 0 - retval.append("--transform [ %s, %d ]" % - (self.inputs.transforms[ii], invert_code)) - else: - raise Exception(("ERROR: The useInverse list must have the same number " - "of entries as the transformsFileName list.")) - else: - retval.append("--transform %s" % self.inputs.transforms[ii]) - return " ".join(retval) - - def _get_output_warped_filename(self): - if isdefined(self.inputs.print_out_composite_warp_file): - return "--output [ %s, %d ]" % (self._gen_filename("output_image"), - int(self.inputs.print_out_composite_warp_file)) - else: - return "--output %s" % (self._gen_filename("output_image")) - - def _format_arg(self, opt, spec, val): - if opt == "output_image": - return self._get_output_warped_filename() - elif opt == "transforms": - return self._get_transform_filenames() - elif opt == 'interpolation': - if self.inputs.interpolation in ['BSpline', 'MultiLabel', 'Gaussian'] and \ - isdefined(self.inputs.interpolation_parameters): - return '--interpolation %s[ %s ]' % (self.inputs.interpolation, - ', '.join([str(param) - for param in self.inputs.interpolation_parameters])) - else: - return '--interpolation %s' % self.inputs.interpolation - return super(ApplyTransforms, self)._format_arg(opt, spec, val) - - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output_image'] = os.path.abspath( - self._gen_filename('output_image')) - return outputs + _input_spec = ApplyTransformsInputSpec + _output_spec = ApplyTransformsOutputSpec class ApplyTransformsToPointsInputSpec(ANTSCommandInputSpec): @@ -381,6 +338,27 @@ class ApplyTransformsToPointsInputSpec(ANTSCommandInputSpec): invert_transform_flags = traits.List(traits.Bool(), desc='list indicating if a transform should be reversed') + def _get_transform_filenames(self): + retval = [] + for ii in range(len(self.transforms)): + if isdefined(self.invert_transform_flags): + if len(self.transforms) == len(self.invert_transform_flags): + invert_code = 1 if self.invert_transform_flags[ + ii] else 0 + retval.append("--transform [ %s, %d ]" % + (self.transforms[ii], invert_code)) + else: + raise Exception(("ERROR: The useInverse list must have the same number " + "of entries as the transformsFileName list.")) + else: + retval.append("--transform %s" % self.transforms[ii]) + return " ".join(retval) + + def _format_arg(self, opt, spec, val): + if opt == "transforms": + return self._get_transform_filenames() + return super(ApplyTransformsToPointsInputSpec, self)._format_arg(opt, spec, val) + class ApplyTransformsToPointsOutputSpec(TraitedSpec): output_file = File(exists=True, desc='csv file with transformed coordinates') @@ -406,26 +384,5 @@ class ApplyTransformsToPoints(ANTSCommand): """ _cmd = 'antsApplyTransformsToPoints' - input_spec = ApplyTransformsToPointsInputSpec - output_spec = ApplyTransformsToPointsOutputSpec - - def _get_transform_filenames(self): - retval = [] - for ii in range(len(self.inputs.transforms)): - if isdefined(self.inputs.invert_transform_flags): - if len(self.inputs.transforms) == len(self.inputs.invert_transform_flags): - invert_code = 1 if self.inputs.invert_transform_flags[ - ii] else 0 - retval.append("--transform [ %s, %d ]" % - (self.inputs.transforms[ii], invert_code)) - else: - raise Exception(("ERROR: The useInverse list must have the same number " - "of entries as the transformsFileName list.")) - else: - retval.append("--transform %s" % self.inputs.transforms[ii]) - return " ".join(retval) - - def _format_arg(self, opt, spec, val): - if opt == "transforms": - return self._get_transform_filenames() - return super(ApplyTransformsToPoints, self)._format_arg(opt, spec, val) + _input_spec = ApplyTransformsToPointsInputSpec + _output_spec = ApplyTransformsToPointsOutputSpec diff --git a/nipype/interfaces/ants/segmentation.py b/nipype/interfaces/ants/segmentation.py index 619057b693..6d1ec5e600 100644 --- a/nipype/interfaces/ants/segmentation.py +++ b/nipype/interfaces/ants/segmentation.py @@ -47,11 +47,57 @@ class AtroposInputSpec(ANTSCommandInputSpec): usedefault=True) use_mixture_model_proportions = traits.Bool( requires=['posterior_formulation']) - out_classified_image_name = File(argstr="%s", genfile=True, - hash_files=False) - save_posteriors = traits.Bool() - output_posteriors_name_template = traits.Str('POSTERIOR_%02d.nii.gz', - usedefault=True) + out_classified_image_name = File( + name_source='intensity_images', name_template='%s_labeled', keep_extension=True, + argstr='--output [%s]', hash_files=False) + save_posteriors = traits.Bool(False, usedefault=True, desc='save posterior probability maps') + posteriors = File('posterior_%02d.nii.gz', usedefault=True) + + def _format_arg(self, opt, spec, val): + if opt == 'initialization': + retval = "--initialization %s[%d" % (val, + self.number_of_tissue_classes) + if val == "PriorProbabilityImages": + _, _, ext = split_filename( + self.prior_probability_images[0]) + retval += ",priors/priorProbImages%02d" + \ + ext + ",%g" % self.prior_weighting + if isdefined(self.prior_probability_threshold): + retval += ",%g" % self.prior_probability_threshold + return retval + "]" + if opt == 'mrf_smoothing_factor': + retval = "--mrf [%g" % val + if isdefined(self.mrf_radius): + retval += ",%s" % self._format_xarray([str(s) for s in self.mrf_radius]) + return retval + "]" + if opt == "icm_use_synchronous_update": + retval = "--icm [%d" % val + if isdefined(self.maximum_number_of_icm_terations): + retval += ",%g" % self.maximum_number_of_icm_terations + return retval + "]" + if opt == "n_iterations": + retval = "--convergence [%d" % val + if isdefined(self.convergence_threshold): + retval += ",%g" % self.convergence_threshold + return retval + "]" + if opt == "posterior_formulation": + retval = "--posterior-formulation %s" % val + if isdefined(self.use_mixture_model_proportions): + retval += "[%d]" % self.use_mixture_model_proportions + return retval + if opt == "out_classified_image_name": + retval = super(AtroposInputSpec, self)._format_arg(opt, spec, val) + if self.save_posteriors: + retval = retval[:-1] + ', ' + super( + AtroposInputSpec, self)._format_arg('posteriors') + ']' + return retval + return super(AtroposInputSpec, self)._format_arg(opt, spec, val) + + def parse_args(self, skip=None): + if skip is None: + skip = [] + skip += ['save_posteriors', 'posteriors'] + return super(AtroposInputSpec, self).parse_args(skip=skip) class AtroposOutputSpec(TraitedSpec): @@ -95,49 +141,10 @@ class Atropos(ANTSCommand): --likelihood-model Gaussian --mask-image mask.nii --mrf [0.2,1x1x1] --convergence [5,1e-06] \ --output [structural_labeled.nii,POSTERIOR_%02d.nii.gz] --posterior-formulation Socrates[1] --use-random-seed 1' """ - input_spec = AtroposInputSpec - output_spec = AtroposOutputSpec + _input_spec = AtroposInputSpec + _output_spec = AtroposOutputSpec _cmd = 'Atropos' - def _format_arg(self, opt, spec, val): - if opt == 'initialization': - retval = "--initialization %s[%d" % (val, - self.inputs.number_of_tissue_classes) - if val == "PriorProbabilityImages": - _, _, ext = split_filename( - self.inputs.prior_probability_images[0]) - retval += ",priors/priorProbImages%02d" + \ - ext + ",%g" % self.inputs.prior_weighting - if isdefined(self.inputs.prior_probability_threshold): - retval += ",%g" % self.inputs.prior_probability_threshold - return retval + "]" - if opt == 'mrf_smoothing_factor': - retval = "--mrf [%g" % val - if isdefined(self.inputs.mrf_radius): - retval += ",%s" % self._format_xarray([str(s) for s in self.inputs.mrf_radius]) - return retval + "]" - if opt == "icm_use_synchronous_update": - retval = "--icm [%d" % val - if isdefined(self.inputs.maximum_number_of_icm_terations): - retval += ",%g" % self.inputs.maximum_number_of_icm_terations - return retval + "]" - if opt == "n_iterations": - retval = "--convergence [%d" % val - if isdefined(self.inputs.convergence_threshold): - retval += ",%g" % self.inputs.convergence_threshold - return retval + "]" - if opt == "posterior_formulation": - retval = "--posterior-formulation %s" % val - if isdefined(self.inputs.use_mixture_model_proportions): - retval += "[%d]" % self.inputs.use_mixture_model_proportions - return retval - if opt == "out_classified_image_name": - retval = "--output [%s" % val - if isdefined(self.inputs.save_posteriors): - retval += ",%s" % self.inputs.output_posteriors_name_template - return retval + "]" - return super(ANTSCommand, self)._format_arg(opt, spec, val) - def _run_interface(self, runtime, correct_return_codes=[0]): if self.inputs.initialization == "PriorProbabilityImages": priors_directory = os.path.join(os.getcwd(), "priors") @@ -153,25 +160,6 @@ def _run_interface(self, runtime, correct_return_codes=[0]): runtime = super(Atropos, self)._run_interface(runtime) return runtime - def _gen_filename(self, name): - if name == 'out_classified_image_name': - output = self.inputs.out_classified_image_name - if not isdefined(output): - _, name, ext = split_filename(self.inputs.intensity_images[0]) - output = name + '_labeled' + ext - return output - return None - - def _list_outputs(self): - outputs = self._outputs().get() - outputs['classified_image'] = os.path.abspath( - self._gen_filename('out_classified_image_name')) - if isdefined(self.inputs.save_posteriors) and self.inputs.save_posteriors: - outputs['posteriors'] = [] - for i in range(self.inputs.number_of_tissue_classes): - outputs['posteriors'].append(os.path.abspath(self.inputs.output_posteriors_name_template % (i + 1))) - return outputs - class LaplacianThicknessInputSpec(ANTSCommandInputSpec): input_wm = File(argstr='%s', mandatory=True, copyfile=True, @@ -212,8 +200,8 @@ class LaplacianThickness(ANTSCommand): """ _cmd = 'LaplacianThickness' - input_spec = LaplacianThicknessInputSpec - output_spec = LaplacianThicknessOutputSpec + _input_spec = LaplacianThicknessInputSpec + _output_spec = LaplacianThicknessOutputSpec def _gen_filename(self, name): if name == 'output_image': @@ -224,14 +212,12 @@ def _gen_filename(self, name): return output return None - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): _, name, ext = split_filename(os.path.abspath(self.inputs.input_wm)) - outputs['output_image'] = os.path.join(os.getcwd(), + self.outputs.output_image = os.path.join(os.getcwd(), ''.join((name, self.inputs.output_image, ext))) - return outputs class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec): @@ -243,9 +229,10 @@ class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec): 'coregistered functional)')) mask_image = File(argstr='--mask-image %s') weight_image = File(argstr='--weight-image %s') - output_image = traits.Str(argstr='--output %s', - desc='output file name', genfile=True, - hash_files=False) + output_image = File( + name_source='input_image', name_template='%s_corrected', + argstr='--output %s', desc='output file name', keep_extension=True, + hash_files=False) bspline_fitting_distance = traits.Float(argstr="--bspline-fitting %s") bspline_order = traits.Int(requires=['bspline_fitting_distance']) shrink_factor = traits.Int(argstr="--shrink-factor %d") @@ -254,9 +241,41 @@ class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec): save_bias = traits.Bool(False, mandatory=True, usedefault=True, desc=('True if the estimated bias should be saved' ' to file.'), xor=['bias_image']) - bias_image = File(desc='Filename for the estimated bias.', - hash_files=False) + bias_image = File(name_source='input_image', name_template='%s_bias', + keep_extension=True, hash_files=False, argstr='%s', + desc='Filename for the estimated bias.') + def _format_arg(self, name, trait_spec, value): + if name == 'bspline_fitting_distance': + if isdefined(self.bspline_order): + newval = '[ %g, %d ]' % (value, self.bspline_order) + else: + newval = '[ %g ]' % value + return trait_spec.argstr % newval + + if name == 'n_iterations': + if isdefined(self.convergence_threshold): + newval = '[ %s, %g ]' % (self._format_xarray([str(elt) for elt in value]), + self.convergence_threshold) + else: + newval = '[ %s ]' % self._format_xarray([str(elt) for elt in value]) + return trait_spec.argstr % newval + + if name == 'output_image' and self.save_bias: + val_out = super(N4BiasFieldCorrectionInputSpec, self)._format_arg( + name, trait_spec, value) + val_bias = super(N4BiasFieldCorrectionInputSpec, self)._format_arg('bias_image') + retval = '[ ' + val_out[9:] + ', ' + val_bias + ' ]' + return trait_spec.argstr % retval + + return super(N4BiasFieldCorrectionInputSpec, + self)._format_arg(name, trait_spec, value) + + def parse_args(self, skip=None): + if skip is None: + skip = [] + skip += ['save_bias', 'bias_image'] + return super(N4BiasFieldCorrectionInputSpec, self).parse_args(skip=skip) class N4BiasFieldCorrectionOutputSpec(TraitedSpec): output_image = File(exists=True, desc='Warped image') @@ -320,66 +339,8 @@ class N4BiasFieldCorrection(ANTSCommand): """ _cmd = 'N4BiasFieldCorrection' - input_spec = N4BiasFieldCorrectionInputSpec - output_spec = N4BiasFieldCorrectionOutputSpec - - def _gen_filename(self, name): - if name == 'output_image': - output = self.inputs.output_image - if not isdefined(output): - _, name, ext = split_filename(self.inputs.input_image) - output = name + '_corrected' + ext - return output - - if name == 'bias_image': - output = self.inputs.bias_image - if not isdefined(output): - _, name, ext = split_filename(self.inputs.input_image) - output = name + '_bias' + ext - return output - return None - - def _format_arg(self, name, trait_spec, value): - if ((name == 'output_image') and - (self.inputs.save_bias or isdefined(self.inputs.bias_image))): - bias_image = self._gen_filename('bias_image') - output = self._gen_filename('output_image') - newval = '[ %s, %s ]' % (output, bias_image) - return trait_spec.argstr % newval - - if name == 'bspline_fitting_distance': - if isdefined(self.inputs.bspline_order): - newval = '[ %g, %d ]' % (value, self.inputs.bspline_order) - else: - newval = '[ %g ]' % value - return trait_spec.argstr % newval - - if name == 'n_iterations': - if isdefined(self.inputs.convergence_threshold): - newval = '[ %s, %g ]' % (self._format_xarray([str(elt) for elt in value]), - self.inputs.convergence_threshold) - else: - newval = '[ %s ]' % self._format_xarray([str(elt) for elt in value]) - return trait_spec.argstr % newval - - return super(N4BiasFieldCorrection, - self)._format_arg(name, trait_spec, value) - - def _parse_inputs(self, skip=None): - if skip is None: - skip = [] - skip += ['save_bias', 'bias_image'] - return super(N4BiasFieldCorrection, self)._parse_inputs(skip=skip) - - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output_image'] = os.path.abspath( - self._gen_filename('output_image')) - - if self.inputs.save_bias or isdefined(self.inputs.bias_image): - outputs['bias_image'] = os.path.abspath( - self._gen_filename('bias_image')) - return outputs + _input_spec = N4BiasFieldCorrectionInputSpec + _output_spec = N4BiasFieldCorrectionOutputSpec class CorticalThicknessInputSpec(ANTSCommandInputSpec): @@ -432,7 +393,7 @@ class CorticalThicknessInputSpec(ANTSCommandInputSpec): posterior_formulation = traits.Str(argstr='-b %s', desc=('Atropos posterior formulation and whether or not' 'to use mixture model proportions.' - '''e.g 'Socrates[1]' (default) or 'Aristotle[1]'.''' + """e.g 'Socrates[1]' (default) or 'Aristotle[1]'.""" 'Choose the latter if you' 'want use the distance priors (see also the -l option' 'for label propagation control).')) @@ -449,7 +410,7 @@ class CorticalThicknessInputSpec(ANTSCommandInputSpec): desc='Cortical ROI labels to use as a prior for ATITH.') label_propagation = traits.Str(argstr='-l %s', desc=('Incorporate a distance prior one the posterior formulation. Should be' - '''of the form 'label[lambda,boundaryProbability]' where label''' + """of the form 'label[lambda,boundaryProbability]' where label""" 'is a value of 1,2,3,... denoting label ID. The label' 'probability for anything outside the current label' ' = boundaryProbability * exp( -lambda * distanceFromBoundary )' @@ -467,6 +428,29 @@ class CorticalThicknessInputSpec(ANTSCommandInputSpec): 'Requires single thread computation for complete reproducibility.')) + def _format_arg(self, opt, spec, val): + if opt == 'anatomical_image': + retval = '-a %s' % val + return retval + if opt == 'brain_template': + retval = '-e %s' % val + return retval + if opt == 'brain_probability_mask': + retval = '-m %s' % val + return retval + if opt == 'out_prefix': + retval = '-o %s' % val + return retval + if opt == 't1_registration_template': + retval = '-t %s' % val + return retval + if opt == 'segmentation_priors': + _, _, ext = split_filename(self.segmentation_priors[0]) + retval = "-p nipype_priors/BrainSegmentationPrior%02d" + ext + return retval + return super(CorticalThicknessInputSpec, self)._format_arg(opt, spec, val) + + class CorticalThicknessOutputSpec(TraitedSpec): BrainExtractionMask = File(exists=True, desc='brain extraction mask') BrainSegmentation = File(exists=True, desc='brain segmentaion image') @@ -506,32 +490,10 @@ class CorticalThickness(ANTSCommand): -s nii.gz -o antsCT_ -p nipype_priors/BrainSegmentationPrior%02d.nii.gz -t brain_study_template.nii.gz' """ - input_spec = CorticalThicknessInputSpec - output_spec = CorticalThicknessOutputSpec + _input_spec = CorticalThicknessInputSpec + _output_spec = CorticalThicknessOutputSpec _cmd = 'antsCorticalThickness.sh' - def _format_arg(self, opt, spec, val): - if opt == 'anatomical_image': - retval = '-a %s' % val - return retval - if opt == 'brain_template': - retval = '-e %s' % val - return retval - if opt == 'brain_probability_mask': - retval = '-m %s' % val - return retval - if opt == 'out_prefix': - retval = '-o %s' % val - return retval - if opt == 't1_registration_template': - retval = '-t %s' % val - return retval - if opt == 'segmentation_priors': - _, _, ext = split_filename(self.inputs.segmentation_priors[0]) - retval = "-p nipype_priors/BrainSegmentationPrior%02d" + ext - return retval - return super(ANTSCommand, self)._format_arg(opt, spec, val) - def _run_interface(self, runtime, correct_return_codes=[0]): priors_directory = os.path.join(os.getcwd(), "nipype_priors") if not os.path.exists(priors_directory): @@ -545,17 +507,16 @@ def _run_interface(self, runtime, correct_return_codes=[0]): runtime = super(CorticalThickness, self)._run_interface(runtime) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['BrainExtractionMask'] = os.path.join(os.getcwd(), + def _post_run(self): + self.outputs.BrainExtractionMask = os.path.join(os.getcwd(), self.inputs.out_prefix + 'BrainExtractionMask.' + self.inputs.image_suffix) - outputs['BrainSegmentation'] = os.path.join(os.getcwd(), + self.outputs.BrainSegmentation = os.path.join(os.getcwd(), self.inputs.out_prefix + 'BrainSegmentation.' + self.inputs.image_suffix) - outputs['BrainSegmentationN4'] = os.path.join(os.getcwd(), + self.outputs.BrainSegmentationN4 = os.path.join(os.getcwd(), self.inputs.out_prefix + 'BrainSegmentation0N4.' + self.inputs.image_suffix) @@ -565,37 +526,36 @@ def _list_outputs(self): self.inputs.out_prefix + 'BrainSegmentationPosteriors%02d.' % (i + 1) + self.inputs.image_suffix)) - outputs['BrainSegmentationPosteriors'] = posteriors - outputs['CorticalThickness'] = os.path.join(os.getcwd(), + self.outputs.BrainSegmentationPosteriors = posteriors + self.outputs.CorticalThickness = os.path.join(os.getcwd(), self.inputs.out_prefix + 'CorticalThickness.' + self.inputs.image_suffix) - outputs['TemplateToSubject1GenericAffine'] = os.path.join(os.getcwd(), + self.outputs.TemplateToSubject1GenericAffine = os.path.join(os.getcwd(), self.inputs.out_prefix + 'TemplateToSubject1GenericAffine.mat') - outputs['TemplateToSubject0Warp'] = os.path.join(os.getcwd(), + self.outputs.TemplateToSubject0Warp = os.path.join(os.getcwd(), self.inputs.out_prefix + 'TemplateToSubject0Warp.' + self.inputs.image_suffix) - outputs['SubjectToTemplate1Warp'] = os.path.join(os.getcwd(), + self.outputs.SubjectToTemplate1Warp = os.path.join(os.getcwd(), self.inputs.out_prefix + 'SubjectToTemplate1Warp.' + self.inputs.image_suffix) - outputs['SubjectToTemplate0GenericAffine'] = os.path.join(os.getcwd(), + self.outputs.SubjectToTemplate0GenericAffine = os.path.join(os.getcwd(), self.inputs.out_prefix + 'SubjectToTemplate0GenericAffine.mat') - outputs['SubjectToTemplateLogJacobian'] = os.path.join(os.getcwd(), + self.outputs.SubjectToTemplateLogJacobian = os.path.join(os.getcwd(), self.inputs.out_prefix + 'SubjectToTemplateLogJacobian.' + self.inputs.image_suffix) - outputs['CorticalThicknessNormedToTemplate'] = os.path.join(os.getcwd(), + self.outputs.CorticalThicknessNormedToTemplate = os.path.join(os.getcwd(), self.inputs.out_prefix + 'CorticalThickness.' + self.inputs.image_suffix) - outputs['BrainVolumes'] = os.path.join(os.getcwd(), + self.outputs.BrainVolumes = os.path.join(os.getcwd(), self.inputs.out_prefix + 'brainvols.csv') - return outputs class antsCorticalThickness(CorticalThickness): @@ -667,21 +627,19 @@ class BrainExtraction(ANTSCommand): 'antsBrainExtraction.sh -a T1.nii.gz -m ProbabilityMaskOfStudyTemplate.nii.gz -e study_template.nii.gz -d 3 \ -s nii.gz -o highres001_' """ - input_spec = BrainExtractionInputSpec - output_spec = BrainExtractionOutputSpec + _input_spec = BrainExtractionInputSpec + _output_spec = BrainExtractionOutputSpec _cmd = 'antsBrainExtraction.sh' - def _list_outputs(self): - outputs = self._outputs().get() - outputs['BrainExtractionMask'] = os.path.join(os.getcwd(), + def _post_run(self): + self.outputs.BrainExtractionMask = os.path.join(os.getcwd(), self.inputs.out_prefix + 'BrainExtractionMask.' + self.inputs.image_suffix) - outputs['BrainExtractionBrain'] = os.path.join(os.getcwd(), + self.outputs.BrainExtractionBrain = os.path.join(os.getcwd(), self.inputs.out_prefix + 'BrainExtractionBrain.' + self.inputs.image_suffix) - return outputs class antsBrainExtraction(BrainExtraction): @@ -729,6 +687,24 @@ class JointFusionInputSpec(ANTSCommandInputSpec): atlas_group_weights = traits.ListInt(argstr='-gpw %d...', desc=('Assign the voting weights to ' 'each atlas group')) + def _format_arg(self, opt, spec, val): + if opt == 'method': + if '[' in val: + retval = '-m {0}'.format(val) + else: + retval = '-m {0}[{1},{2}]'.format( + self.method, self.alpha, self.beta) + elif opt == 'patch_radius': + retval = '-rp {0}'.format(self._format_xarray(val)) + elif opt == 'search_radius': + retval = '-rs {0}'.format(self._format_xarray(val)) + else: + if opt == 'warped_intensity_images': + assert len(val) == self.modalities * len(self.warped_label_images), \ + "Number of intensity images and label maps must be the same {0}!={1}".format( + len(val), len(self.warped_label_images)) + return super(JointFusionInputSpec, self)._format_arg(opt, spec, val) + return retval class JointFusionOutputSpec(TraitedSpec): @@ -767,34 +743,13 @@ class JointFusion(ANTSCommand): 'jointfusion 3 1 -m Joint[0.5,1] -rp 3x2x1 -rs 1x2x3 -tg T1.nii -g im1.nii -g im2.nii -g im3.nii \ -l segmentation0.nii.gz -l segmentation1.nii.gz -l segmentation1.nii.gz fusion_labelimage_output.nii' """ - input_spec = JointFusionInputSpec - output_spec = JointFusionOutputSpec + _input_spec = JointFusionInputSpec + _output_spec = JointFusionOutputSpec _cmd = 'jointfusion' - def _format_arg(self, opt, spec, val): - if opt == 'method': - if '[' in val: - retval = '-m {0}'.format(val) - else: - retval = '-m {0}[{1},{2}]'.format( - self.inputs.method, self.inputs.alpha, self.inputs.beta) - elif opt == 'patch_radius': - retval = '-rp {0}'.format(self._format_xarray(val)) - elif opt == 'search_radius': - retval = '-rs {0}'.format(self._format_xarray(val)) - else: - if opt == 'warped_intensity_images': - assert len(val) == self.inputs.modalities * len(self.inputs.warped_label_images), \ - "Number of intensity images and label maps must be the same {0}!={1}".format( - len(val), len(self.inputs.warped_label_images)) - return super(ANTSCommand, self)._format_arg(opt, spec, val) - return retval - - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output_label_image'] = os.path.abspath( + def _post_run(self): + self.outputs.output_label_image = os.path.abspath( self.inputs.output_label_image) - return outputs class DenoiseImageInputSpec(ANTSCommandInputSpec): @@ -820,11 +775,28 @@ class DenoiseImageInputSpec(ANTSCommandInputSpec): save_noise = traits.Bool(False, mandatory=True, usedefault=True, desc=('True if the estimated noise should be saved ' 'to file.'), xor=['noise_image']) - noise_image = File(name_source=['input_image'], hash_files=False, + noise_image = File(name_source=['input_image'], hash_files=False, argstr='%s', keep_extension=True, name_template='%s_noise', desc='Filename for the estimated noise.') verbose = traits.Bool(False, argstr="-v", desc=('Verbose output.')) + def _format_arg(self, name, trait_spec, value): + if (name == 'output_image') and self.save_noise: + val_out = super(DenoiseImageInputSpec, self)._format_arg( + name, trait_spec, value) + val_noise = super(DenoiseImageInputSpec, self)._format_arg('noise_image') + newval = '[ ' + val_out[3:] + ', ' + val_noise + ' ]' + return trait_spec.argstr % newval + + return super(DenoiseImageInputSpec, + self)._format_arg(name, trait_spec, value) + + def parse_args(self, skip=None): + if skip is None: + skip = [] + skip += ['save_noise', 'noise_image'] + return super(DenoiseImageInputSpec, self).parse_args(skip) + class DenoiseImageOutputSpec(TraitedSpec): output_image = File(exists=True) @@ -856,20 +828,10 @@ class DenoiseImage(ANTSCommand): >>> denoise_3.cmdline 'DenoiseImage -i im1.nii -n Gaussian -o [ im1_noise_corrected.nii, im1_noise.nii ] -s 1' """ - input_spec = DenoiseImageInputSpec - output_spec = DenoiseImageOutputSpec + _input_spec = DenoiseImageInputSpec + _output_spec = DenoiseImageOutputSpec _cmd = 'DenoiseImage' - def _format_arg(self, name, trait_spec, value): - if ((name == 'output_image') and - (self.inputs.save_noise or isdefined(self.inputs.noise_image))): - newval = '[ %s, %s ]' % (self._filename_from_source('output_image'), - self._filename_from_source('noise_image')) - return trait_spec.argstr % newval - - return super(DenoiseImage, - self)._format_arg(name, trait_spec, value) - class AntsJointFusionInputSpec(ANTSCommandInputSpec): dimension = traits.Enum(3, 2, 4, argstr='-d %d', usedefault=False, @@ -938,6 +900,46 @@ class AntsJointFusionInputSpec(ANTSCommandInputSpec): 'file name format.') verbose = traits.Bool(False, argstr="-v", desc=('Verbose output.')) + def _format_arg(self, opt, spec, val): + if opt == 'exclusion_image_label': + retval = [] + for ii in range(len(self.exclusion_image_label)): + retval.append('-e {0}[{1}]'.format( + self.exclusion_image_label[ii], + self.exclusion_image[ii])) + retval = ' '.join(retval) + elif opt == 'patch_radius': + retval = '-p {0}'.format(self._format_xarray(val)) + elif opt == 'search_radius': + retval = '-s {0}'.format(self._format_xarray(val)) + elif opt == 'out_label_fusion': + if isdefined(self.out_intensity_fusion_name_format): + if isdefined(self.out_label_post_prob_name_format): + if isdefined(self.out_atlas_voting_weight_name_format): + retval = '-o [{0}, {1}, {2}, {3}]'.format(self.out_label_fusion, + self.out_intensity_fusion_name_format, + self.out_label_post_prob_name_format, + self.out_atlas_voting_weight_name_format) + else: + retval = '-o [{0}, {1}, {2}]'.format(self.out_label_fusion, + self.out_intensity_fusion_name_format, + self.out_label_post_prob_name_format) + else: + retval = '-o [{0}, {1}]'.format(self.out_label_fusion, + self.out_intensity_fusion_name_format) + else: + retval = '-o {0}'.format(self.out_label_fusion) + elif opt == 'out_intensity_fusion_name_format': + retval = '' + if not isdefined(self.out_label_fusion): + retval = '-o {0}'.format(self.out_intensity_fusion_name_format) + else: + if opt == 'atlas_segmentation_image': + assert len(val) == len(self.atlas_image), "Number of specified " \ + "segmentations should be identical to the number of atlas image " \ + "sets {0}!={1}".format(len(val), len(self.atlas_image)) + return super(AntsJointFusionInputSpec, self)._format_arg(opt, spec, val) + return retval class AntsJointFusionOutputSpec(TraitedSpec): out_label_fusion = File(exists=True) @@ -1006,53 +1008,12 @@ class AntsJointFusion(ANTSCommand): -p 3x2x1 -s mask.nii -t ['im1.nii', 'im2.nii'] -v" """ - input_spec = AntsJointFusionInputSpec - output_spec = AntsJointFusionOutputSpec + _input_spec = AntsJointFusionInputSpec + _output_spec = AntsJointFusionOutputSpec _cmd = 'antsJointFusion' - def _format_arg(self, opt, spec, val): - if opt == 'exclusion_image_label': - retval = [] - for ii in range(len(self.inputs.exclusion_image_label)): - retval.append('-e {0}[{1}]'.format( - self.inputs.exclusion_image_label[ii], - self.inputs.exclusion_image[ii])) - retval = ' '.join(retval) - elif opt == 'patch_radius': - retval = '-p {0}'.format(self._format_xarray(val)) - elif opt == 'search_radius': - retval = '-s {0}'.format(self._format_xarray(val)) - elif opt == 'out_label_fusion': - if isdefined(self.inputs.out_intensity_fusion_name_format): - if isdefined(self.inputs.out_label_post_prob_name_format): - if isdefined(self.inputs.out_atlas_voting_weight_name_format): - retval = '-o [{0}, {1}, {2}, {3}]'.format(self.inputs.out_label_fusion, - self.inputs.out_intensity_fusion_name_format, - self.inputs.out_label_post_prob_name_format, - self.inputs.out_atlas_voting_weight_name_format) - else: - retval = '-o [{0}, {1}, {2}]'.format(self.inputs.out_label_fusion, - self.inputs.out_intensity_fusion_name_format, - self.inputs.out_label_post_prob_name_format) - else: - retval = '-o [{0}, {1}]'.format(self.inputs.out_label_fusion, - self.inputs.out_intensity_fusion_name_format) - else: - retval = '-o {0}'.format(self.inputs.out_label_fusion) - elif opt == 'out_intensity_fusion_name_format': - retval = '' - if not isdefined(self.inputs.out_label_fusion): - retval = '-o {0}'.format(self.inputs.out_intensity_fusion_name_format) - else: - if opt == 'atlas_segmentation_image': - assert len(val) == len(self.inputs.atlas_image), "Number of specified " \ - "segmentations should be identical to the number of atlas image " \ - "sets {0}!={1}".format(len(val), len(self.inputs.atlas_image)) - return super(ANTSCommand, self)._format_arg(opt, spec, val) - return retval - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): if isdefined(self.inputs.out_label_fusion): outputs['out_label_fusion'] = os.path.abspath( self.inputs.out_label_fusion) @@ -1066,4 +1027,4 @@ def _list_outputs(self): outputs['out_atlas_voting_weight_name_format'] = os.path.abspath( self.inputs.out_atlas_voting_weight_name_format) - return outputs + diff --git a/nipype/interfaces/ants/tests/test_auto_ANTS.py b/nipype/interfaces/ants/tests/test_auto_ANTS.py index 36f153c532..0ca055f8c5 100644 --- a/nipype/interfaces/ants/tests/test_auto_ANTS.py +++ b/nipype/interfaces/ants/tests/test_auto_ANTS.py @@ -14,16 +14,10 @@ def test_ANTS_inputs(): position=1, usedefault=False, ), - environ=dict(nohash=True, - usedefault=True, - ), fixed_image=dict(mandatory=True, ), gradient_step_length=dict(requires=['transformation_model'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), metric=dict(mandatory=True, ), metric_weight=dict(requires=['metric'], @@ -65,8 +59,6 @@ def test_ANTS_inputs(): ), symmetry_type=dict(requires=['delta_time'], ), - terminal_output=dict(nohash=True, - ), transformation_model=dict(argstr='%s', mandatory=True, ), @@ -74,7 +66,7 @@ def test_ANTS_inputs(): usedefault=True, ), ) - inputs = ANTS.input_spec() + inputs = ANTS._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -82,13 +74,22 @@ def test_ANTS_inputs(): def test_ANTS_outputs(): - output_map = dict(affine_transform=dict(), - inverse_warp_transform=dict(), + output_map = dict(affine_transform=dict(keep_extension=False, + name_source='output_transform_prefix', + name_template='%sAffine.txt', + ), + inverse_warp_transform=dict(keep_extension=False, + name_source='output_transform_prefix', + name_template='%sInverseWarp.nii.gz', + ), metaheader=dict(), metaheader_raw=dict(), - warp_transform=dict(), + warp_transform=dict(keep_extension=False, + name_source='output_transform_prefix', + name_template='%sWarp.nii.gz', + ), ) - outputs = ANTS.output_spec() + outputs = ANTS._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_ANTSCommand.py b/nipype/interfaces/ants/tests/test_auto_ANTSCommand.py index 1c2a67f3bb..e1899648f4 100644 --- a/nipype/interfaces/ants/tests/test_auto_ANTSCommand.py +++ b/nipype/interfaces/ants/tests/test_auto_ANTSCommand.py @@ -6,21 +6,21 @@ def test_ANTSCommand_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), num_threads=dict(nohash=True, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ANTSCommand.input_spec() + inputs = ANTSCommand._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_ANTSCommand_outputs(): + output_map = dict() + outputs = ANTSCommand._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/ants/tests/test_auto_AntsJointFusion.py b/nipype/interfaces/ants/tests/test_auto_AntsJointFusion.py index 478c0c1400..aa513253a5 100644 --- a/nipype/interfaces/ants/tests/test_auto_AntsJointFusion.py +++ b/nipype/interfaces/ants/tests/test_auto_AntsJointFusion.py @@ -24,16 +24,10 @@ def test_AntsJointFusion_inputs(): dimension=dict(argstr='-d %d', usedefault=False, ), - environ=dict(nohash=True, - usedefault=True, - ), exclusion_image=dict(), exclusion_image_label=dict(argstr='-e %s', requires=['exclusion_image'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), mask_image=dict(argstr='-x %s', ), num_threads=dict(nohash=True, @@ -68,12 +62,10 @@ def test_AntsJointFusion_inputs(): target_image=dict(argstr='-t %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-v', ), ) - inputs = AntsJointFusion.input_spec() + inputs = AntsJointFusion._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -86,7 +78,7 @@ def test_AntsJointFusion_outputs(): out_label_fusion=dict(), out_label_post_prob_name_format=dict(), ) - outputs = AntsJointFusion.output_spec() + outputs = AntsJointFusion._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_ApplyTransforms.py b/nipype/interfaces/ants/tests/test_auto_ApplyTransforms.py index 63d4f78e08..d90ef0c189 100644 --- a/nipype/interfaces/ants/tests/test_auto_ApplyTransforms.py +++ b/nipype/interfaces/ants/tests/test_auto_ApplyTransforms.py @@ -11,14 +11,8 @@ def test_ApplyTransforms_inputs(): ), dimension=dict(argstr='--dimensionality %d', ), - environ=dict(nohash=True, - usedefault=True, - ), float=dict(argstr='--float %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='--input %s', mandatory=True, ), @@ -35,21 +29,21 @@ def test_ApplyTransforms_inputs(): out_postfix=dict(usedefault=True, ), output_image=dict(argstr='--output %s', - genfile=True, hash_files=False, + keep_extension=True, + name_source='input_image', + name_template='%s_warped', ), - print_out_composite_warp_file=dict(requires=['output_image'], + print_out_composite_warp_file=dict(usedefault=True, ), reference_image=dict(argstr='--reference-image %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), transforms=dict(argstr='%s', mandatory=True, ), ) - inputs = ApplyTransforms.input_spec() + inputs = ApplyTransforms._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -59,7 +53,7 @@ def test_ApplyTransforms_inputs(): def test_ApplyTransforms_outputs(): output_map = dict(output_image=dict(), ) - outputs = ApplyTransforms.output_spec() + outputs = ApplyTransforms._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_ApplyTransformsToPoints.py b/nipype/interfaces/ants/tests/test_auto_ApplyTransformsToPoints.py index 3c6be3669a..5924f5d341 100644 --- a/nipype/interfaces/ants/tests/test_auto_ApplyTransformsToPoints.py +++ b/nipype/interfaces/ants/tests/test_auto_ApplyTransformsToPoints.py @@ -8,12 +8,6 @@ def test_ApplyTransformsToPoints_inputs(): ), dimension=dict(argstr='--dimensionality %d', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='--input %s', mandatory=True, ), @@ -26,13 +20,11 @@ def test_ApplyTransformsToPoints_inputs(): name_source=['input_file'], name_template='%s_transformed.csv', ), - terminal_output=dict(nohash=True, - ), transforms=dict(argstr='%s', mandatory=True, ), ) - inputs = ApplyTransformsToPoints.input_spec() + inputs = ApplyTransformsToPoints._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_ApplyTransformsToPoints_inputs(): def test_ApplyTransformsToPoints_outputs(): output_map = dict(output_file=dict(), ) - outputs = ApplyTransformsToPoints.output_spec() + outputs = ApplyTransformsToPoints._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_Atropos.py b/nipype/interfaces/ants/tests/test_auto_Atropos.py index e19aa5591c..ed8549f966 100644 --- a/nipype/interfaces/ants/tests/test_auto_Atropos.py +++ b/nipype/interfaces/ants/tests/test_auto_Atropos.py @@ -11,14 +11,8 @@ def test_Atropos_inputs(): dimension=dict(argstr='--image-dimensionality %d', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), icm_use_synchronous_update=dict(argstr='%s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initialization=dict(argstr='%s', mandatory=True, requires=['number_of_tissue_classes'], @@ -44,20 +38,21 @@ def test_Atropos_inputs(): ), number_of_tissue_classes=dict(mandatory=True, ), - out_classified_image_name=dict(argstr='%s', - genfile=True, + out_classified_image_name=dict(argstr='--output [%s]', hash_files=False, - ), - output_posteriors_name_template=dict(usedefault=True, + keep_extension=True, + name_source='intensity_images', + name_template='%s_labeled', ), posterior_formulation=dict(argstr='%s', ), + posteriors=dict(usedefault=True, + ), prior_probability_images=dict(), prior_probability_threshold=dict(requires=['prior_weighting'], ), prior_weighting=dict(), - save_posteriors=dict(), - terminal_output=dict(nohash=True, + save_posteriors=dict(usedefault=True, ), use_mixture_model_proportions=dict(requires=['posterior_formulation'], ), @@ -65,7 +60,7 @@ def test_Atropos_inputs(): usedefault=True, ), ) - inputs = Atropos.input_spec() + inputs = Atropos._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -76,7 +71,7 @@ def test_Atropos_outputs(): output_map = dict(classified_image=dict(), posteriors=dict(), ) - outputs = Atropos.output_spec() + outputs = Atropos._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_AverageAffineTransform.py b/nipype/interfaces/ants/tests/test_auto_AverageAffineTransform.py index 347b07ef6e..ddcfb4b707 100644 --- a/nipype/interfaces/ants/tests/test_auto_AverageAffineTransform.py +++ b/nipype/interfaces/ants/tests/test_auto_AverageAffineTransform.py @@ -11,12 +11,6 @@ def test_AverageAffineTransform_inputs(): position=0, usedefault=False, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), num_threads=dict(nohash=True, usedefault=True, ), @@ -24,14 +18,12 @@ def test_AverageAffineTransform_inputs(): mandatory=True, position=1, ), - terminal_output=dict(nohash=True, - ), transforms=dict(argstr='%s', mandatory=True, position=3, ), ) - inputs = AverageAffineTransform.input_spec() + inputs = AverageAffineTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +33,7 @@ def test_AverageAffineTransform_inputs(): def test_AverageAffineTransform_outputs(): output_map = dict(affine_transform=dict(), ) - outputs = AverageAffineTransform.output_spec() + outputs = AverageAffineTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_AverageImages.py b/nipype/interfaces/ants/tests/test_auto_AverageImages.py index 2e25305f3a..d1c15280fa 100644 --- a/nipype/interfaces/ants/tests/test_auto_AverageImages.py +++ b/nipype/interfaces/ants/tests/test_auto_AverageImages.py @@ -10,12 +10,6 @@ def test_AverageImages_inputs(): mandatory=True, position=0, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), images=dict(argstr='%s', mandatory=True, position=3, @@ -32,10 +26,8 @@ def test_AverageImages_inputs(): position=1, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = AverageImages.input_spec() + inputs = AverageImages._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_AverageImages_inputs(): def test_AverageImages_outputs(): output_map = dict(output_average_image=dict(), ) - outputs = AverageImages.output_spec() + outputs = AverageImages._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_BrainExtraction.py b/nipype/interfaces/ants/tests/test_auto_BrainExtraction.py index b1448a641d..24c640eea1 100644 --- a/nipype/interfaces/ants/tests/test_auto_BrainExtraction.py +++ b/nipype/interfaces/ants/tests/test_auto_BrainExtraction.py @@ -21,14 +21,8 @@ def test_BrainExtraction_inputs(): dimension=dict(argstr='-d %d', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), extraction_registration_mask=dict(argstr='-f %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_suffix=dict(argstr='-s %s', usedefault=True, ), @@ -40,14 +34,12 @@ def test_BrainExtraction_inputs(): out_prefix=dict(argstr='-o %s', usedefault=True, ), - terminal_output=dict(nohash=True, - ), use_floatingpoint_precision=dict(argstr='-q %d', ), use_random_seeding=dict(argstr='-u %d', ), ) - inputs = BrainExtraction.input_spec() + inputs = BrainExtraction._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +50,7 @@ def test_BrainExtraction_outputs(): output_map = dict(BrainExtractionBrain=dict(), BrainExtractionMask=dict(), ) - outputs = BrainExtraction.output_spec() + outputs = BrainExtraction._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_ConvertScalarImageToRGB.py b/nipype/interfaces/ants/tests/test_auto_ConvertScalarImageToRGB.py index cc2dfada40..b47517fa5d 100644 --- a/nipype/interfaces/ants/tests/test_auto_ConvertScalarImageToRGB.py +++ b/nipype/interfaces/ants/tests/test_auto_ConvertScalarImageToRGB.py @@ -20,12 +20,6 @@ def test_ConvertScalarImageToRGB_inputs(): position=0, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='%s', mandatory=True, position=1, @@ -57,10 +51,8 @@ def test_ConvertScalarImageToRGB_inputs(): position=2, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ConvertScalarImageToRGB.input_spec() + inputs = ConvertScalarImageToRGB._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -70,7 +62,7 @@ def test_ConvertScalarImageToRGB_inputs(): def test_ConvertScalarImageToRGB_outputs(): output_map = dict(output_image=dict(), ) - outputs = ConvertScalarImageToRGB.output_spec() + outputs = ConvertScalarImageToRGB._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_CorticalThickness.py b/nipype/interfaces/ants/tests/test_auto_CorticalThickness.py index df40609826..d518ffbbb8 100644 --- a/nipype/interfaces/ants/tests/test_auto_CorticalThickness.py +++ b/nipype/interfaces/ants/tests/test_auto_CorticalThickness.py @@ -24,14 +24,8 @@ def test_CorticalThickness_inputs(): dimension=dict(argstr='-d %d', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), extraction_registration_mask=dict(argstr='-f %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_suffix=dict(argstr='-s %s', usedefault=True, ), @@ -61,14 +55,12 @@ def test_CorticalThickness_inputs(): t1_registration_template=dict(argstr='-t %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), use_floatingpoint_precision=dict(argstr='-j %d', ), use_random_seeding=dict(argstr='-u %d', ), ) - inputs = CorticalThickness.input_spec() + inputs = CorticalThickness._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -89,7 +81,7 @@ def test_CorticalThickness_outputs(): TemplateToSubject0Warp=dict(), TemplateToSubject1GenericAffine=dict(), ) - outputs = CorticalThickness.output_spec() + outputs = CorticalThickness._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_CreateTiledMosaic.py b/nipype/interfaces/ants/tests/test_auto_CreateTiledMosaic.py index a5222ef3de..da43fb52d5 100644 --- a/nipype/interfaces/ants/tests/test_auto_CreateTiledMosaic.py +++ b/nipype/interfaces/ants/tests/test_auto_CreateTiledMosaic.py @@ -10,14 +10,8 @@ def test_CreateTiledMosaic_inputs(): ), direction=dict(argstr='-d %d', ), - environ=dict(nohash=True, - usedefault=True, - ), flip_slice=dict(argstr='-f %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='-i %s', mandatory=True, ), @@ -38,12 +32,10 @@ def test_CreateTiledMosaic_inputs(): ), slices=dict(argstr='-s %s', ), - terminal_output=dict(nohash=True, - ), tile_geometry=dict(argstr='-t %s', ), ) - inputs = CreateTiledMosaic.input_spec() + inputs = CreateTiledMosaic._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +45,7 @@ def test_CreateTiledMosaic_inputs(): def test_CreateTiledMosaic_outputs(): output_map = dict(output_image=dict(), ) - outputs = CreateTiledMosaic.output_spec() + outputs = CreateTiledMosaic._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_DenoiseImage.py b/nipype/interfaces/ants/tests/test_auto_DenoiseImage.py index 01b610ea30..0f100a7744 100644 --- a/nipype/interfaces/ants/tests/test_auto_DenoiseImage.py +++ b/nipype/interfaces/ants/tests/test_auto_DenoiseImage.py @@ -9,16 +9,11 @@ def test_DenoiseImage_inputs(): dimension=dict(argstr='-d %d', usedefault=False, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='-i %s', mandatory=True, ), - noise_image=dict(hash_files=False, + noise_image=dict(argstr='%s', + hash_files=False, keep_extension=True, name_source=['input_image'], name_template='%s_noise', @@ -42,12 +37,10 @@ def test_DenoiseImage_inputs(): shrink_factor=dict(argstr='-s %s', usedefault=True, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-v', ), ) - inputs = DenoiseImage.input_spec() + inputs = DenoiseImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +51,7 @@ def test_DenoiseImage_outputs(): output_map = dict(noise_image=dict(), output_image=dict(), ) - outputs = DenoiseImage.output_spec() + outputs = DenoiseImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_GenWarpFields.py b/nipype/interfaces/ants/tests/test_auto_GenWarpFields.py index a6a3e5c6a7..a9fc62745d 100644 --- a/nipype/interfaces/ants/tests/test_auto_GenWarpFields.py +++ b/nipype/interfaces/ants/tests/test_auto_GenWarpFields.py @@ -12,14 +12,8 @@ def test_GenWarpFields_inputs(): position=1, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), force_proceed=dict(argstr='-f 1', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='-i %s', copyfile=False, mandatory=True, @@ -43,13 +37,11 @@ def test_GenWarpFields_inputs(): ), similarity_metric=dict(argstr='-s %s', ), - terminal_output=dict(nohash=True, - ), transformation_model=dict(argstr='-t %s', usedefault=True, ), ) - inputs = GenWarpFields.input_spec() + inputs = GenWarpFields._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -63,7 +55,7 @@ def test_GenWarpFields_outputs(): output_file=dict(), warp_field=dict(), ) - outputs = GenWarpFields.output_spec() + outputs = GenWarpFields._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_JacobianDeterminant.py b/nipype/interfaces/ants/tests/test_auto_JacobianDeterminant.py index c83a95a5f9..13ae2a9928 100644 --- a/nipype/interfaces/ants/tests/test_auto_JacobianDeterminant.py +++ b/nipype/interfaces/ants/tests/test_auto_JacobianDeterminant.py @@ -11,12 +11,6 @@ def test_JacobianDeterminant_inputs(): position=0, usedefault=False, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), norm_by_total=dict(argstr='%d', position=5, ), @@ -35,8 +29,6 @@ def test_JacobianDeterminant_inputs(): template_mask=dict(argstr='%s', position=4, ), - terminal_output=dict(nohash=True, - ), use_log=dict(argstr='%d', position=3, ), @@ -45,7 +37,7 @@ def test_JacobianDeterminant_inputs(): position=1, ), ) - inputs = JacobianDeterminant.input_spec() + inputs = JacobianDeterminant._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_JacobianDeterminant_inputs(): def test_JacobianDeterminant_outputs(): output_map = dict(jacobian_image=dict(), ) - outputs = JacobianDeterminant.output_spec() + outputs = JacobianDeterminant._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_JointFusion.py b/nipype/interfaces/ants/tests/test_auto_JointFusion.py index 76d8d46969..b9bef8aa36 100644 --- a/nipype/interfaces/ants/tests/test_auto_JointFusion.py +++ b/nipype/interfaces/ants/tests/test_auto_JointFusion.py @@ -21,14 +21,8 @@ def test_JointFusion_inputs(): position=0, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), exclusion_region=dict(argstr='-x %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), method=dict(argstr='-m %s', usedefault=True, ), @@ -56,8 +50,6 @@ def test_JointFusion_inputs(): target_image=dict(argstr='-tg %s...', mandatory=True, ), - terminal_output=dict(nohash=True, - ), warped_intensity_images=dict(argstr='-g %s...', mandatory=True, ), @@ -65,7 +57,7 @@ def test_JointFusion_inputs(): mandatory=True, ), ) - inputs = JointFusion.input_spec() + inputs = JointFusion._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -75,7 +67,7 @@ def test_JointFusion_inputs(): def test_JointFusion_outputs(): output_map = dict(output_label_image=dict(), ) - outputs = JointFusion.output_spec() + outputs = JointFusion._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_LaplacianThickness.py b/nipype/interfaces/ants/tests/test_auto_LaplacianThickness.py index 60cfb494e3..9c4d958e7c 100644 --- a/nipype/interfaces/ants/tests/test_auto_LaplacianThickness.py +++ b/nipype/interfaces/ants/tests/test_auto_LaplacianThickness.py @@ -9,12 +9,6 @@ def test_LaplacianThickness_inputs(): dT=dict(argstr='dT=%d', position=6, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_gm=dict(argstr='%s', copyfile=True, mandatory=True, @@ -45,10 +39,8 @@ def test_LaplacianThickness_inputs(): sulcus_prior=dict(argstr='use-sulcus-prior', position=7, ), - terminal_output=dict(nohash=True, - ), ) - inputs = LaplacianThickness.input_spec() + inputs = LaplacianThickness._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +50,7 @@ def test_LaplacianThickness_inputs(): def test_LaplacianThickness_outputs(): output_map = dict(output_image=dict(), ) - outputs = LaplacianThickness.output_spec() + outputs = LaplacianThickness._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_MultiplyImages.py b/nipype/interfaces/ants/tests/test_auto_MultiplyImages.py index 5a3d682551..0ba5e39c6a 100644 --- a/nipype/interfaces/ants/tests/test_auto_MultiplyImages.py +++ b/nipype/interfaces/ants/tests/test_auto_MultiplyImages.py @@ -11,16 +11,10 @@ def test_MultiplyImages_inputs(): position=0, usedefault=False, ), - environ=dict(nohash=True, - usedefault=True, - ), first_input=dict(argstr='%s', mandatory=True, position=1, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), num_threads=dict(nohash=True, usedefault=True, ), @@ -32,10 +26,8 @@ def test_MultiplyImages_inputs(): mandatory=True, position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = MultiplyImages.input_spec() + inputs = MultiplyImages._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_MultiplyImages_inputs(): def test_MultiplyImages_outputs(): output_map = dict(output_product_image=dict(), ) - outputs = MultiplyImages.output_spec() + outputs = MultiplyImages._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_N4BiasFieldCorrection.py b/nipype/interfaces/ants/tests/test_auto_N4BiasFieldCorrection.py index 18921d811c..b2b4e910bc 100644 --- a/nipype/interfaces/ants/tests/test_auto_N4BiasFieldCorrection.py +++ b/nipype/interfaces/ants/tests/test_auto_N4BiasFieldCorrection.py @@ -6,7 +6,11 @@ def test_N4BiasFieldCorrection_inputs(): input_map = dict(args=dict(argstr='%s', ), - bias_image=dict(hash_files=False, + bias_image=dict(argstr='%s', + hash_files=False, + keep_extension=True, + name_source='input_image', + name_template='%s_bias', ), bspline_fitting_distance=dict(argstr='--bspline-fitting %s', ), @@ -17,12 +21,6 @@ def test_N4BiasFieldCorrection_inputs(): dimension=dict(argstr='-d %d', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='--input-image %s', mandatory=True, ), @@ -34,8 +32,10 @@ def test_N4BiasFieldCorrection_inputs(): usedefault=True, ), output_image=dict(argstr='--output %s', - genfile=True, hash_files=False, + keep_extension=True, + name_source='input_image', + name_template='%s_corrected', ), save_bias=dict(mandatory=True, usedefault=True, @@ -43,12 +43,10 @@ def test_N4BiasFieldCorrection_inputs(): ), shrink_factor=dict(argstr='--shrink-factor %d', ), - terminal_output=dict(nohash=True, - ), weight_image=dict(argstr='--weight-image %s', ), ) - inputs = N4BiasFieldCorrection.input_spec() + inputs = N4BiasFieldCorrection._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -59,7 +57,7 @@ def test_N4BiasFieldCorrection_outputs(): output_map = dict(bias_image=dict(), output_image=dict(), ) - outputs = N4BiasFieldCorrection.output_spec() + outputs = N4BiasFieldCorrection._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_Registration.py b/nipype/interfaces/ants/tests/test_auto_Registration.py index 990f97eea5..c5c1afdd46 100644 --- a/nipype/interfaces/ants/tests/test_auto_Registration.py +++ b/nipype/interfaces/ants/tests/test_auto_Registration.py @@ -18,18 +18,12 @@ def test_Registration_inputs(): dimension=dict(argstr='--dimensionality %d', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), fixed_image=dict(mandatory=True, ), fixed_image_mask=dict(argstr='%s', ), float=dict(argstr='--float %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initial_moving_transform=dict(argstr='%s', xor=['initial_moving_transform_com'], ), @@ -95,8 +89,6 @@ def test_Registration_inputs(): ), smoothing_sigmas=dict(mandatory=True, ), - terminal_output=dict(nohash=True, - ), transform_parameters=dict(), transforms=dict(argstr='%s', mandatory=True, @@ -114,7 +106,7 @@ def test_Registration_inputs(): usedefault=True, ), ) - inputs = Registration.input_spec() + inputs = Registration._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -132,7 +124,7 @@ def test_Registration_outputs(): save_state=dict(), warped_image=dict(), ) - outputs = Registration.output_spec() + outputs = Registration._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_WarpImageMultiTransform.py b/nipype/interfaces/ants/tests/test_auto_WarpImageMultiTransform.py index 09770d9d0f..962df40b51 100644 --- a/nipype/interfaces/ants/tests/test_auto_WarpImageMultiTransform.py +++ b/nipype/interfaces/ants/tests/test_auto_WarpImageMultiTransform.py @@ -10,12 +10,6 @@ def test_WarpImageMultiTransform_inputs(): position=1, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='%s', mandatory=True, position=2, @@ -24,23 +18,22 @@ def test_WarpImageMultiTransform_inputs(): num_threads=dict(nohash=True, usedefault=True, ), - out_postfix=dict(hash_files=False, + out_postfix=dict(deprecated=True, + hash_files=False, + new_name='output_image', usedefault=True, xor=['output_image'], ), output_image=dict(argstr='%s', - genfile=True, - hash_files=False, - position=3, - xor=['out_postfix'], + keep_extension=True, + name_source='input_image', + name_template='%s_wimt', ), reference_image=dict(argstr='-R %s', xor=['tightest_box'], ), reslice_by_header=dict(argstr='--reslice-by-header', ), - terminal_output=dict(nohash=True, - ), tightest_box=dict(argstr='--tightest-bounding-box', xor=['reference_image'], ), @@ -53,7 +46,7 @@ def test_WarpImageMultiTransform_inputs(): use_nearest=dict(argstr='--use-NN', ), ) - inputs = WarpImageMultiTransform.input_spec() + inputs = WarpImageMultiTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -63,7 +56,7 @@ def test_WarpImageMultiTransform_inputs(): def test_WarpImageMultiTransform_outputs(): output_map = dict(output_image=dict(), ) - outputs = WarpImageMultiTransform.output_spec() + outputs = WarpImageMultiTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_WarpTimeSeriesImageMultiTransform.py b/nipype/interfaces/ants/tests/test_auto_WarpTimeSeriesImageMultiTransform.py index 0e46ce34a5..0a3212577b 100644 --- a/nipype/interfaces/ants/tests/test_auto_WarpTimeSeriesImageMultiTransform.py +++ b/nipype/interfaces/ants/tests/test_auto_WarpTimeSeriesImageMultiTransform.py @@ -10,12 +10,6 @@ def test_WarpTimeSeriesImageMultiTransform_inputs(): position=1, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='%s', copyfile=True, mandatory=True, @@ -25,15 +19,19 @@ def test_WarpTimeSeriesImageMultiTransform_inputs(): usedefault=True, ), out_postfix=dict(argstr='%s', - usedefault=True, + deprecated=True, + new_name='output_image', + ), + output_image=dict(argstr='%s', + keep_extension=True, + name_source='input_image', + name_template='%s_wtsimt', ), reference_image=dict(argstr='-R %s', xor=['tightest_box'], ), reslice_by_header=dict(argstr='--reslice-by-header', ), - terminal_output=dict(nohash=True, - ), tightest_box=dict(argstr='--tightest-bounding-box', xor=['reference_image'], ), @@ -46,7 +44,7 @@ def test_WarpTimeSeriesImageMultiTransform_inputs(): use_nearest=dict(argstr='--use-NN', ), ) - inputs = WarpTimeSeriesImageMultiTransform.input_spec() + inputs = WarpTimeSeriesImageMultiTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -56,7 +54,7 @@ def test_WarpTimeSeriesImageMultiTransform_inputs(): def test_WarpTimeSeriesImageMultiTransform_outputs(): output_map = dict(output_image=dict(), ) - outputs = WarpTimeSeriesImageMultiTransform.output_spec() + outputs = WarpTimeSeriesImageMultiTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_antsBrainExtraction.py b/nipype/interfaces/ants/tests/test_auto_antsBrainExtraction.py index 5661eddd02..2a95d05cc0 100644 --- a/nipype/interfaces/ants/tests/test_auto_antsBrainExtraction.py +++ b/nipype/interfaces/ants/tests/test_auto_antsBrainExtraction.py @@ -21,14 +21,8 @@ def test_antsBrainExtraction_inputs(): dimension=dict(argstr='-d %d', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), extraction_registration_mask=dict(argstr='-f %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_suffix=dict(argstr='-s %s', usedefault=True, ), @@ -40,14 +34,12 @@ def test_antsBrainExtraction_inputs(): out_prefix=dict(argstr='-o %s', usedefault=True, ), - terminal_output=dict(nohash=True, - ), use_floatingpoint_precision=dict(argstr='-q %d', ), use_random_seeding=dict(argstr='-u %d', ), ) - inputs = antsBrainExtraction.input_spec() + inputs = antsBrainExtraction._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +50,7 @@ def test_antsBrainExtraction_outputs(): output_map = dict(BrainExtractionBrain=dict(), BrainExtractionMask=dict(), ) - outputs = antsBrainExtraction.output_spec() + outputs = antsBrainExtraction._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_antsCorticalThickness.py b/nipype/interfaces/ants/tests/test_auto_antsCorticalThickness.py index 0944ebf1b7..38e0df0393 100644 --- a/nipype/interfaces/ants/tests/test_auto_antsCorticalThickness.py +++ b/nipype/interfaces/ants/tests/test_auto_antsCorticalThickness.py @@ -24,14 +24,8 @@ def test_antsCorticalThickness_inputs(): dimension=dict(argstr='-d %d', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), extraction_registration_mask=dict(argstr='-f %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_suffix=dict(argstr='-s %s', usedefault=True, ), @@ -61,14 +55,12 @@ def test_antsCorticalThickness_inputs(): t1_registration_template=dict(argstr='-t %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), use_floatingpoint_precision=dict(argstr='-j %d', ), use_random_seeding=dict(argstr='-u %d', ), ) - inputs = antsCorticalThickness.input_spec() + inputs = antsCorticalThickness._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -89,7 +81,7 @@ def test_antsCorticalThickness_outputs(): TemplateToSubject0Warp=dict(), TemplateToSubject1GenericAffine=dict(), ) - outputs = antsCorticalThickness.output_spec() + outputs = antsCorticalThickness._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_antsIntroduction.py b/nipype/interfaces/ants/tests/test_auto_antsIntroduction.py index be61025e30..741b10dde4 100644 --- a/nipype/interfaces/ants/tests/test_auto_antsIntroduction.py +++ b/nipype/interfaces/ants/tests/test_auto_antsIntroduction.py @@ -12,14 +12,8 @@ def test_antsIntroduction_inputs(): position=1, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), force_proceed=dict(argstr='-f 1', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='-i %s', copyfile=False, mandatory=True, @@ -43,13 +37,11 @@ def test_antsIntroduction_inputs(): ), similarity_metric=dict(argstr='-s %s', ), - terminal_output=dict(nohash=True, - ), transformation_model=dict(argstr='-t %s', usedefault=True, ), ) - inputs = antsIntroduction.input_spec() + inputs = antsIntroduction._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -63,7 +55,7 @@ def test_antsIntroduction_outputs(): output_file=dict(), warp_field=dict(), ) - outputs = antsIntroduction.output_spec() + outputs = antsIntroduction._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_auto_buildtemplateparallel.py b/nipype/interfaces/ants/tests/test_auto_buildtemplateparallel.py index 6992ce5c11..021948bb19 100644 --- a/nipype/interfaces/ants/tests/test_auto_buildtemplateparallel.py +++ b/nipype/interfaces/ants/tests/test_auto_buildtemplateparallel.py @@ -12,14 +12,8 @@ def test_buildtemplateparallel_inputs(): position=1, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), gradient_step_size=dict(argstr='-g %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='%s', mandatory=True, position=-1, @@ -46,14 +40,12 @@ def test_buildtemplateparallel_inputs(): ), similarity_metric=dict(argstr='-s %s', ), - terminal_output=dict(nohash=True, - ), transformation_model=dict(argstr='-t %s', usedefault=True, ), use_first_as_target=dict(), ) - inputs = buildtemplateparallel.input_spec() + inputs = buildtemplateparallel._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -65,7 +57,7 @@ def test_buildtemplateparallel_outputs(): subject_outfiles=dict(), template_files=dict(), ) - outputs = buildtemplateparallel.output_spec() + outputs = buildtemplateparallel._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/tests/test_spec_JointFusion.py b/nipype/interfaces/ants/tests/test_spec_JointFusion.py index ed6d283032..470c394613 100644 --- a/nipype/interfaces/ants/tests/test_spec_JointFusion.py +++ b/nipype/interfaces/ants/tests/test_spec_JointFusion.py @@ -47,7 +47,7 @@ def test_JointFusion_radius(): for attr in ['patch_radius', 'search_radius']: for x in range(5): set_radius(attr, x, x + 1, x**x) - yield assert_equal, at._format_arg(attr, None, getattr(at.inputs, attr))[4:], '{0}x{1}x{2}'.format(x, x + 1, x**x) + yield assert_equal, at.inputs._format_arg(attr, None, getattr(at.inputs, attr))[4:], '{0}x{1}x{2}'.format(x, x + 1, x**x) def test_JointFusion_cmd(): @@ -75,4 +75,4 @@ def test_JointFusion_cmd(): segmentation_images[1]) yield assert_equal, at.cmdline, expected_command # setting intensity or labels with unequal lengths raises error - yield assert_raises, AssertionError, at._format_arg, 'warped_intensity_images', InputMultiPath, warped_intensity_images + [example_data('im3.nii')] + yield assert_raises, AssertionError, at.inputs._format_arg, 'warped_intensity_images', InputMultiPath, warped_intensity_images + [example_data('im3.nii')] diff --git a/nipype/interfaces/ants/utils.py b/nipype/interfaces/ants/utils.py index c3253b7256..1290702c7e 100644 --- a/nipype/interfaces/ants/utils.py +++ b/nipype/interfaces/ants/utils.py @@ -39,18 +39,16 @@ class AverageAffineTransform(ANTSCommand): 'AverageAffineTransform 3 MYtemplatewarp.mat trans.mat func_to_struct.mat' """ _cmd = 'AverageAffineTransform' - input_spec = AverageAffineTransformInputSpec - output_spec = AverageAffineTransformOutputSpec + _input_spec = AverageAffineTransformInputSpec + _output_spec = AverageAffineTransformOutputSpec def _format_arg(self, opt, spec, val): return super(AverageAffineTransform, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['affine_transform'] = os.path.abspath( + def _post_run(self): + self.outputs.affine_transform = os.path.abspath( self.inputs.output_affine_transform) - return outputs - + class AverageImagesInputSpec(ANTSCommandInputSpec): dimension = traits.Enum(3, 2, argstr='%d', mandatory=True, @@ -81,18 +79,16 @@ class AverageImages(ANTSCommand): 'AverageImages 3 average.nii.gz 1 rc1s1.nii rc1s1.nii' """ _cmd = 'AverageImages' - input_spec = AverageImagesInputSpec - output_spec = AverageImagesOutputSpec + _input_spec = AverageImagesInputSpec + _output_spec = AverageImagesOutputSpec def _format_arg(self, opt, spec, val): return super(AverageImages, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output_average_image'] = os.path.realpath( + def _post_run(self): + self.outputs.output_average_image = os.path.realpath( self.inputs.output_average_image) - return outputs - + class MultiplyImagesInputSpec(ANTSCommandInputSpec): dimension = traits.Enum(3, 2, argstr='%d', usedefault=False, mandatory=True, position=0, @@ -122,18 +118,16 @@ class MultiplyImages(ANTSCommand): 'MultiplyImages 3 moving2.nii 0.25 out.nii' """ _cmd = 'MultiplyImages' - input_spec = MultiplyImagesInputSpec - output_spec = MultiplyImagesOutputSpec + _input_spec = MultiplyImagesInputSpec + _output_spec = MultiplyImagesOutputSpec def _format_arg(self, opt, spec, val): return super(MultiplyImages, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output_product_image'] = os.path.abspath( + def _post_run(self): + self.outputs.output_product_image = os.path.abspath( self.inputs.output_product_image) - return outputs - + class JacobianDeterminantInputSpec(ANTSCommandInputSpec): dimension = traits.Enum(3, 2, argstr='%d', usedefault=False, mandatory=True, @@ -175,8 +169,8 @@ class JacobianDeterminant(ANTSCommand): """ _cmd = 'ANTSJacobian' - input_spec = JacobianDeterminantInputSpec - output_spec = JacobianDeterminantOutputSpec + _input_spec = JacobianDeterminantInputSpec + _output_spec = JacobianDeterminantOutputSpec def _gen_filename(self, name): if name == 'output_prefix': @@ -187,12 +181,11 @@ def _gen_filename(self, name): return output return None - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): if self.inputs.use_log == 1: - outputs['jacobian_image'] = os.path.abspath( + self.outputs.jacobian_image = os.path.abspath( self._gen_filename('output_prefix') + 'logjacobian.nii.gz') else: - outputs['jacobian_image'] = os.path.abspath( + self.outputs.jacobian_image = os.path.abspath( self._gen_filename('output_prefix') + 'jacobian.nii.gz') - return outputs + \ No newline at end of file diff --git a/nipype/interfaces/ants/visualization.py b/nipype/interfaces/ants/visualization.py index 624f8e10b1..2412335e65 100644 --- a/nipype/interfaces/ants/visualization.py +++ b/nipype/interfaces/ants/visualization.py @@ -58,18 +58,16 @@ class ConvertScalarImageToRGB(ANTSCommand): 'ConvertScalarImageToRGB 3 T1.nii.gz rgb.nii.gz none jet none 0 6 0 255' """ _cmd = 'ConvertScalarImageToRGB' - input_spec = ConvertScalarImageToRGBInputSpec - output_spec = ConvertScalarImageToRGBOutputSpec + _input_spec = ConvertScalarImageToRGBInputSpec + _output_spec = ConvertScalarImageToRGBOutputSpec def _format_arg(self, opt, spec, val): return super(ConvertScalarImageToRGB, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output_image'] = os.path.join(os.getcwd(), + def _post_run(self): + self.outputs.output_image = os.path.join(os.getcwd(), self.inputs.output_image) - return outputs - + class CreateTiledMosaicInputSpec(ANTSCommandInputSpec): input_image = File(argstr='-i %s', exists=True, @@ -146,11 +144,10 @@ class CreateTiledMosaic(ANTSCommand): """ _cmd = 'CreateTiledMosaic' - input_spec = CreateTiledMosaicInputSpec - output_spec = CreateTiledMosaicOutputSpec + _input_spec = CreateTiledMosaicInputSpec + _output_spec = CreateTiledMosaicOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output_image'] = os.path.join(os.getcwd(), + def _post_run(self): + self.outputs.output_image = os.path.join(os.getcwd(), self.inputs.output_image) - return outputs + \ No newline at end of file diff --git a/nipype/interfaces/base.py b/nipype/interfaces/base.py deleted file mode 100644 index eb2d406532..0000000000 --- a/nipype/interfaces/base.py +++ /dev/null @@ -1,1869 +0,0 @@ -# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- -# vi: set ft=python sts=4 ts=4 sw=4 et: -""" -Package contains interfaces for using existing functionality in other packages - -Exaples FSL, matlab/SPM , afni - -Requires Packages to be installed -""" - -from __future__ import print_function -from __future__ import division -from future import standard_library -standard_library.install_aliases() -from builtins import range -from builtins import object - -from configparser import NoOptionError -from copy import deepcopy -import datetime -import errno -import os -import re -import platform -from socket import getfqdn -from string import Template -import select -import subprocess -import sys -import random -import time -import fnmatch -from textwrap import wrap -from datetime import datetime as dt -from dateutil.parser import parse as parseutc -from warnings import warn - - -from .traits_extension import (traits, Undefined, TraitDictObject, - TraitListObject, TraitError, - isdefined, File, Directory, - has_metadata) -from ..utils.filemanip import (md5, hash_infile, FileNotFoundError, - hash_timestamp, save_json, - split_filename) -from ..utils.misc import is_container, trim, str2bool -from ..utils.provenance import write_provenance -from .. import config, logging, LooseVersion -from .. import __version__ -from ..external.six import string_types - -nipype_version = LooseVersion(__version__) - -iflogger = logging.getLogger('interface') - - -__docformat__ = 'restructuredtext' - - -class NipypeInterfaceError(Exception): - def __init__(self, value): - self.value = value - - def __str__(self): - return repr(self.value) - -def _exists_in_path(cmd, environ): - ''' - Based on a code snippet from - http://orip.org/2009/08/python-checking-if-executable-exists-in.html - ''' - - if 'PATH' in environ: - input_environ = environ.get("PATH") - else: - input_environ = os.environ.get("PATH", "") - extensions = os.environ.get("PATHEXT", "").split(os.pathsep) - for directory in input_environ.split(os.pathsep): - base = os.path.join(directory, cmd) - options = [base] + [(base + ext) for ext in extensions] - for filename in options: - if os.path.exists(filename): - return True, filename - return False, None - - -def load_template(name): - """Load a template from the script_templates directory - - Parameters - ---------- - name : str - The name of the file to load - - Returns - ------- - template : string.Template - - """ - - full_fname = os.path.join(os.path.dirname(__file__), - 'script_templates', name) - template_file = open(full_fname) - template = Template(template_file.read()) - template_file.close() - return template - - -class Bunch(object): - """Dictionary-like class that provides attribute-style access to it's items. - - A `Bunch` is a simple container that stores it's items as class - attributes. Internally all items are stored in a dictionary and - the class exposes several of the dictionary methods. - - Examples - -------- - >>> from nipype.interfaces.base import Bunch - >>> inputs = Bunch(infile='subj.nii', fwhm=6.0, register_to_mean=True) - >>> inputs - Bunch(fwhm=6.0, infile='subj.nii', register_to_mean=True) - >>> inputs.register_to_mean = False - >>> inputs - Bunch(fwhm=6.0, infile='subj.nii', register_to_mean=False) - - - Notes - ----- - The Bunch pattern came from the Python Cookbook: - - .. [1] A. Martelli, D. Hudgeon, "Collecting a Bunch of Named - Items", Python Cookbook, 2nd Ed, Chapter 4.18, 2005. - - """ - - def __init__(self, *args, **kwargs): - self.__dict__.update(*args, **kwargs) - - def update(self, *args, **kwargs): - """update existing attribute, or create new attribute - - Note: update is very much like HasTraits.set""" - self.__dict__.update(*args, **kwargs) - - def items(self): - """iterates over bunch attributes as key, value pairs""" - return list(self.__dict__.items()) - - def iteritems(self): - """iterates over bunch attributes as key, value pairs""" - warn('iteritems is deprecated, use items instead') - return list(self.items()) - - def get(self, *args): - '''Support dictionary get() functionality - ''' - return self.__dict__.get(*args) - - def set(self, **kwargs): - '''Support dictionary get() functionality - ''' - return self.__dict__.update(**kwargs) - - def dictcopy(self): - """returns a deep copy of existing Bunch as a dictionary""" - return deepcopy(self.__dict__) - - def __repr__(self): - """representation of the sorted Bunch as a string - - Currently, this string representation of the `inputs` Bunch of - interfaces is hashed to determine if the process' dirty-bit - needs setting or not. Till that mechanism changes, only alter - this after careful consideration. - """ - outstr = ['Bunch('] - first = True - for k, v in sorted(self.items()): - if not first: - outstr.append(', ') - if isinstance(v, dict): - pairs = [] - for key, value in sorted(v.items()): - pairs.append("'%s': %s" % (key, value)) - v = '{' + ', '.join(pairs) + '}' - outstr.append('%s=%s' % (k, v)) - else: - outstr.append('%s=%r' % (k, v)) - first = False - outstr.append(')') - return ''.join(outstr) - - def _hash_infile(self, adict, key): - # Inject file hashes into adict[key] - stuff = adict[key] - if not is_container(stuff): - stuff = [stuff] - file_list = [] - for afile in stuff: - if os.path.isfile(afile): - md5obj = md5() - with open(afile, 'rb') as fp: - while True: - data = fp.read(8192) - if not data: - break - md5obj.update(data) - md5hex = md5obj.hexdigest() - else: - md5hex = None - file_list.append((afile, md5hex)) - return file_list - - def _get_bunch_hash(self): - """Return a dictionary of our items with hashes for each file. - - Searches through dictionary items and if an item is a file, it - calculates the md5 hash of the file contents and stores the - file name and hash value as the new key value. - - However, the overall bunch hash is calculated only on the hash - value of a file. The path and name of the file are not used in - the overall hash calculation. - - Returns - ------- - dict_withhash : dict - Copy of our dictionary with the new file hashes included - with each file. - hashvalue : str - The md5 hash value of the `dict_withhash` - - """ - - infile_list = [] - for key, val in list(self.items()): - if is_container(val): - # XXX - SG this probably doesn't catch numpy arrays - # containing embedded file names either. - if isinstance(val, dict): - # XXX - SG should traverse dicts, but ignoring for now - item = None - else: - if len(val) == 0: - raise AttributeError('%s attribute is empty' % key) - item = val[0] - else: - item = val - try: - if os.path.isfile(item): - infile_list.append(key) - except TypeError: - # `item` is not a file or string. - continue - dict_withhash = self.dictcopy() - dict_nofilename = self.dictcopy() - for item in infile_list: - dict_withhash[item] = self._hash_infile(dict_withhash, item) - dict_nofilename[item] = [val[1] for val in dict_withhash[item]] - # Sort the items of the dictionary, before hashing the string - # representation so we get a predictable order of the - # dictionary. - sorted_dict = str(sorted(dict_nofilename.items())) - return dict_withhash, md5(sorted_dict.encode()).hexdigest() - - def __pretty__(self, p, cycle): - '''Support for the pretty module - - pretty is included in ipython.externals for ipython > 0.10''' - if cycle: - p.text('Bunch(...)') - else: - p.begin_group(6, 'Bunch(') - first = True - for k, v in sorted(self.items()): - if not first: - p.text(',') - p.breakable() - p.text(k + '=') - p.pretty(v) - first = False - p.end_group(6, ')') - - -class InterfaceResult(object): - """Object that contains the results of running a particular Interface. - - Attributes - ---------- - version : version of this Interface result object (a readonly property) - interface : class type - A copy of the `Interface` class that was run to generate this result. - inputs : a traits free representation of the inputs - outputs : Bunch - An `Interface` specific Bunch that contains all possible files - that are generated by the interface. The `outputs` are used - as the `inputs` to another node when interfaces are used in - the pipeline. - runtime : Bunch - - Contains attributes that describe the runtime environment when - the `Interface` was run. Contains the attributes: - - * cmdline : The command line string that was executed - * cwd : The directory the ``cmdline`` was executed in. - * stdout : The output of running the ``cmdline``. - * stderr : Any error messages output from running ``cmdline``. - * returncode : The code returned from running the ``cmdline``. - - """ - - def __init__(self, interface, runtime, inputs=None, outputs=None, - provenance=None): - self._version = 2.0 - self.interface = interface - self.runtime = runtime - self.inputs = inputs - self.outputs = outputs - self.provenance = provenance - - @property - def version(self): - return self._version - - -class BaseTraitedSpec(traits.HasTraits): - """Provide a few methods necessary to support nipype interface api - - The inputs attribute of interfaces call certain methods that are not - available in traits.HasTraits. These are provided here. - - new metadata: - - * usedefault : set this to True if the default value of the trait should be - used. Unless this is set, the attributes are set to traits.Undefined - - new attribute: - - * get_hashval : returns a tuple containing the state of the trait as a dict - and hashvalue corresponding to dict. - - XXX Reconsider this in the long run, but it seems like the best - solution to move forward on the refactoring. - """ - - def __init__(self, **kwargs): - """ Initialize handlers and inputs""" - # NOTE: In python 2.6, object.__init__ no longer accepts input - # arguments. HasTraits does not define an __init__ and - # therefore these args were being ignored. - # super(TraitedSpec, self).__init__(*args, **kwargs) - super(BaseTraitedSpec, self).__init__(**kwargs) - traits.push_exception_handler(reraise_exceptions=True) - undefined_traits = {} - for trait in self.copyable_trait_names(): - if not self.traits()[trait].usedefault: - undefined_traits[trait] = Undefined - self.trait_set(trait_change_notify=False, **undefined_traits) - self._generate_handlers() - self.set(**kwargs) - - def items(self): - """ Name, trait generator for user modifiable traits - """ - for name in sorted(self.copyable_trait_names()): - yield name, self.traits()[name] - - def __repr__(self): - """ Return a well-formatted representation of the traits """ - outstr = [] - for name, value in sorted(self.trait_get().items()): - outstr.append('%s = %s' % (name, value)) - return '\n' + '\n'.join(outstr) + '\n' - - def _generate_handlers(self): - """Find all traits with the 'xor' metadata and attach an event - handler to them. - """ - has_xor = dict(xor=lambda t: t is not None) - xors = self.trait_names(**has_xor) - for elem in xors: - self.on_trait_change(self._xor_warn, elem) - has_requires = dict(requires=lambda t: t is not None) - requires = self.trait_names(**has_requires) - for elem in requires: - self.on_trait_change(self._requires_warn, elem) - has_deprecation = dict(deprecated=lambda t: t is not None) - deprecated = self.trait_names(**has_deprecation) - for elem in deprecated: - self.on_trait_change(self._deprecated_warn, elem) - - def _xor_warn(self, obj, name, old, new): - """ Generates warnings for xor traits - """ - if isdefined(new): - trait_spec = self.traits()[name] - # for each xor, set to default_value - for trait_name in trait_spec.xor: - if trait_name == name: - # skip ourself - continue - if isdefined(getattr(self, trait_name)): - self.trait_set(trait_change_notify=False, - **{'%s' % name: Undefined}) - msg = ('Input "%s" is mutually exclusive with input "%s", ' - 'which is already set') % (name, trait_name) - raise IOError(msg) - - def _requires_warn(self, obj, name, old, new): - """Part of the xor behavior - """ - if isdefined(new): - trait_spec = self.traits()[name] - msg = None - for trait_name in trait_spec.requires: - if not isdefined(getattr(self, trait_name)): - if not msg: - msg = 'Input %s requires inputs: %s' \ - % (name, ', '.join(trait_spec.requires)) - if msg: # only one requires warning at a time. - warn(msg) - - def _deprecated_warn(self, obj, name, old, new): - """Checks if a user assigns a value to a deprecated trait - """ - if isdefined(new): - trait_spec = self.traits()[name] - msg1 = ('Input %s in interface %s is deprecated.' % - (name, - self.__class__.__name__.split('InputSpec')[0])) - msg2 = ('Will be removed or raise an error as of release %s' - % trait_spec.deprecated) - if trait_spec.new_name: - if trait_spec.new_name not in self.copyable_trait_names(): - raise TraitError(msg1 + ' Replacement trait %s not found' % - trait_spec.new_name) - msg3 = 'It has been replaced by %s.' % trait_spec.new_name - else: - msg3 = '' - msg = ' '.join((msg1, msg2, msg3)) - if LooseVersion(str(trait_spec.deprecated)) < nipype_version: - raise TraitError(msg) - else: - if trait_spec.new_name: - msg += 'Unsetting old value %s; setting new value %s.' % ( - name, trait_spec.new_name) - warn(msg) - if trait_spec.new_name: - self.trait_set(trait_change_notify=False, - **{'%s' % name: Undefined, - '%s' % trait_spec.new_name: new}) - - def _hash_infile(self, adict, key): - """ Inject file hashes into adict[key]""" - stuff = adict[key] - if not is_container(stuff): - stuff = [stuff] - file_list = [] - for afile in stuff: - if is_container(afile): - hashlist = self._hash_infile({'infiles': afile}, 'infiles') - hash = [val[1] for val in hashlist] - else: - if config.get('execution', - 'hash_method').lower() == 'timestamp': - hash = hash_timestamp(afile) - elif config.get('execution', - 'hash_method').lower() == 'content': - hash = hash_infile(afile) - else: - raise Exception("Unknown hash method: %s" % - config.get('execution', 'hash_method')) - file_list.append((afile, hash)) - return file_list - - def get(self, **kwargs): - """ Returns traited class as a dict - - Augments the trait get function to return a dictionary without - notification handles - """ - out = super(BaseTraitedSpec, self).get(**kwargs) - out = self._clean_container(out, Undefined) - return out - - def get_traitsfree(self, **kwargs): - """ Returns traited class as a dict - - Augments the trait get function to return a dictionary without - any traits. The dictionary does not contain any attributes that - were Undefined - """ - out = super(BaseTraitedSpec, self).get(**kwargs) - out = self._clean_container(out, skipundefined=True) - return out - - def _clean_container(self, object, undefinedval=None, skipundefined=False): - """Convert a traited obejct into a pure python representation. - """ - if isinstance(object, TraitDictObject) or isinstance(object, dict): - out = {} - for key, val in list(object.items()): - if isdefined(val): - out[key] = self._clean_container(val, undefinedval) - else: - if not skipundefined: - out[key] = undefinedval - elif (isinstance(object, TraitListObject) or - isinstance(object, list) or isinstance(object, tuple)): - out = [] - for val in object: - if isdefined(val): - out.append(self._clean_container(val, undefinedval)) - else: - if not skipundefined: - out.append(undefinedval) - else: - out.append(None) - if isinstance(object, tuple): - out = tuple(out) - else: - if isdefined(object): - out = object - else: - if not skipundefined: - out = undefinedval - return out - - def get_hashval(self, hash_method=None): - """Return a dictionary of our items with hashes for each file. - - Searches through dictionary items and if an item is a file, it - calculates the md5 hash of the file contents and stores the - file name and hash value as the new key value. - - However, the overall bunch hash is calculated only on the hash - value of a file. The path and name of the file are not used in - the overall hash calculation. - - Returns - ------- - dict_withhash : dict - Copy of our dictionary with the new file hashes included - with each file. - hashvalue : str - The md5 hash value of the traited spec - - """ - - dict_withhash = [] - dict_nofilename = [] - for name, val in sorted(self.get().items()): - if isdefined(val): - trait = self.trait(name) - if has_metadata(trait.trait_type, "nohash", True): - continue - hash_files = (not has_metadata(trait.trait_type, "hash_files", - False) and not - has_metadata(trait.trait_type, "name_source")) - dict_nofilename.append((name, - self._get_sorteddict(val, hash_method=hash_method, - hash_files=hash_files))) - dict_withhash.append((name, - self._get_sorteddict(val, True, hash_method=hash_method, - hash_files=hash_files))) - return dict_withhash, md5(str(dict_nofilename).encode()).hexdigest() - - def _get_sorteddict(self, object, dictwithhash=False, hash_method=None, - hash_files=True): - if isinstance(object, dict): - out = [] - for key, val in sorted(object.items()): - if isdefined(val): - out.append((key, - self._get_sorteddict(val, dictwithhash, - hash_method=hash_method, - hash_files=hash_files))) - elif isinstance(object, (list, tuple)): - out = [] - for val in object: - if isdefined(val): - out.append(self._get_sorteddict(val, dictwithhash, - hash_method=hash_method, - hash_files=hash_files)) - if isinstance(object, tuple): - out = tuple(out) - else: - if isdefined(object): - if (hash_files and isinstance(object, string_types) and - os.path.isfile(object)): - if hash_method is None: - hash_method = config.get('execution', 'hash_method') - - if hash_method.lower() == 'timestamp': - hash = hash_timestamp(object) - elif hash_method.lower() == 'content': - hash = hash_infile(object) - else: - raise Exception("Unknown hash method: %s" % hash_method) - if dictwithhash: - out = (object, hash) - else: - out = hash - elif isinstance(object, float): - out = '%.10f' % object - else: - out = object - return out - - -class DynamicTraitedSpec(BaseTraitedSpec): - """ A subclass to handle dynamic traits - - This class is a workaround for add_traits and clone_traits not - functioning well together. - """ - - def __deepcopy__(self, memo): - """ bug in deepcopy for HasTraits results in weird cloning behavior for - added traits - """ - id_self = id(self) - if id_self in memo: - return memo[id_self] - dup_dict = deepcopy(self.get(), memo) - # access all keys - for key in self.copyable_trait_names(): - _ = getattr(self, key) - # clone once - dup = self.clone_traits(memo=memo) - for key in self.copyable_trait_names(): - try: - _ = getattr(dup, key) - except: - pass - # clone twice - dup = self.clone_traits(memo=memo) - dup.set(**dup_dict) - return dup - - -class TraitedSpec(BaseTraitedSpec): - """ Create a subclass with strict traits. - - This is used in 90% of the cases. - """ - _ = traits.Disallow - - -class Interface(object): - """This is an abstract definition for Interface objects. - - It provides no functionality. It defines the necessary attributes - and methods all Interface objects should have. - - """ - - input_spec = None # A traited input specification - output_spec = None # A traited output specification - - # defines if the interface can reuse partial results after interruption - _can_resume = False - - @property - def can_resume(self): - return self._can_resume - - # should the interface be always run even if the inputs were not changed? - _always_run = False - - @property - def always_run(self): - return self._always_run - - def __init__(self, **inputs): - """Initialize command with given args and inputs.""" - raise NotImplementedError - - @classmethod - def help(cls): - """ Prints class help""" - raise NotImplementedError - - @classmethod - def _inputs_help(cls): - """ Prints inputs help""" - raise NotImplementedError - - @classmethod - def _outputs_help(cls): - """ Prints outputs help""" - raise NotImplementedError - - @classmethod - def _outputs(cls): - """ Initializes outputs""" - raise NotImplementedError - - @property - def version(self): - raise NotImplementedError - - def run(self): - """Execute the command.""" - raise NotImplementedError - - def aggregate_outputs(self, runtime=None, needed_outputs=None): - """Called to populate outputs""" - raise NotImplementedError - - def _list_outputs(self): - """ List expected outputs""" - raise NotImplementedError - - def _get_filecopy_info(self): - """ Provides information about file inputs to copy or link to cwd. - Necessary for pipeline operation - """ - raise NotImplementedError - - -class BaseInterfaceInputSpec(TraitedSpec): - ignore_exception = traits.Bool(False, desc="Print an error message instead \ -of throwing an exception in case the interface fails to run", usedefault=True, - nohash=True) - - -class BaseInterface(Interface): - """Implements common interface functionality. - - Implements - ---------- - - * Initializes inputs/outputs from input_spec/output_spec - * Provides help based on input_spec and output_spec - * Checks for mandatory inputs before running an interface - * Runs an interface and returns results - * Determines which inputs should be copied or linked to cwd - - This class does not implement aggregate_outputs, input_spec or - output_spec. These should be defined by derived classes. - - This class cannot be instantiated. - - """ - input_spec = BaseInterfaceInputSpec - _version = None - _additional_metadata = [] - _redirect_x = False - - def __init__(self, **inputs): - if not self.input_spec: - raise Exception('No input_spec in class: %s' % - self.__class__.__name__) - self.inputs = self.input_spec(**inputs) - - @classmethod - def help(cls, returnhelp=False): - """ Prints class help - """ - - if cls.__doc__: - # docstring = cls.__doc__.split('\n') - # docstring = [trim(line, '') for line in docstring] - docstring = trim(cls.__doc__).split('\n') + [''] - else: - docstring = [''] - - allhelp = '\n'.join(docstring + cls._inputs_help() + [''] + - cls._outputs_help() + ['']) - if returnhelp: - return allhelp - else: - print(allhelp) - - @classmethod - def _get_trait_desc(self, inputs, name, spec): - desc = spec.desc - xor = spec.xor - requires = spec.requires - argstr = spec.argstr - - manhelpstr = ['\t%s' % name] - - type_info = spec.full_info(inputs, name, None) - - default = '' - if spec.usedefault: - default = ', nipype default value: %s' % str(spec.default_value()[1]) - line = "(%s%s)" % (type_info, default) - - manhelpstr = wrap(line, 70, - initial_indent=manhelpstr[0] + ': ', - subsequent_indent='\t\t ') - - if desc: - for line in desc.split('\n'): - line = re.sub("\s+", " ", line) - manhelpstr += wrap(line, 70, - initial_indent='\t\t', - subsequent_indent='\t\t') - - if argstr: - pos = spec.position - if pos is not None: - manhelpstr += wrap('flag: %s, position: %s' % (argstr, pos), 70, - initial_indent='\t\t', - subsequent_indent='\t\t') - else: - manhelpstr += wrap('flag: %s' % argstr, 70, - initial_indent='\t\t', - subsequent_indent='\t\t') - - if xor: - line = '%s' % ', '.join(xor) - manhelpstr += wrap(line, 70, - initial_indent='\t\tmutually_exclusive: ', - subsequent_indent='\t\t ') - - if requires: - others = [field for field in requires if field != name] - line = '%s' % ', '.join(others) - manhelpstr += wrap(line, 70, - initial_indent='\t\trequires: ', - subsequent_indent='\t\t ') - return manhelpstr - - @classmethod - def _inputs_help(cls): - """ Prints description for input parameters - """ - helpstr = ['Inputs::'] - - inputs = cls.input_spec() - if len(list(inputs.traits(transient=None).items())) == 0: - helpstr += ['', '\tNone'] - return helpstr - - manhelpstr = ['', '\t[Mandatory]'] - mandatory_items = inputs.traits(mandatory=True) - for name, spec in sorted(mandatory_items.items()): - manhelpstr += cls._get_trait_desc(inputs, name, spec) - - opthelpstr = ['', '\t[Optional]'] - for name, spec in sorted(inputs.traits(transient=None).items()): - if name in mandatory_items: - continue - opthelpstr += cls._get_trait_desc(inputs, name, spec) - - if manhelpstr: - helpstr += manhelpstr - if opthelpstr: - helpstr += opthelpstr - return helpstr - - @classmethod - def _outputs_help(cls): - """ Prints description for output parameters - """ - helpstr = ['Outputs::', ''] - if cls.output_spec: - outputs = cls.output_spec() #pylint: disable=E1102 - for name, spec in sorted(outputs.traits(transient=None).items()): - helpstr += cls._get_trait_desc(outputs, name, spec) - if len(helpstr) == 2: - helpstr += ['\tNone'] - return helpstr - - def _outputs(self): - """ Returns a bunch containing output fields for the class - """ - outputs = None - if self.output_spec: - outputs = self.output_spec() #pylint: disable=E1102 - - return outputs - - @classmethod - def _get_filecopy_info(cls): - """ Provides information about file inputs to copy or link to cwd. - Necessary for pipeline operation - """ - info = [] - if cls.input_spec is None: - return info - metadata = dict(copyfile=lambda t: t is not None) - for name, spec in sorted(cls.input_spec().traits(**metadata).items()): - info.append(dict(key=name, - copy=spec.copyfile)) - return info - - def _check_requires(self, spec, name, value): - """ check if required inputs are satisfied - """ - if spec.requires: - values = [not isdefined(getattr(self.inputs, field)) - for field in spec.requires] - if any(values) and isdefined(value): - msg = ("%s requires a value for input '%s' because one of %s " - "is set. For a list of required inputs, see %s.help()" % - (self.__class__.__name__, name, - ', '.join(spec.requires), self.__class__.__name__)) - raise ValueError(msg) - - def _check_xor(self, spec, name, value): - """ check if mutually exclusive inputs are satisfied - """ - if spec.xor: - values = [isdefined(getattr(self.inputs, field)) - for field in spec.xor] - if not any(values) and not isdefined(value): - msg = ("%s requires a value for one of the inputs '%s'. " - "For a list of required inputs, see %s.help()" % - (self.__class__.__name__, ', '.join(spec.xor), - self.__class__.__name__)) - raise ValueError(msg) - - def _check_mandatory_inputs(self): - """ Raises an exception if a mandatory input is Undefined - """ - for name, spec in list(self.inputs.traits(mandatory=True).items()): - value = getattr(self.inputs, name) - self._check_xor(spec, name, value) - if not isdefined(value) and spec.xor is None: - msg = ("%s requires a value for input '%s'. " - "For a list of required inputs, see %s.help()" % - (self.__class__.__name__, name, self.__class__.__name__)) - raise ValueError(msg) - if isdefined(value): - self._check_requires(spec, name, value) - for name, spec in list(self.inputs.traits(mandatory=None, - transient=None).items()): - self._check_requires(spec, name, getattr(self.inputs, name)) - - def _check_version_requirements(self, trait_object, raise_exception=True): - """ Raises an exception on version mismatch - """ - unavailable_traits = [] - # check minimum version - check = dict(min_ver=lambda t: t is not None) - names = trait_object.trait_names(**check) - - if names and self.version: - version = LooseVersion(str(self.version)) - for name in names: - min_ver = LooseVersion(str(trait_object.traits()[name].min_ver)) - if min_ver > version: - unavailable_traits.append(name) - if not isdefined(getattr(trait_object, name)): - continue - if raise_exception: - raise Exception('Trait %s (%s) (version %s < required %s)' % - (name, self.__class__.__name__, - version, min_ver)) - check = dict(max_ver=lambda t: t is not None) - names = trait_object.trait_names(**check) - for name in names: - max_ver = LooseVersion(str(trait_object.traits()[name].max_ver)) - if max_ver < version: - unavailable_traits.append(name) - if not isdefined(getattr(trait_object, name)): - continue - if raise_exception: - raise Exception('Trait %s (%s) (version %s > required %s)' % - (name, self.__class__.__name__, - version, max_ver)) - return unavailable_traits - - def _run_wrapper(self, runtime): - sysdisplay = os.getenv('DISPLAY') - if self._redirect_x: - try: - from xvfbwrapper import Xvfb - except ImportError: - iflogger.error('Xvfb wrapper could not be imported') - raise - - vdisp = Xvfb(nolisten='tcp') - vdisp.start() - try: - vdisp_num = vdisp.new_display - except AttributeError: # outdated version of xvfbwrapper - vdisp_num = vdisp.vdisplay_num - - iflogger.info('Redirecting X to :%d' % vdisp_num) - runtime.environ['DISPLAY'] = ':%d' % vdisp_num - - runtime = self._run_interface(runtime) - - if self._redirect_x: - vdisp.stop() - - return runtime - - def _run_interface(self, runtime): - """ Core function that executes interface - """ - raise NotImplementedError - - def run(self, **inputs): - """Execute this interface. - - This interface will not raise an exception if runtime.returncode is - non-zero. - - Parameters - ---------- - inputs : allows the interface settings to be updated - - Returns - ------- - results : an InterfaceResult object containing a copy of the instance - that was executed, provenance information and, if successful, results - """ - self.inputs.set(**inputs) - self._check_mandatory_inputs() - self._check_version_requirements(self.inputs) - interface = self.__class__ - # initialize provenance tracking - env = deepcopy(dict(os.environ)) - runtime = Bunch(cwd=os.getcwd(), - returncode=None, - duration=None, - environ=env, - startTime=dt.isoformat(dt.utcnow()), - endTime=None, - platform=platform.platform(), - hostname=getfqdn(), - version=self.version) - try: - runtime = self._run_wrapper(runtime) - outputs = self.aggregate_outputs(runtime) - runtime.endTime = dt.isoformat(dt.utcnow()) - timediff = parseutc(runtime.endTime) - parseutc(runtime.startTime) - runtime.duration = (timediff.days * 86400 + timediff.seconds + - timediff.microseconds / 100000.) - results = InterfaceResult(interface, runtime, - inputs=self.inputs.get_traitsfree(), - outputs=outputs) - prov_record = None - if str2bool(config.get('execution', 'write_provenance')): - prov_record = write_provenance(results) - results.provenance = prov_record - except Exception as e: - runtime.endTime = dt.isoformat(dt.utcnow()) - timediff = parseutc(runtime.endTime) - parseutc(runtime.startTime) - runtime.duration = (timediff.days * 86400 + timediff.seconds + - timediff.microseconds / 100000.) - if len(e.args) == 0: - e.args = ("") - - message = "\nInterface %s failed to run." % self.__class__.__name__ - - if config.has_option('logging', 'interface_level') and \ - config.get('logging', 'interface_level').lower() == 'debug': - inputs_str = "Inputs:" + str(self.inputs) + "\n" - else: - inputs_str = '' - - if len(e.args) == 1 and isinstance(e.args[0], string_types): - e.args = (e.args[0] + " ".join([message, inputs_str]),) - else: - e.args += (message, ) - if inputs_str != '': - e.args += (inputs_str, ) - - # exception raising inhibition for special cases - import traceback - runtime.traceback = traceback.format_exc() - runtime.traceback_args = e.args - inputs = None - try: - inputs = self.inputs.get_traitsfree() - except Exception as e: - pass - results = InterfaceResult(interface, runtime, inputs=inputs) - prov_record = None - if str2bool(config.get('execution', 'write_provenance')): - try: - prov_record = write_provenance(results) - except Exception: - prov_record = None - results.provenance = prov_record - if hasattr(self.inputs, 'ignore_exception') and \ - isdefined(self.inputs.ignore_exception) and \ - self.inputs.ignore_exception: - pass - else: - raise - return results - - def _list_outputs(self): - """ List the expected outputs - """ - if self.output_spec: - raise NotImplementedError - else: - return None - - def aggregate_outputs(self, runtime=None, needed_outputs=None): - """ Collate expected outputs and check for existence - """ - predicted_outputs = self._list_outputs() - outputs = self._outputs() - if predicted_outputs: - _unavailable_outputs = [] - if outputs: - _unavailable_outputs = \ - self._check_version_requirements(self._outputs()) - for key, val in list(predicted_outputs.items()): - if needed_outputs and key not in needed_outputs: - continue - if key in _unavailable_outputs: - raise KeyError(('Output trait %s not available in version ' - '%s of interface %s. Please inform ' - 'developers.') % (key, self.version, - self.__class__.__name__)) - try: - setattr(outputs, key, val) - _ = getattr(outputs, key) - except TraitError as error: - if hasattr(error, 'info') and \ - error.info.startswith("an existing"): - msg = ("File/Directory '%s' not found for %s output " - "'%s'." % (val, self.__class__.__name__, key)) - raise FileNotFoundError(msg) - else: - raise error - return outputs - - @property - def version(self): - if self._version is None: - if str2bool(config.get('execution', 'stop_on_unknown_version')): - raise ValueError('Interface %s has no version information' % - self.__class__.__name__) - return self._version - - -class Stream(object): - """Function to capture stdout and stderr streams with timestamps - - stackoverflow.com/questions/4984549/merge-and-sync-stdout-and-stderr/5188359 - """ - - def __init__(self, name, impl): - self._name = name - self._impl = impl - self._buf = '' - self._rows = [] - self._lastidx = 0 - - def fileno(self): - "Pass-through for file descriptor." - return self._impl.fileno() - - def read(self, drain=0): - "Read from the file descriptor. If 'drain' set, read until EOF." - while self._read(drain) is not None: - if not drain: - break - - def _read(self, drain): - "Read from the file descriptor" - fd = self.fileno() - buf = os.read(fd, 4096).decode() - if not buf and not self._buf: - return None - if '\n' not in buf: - if not drain: - self._buf += buf - return [] - - # prepend any data previously read, then split into lines and format - buf = self._buf + buf - if '\n' in buf: - tmp, rest = buf.rsplit('\n', 1) - else: - tmp = buf - rest = None - self._buf = rest - now = datetime.datetime.now().isoformat() - rows = tmp.split('\n') - self._rows += [(now, '%s %s:%s' % (self._name, now, r), r) - for r in rows] - for idx in range(self._lastidx, len(self._rows)): - iflogger.info(self._rows[idx][1]) - self._lastidx = len(self._rows) - - -def run_command(runtime, output=None, timeout=0.01, redirect_x=False): - """Run a command, read stdout and stderr, prefix with timestamp. - - The returned runtime contains a merged stdout+stderr log with timestamps - """ - PIPE = subprocess.PIPE - - cmdline = runtime.cmdline - if redirect_x: - exist_xvfb, _ = _exists_in_path('xvfb-run', runtime.environ) - if not exist_xvfb: - raise RuntimeError('Xvfb was not found, X redirection aborted') - cmdline = 'xvfb-run -a ' + cmdline - - if output == 'file': - errfile = os.path.join(runtime.cwd, 'stderr.nipype') - outfile = os.path.join(runtime.cwd, 'stdout.nipype') - stderr = open(errfile, 'wt') # t=='text'===default - stdout = open(outfile, 'wt') - - proc = subprocess.Popen(cmdline, - stdout=stdout, - stderr=stderr, - shell=True, - cwd=runtime.cwd, - env=runtime.environ) - else: - proc = subprocess.Popen(cmdline, - stdout=PIPE, - stderr=PIPE, - shell=True, - cwd=runtime.cwd, - env=runtime.environ) - result = {} - errfile = os.path.join(runtime.cwd, 'stderr.nipype') - outfile = os.path.join(runtime.cwd, 'stdout.nipype') - if output == 'stream': - streams = [Stream('stdout', proc.stdout), Stream('stderr', proc.stderr)] - - def _process(drain=0): - try: - res = select.select(streams, [], [], timeout) - except select.error as e: - iflogger.info(str(e)) - if e[0] == errno.EINTR: - return - else: - raise - else: - for stream in res[0]: - stream.read(drain) - - while proc.returncode is None: - proc.poll() - _process() - _process(drain=1) - - # collect results, merge and return - result = {} - temp = [] - for stream in streams: - rows = stream._rows - temp += rows - result[stream._name] = [r[2] for r in rows] - temp.sort() - result['merged'] = [r[1] for r in temp] - if output == 'allatonce': - stdout, stderr = proc.communicate() - if stdout and isinstance(stdout, bytes): - try: - stdout = stdout.decode() - except UnicodeDecodeError: - stdout = stdout.decode("ISO-8859-1") - if stderr and isinstance(stderr, bytes): - try: - stderr = stderr.decode() - except UnicodeDecodeError: - stderr = stderr.decode("ISO-8859-1") - - result['stdout'] = str(stdout).split('\n') - result['stderr'] = str(stderr).split('\n') - result['merged'] = '' - if output == 'file': - ret_code = proc.wait() - stderr.flush() - stdout.flush() - result['stdout'] = [line.strip() for line in open(outfile).readlines()] - result['stderr'] = [line.strip() for line in open(errfile).readlines()] - result['merged'] = '' - if output == 'none': - proc.communicate() - result['stdout'] = [] - result['stderr'] = [] - result['merged'] = '' - runtime.stderr = '\n'.join(result['stderr']) - runtime.stdout = '\n'.join(result['stdout']) - runtime.merged = result['merged'] - runtime.returncode = proc.returncode - return runtime - - -def get_dependencies(name, environ): - """Return library dependencies of a dynamically linked executable - - Uses otool on darwin, ldd on linux. Currently doesn't support windows. - - """ - PIPE = subprocess.PIPE - if sys.platform == 'darwin': - proc = subprocess.Popen('otool -L `which %s`' % name, - stdout=PIPE, - stderr=PIPE, - shell=True, - env=environ) - elif 'linux' in sys.platform: - proc = subprocess.Popen('ldd `which %s`' % name, - stdout=PIPE, - stderr=PIPE, - shell=True, - env=environ) - else: - return 'Platform %s not supported' % sys.platform - o, e = proc.communicate() - return o.rstrip() - - -class CommandLineInputSpec(BaseInterfaceInputSpec): - args = traits.Str(argstr='%s', desc='Additional parameters to the command') - environ = traits.DictStrStr(desc='Environment variables', usedefault=True, - nohash=True) - # This input does not have a "usedefault=True" so the set_default_terminal_output() - # method would work - terminal_output = traits.Enum('stream', 'allatonce', 'file', 'none', - desc=('Control terminal output: `stream` - ' - 'displays to terminal immediately (default), ' - '`allatonce` - waits till command is ' - 'finished to display output, `file` - ' - 'writes output to file, `none` - output' - ' is ignored'), - nohash=True) - - -class CommandLine(BaseInterface): - """Implements functionality to interact with command line programs - class must be instantiated with a command argument - - Parameters - ---------- - - command : string - define base immutable `command` you wish to run - - args : string, optional - optional arguments passed to base `command` - - - Examples - -------- - >>> import pprint - >>> from nipype.interfaces.base import CommandLine - >>> cli = CommandLine(command='ls', environ={'DISPLAY': ':1'}) - >>> cli.inputs.args = '-al' - >>> cli.cmdline - 'ls -al' - - >>> pprint.pprint(cli.inputs.trait_get()) # doctest: +NORMALIZE_WHITESPACE - {'args': '-al', - 'environ': {'DISPLAY': ':1'}, - 'ignore_exception': False, - 'terminal_output': 'stream'} - - >>> cli.inputs.get_hashval() - ([('args', '-al')], '11c37f97649cd61627f4afe5136af8c0') - - """ - - input_spec = CommandLineInputSpec - _cmd = None - _version = None - _terminal_output = 'stream' - - def __init__(self, command=None, **inputs): - super(CommandLine, self).__init__(**inputs) - self._environ = None - if not hasattr(self, '_cmd'): - self._cmd = None - if self.cmd is None and command is None: - raise Exception("Missing command") - if command: - self._cmd = command - self.inputs.on_trait_change(self._terminal_output_update, - 'terminal_output') - if not isdefined(self.inputs.terminal_output): - self.inputs.terminal_output = self._terminal_output - else: - self._terminal_output_update() - - def _terminal_output_update(self): - self._terminal_output = self.inputs.terminal_output - - @classmethod - def set_default_terminal_output(cls, output_type): - """Set the default terminal output for CommandLine Interfaces. - - This method is used to set default terminal output for - CommandLine Interfaces. However, setting this will not - update the output type for any existing instances. For these, - assign the .inputs.terminal_output. - """ - - if output_type in ['stream', 'allatonce', 'file', 'none']: - cls._terminal_output = output_type - else: - raise AttributeError('Invalid terminal output_type: %s' % - output_type) - - @property - def cmd(self): - """sets base command, immutable""" - return self._cmd - - @property - def cmdline(self): - """ `command` plus any arguments (args) - validates arguments and generates command line""" - self._check_mandatory_inputs() - allargs = self._parse_inputs() - allargs.insert(0, self.cmd) - return ' '.join(allargs) - - def raise_exception(self, runtime): - message = "Command:\n" + runtime.cmdline + "\n" - message += "Standard output:\n" + runtime.stdout + "\n" - message += "Standard error:\n" + runtime.stderr + "\n" - message += "Return code: " + str(runtime.returncode) - raise RuntimeError(message) - - @classmethod - def help(cls, returnhelp=False): - allhelp = super(CommandLine, cls).help(returnhelp=True) - - allhelp = "Wraps command **%s**\n\n" % cls._cmd + allhelp - - if returnhelp: - return allhelp - else: - print(allhelp) - - def _get_environ(self): - out_environ = {} - if not self._redirect_x: - try: - display_var = config.get('execution', 'display_variable') - out_environ = {'DISPLAY': display_var} - except NoOptionError: - pass - iflogger.debug(out_environ) - if isdefined(self.inputs.environ): - out_environ.update(self.inputs.environ) - return out_environ - - def version_from_command(self, flag='-v'): - cmdname = self.cmd.split()[0] - env = dict(os.environ) - if _exists_in_path(cmdname, env): - out_environ = self._get_environ() - env.update(out_environ) - proc = subprocess.Popen(' '.join((cmdname, flag)), - shell=True, - env=env, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ) - o, e = proc.communicate() - return o - - def _run_wrapper(self, runtime): - runtime = self._run_interface(runtime) - return runtime - - def _run_interface(self, runtime, correct_return_codes=[0]): - """Execute command via subprocess - - Parameters - ---------- - runtime : passed by the run function - - Returns - ------- - runtime : updated runtime information - adds stdout, stderr, merged, cmdline, dependencies, command_path - - """ - setattr(runtime, 'stdout', None) - setattr(runtime, 'stderr', None) - setattr(runtime, 'cmdline', self.cmdline) - out_environ = self._get_environ() - runtime.environ.update(out_environ) - executable_name = self.cmd.split()[0] - exist_val, cmd_path = _exists_in_path(executable_name, - runtime.environ) - if not exist_val: - raise IOError("command '%s' could not be found on host %s" % - (self.cmd.split()[0], runtime.hostname)) - setattr(runtime, 'command_path', cmd_path) - setattr(runtime, 'dependencies', get_dependencies(executable_name, - runtime.environ)) - runtime = run_command(runtime, output=self.inputs.terminal_output, - redirect_x=self._redirect_x) - if runtime.returncode is None or \ - runtime.returncode not in correct_return_codes: - self.raise_exception(runtime) - - return runtime - - def _format_arg(self, name, trait_spec, value): - """A helper function for _parse_inputs - - Formats a trait containing argstr metadata - """ - argstr = trait_spec.argstr - iflogger.debug('%s_%s' % (name, str(value))) - if trait_spec.is_trait_type(traits.Bool) and "%" not in argstr: - if value: - # Boolean options have no format string. Just append options - # if True. - return argstr - else: - return None - # traits.Either turns into traits.TraitCompound and does not have any - # inner_traits - elif trait_spec.is_trait_type(traits.List) \ - or (trait_spec.is_trait_type(traits.TraitCompound) and - isinstance(value, list)): - # This is a bit simple-minded at present, and should be - # construed as the default. If more sophisticated behavior - # is needed, it can be accomplished with metadata (e.g. - # format string for list member str'ification, specifying - # the separator, etc.) - - # Depending on whether we stick with traitlets, and whether or - # not we beef up traitlets.List, we may want to put some - # type-checking code here as well - sep = trait_spec.sep - if sep is None: - sep = ' ' - if argstr.endswith('...'): - - # repeatable option - # --id %d... will expand to - # --id 1 --id 2 --id 3 etc.,. - argstr = argstr.replace('...', '') - return sep.join([argstr % elt for elt in value]) - else: - return argstr % sep.join(str(elt) for elt in value) - else: - # Append options using format string. - return argstr % value - - def _filename_from_source(self, name, chain=None): - if chain is None: - chain = [] - - trait_spec = self.inputs.trait(name) - retval = getattr(self.inputs, name) - source_ext = None - if not isdefined(retval) or "%s" in retval: - if not trait_spec.name_source: - return retval - if isdefined(retval) and "%s" in retval: - name_template = retval - else: - name_template = trait_spec.name_template - if not name_template: - name_template = "%s_generated" - - ns = trait_spec.name_source - while isinstance(ns, list): - if len(ns) > 1: - iflogger.warn('Only one name_source per trait is allowed') - ns = ns[0] - - if not isinstance(ns, string_types): - raise ValueError(('name_source of \'%s\' trait sould be an ' - 'input trait name') % name) - - if isdefined(getattr(self.inputs, ns)): - name_source = ns - source = getattr(self.inputs, name_source) - while isinstance(source, list): - source = source[0] - - # special treatment for files - try: - _, base, source_ext = split_filename(source) - except AttributeError: - base = source - else: - if name in chain: - raise NipypeInterfaceError('Mutually pointing name_sources') - - chain.append(name) - base = self._filename_from_source(ns, chain) - if isdefined(base): - _, _, source_ext = split_filename(base) - - chain = None - retval = name_template % base - _, _, ext = split_filename(retval) - if trait_spec.keep_extension and (ext or source_ext): - if (ext is None or not ext) and source_ext: - retval = retval + source_ext - else: - retval = self._overload_extension(retval, name) - return retval - - def _gen_filename(self, name): - raise NotImplementedError - - def _overload_extension(self, value, name=None): - return value - - def _list_outputs(self): - metadata = dict(name_source=lambda t: t is not None) - traits = self.inputs.traits(**metadata) - if traits: - outputs = self.output_spec().get() #pylint: disable=E1102 - for name, trait_spec in traits.items(): - out_name = name - if trait_spec.output_name is not None: - out_name = trait_spec.output_name - outputs[out_name] = \ - os.path.abspath(self._filename_from_source(name)) - return outputs - - def _parse_inputs(self, skip=None): - """Parse all inputs using the ``argstr`` format string in the Trait. - - Any inputs that are assigned (not the default_value) are formatted - to be added to the command line. - - Returns - ------- - all_args : list - A list of all inputs formatted for the command line. - - """ - all_args = [] - initial_args = {} - final_args = {} - metadata = dict(argstr=lambda t: t is not None) - for name, spec in sorted(self.inputs.traits(**metadata).items()): - if skip and name in skip: - continue - value = getattr(self.inputs, name) - if spec.genfile or spec.name_source: - value = self._filename_from_source(name) - if not isdefined(value): - value = self._gen_filename(name) - if not isdefined(value): - continue - arg = self._format_arg(name, spec, value) - if arg is None: - continue - pos = spec.position - if pos is not None: - if int(pos) >= 0: - initial_args[pos] = arg - else: - final_args[pos] = arg - else: - all_args.append(arg) - first_args = [arg for pos, arg in sorted(initial_args.items())] - last_args = [arg for pos, arg in sorted(final_args.items())] - return first_args + all_args + last_args - - -class StdOutCommandLineInputSpec(CommandLineInputSpec): - out_file = File(argstr="> %s", position=-1, genfile=True) - - -class StdOutCommandLine(CommandLine): - input_spec = StdOutCommandLineInputSpec - - def _gen_filename(self, name): - if name is 'out_file': - return self._gen_outfilename() - else: - return None - - def _gen_outfilename(self): - raise NotImplementedError - - -class MpiCommandLineInputSpec(CommandLineInputSpec): - use_mpi = traits.Bool(False, - desc="Whether or not to run the command with mpiexec", - usedefault=True) - n_procs = traits.Int(desc="Num processors to specify to mpiexec. Do not " - "specify if this is managed externally (e.g. through " - "SGE)") - - -class MpiCommandLine(CommandLine): - '''Implements functionality to interact with command line programs - that can be run with MPI (i.e. using 'mpiexec'). - - Examples - -------- - >>> from nipype.interfaces.base import MpiCommandLine - >>> mpi_cli = MpiCommandLine(command='my_mpi_prog') - >>> mpi_cli.inputs.args = '-v' - >>> mpi_cli.cmdline - 'my_mpi_prog -v' - - >>> mpi_cli.inputs.use_mpi = True - >>> mpi_cli.inputs.n_procs = 8 - >>> mpi_cli.cmdline - 'mpiexec -n 8 my_mpi_prog -v' - ''' - input_spec = MpiCommandLineInputSpec - - @property - def cmdline(self): - """Adds 'mpiexec' to begining of command""" - result = [] - if self.inputs.use_mpi: - result.append('mpiexec') - if self.inputs.n_procs: - result.append('-n %d' % self.inputs.n_procs) - result.append(super(MpiCommandLine, self).cmdline) - return ' '.join(result) - - -class SEMLikeCommandLine(CommandLine): - """In SEM derived interface all outputs have corresponding inputs. - However, some SEM commands create outputs that are not defined in the XML. - In those cases one has to create a subclass of the autogenerated one and - overload the _list_outputs method. _outputs_from_inputs should still be - used but only for the reduced (by excluding those that do not have - corresponding inputs list of outputs. - """ - - def _list_outputs(self): - outputs = self.output_spec().get() #pylint: disable=E1102 - return self._outputs_from_inputs(outputs) - - def _outputs_from_inputs(self, outputs): - for name in list(outputs.keys()): - corresponding_input = getattr(self.inputs, name) - if isdefined(corresponding_input): - if (isinstance(corresponding_input, bool) and - corresponding_input): - outputs[name] = \ - os.path.abspath(self._outputs_filenames[name]) - else: - if isinstance(corresponding_input, list): - outputs[name] = [os.path.abspath(inp) - for inp in corresponding_input] - else: - outputs[name] = os.path.abspath(corresponding_input) - return outputs - - def _format_arg(self, name, spec, value): - if name in list(self._outputs_filenames.keys()): - if isinstance(value, bool): - if value: - value = os.path.abspath(self._outputs_filenames[name]) - else: - return "" - return super(SEMLikeCommandLine, self)._format_arg(name, spec, value) - - -class MultiPath(traits.List): - """ Abstract class - shared functionality of input and output MultiPath - """ - - def validate(self, object, name, value): - if not isdefined(value) or \ - (isinstance(value, list) and len(value) == 0): - return Undefined - newvalue = value - - if not isinstance(value, list) \ - or (self.inner_traits() and - isinstance(self.inner_traits()[0].trait_type, - traits.List) and not - isinstance(self.inner_traits()[0].trait_type, - InputMultiPath) and - isinstance(value, list) and - value and not - isinstance(value[0], list)): - newvalue = [value] - value = super(MultiPath, self).validate(object, name, newvalue) - - if len(value) > 0: - return value - - self.error(object, name, value) - - -class OutputMultiPath(MultiPath): - """ Implements a user friendly traits that accepts one or more - paths to files or directories. This is the output version which - return a single string whenever possible (when it was set to a - single value or a list of length 1). Default value of this trait - is _Undefined. It does not accept empty lists. - - XXX This should only be used as a final resort. We should stick to - established Traits to the extent possible. - - XXX This needs to be vetted by somebody who understands traits - - >>> from nipype.interfaces.base import OutputMultiPath - >>> class A(TraitedSpec): - ... foo = OutputMultiPath(File(exists=False)) - >>> a = A() - >>> a.foo - - - >>> a.foo = '/software/temp/foo.txt' - >>> a.foo - '/software/temp/foo.txt' - - >>> a.foo = ['/software/temp/foo.txt'] - >>> a.foo - '/software/temp/foo.txt' - - >>> a.foo = ['/software/temp/foo.txt', '/software/temp/goo.txt'] - >>> a.foo - ['/software/temp/foo.txt', '/software/temp/goo.txt'] - - """ - - def get(self, object, name): - value = self.get_value(object, name) - if len(value) == 0: - return Undefined - elif len(value) == 1: - return value[0] - else: - return value - - def set(self, object, name, value): - self.set_value(object, name, value) - - -class InputMultiPath(MultiPath): - """ Implements a user friendly traits that accepts one or more - paths to files or directories. This is the input version which - always returns a list. Default value of this trait - is _Undefined. It does not accept empty lists. - - XXX This should only be used as a final resort. We should stick to - established Traits to the extent possible. - - XXX This needs to be vetted by somebody who understands traits - - >>> from nipype.interfaces.base import InputMultiPath - >>> class A(TraitedSpec): - ... foo = InputMultiPath(File(exists=False)) - >>> a = A() - >>> a.foo - - - >>> a.foo = '/software/temp/foo.txt' - >>> a.foo - ['/software/temp/foo.txt'] - - >>> a.foo = ['/software/temp/foo.txt'] - >>> a.foo - ['/software/temp/foo.txt'] - - >>> a.foo = ['/software/temp/foo.txt', '/software/temp/goo.txt'] - >>> a.foo - ['/software/temp/foo.txt', '/software/temp/goo.txt'] - - """ - pass diff --git a/nipype/interfaces/base/__init__.py b/nipype/interfaces/base/__init__.py new file mode 100644 index 0000000000..6283bb3653 --- /dev/null +++ b/nipype/interfaces/base/__init__.py @@ -0,0 +1,11 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +""" +The nipype.interface.base module provides the inputs/outputs specifications +and interface structures +""" + +from .interfaces import * +from .specs import * +from .traits_extension import * +from .runtime import * \ No newline at end of file diff --git a/nipype/interfaces/base/interfaces.py b/nipype/interfaces/base/interfaces.py new file mode 100644 index 0000000000..7abc6d203f --- /dev/null +++ b/nipype/interfaces/base/interfaces.py @@ -0,0 +1,546 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +""" +Base interfaces that will be implemented with installed packages +with implementation in nipype (:module:`nipype.interfaces`) or +pure python implementations (:module:`nipype.algorithms`). + + .. testsetup:: + + >>> import os + >>> filepath = op.dirname(op.realpath( __file__ )) + >>> datadir = op.realpath(op.join(filepath, '../../testing/data')) + >>> os.chdir(datadir) + >>> from nipype.interfaces.base.specs import BaseInputSpec, BaseOutputSpec + >>> from nipype.interfaces.base import traits_extension as traits + >>> import pprint + +""" + +from __future__ import print_function +from __future__ import division + +from copy import deepcopy +import os +import os.path as op +import platform +from socket import getfqdn +import subprocess +from datetime import datetime as dt +from dateutil.parser import parse as parseutc + +from future import standard_library +standard_library.install_aliases() +from builtins import range +from builtins import object + +from configparser import NoOptionError +from traits.api import Interface, Instance, provides, HasTraits +from .traits_extension import traits, Undefined, File, MultiPath +from ...utils.misc import trim, str2bool +from ...utils.provenance import write_provenance +from ... import config, logging, LooseVersion +from ... import __version__ +from ...external.six import string_types + +# Make all the traits and spec interfaces available through base +# for backwards compatibility, even though import * is discouraged +# in production environments. +from .traits_extension import isdefined, Command, File, BaseFile +from .specs import (IInputSpec, IOutputSpec, IInputCommandLineSpec, + BaseInputSpec, BaseOutputSpec, CommandLineInputSpec, + StdOutCommandLineInputSpec, StdOutCommandLineOutputSpec, + MpiCommandLineInputSpec, + SEMLikeCommandLineInputSpec) +from .runtime import (Bunch, InterfaceResult, get_dependencies, + run_command, raise_exception) + +IFLOGGER = logging.getLogger('interface') +__docformat__ = 'restructuredtext' + + +class IBase(Interface): + """This is an abstract definition for Interface objects. + + It provides no functionality. It defines the necessary attributes + and methods all Interface objects should have. + + """ + def pre_run(self, **inputs): + """Hook executed before running""" + + def run(self, dry_run=False, **inputs): + """ + The interface runner + + Parameters + ---------- + inputs : allows the interface settings to be updated + + Returns + ------- + results : an InterfaceResult object containing a copy of the instance + that was executed, provenance information and, if successful, results + """ + + def post_run(self): + """Hook executed after running""" + + def _aggregate_outputs(self): + """Fill in the ouputs after running the interface""" + +class ICommandBase(Interface): + """Abstract class for interfaces wrapping a command line""" + + @property + def cmdline(self): + """The command line that is to be executed""" + + +@provides(IBase) +class BaseInterface(HasTraits): + """ + Implements common interface functionality. + + To implement an interface, one should define the input and + output specification types (`_input_spec` and `_output_spec`). + + The input interface will be available in thorugh the `inputs` trait. + The behavior is the same for outputs. + + Examples + -------- + + >>> class IfaceAInputSpec(BaseInputSpec): + ... foo = File(exists=True) + ... bar = traits.Int(10, usedefault=True) + ... out_foo = File('out_file.txt', usedefault=True) + + >>> class IfaceAOutputSpec(BaseOutputSpec): + ... out_foo = File(exists=True) + + >>> class IfaceA(BaseInterface): + ... _input_spec = IfaceAInputSpec + ... _output_spec = IfaceAOutputSpec + ... version = 1.0 + + >>> new_a = IfaceA() + >>> new_a.inputs.foo = 'functional.nii' + >>> new_a.inputs.get_traitsfree() + {'foo': 'functional.nii', 'bar': 10, 'out_foo': 'out_file.txt'} + + >>> new_a.run(dry_run=True) # doctest: +SKIP + + + """ + _additional_metadata = [] + _input_spec = BaseInputSpec + _output_spec = BaseOutputSpec + + inputs = Instance(IInputSpec) + outputs = Instance(IOutputSpec) + status = traits.Enum('ready', 'starting', 'running', 'ending', + 'errored', 'finished') + version = traits.Str + redirect_x = traits.Bool + can_resume = traits.Bool(True) + always_run = traits.Bool + ignore_exception = traits.Bool + + def __init__(self, **inputs): + self.inputs = self._input_spec() + self.inputs.set(**inputs) + self.outputs = self._output_spec() + + def _run_wrapper(self, runtime, dry_run=False): + if dry_run: + return runtime + + sysdisplay = os.getenv('DISPLAY') + if self.redirect_x: + try: + from xvfbwrapper import Xvfb + except ImportError: + IFLOGGER.error('Xvfb wrapper could not be imported') + raise + + vdisp = Xvfb(nolisten='tcp') + vdisp.start() + + try: + vdisp_num = vdisp.new_display + except AttributeError: # outdated version of xvfbwrapper + vdisp_num = vdisp.vdisplay_num + + IFLOGGER.info('Redirecting X to :%d', vdisp_num) + runtime.environ['DISPLAY'] = ':%d' % vdisp_num + + runtime = self._run_interface(runtime) + + if self.redirect_x: + vdisp.stop() + + return runtime + + def _run_interface(self, runtime, dry_run=False, **kwargs): + """ Core function that executes interface""" + raise NotImplementedError('BaseInterface running is disabled.') + + def pre_run(self, **inputs): + """ Implementation of the pre-execution hook""" + inputs.pop('dry_run', None) # Remove the dry_run key + self.inputs.set(**inputs) + self.inputs.check_inputs() + self.check_version() + + def post_run(self): + """ Implementation of the post-execution hook""" + pass + + def _aggregate_outputs(self, dry_run=False): + """ + Anticipates the outputs. If, for some reason, the outputs cannot be + guessed from the inputs and the rules inside this method, + use :member:`nipype.interfaces.base.IBase.post_run()` to specify + these outputs + """ + outputs = [k[0] for k in list(self.outputs.items())] + for name, value, spec in self.inputs.get_defined(): + # Rule #1: outputs with a corresponding input (same name) are + # automatically copied. + if name in outputs: + try: + setattr(self.outputs, name, value) + except traits.TraitError: # file does not exist + _genfile_dryrun(name, value) + setattr(self.outputs, name, value) + + # Rule #2: boolean inputs that start with save_ automatically + # enable the corresponding out_ and vice-versa + if name.startswith('save_') and isinstance(value, bool): + out_name = 'out_' + name[5:] + if not value and out_name in outputs: + setattr(self.outputs, Undefined) + + # Rule #3: inputs specifying an output_name metadata will be + # mapped to the corresponding output + if spec.output_name and self.outputs.traits()[spec.output_name]: + try: + setattr(self.outputs, spec.output_name, value) + except traits.TraitError: # file does not exist + _genfile_dryrun(name, value) + setattr(self.outputs, spec.output_name, value) + + + + def run(self, dry_run=False, **inputs): + """Basic implementation of the interface runner""" + self.status = 'starting' + self.pre_run(**inputs) + # initialize provenance tracking + runtime = Bunch( + cwd=os.getcwd(), returncode=None, duration=None, environ=deepcopy(dict(os.environ)), + startTime=dt.isoformat(dt.utcnow()), endTime=None, traceback=None, + platform=platform.platform(), hostname=getfqdn(), version=self.version) + + self.status = 'running' + exception = None + try: + runtime = self._run_wrapper(runtime, dry_run) + except Exception as error: # pylint: disable=W0703 + runtime, exception = self.handle_error(runtime, error) + if not self.ignore_exception: + raise + finally: + runtime.endTime = dt.isoformat(dt.utcnow()) + timediff = parseutc(runtime.endTime) - parseutc(runtime.startTime) + runtime.duration = (timediff.days * 86400 + timediff.seconds + + timediff.microseconds / 1e5) + results = InterfaceResult(self.__class__, runtime, + inputs=self.inputs.get_traitsfree()) + + if exception is None: + self.status = 'ending' + self._aggregate_outputs(dry_run=dry_run) + self.post_run() + results.outputs = self.outputs + + prov_record = None + if str2bool(config.get('execution', 'write_provenance')): + prov_record = write_provenance(results) + results.provenance = prov_record + + if exception is None: + self.status = 'finished' + return results + + def handle_error(self, runtime, exception): + import traceback + self.status = 'errored' + message = ["Interface %s failed to run." % self.__class__.__name__] + if config.get('logging', 'interface_level', 'info').lower() == 'debug': + message += ["Inputs:\n%s\n" % str(self.inputs)] + + if len(exception.args) == 1 and isinstance(exception.args[0], string_types): + message.insert(0, exception.args[0]) + else: + message += list(exception.args) + # exception raising inhibition for special cases + runtime.traceback = traceback.format_exc() + runtime.traceback_args = message # pylint: disable=W0201 + return runtime, message + + @classmethod + def help(cls, returnhelp=False): + """ Prints class help """ + + docstring = [''] + if cls.__doc__: + docstring = trim(cls.__doc__).split('\n') + docstring + + allhelp = '\n'.join(docstring + cls._input_spec().help()) + if returnhelp: + return allhelp + print(allhelp) + + def check_version(self): + if not self.version: + if str2bool(config.get('execution', 'stop_on_unknown_version')): + raise ValueError('Interface %s has no version information' % + self.__class__.__name__) + return [] + + return self.inputs.check_version(LooseVersion(str(self.version))) + + +@provides(IBase, ICommandBase) +class CommandLine(BaseInterface): + """Implements functionality to interact with command line programs + class must be instantiated with a command argument + + Parameters + ---------- + + command : string + define base immutable `command` you wish to run + + args : string, optional + optional arguments passed to base `command` + + + Examples + -------- + >>> import pprint + >>> from nipype.interfaces.base import CommandLine + >>> cli = CommandLine(command='ls', environ={'DISPLAY': ':1'}) + >>> cli.inputs.args = '-al' + >>> cli.cmdline + 'ls -al' + + >>> pprint.pprint(cli.inputs.trait_get()) # doctest: +NORMALIZE_WHITESPACE + {'args': '-al'} + + >>> cli.inputs.get_hashval() + ([('args', '-al')], '11c37f97649cd61627f4afe5136af8c0') + + """ + + _cmd = None + _input_spec = CommandLineInputSpec + #_output_spec = OutputSpec + inputs = Instance(IInputCommandLineSpec) + outputs = Instance(IOutputSpec) + environ = traits.DictStrStr(dict(os.environ), desc='Environment variables') + command = Command + terminal_output = traits.Enum( + 'stream', 'allatonce', 'file', 'none', + desc='Control terminal output: `stream` - displays to terminal immediately (default), ' + '`allatonce` - waits till command is finished to display output, `file` - ' + 'writes output to file, `none` - output is ignored') + + def _environ_default(self): + return dict(os.environ) + + def _redirect_x_changed(self, new): + if not new: + try: + display_var = config.get('execution', 'display_variable') + self.environ['DISPLAY'] = display_var + except NoOptionError: + pass + + + def __init__(self, command=None, environ=None, **inputs): + # Force refresh of the redirect_x trait + self._redirect_x_changed(self.redirect_x) + + # First modify environment variables if passed + if environ is not None: + for k, value in list(environ.items()): + self.environ[k] = value + + args = [] + # Set command to force validation + if command is not None: + cmdchunks = command.split() + self.command = cmdchunks[0] + if len(cmdchunks) > 1: + args += cmdchunks[1:] + elif self._cmd is not None: + self.command = self._cmd + else: + raise RuntimeError('CommandLine interfaces require' + ' the definition of a command') + super(CommandLine, self).__init__(**inputs) + + newargs = inputs.pop('args', []) + if newargs: + if not isinstance(newargs, list): + newargs = [newargs] + args += newargs + if args: + self.inputs.args = ' '.join(args) + + + @property + def cmdline(self): + """ `command` plus any arguments (args) + validates arguments and generates command line""" + self.inputs.check_inputs() + return ' '.join([self.command] + self.inputs.parse_args()) + + def _run_interface(self, runtime, **kwargs): + """Execute command via subprocess + + Parameters + ---------- + runtime : passed by the run function + + Returns + ------- + runtime : updated runtime information + adds stdout, stderr, merged, cmdline, dependencies, command_path + + """ + correct_return_codes = [0] + if 'correct_return_codes' in kwargs.keys(): + correct_return_codes = kwargs[correct_return_codes] + + runtime.environ.update(self.environ) + setattr(runtime, 'stdout', None) + setattr(runtime, 'stderr', None) + setattr(runtime, 'cmdline', self.cmdline) + setattr(runtime, 'command_path', self.trait('command').path) + setattr(runtime, 'dependencies', get_dependencies( + self.command.split()[0], runtime.environ)) + runtime = run_command(runtime, output=self.terminal_output, + redirect_x=self.redirect_x) + if runtime.returncode is None or \ + runtime.returncode not in correct_return_codes: + raise_exception(runtime) + return runtime + + def version_from_command(self, flag='-v'): + """Call command -v to get version""" + cmdname = self.command.split()[0] + proc = subprocess.Popen( + ' '.join((cmdname, flag)), shell=True, env=self.environ, + stdout=subprocess.PIPE, stderr=subprocess.PIPE,) + out, _ = proc.communicate() + return out + + @classmethod + def help(cls, returnhelp=False): + if cls._cmd is not None: + allhelp = 'Wraps the ``%s`` command\n\n' % cls._cmd + else: + allhelp = 'Wraps a system command specified by the ``command`` attribute\n\n' + + allhelp += super(CommandLine, cls).help(returnhelp=True) + + if returnhelp: + return allhelp + print(allhelp) + +@provides(IBase, ICommandBase) +class StdOutCommandLine(CommandLine): + """A command line that writes into the output stream""" + _input_spec = StdOutCommandLineInputSpec + _output_spec = StdOutCommandLineOutputSpec + + +@provides(IBase, ICommandBase) +class MpiCommandLine(CommandLine): + """Implements functionality to interact with command line programs + that can be run with MPI (i.e. using 'mpiexec'). + + Examples + -------- + >>> from nipype.interfaces.base import MpiCommandLine + >>> mpi_cli = MpiCommandLine(command='ls') + >>> mpi_cli.inputs.args = '-v' + >>> mpi_cli.cmdline + 'ls -v' + + >>> mpi_cli.inputs.use_mpi = True + >>> mpi_cli.inputs.n_procs = 8 + >>> mpi_cli.cmdline + 'mpiexec -n 8 ls -v' + """ + _input_spec = MpiCommandLineInputSpec + + @property + def cmdline(self): + """Adds 'mpiexec' to begining of command""" + result = [] + if self.inputs.use_mpi: + result.append('mpiexec') + if isdefined(self.inputs.n_procs): + result.append('-n %d' % self.inputs.n_procs) + result.append(super(MpiCommandLine, self).cmdline) + return ' '.join(result) + + +@provides(IBase, ICommandBase) +class SEMLikeCommandLine(CommandLine): + """In SEM derived interface all outputs have corresponding inputs. + However, some SEM commands create outputs that are not defined in the XML. + In those cases one has to create a subclass of the autogenerated one and + overload the _list_outputs method. _outputs_from_inputs should still be + used but only for the reduced (by excluding those that do not have + corresponding inputs list of outputs. + """ + _input_spec = SEMLikeCommandLineInputSpec + + def post_run(self): + for name in list(self.outputs.keys()): + corresponding_input = getattr(self.inputs, name) + if isdefined(corresponding_input): + if (isinstance(corresponding_input, bool) and + corresponding_input): + setattr(self.outputs, name, op.abspath( + self._outputs_filenames[name])) + else: + if isinstance(corresponding_input, list): + setattr(self.outputs, name, + [op.abspath(inp) for inp in corresponding_input]) + else: + setattr(self.outputs, name, op.abspath(corresponding_input)) + + +def _genfile_dryrun(name, value, out_name=None): + if out_name is None: + out_name = name + + if isinstance(value, string_types): + files = [value] + else: + files = value + + for fname in files: + if not op.isfile(op.abspath(fname)): + with open(fname, 'a'): + os.utime(fname, None) + IFLOGGER.debug('Successfully created dry-run output: %s', fname) + else: + IFLOGGER.debug('File exists, skipping touch %s', fname) diff --git a/nipype/interfaces/base/runtime.py b/nipype/interfaces/base/runtime.py new file mode 100644 index 0000000000..3ed48a83c0 --- /dev/null +++ b/nipype/interfaces/base/runtime.py @@ -0,0 +1,448 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +""" +Implementation for the InterfaceResult type and other requirements +""" +from __future__ import print_function +from __future__ import division + +from copy import deepcopy +import os +import os.path as op +import sys +import select +import errno +import subprocess +from datetime import datetime as dt + +from string import Template + +from future import standard_library +standard_library.install_aliases() +from builtins import range +from builtins import object + +from ...utils.misc import is_container +from ...utils.filemanip import md5 +from ... import logging + + +IFLOGGER = logging.getLogger('interface') +__docformat__ = 'restructuredtext' + + +def load_template(name): + """Load a template from the script_templates directory + + Parameters + ---------- + name : str + The name of the file to load + + Returns + ------- + template : string.Template + + """ + + full_fname = op.join(op.dirname(__file__), + 'script_templates', name) + template_file = open(full_fname) + template = Template(template_file.read()) + template_file.close() + return template + + +class Bunch(object): + """Dictionary-like class that provides attribute-style access to it's items. + + A `Bunch` is a simple container that stores it's items as class + attributes. Internally all items are stored in a dictionary and + the class exposes several of the dictionary methods. + + Examples + -------- + >>> from nipype.interfaces.base import Bunch + >>> inputs = Bunch(infile='subj.nii', fwhm=6.0, register_to_mean=True) + >>> inputs + Bunch(fwhm=6.0, infile='subj.nii', register_to_mean=True) + >>> inputs.register_to_mean = False + >>> inputs + Bunch(fwhm=6.0, infile='subj.nii', register_to_mean=False) + + + Notes + ----- + The Bunch pattern came from the Python Cookbook: + + .. [1] A. Martelli, D. Hudgeon, "Collecting a Bunch of Named + Items", Python Cookbook, 2nd Ed, Chapter 4.18, 2005. + + """ + + def __init__(self, *args, **kwargs): + self.__dict__.update(*args, **kwargs) + + def update(self, *args, **kwargs): + """update existing attribute, or create new attribute + + Note: update is very much like HasTraits.set""" + self.__dict__.update(*args, **kwargs) + + def items(self): + """iterates over bunch attributes as key, value pairs""" + return list(self.__dict__.items()) + + def iteritems(self): + """iterates over bunch attributes as key, value pairs""" + IFLOGGER.warn('iteritems is deprecated, use items instead') + return list(self.items()) + + def get(self, *args): + """Support dictionary get() functionality + """ + return self.__dict__.get(*args) + + def set(self, **kwargs): + """Support dictionary get() functionality + """ + return self.__dict__.update(**kwargs) + + def dictcopy(self): + """returns a deep copy of existing Bunch as a dictionary""" + return deepcopy(self.__dict__) + + def __repr__(self): + """representation of the sorted Bunch as a string + + Currently, this string representation of the `inputs` Bunch of + interfaces is hashed to determine if the process' dirty-bit + needs setting or not. Till that mechanism changes, only alter + this after careful consideration. + """ + outstr = ['Bunch('] + first = True + for k, input_value in sorted(self.items()): + if not first: + outstr.append(', ') + if isinstance(input_value, dict): + pairs = [] + for key, value in sorted(input_value.items()): + pairs.append("'%s': %s" % (key, value)) + input_value = '{' + ', '.join(pairs) + '}' + outstr.append('%s=%s' % (k, input_value)) + else: + outstr.append('%s=%r' % (k, input_value)) + first = False + outstr.append(')') + return ''.join(outstr) + + def _get_bunch_hash(self): + """Return a dictionary of our items with hashes for each file. + + Searches through dictionary items and if an item is a file, it + calculates the md5 hash of the file contents and stores the + file name and hash value as the new key value. + + However, the overall bunch hash is calculated only on the hash + value of a file. The path and name of the file are not used in + the overall hash calculation. + + Returns + ------- + dict_withhash : dict + Copy of our dictionary with the new file hashes included + with each file. + hashvalue : str + The md5 hash value of the `dict_withhash` + + """ + + infile_list = [] + for key, val in list(self.items()): + if is_container(val): + # XXX - SG this probably doesn't catch numpy arrays + # containing embedded file names either. + if isinstance(val, dict): + # XXX - SG should traverse dicts, but ignoring for now + item = None + else: + if len(val) == 0: + raise AttributeError('%s attribute is empty' % key) + item = val[0] + else: + item = val + try: + if op.isfile(item): + infile_list.append(key) + except TypeError: + # `item` is not a file or string. + continue + dict_withhash = self.dictcopy() + dict_nofilename = self.dictcopy() + for item in infile_list: + dict_withhash[item] = self._hash_infile(dict_withhash, item) + dict_nofilename[item] = [val[1] for val in dict_withhash[item]] + # Sort the items of the dictionary, before hashing the string + # representation so we get a predictable order of the + # dictionary. + sorted_dict = str(sorted(dict_nofilename.items())) + return dict_withhash, md5(sorted_dict.encode()).hexdigest() + + def _hash_infile(self, adict, key): + """Compute hashes of files""" + # Inject file hashes into adict[key] + stuff = adict[key] + if not is_container(stuff): + stuff = [stuff] + file_list = [] + for fname in stuff: + if op.isfile(fname): + md5obj = md5() + with open(fname, 'rb') as filep: + while True: + data = filep.read(8192) + if not data: + break + md5obj.update(data) + md5hex = md5obj.hexdigest() + else: + md5hex = None + file_list.append((fname, md5hex)) + return file_list + + def __pretty__(self, p, cycle): + """Support for the pretty module + + pretty is included in ipython.externals for ipython > 0.10""" + if cycle: + p.text('Bunch(...)') + else: + p.begin_group(6, 'Bunch(') + first = True + for k, input_value in sorted(self.items()): + if not first: + p.text(',') + p.breakable() + p.text(k + '=') + p.pretty(input_value) + first = False + p.end_group(6, ')') + + +class InterfaceResult(object): + """Object that contains the results of running a particular Interface. + + Attributes + ---------- + version : version of this Interface result object (a readonly property) + interface : class type + A copy of the `Interface` class that was run to generate this result. + inputs : a traits free representation of the inputs + outputs : Bunch + An `Interface` specific Bunch that contains all possible files + that are generated by the interface. The `outputs` are used + as the `inputs` to another node when interfaces are used in + the pipeline. + runtime : Bunch + + Contains attributes that describe the runtime environment when + the `Interface` was run. Contains the attributes: + + * cmdline : The command line string that was executed + * cwd : The directory the ``cmdline`` was executed in. + * stdout : The output of running the ``cmdline``. + * stderr : Any error messages output from running ``cmdline``. + * returncode : The code returned from running the ``cmdline``. + + """ + + def __init__(self, interface, runtime, inputs=None, outputs=None, + provenance=None): + self._version = 2.0 + self.interface = interface + self.runtime = runtime + self.inputs = inputs + self.outputs = outputs + self.provenance = provenance + + @property + def version(self): + return self._version + +class Stream(object): + """Function to capture stdout and stderr streams with timestamps + + stackoverflow.com/questions/4984549/merge-and-sync-stdout-and-stderr/5188359 + """ + + def __init__(self, name, impl): + self._name = name + self._impl = impl + self._buf = '' + self._rows = [] + self._lastidx = 0 + + def fileno(self): + "Pass-through for file descriptor." + return self._impl.fileno() + + def read(self, drain=0): + "Read from the file descriptor. If 'drain' set, read until EOF." + while self._read(drain) is not None: + if not drain: + break + + def _read(self, drain): + "Read from the file descriptor" + fd = self.fileno() + buf = os.read(fd, 4096).decode() + if not buf and not self._buf: + return None + if '\n' not in buf: + if not drain: + self._buf += buf + return [] + + # prepend any data previously read, then split into lines and format + buf = self._buf + buf + if '\n' in buf: + tmp, rest = buf.rsplit('\n', 1) + else: + tmp = buf + rest = None + self._buf = rest + now = dt.now().isoformat() + rows = tmp.split('\n') + self._rows += [(now, '%s %s:%s' % (self._name, now, r), r) + for r in rows] + for idx in range(self._lastidx, len(self._rows)): + IFLOGGER.info(self._rows[idx][1]) + self._lastidx = len(self._rows) + + +def run_command(runtime, output=None, timeout=0.01, redirect_x=False): + """Run a command, read stdout and stderr, prefix with timestamp. + + The returned runtime contains a merged stdout+stderr log with timestamps + """ + PIPE = subprocess.PIPE + + cmdline = runtime.cmdline + if redirect_x: + exist_xvfb, _ = _exists_in_path('xvfb-run', runtime.environ) + if not exist_xvfb: + raise RuntimeError('Xvfb was not found, X redirection aborted') + cmdline = 'xvfb-run -a ' + cmdline + + if output == 'file': + errfile = op.join(runtime.cwd, 'stderr.nipype') + outfile = op.join(runtime.cwd, 'stdout.nipype') + stderr = open(errfile, 'wt') # t=='text'===default + stdout = open(outfile, 'wt') + + proc = subprocess.Popen(cmdline, + stdout=stdout, + stderr=stderr, + shell=True, + cwd=runtime.cwd, + env=runtime.environ) + else: + proc = subprocess.Popen(cmdline, + stdout=PIPE, + stderr=PIPE, + shell=True, + cwd=runtime.cwd, + env=runtime.environ) + result = {} + errfile = op.join(runtime.cwd, 'stderr.nipype') + outfile = op.join(runtime.cwd, 'stdout.nipype') + if output == 'stream': + streams = [Stream('stdout', proc.stdout), Stream('stderr', proc.stderr)] + + def _process(drain=0): + try: + res = select.select(streams, [], [], timeout) + except select.error as e: + IFLOGGER.info(str(e)) + if e[0] == errno.EINTR: + return + else: + raise + else: + for stream in res[0]: + stream.read(drain) + + while proc.returncode is None: + proc.poll() + _process() + _process(drain=1) + + # collect results, merge and return + result = {} + temp = [] + for stream in streams: + rows = stream._rows + temp += rows + result[stream._name] = [r[2] for r in rows] + temp.sort() + result['merged'] = [r[1] for r in temp] + if output == 'allatonce': + stdout, stderr = proc.communicate() + if stdout and isinstance(stdout, bytes): + try: + stdout = stdout.decode() + except UnicodeDecodeError: + stdout = stdout.decode("ISO-8859-1") + if stderr and isinstance(stderr, bytes): + try: + stderr = stderr.decode() + except UnicodeDecodeError: + stderr = stderr.decode("ISO-8859-1") + + result['stdout'] = str(stdout).split('\n') + result['stderr'] = str(stderr).split('\n') + result['merged'] = '' + if output == 'file': + ret_code = proc.wait() + stderr.flush() + stdout.flush() + result['stdout'] = [line.strip() for line in open(outfile).readlines()] + result['stderr'] = [line.strip() for line in open(errfile).readlines()] + result['merged'] = '' + if output == 'none': + proc.communicate() + result['stdout'] = [] + result['stderr'] = [] + result['merged'] = '' + runtime.stderr = '\n'.join(result['stderr']) + runtime.stdout = '\n'.join(result['stdout']) + runtime.merged = result['merged'] + runtime.returncode = proc.returncode + return runtime + + +def get_dependencies(name, environ): + """Return library dependencies of a dynamically linked executable + + Uses otool on darwin, ldd on linux. Currently doesn't support windows. + + """ + PIPE = subprocess.PIPE + if sys.platform == 'darwin': + proc = subprocess.Popen( + 'otool -L `which %s`' % name, stdout=PIPE, stderr=PIPE, shell=True, env=environ) + elif 'linux' in sys.platform: + proc = subprocess.Popen( + 'ldd `which %s`' % name, stdout=PIPE, stderr=PIPE, shell=True, env=environ) + else: + return 'Platform %s not supported' % sys.platform + o, _ = proc.communicate() + return o.rstrip() + +def raise_exception(runtime): + message = "Command:\n" + runtime.cmdline + "\n" + message += "Standard output:\n" + runtime.stdout + "\n" + message += "Standard error:\n" + runtime.stderr + "\n" + message += "Return code: " + str(runtime.returncode) + raise RuntimeError(message) diff --git a/nipype/interfaces/base/specs.py b/nipype/interfaces/base/specs.py new file mode 100644 index 0000000000..911438a5a6 --- /dev/null +++ b/nipype/interfaces/base/specs.py @@ -0,0 +1,728 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +""" +Definition of inputs/outputs of interfaces. +""" + +from __future__ import print_function +from __future__ import division + +from copy import deepcopy +import os +import re +from textwrap import wrap + +from future import standard_library +standard_library.install_aliases() +from builtins import range +from builtins import object + +from traits.api import Interface, provides +from ...utils.filemanip import md5, auto_hash +from ...utils.misc import is_container +from ... import logging, LooseVersion +from ... import __version__ +from ...external.six import string_types + +from .traits_extension import (traits, Undefined, TraitDictObject, TraitListObject, TraitError, + isdefined, File, has_metadata) + + +NIPYPE_VERSION = LooseVersion(__version__) +IFLOGGER = logging.getLogger('interface') +__docformat__ = 'restructuredtext' + +class IInputSpec(Interface): + """The abstract interface for inputs specifications""" + def items(self): + """Name, trait generator for user modifiable traits""" + + def check_inputs(self): + """Checks the correctness of inputs set""" + + def check_version(self): + """ + Checks if the version the implemented interface + matches that of the installed software + """ + + def get(self, **kwargs): + """ Returns traited class as a dict""" + + def get_traitsfree(self, **kwargs): + """ Returns traited class as a dict without traits""" + + def get_defined(self): + """ Returns the traits that have been set""" + + @classmethod + def help(cls): + """Print help of these traits""" + + +class IOutputSpec(Interface): + """The abstract interface for outputs specifications""" + def items(self): + """Name, trait generator for user modifiable traits""" + + def get(self, **kwargs): + """ Returns traited class as a dict""" + + def get_traitsfree(self, **kwargs): + """ Returns traited class as a dict without traits""" + + @classmethod + def help(cls): + """Print help of these traits""" + + +class IInputCommandLineSpec(Interface): + """An interface definition for command line interfaces""" + def parse_args(self): + """Parse inputs to commandline arguments""" + + +@provides(IOutputSpec) +class BaseSpec(traits.HasTraits): + """A common interface for inputs and outputs""" + + def __repr__(self): + """ Return a well-formatted representation of the traits """ + outstr = [] + for name, value in sorted(self.trait_get().items()): + outstr.append('%s = %s' % (name, value)) + return '\n' + '\n'.join(outstr) + '\n' + + def items(self): + """ Name, trait generator for user modifiable traits""" + for name in sorted(self.copyable_trait_names()): + yield name, self.traits()[name] + + def get_defined(self): + """ Trait generator for modified traits by user""" + for name in sorted(self.copyable_trait_names()): + value = getattr(self, name) + if isdefined(value): + yield name, value, self.traits()[name] + + @classmethod + def help(cls): + """Print help of these traits""" + helpstr = [] + for name, spec in sorted(cls().traits(transient=None).items()): + helpstr += cls._get_trait_desc(name, spec) + if len(helpstr) == 0: + helpstr += ['\tNone'] + return helpstr + + def get(self, **kwargs): + """ Returns traited class as a dict + + Augments the trait get function to return a dictionary without + notification handles + """ + out = super(BaseSpec, self).get(**kwargs) + out = self._clean_container(out, Undefined) + return out + + def get_traitsfree(self, **kwargs): + """ Returns traited class as a dict + + Augments the trait get function to return a dictionary without + any traits. The dictionary does not contain any attributes that + were Undefined + """ + out = super(BaseSpec, self).get(**kwargs) + out = self._clean_container(out, skipundefined=True) + return out + + def _clean_container(self, obj, undefinedval=None, skipundefined=False): + """Convert a traited obejct into a pure python representation. + """ + if isinstance(obj, TraitDictObject) or isinstance(obj, dict): + outdict = {} + for key, val in list(obj.items()): + if isdefined(val): + outdict[key] = self._clean_container(val, undefinedval) + else: + if not skipundefined: + outdict[key] = undefinedval + return outdict + elif (isinstance(obj, TraitListObject) or + isinstance(obj, list) or isinstance(obj, tuple)): + out = [] + for val in obj: + if isdefined(val): + out.append(self._clean_container(val, undefinedval)) + else: + if not skipundefined: + out.append(undefinedval) + else: + out.append(None) + if isinstance(obj, tuple): + return tuple(out) + else: + if isdefined(obj): + out = obj + else: + if not skipundefined: + out = undefinedval + return out + + @classmethod + def _get_trait_desc(cls, name, spec=None): + obj = cls() + if spec is None: + spec = obj.traits()[name] + + desc = spec.desc + xor = spec.xor + requires = spec.requires + argstr = spec.argstr + name_source = spec.name_source + if name_source is None: + name_source = spec.ns + + manhelpstr = ['\t%s' % name] + + type_info = spec.full_info(obj, name, None) + + default = '' + if spec.usedefault: + default = ', nipype default value: %s' % str(spec.default_value()[1]) + line = "(%s%s)" % (type_info, default) + + manhelpstr = wrap(line, 70, + initial_indent=manhelpstr[0] + ': ', + subsequent_indent='\t\t ') + + if desc: + for line in desc.split('\n'): + line = re.sub(r'\s+', ' ', line) + manhelpstr += wrap(line, 70, initial_indent='\t\t', + subsequent_indent='\t\t') + + if argstr: + pos = spec.position + if pos is not None: + manhelpstr += wrap('flag: %s, position: %s' % (argstr, pos), 70, + initial_indent='\t\t', subsequent_indent='\t\t') + else: + manhelpstr += wrap('flag: %s' % argstr, 70, initial_indent='\t\t', + subsequent_indent='\t\t') + + if xor: + line = '%s' % ', '.join(xor) + manhelpstr += wrap(line, 70, initial_indent='\t\tmutually_exclusive: ', + subsequent_indent='\t\t ') + + if requires: + others = [field for field in requires if field != name] + line = '%s' % ', '.join(others) + manhelpstr += wrap(line, 70, initial_indent='\t\trequires: ', + subsequent_indent='\t\t ') + + if name_source: + tpl = ', name_template not defined' + if spec.name_template: + tpl = ', name_template is \'%s\'' % spec.name_template + manhelpstr += wrap(('name source: %s' % name_source) + tpl, 70, + initial_indent='\t\t', subsequent_indent='\t\t ') + return manhelpstr + + +@provides(IOutputSpec) +class BaseOutputSpec(BaseSpec): + """ Base class for OutputSpecs with strict traits """ + _ = traits.Disallow + + @classmethod + def help(cls): + return ['Outputs ::', ''] + super(BaseOutputSpec, cls).help() + + +@provides(IInputSpec) +class BaseTraitedSpec(BaseSpec): + """Provide a few methods necessary to support nipype interface api + + The inputs attribute of interfaces call certain methods that are not + available in traits.HasTraits. These are provided here. + + new metadata: + + * usedefault : set this to True if the default value of the trait should be + used. Unless this is set, the attributes are set to traits.Undefined + + new attribute: + + * get_hashval : returns a tuple containing the state of the trait as a dict + and hashvalue corresponding to dict. + + XXX Reconsider this in the long run, but it seems like the best + solution to move forward on the refactoring. + """ + + def __init__(self, **kwargs): + """ Initialize handlers and inputs""" + # NOTE: In python 2.6, object.__init__ no longer accepts input + # arguments. HasTraits does not define an __init__ and + # therefore these args were being ignored. + # super(TraitedSpec, self).__init__(*args, **kwargs) + super(BaseTraitedSpec, self).__init__(**kwargs) + traits.push_exception_handler(reraise_exceptions=True) + undefined_traits = {} + for trait in self.copyable_trait_names(): + if not self.traits()[trait].usedefault: + undefined_traits[trait] = Undefined + self.trait_set(trait_change_notify=False, **undefined_traits) + + # Attach deprecated handler + has_deprecation = dict(deprecated=lambda t: t is not None) + deprecated = self.trait_names(**has_deprecation) + for elem in deprecated: + self.on_trait_change(self._check_deprecated, elem) + + # Forward inputs + self.set(**kwargs) + + def __repr__(self): + """ Return a well-formatted representation of the traits """ + outstr = [] + for name, value in sorted(self.trait_get().items()): + outstr.append('%s = %s' % (name, value)) + return '\n' + '\n'.join(outstr) + '\n' + + def _check_deprecated(self, name, new): + """ Generate a warning when a deprecated trait is set """ + warn = False + if isdefined(new): + spec = self.traits()[name] + msg1 = ('Input %s in interface %s is deprecated.' % + (name, + self.__class__.__name__.split('InputSpec')[0])) + msg2 = ('Will be removed or raise an error as of release %s' + % spec.deprecated) + if spec.new_name: + if spec.new_name not in self.copyable_trait_names(): + raise TraitError(msg1 + ' Replacement trait %s not found' % + spec.new_name) + msg3 = 'It has been replaced by %s.' % spec.new_name + else: + msg3 = '' + msg = ' '.join((msg1, msg2, msg3)) + if LooseVersion(str(spec.deprecated)) < NIPYPE_VERSION: + raise TraitError(msg) + else: + if spec.new_name: + msg += 'Unsetting old value %s; setting new value %s.' % ( + name, spec.new_name) + IFLOGGER.warn(msg) + warn = True + if spec.new_name: + self.trait_set(trait_change_notify=False, + **{'%s' % name: Undefined, + '%s' % spec.new_name: new}) + return warn + + def _hash_infile(self, adict, key): + """ Inject file hashes into adict[key]""" + stuff = adict[key] + if not is_container(stuff): + stuff = [stuff] + file_list = [] + for afile in stuff: + if is_container(afile): + hashlist = self._hash_infile({'infiles': afile}, 'infiles') + hashval = [val[1] for val in hashlist] + else: + hashval = auto_hash(afile) + + file_list.append((afile, hashval)) + return file_list + + def get_hashval(self, hash_method=None): + """Return a dictionary of our items with hashes for each file. + + Searches through dictionary items and if an item is a file, it + calculates the md5 hash of the file contents and stores the + file name and hash value as the new key value. + + However, the overall bunch hash is calculated only on the hash + value of a file. The path and name of the file are not used in + the overall hash calculation. + + Returns + ------- + dict_withhash : dict + Copy of our dictionary with the new file hashes included + with each file. + hashvalue : str + The md5 hash value of the traited spec + + """ + + dict_withhash = [] + dict_nofilename = [] + for name, val in sorted(self.get().items()): + if isdefined(val): + trait = self.trait(name) + if has_metadata(trait.trait_type, "nohash", True): + continue + hash_files = (not has_metadata(trait.trait_type, "hash_files", + False) and not + has_metadata(trait.trait_type, "name_source")) + dict_nofilename.append((name, + self._get_sorteddict(val, hash_method=hash_method, + hash_files=hash_files))) + dict_withhash.append((name, + self._get_sorteddict(val, True, hash_method=hash_method, + hash_files=hash_files))) + return dict_withhash, md5(str(dict_nofilename).encode()).hexdigest() + + def _get_sorteddict(self, obj, dictwithhash=False, hash_method=None, + hash_files=True): + out = None + if isinstance(obj, dict): + obj_items = [(key, val) for key, val in sorted(obj.items()) if isdefined(val)] + out = [(key, self._get_sorteddict(val, dictwithhash, hash_method=hash_method, + hash_files=hash_files)) for key, val in obj_items] + elif isinstance(obj, (list, tuple)): + out = [self._get_sorteddict( + val, dictwithhash, hash_method=hash_method, hash_files=hash_files) + for val in obj if isdefined(val)] + if isinstance(obj, tuple): + return tuple(out) + elif isinstance(obj, float): + out = '%.10f' % obj + elif isinstance(obj, string_types) and hash_files and os.path.isfile(obj): + out = auto_hash(obj, hash_method) + if dictwithhash: + return (obj, out) + elif isdefined(obj): + out = obj + return out + + +@provides(IInputSpec) +class BaseInputSpec(BaseTraitedSpec): + """ Base class for InputSpecs with strict traits """ + _ = traits.Disallow + + def __init__(self, **kwargs): + """ Initialize handlers and inputs""" + super(BaseInputSpec, self).__init__(**kwargs) + + # Attach xor handler + has_xor = dict(xor=lambda t: t is not None) + xors = self.trait_names(**has_xor) + for elem in xors: + self.on_trait_change(self._check_xor, elem) + + def mandatory_items(self): + """Get those items that are mandatory""" + return list(self.traits(mandatory=True).items()) + + def optional_items(self): + """Get those items that are optional""" + allitems = self.traits(transient=None).items() + for k, _ in self.mandatory_items(): + try: + allitems.remove(k) + except ValueError: + pass + return allitems + + def _check_xor(self, obj, name, old, new): + """ Checks inputs with xor list """ + IFLOGGER.debug('Called check_xorg with name %s', name) + if isdefined(getattr(self, name)): + xor_list = self.traits()[name].xor + if not isinstance(xor_list, list): + xor_list = list(xor_list) + + if name in xor_list: + xor_list.remove(name) + # for each xor, set to default_value + for trait_name in xor_list: + trait_val = getattr(self, trait_name) + if isdefined(trait_val) and isinstance(trait_val, bool) and not trait_val: + trait_val = Undefined # Boolean inputs set false should not count as defined + if isdefined(trait_val): + self.trait_set(trait_change_notify=False, + **{'%s' % name: Undefined}) + msg = ('Input "%s" is mutually exclusive with input "%s", ' + 'which is already set') % (name, trait_name) + raise TraitError(msg) + + def _check_requires(self, name, spec=None): + if not isdefined(getattr(self, name)): + return True + if spec is None: + spec = self.traits()[name] + if spec.requires is None: + return True + + req_defined = [isdefined(rname) for rname in getattr(spec, 'requires', [])] + if not all(req_defined): + raise ValueError( + '%s requires a value for input \'%s\' because one of %s is set. For a list of' + ' required inputs, see %s.help()' % (self.__class__.__name__, name, + ', '.join(spec.requires), self.__class__.__name__)) + return True + + + def check_inputs(self): + """ Raises an exception if a mandatory input is Undefined + """ + for name, spec in list(self.mandatory_items()): + value = getattr(self, name) + if not isdefined(value): + xor_spec = getattr(spec, 'xor', []) + if xor_spec is None: + xor_spec = [] + + if not any([isdefined(getattr(self, xname)) for xname in xor_spec]): + raise ValueError( + '%s requires a value for one of these inputs %s. For a list of required inputs, ' + 'see %s.help()' % (self.__class__.__name__, [name] + xor_spec, self.__class__.__name__)) + self._check_requires(name) + + for elem in list(self.optional_items()): + self._check_requires(*elem) + + def get_filecopy_info(self): + """ Provides information about file inputs to copy or link to cwd. + Necessary for pipeline operation + """ + info = [] + metadata = dict(copyfile=lambda t: t is not None) + for name, spec in sorted(self.traits(**metadata).items()): + info.append(dict(key=name, copy=spec.copyfile)) + return info + + def check_version(self, version, raise_exception=True): + """ Raises an exception on version mismatch""" + if not version or version is None: + return + + unavailable_traits = [] + # check minimum version + check = dict(min_ver=lambda t: t is not None) + for name in self.trait_names(**check): + min_ver = LooseVersion(str(self.traits()[name].min_ver)) + if min_ver > version: + unavailable_traits.append(name) + if not isdefined(getattr(self, name)): + continue + + msg = ('Trait %s (%s) (version %s < required %s)' % + (name, self.__class__.__name__, version, min_ver)) + if raise_exception: + raise Exception(msg) + else: + IFLOGGER.warn(msg) + + # Check maximum version + check = dict(max_ver=lambda t: t is not None) + for name in self.trait_names(**check): + max_ver = LooseVersion(str(self.traits()[name].max_ver)) + if max_ver < version: + unavailable_traits.append(name) + if not isdefined(getattr(self, name)): + continue + msg = ('Trait %s (%s) (version %s > required %s)' % + (name, self.__class__.__name__, version, max_ver)) + if raise_exception: + raise Exception(msg) + else: + IFLOGGER.warn(msg) + + return unavailable_traits + + @classmethod + def help(cls): + """Print inputs formatted""" + manhelpstr = [] + for name, spec in sorted(cls().mandatory_items()): + manhelpstr += cls()._get_trait_desc(name, spec) + opthelpstr = [] + for name, spec in sorted(cls().optional_items()): + opthelpstr += cls()._get_trait_desc(name, spec) + + helpstr = ['Inputs ::'] + if manhelpstr: + manhelpstr.insert(0, '') + manhelpstr.insert(1, '\t[Mandatory]') + helpstr += manhelpstr + if opthelpstr: + opthelpstr.insert(0, '') + opthelpstr.insert(1, '\t[Optional]') + helpstr += opthelpstr + + if not helpstr: + helpstr = ['', '\tNone'] + return helpstr + +@provides(IOutputSpec) +class TraitedSpec(BaseTraitedSpec): + """ Create a subclass with strict traits. + + This is used in 90% of the cases. + """ + _ = traits.Disallow + + +@provides(IInputSpec) +class DynamicTraitedSpec(BaseTraitedSpec): + """ A subclass to handle dynamic traits + + This class is a workaround for add_traits and clone_traits not + functioning well together. + """ + + def __deepcopy__(self, memo): + """ bug in deepcopy for HasTraits results in weird cloning behavior for + added traits + """ + id_self = id(self) + if id_self in memo: + return memo[id_self] + dup_dict = deepcopy(self.get(), memo) + # access all keys + for key in self.copyable_trait_names(): + _ = getattr(self, key) + # clone once + dup = self.clone_traits(memo=memo) + for key in self.copyable_trait_names(): + try: + _ = getattr(dup, key) + except: + pass + # clone twice + dup = self.clone_traits(memo=memo) + dup.set(**dup_dict) + return dup + + +@provides(IInputSpec, IInputCommandLineSpec) +class CommandLineInputSpec(BaseInputSpec): + """ The InputSpec for interfaces wrapping a command line """ + args = traits.Str(argstr='%s', desc='Additional parameters to the command') + + def _format_arg(self, name, spec=None, value=None): + """A helper function for parse_args + + Formats a trait containing argstr metadata + """ + if spec is None: + spec = self.traits()[name] + + if value is None: + value = getattr(self, name) + + argstr = spec.argstr + if spec.is_trait_type(traits.Bool) and "%" not in argstr: + if value: + # Boolean options have no format string. Just append options + # if True. + return argstr + else: + return None + # traits.Either turns into traits.TraitCompound and does not have any + # inner_traits + elif spec.is_trait_type(traits.List) \ + or (spec.is_trait_type(traits.TraitCompound) and + isinstance(value, list)): + # This is a bit simple-minded at present, and should be + # construed as the default. If more sophisticated behavior + # is needed, it can be accomplished with metadata (e.g. + # format string for list member str'ification, specifying + # the separator, etc.) + + # Depending on whether we stick with traitlets, and whether or + # not we beef up traitlets.List, we may want to put some + # type-checking code here as well + sep = spec.sep + if sep is None: + sep = ' ' + if argstr.endswith('...'): + + # repeatable option + # --id %d... will expand to + # --id 1 --id 2 --id 3 etc.,. + argstr = argstr.replace('...', '') + return sep.join([argstr % elt for elt in value]) + else: + return argstr % sep.join(str(elt) for elt in value) + else: + # Append options using format string. + return argstr % value + + def parse_args(self, skip=None): + """Parse all inputs using the ``argstr`` format string in the Trait. + + Any inputs that are assigned (not the default_value) are formatted + to be added to the command line. + + Returns + ------- + all_args : list + A list of all inputs formatted for the command line. + + """ + all_args = [] + initial_args = {} + final_args = {} + metadata = dict(argstr=lambda t: t is not None) + for name, spec in sorted(self.traits(**metadata).items()): + if skip and name in skip: + continue + value = getattr(self, name) + if not isdefined(value): + continue + + arg = self._format_arg(name, spec, value) + if arg is None or not arg: + continue + pos = spec.position + if pos is not None: + if int(pos) >= 0: + initial_args[pos] = arg + else: + final_args[pos] = arg + else: + all_args.append(arg) + first_args = [arg for pos, arg in sorted(initial_args.items())] + last_args = [arg for pos, arg in sorted(final_args.items())] + return first_args + all_args + last_args + + +class StdOutCommandLineInputSpec(CommandLineInputSpec): + """Appends a command line argument to pipe standard output to a file""" + out_file = File('standard.out', argstr="> %s", position=-1, usedefault=True) + +class StdOutCommandLineOutputSpec(TraitedSpec): + out_file = File(exists=True, desc='file containing the standard output') + + +@provides(IInputSpec, IInputCommandLineSpec) +class MpiCommandLineInputSpec(CommandLineInputSpec): + """Appends the necessary inputs to run MpiCommandLine interfaces""" + use_mpi = traits.Bool(False, usedefault=True, + desc='Whether or not to run the command with mpiexec') + n_procs = traits.Int(desc='Num processors to specify to mpiexec. Do not specify if this ' + 'is managed externally (e.g. through SGE)') + + +@provides(IInputSpec, IInputCommandLineSpec) +class SEMLikeCommandLineInputSpec(CommandLineInputSpec): + """Redefines the formatting of outputs""" + + def _format_arg(self, name, spec=None, value=None): + if name in list(self._outputs_filenames.keys()): + if isinstance(value, bool): + if value: + value = os.path.abspath(self._outputs_filenames[name]) + else: + return None + return super(SEMLikeCommandLineInputSpec, self)._format_arg(name, spec, value) diff --git a/nipype/interfaces/base/tests/test_auto_BaseInterface.py b/nipype/interfaces/base/tests/test_auto_BaseInterface.py new file mode 100644 index 0000000000..9f3e417907 --- /dev/null +++ b/nipype/interfaces/base/tests/test_auto_BaseInterface.py @@ -0,0 +1,21 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..interfaces import BaseInterface + + +def test_BaseInterface_inputs(): + input_map = dict() + inputs = BaseInterface._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_BaseInterface_outputs(): + output_map = dict() + outputs = BaseInterface._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/base/tests/test_auto_CommandLine.py b/nipype/interfaces/base/tests/test_auto_CommandLine.py new file mode 100644 index 0000000000..6c85e891c7 --- /dev/null +++ b/nipype/interfaces/base/tests/test_auto_CommandLine.py @@ -0,0 +1,23 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..interfaces import CommandLine + + +def test_CommandLine_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + ) + inputs = CommandLine._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_CommandLine_outputs(): + output_map = dict() + outputs = CommandLine._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/base/tests/test_auto_MpiCommandLine.py b/nipype/interfaces/base/tests/test_auto_MpiCommandLine.py new file mode 100644 index 0000000000..8223ac7e41 --- /dev/null +++ b/nipype/interfaces/base/tests/test_auto_MpiCommandLine.py @@ -0,0 +1,26 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..interfaces import MpiCommandLine + + +def test_MpiCommandLine_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + n_procs=dict(), + use_mpi=dict(usedefault=True, + ), + ) + inputs = MpiCommandLine._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_MpiCommandLine_outputs(): + output_map = dict() + outputs = MpiCommandLine._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/base/tests/test_auto_SEMLikeCommandLine.py b/nipype/interfaces/base/tests/test_auto_SEMLikeCommandLine.py new file mode 100644 index 0000000000..29e1f61ae5 --- /dev/null +++ b/nipype/interfaces/base/tests/test_auto_SEMLikeCommandLine.py @@ -0,0 +1,23 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..interfaces import SEMLikeCommandLine + + +def test_SEMLikeCommandLine_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + ) + inputs = SEMLikeCommandLine._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_SEMLikeCommandLine_outputs(): + output_map = dict() + outputs = SEMLikeCommandLine._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/base/tests/test_auto_StdOutCommandLine.py b/nipype/interfaces/base/tests/test_auto_StdOutCommandLine.py new file mode 100644 index 0000000000..2a27e5d256 --- /dev/null +++ b/nipype/interfaces/base/tests/test_auto_StdOutCommandLine.py @@ -0,0 +1,28 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from ....testing import assert_equal +from ..interfaces import StdOutCommandLine + + +def test_StdOutCommandLine_inputs(): + input_map = dict(args=dict(argstr='%s', + ), + out_file=dict(argstr='> %s', + position=-1, + usedefault=True, + ), + ) + inputs = StdOutCommandLine._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_StdOutCommandLine_outputs(): + output_map = dict(out_file=dict(), + ) + outputs = StdOutCommandLine._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/tests/test_base.py b/nipype/interfaces/base/tests/test_base.py similarity index 57% rename from nipype/interfaces/tests/test_base.py rename to nipype/interfaces/base/tests/test_base.py index d186f64b6b..d44605cd67 100644 --- a/nipype/interfaces/tests/test_base.py +++ b/nipype/interfaces/base/tests/test_base.py @@ -1,17 +1,18 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: + from __future__ import print_function from future import standard_library standard_library.install_aliases() import os +import sys import tempfile import shutil -import warnings from nipype.testing import (assert_equal, assert_not_equal, assert_raises, assert_true, assert_false, with_setup, package_check, - skipif) + skipif, example_data) import nipype.interfaces.base as nib from nipype.utils.filemanip import split_filename from nipype.interfaces.base import Undefined, config @@ -54,7 +55,7 @@ def test_bunch_hash(): # NOTE: Since the path to the json file is included in the Bunch, # the hash will be unique to each machine. pth = os.path.split(os.path.abspath(__file__))[0] - json_pth = os.path.join(pth, 'realign_json.json') + json_pth = example_data('realign_json.json') b = nib.Bunch(infile=json_pth, otherthing='blue', yat=True) @@ -86,10 +87,10 @@ def teardown_file(tmp_dir): def test_TraitedSpec(): - yield assert_true, nib.TraitedSpec().get_hashval() - yield assert_equal, nib.TraitedSpec().__repr__(), '\n\n' + yield assert_true, nib.BaseInputSpec().get_hashval() + yield assert_equal, nib.BaseInputSpec().__repr__(), '\n\n' - class spec(nib.TraitedSpec): + class spec(nib.BaseInputSpec): foo = nib.traits.Int goo = nib.traits.Float(usedefault=True) @@ -119,7 +120,7 @@ def test_TraitedSpec_dynamic(): def test_TraitedSpec_logic(): - class spec3(nib.TraitedSpec): + class spec3(nib.BaseInputSpec): _xor_inputs = ('foo', 'bar') foo = nib.traits.Int(xor=_xor_inputs, @@ -134,82 +135,79 @@ class out3(nib.TraitedSpec): output = nib.traits.Int class MyInterface(nib.BaseInterface): - input_spec = spec3 - output_spec = out3 + _input_spec = spec3 + _output_spec = out3 myif = MyInterface() - yield assert_raises, TypeError, setattr(myif.inputs, 'kung', 10.0) + set_kung = lambda: setattr(myif.inputs, 'kung', 'b') + yield assert_raises, nib.TraitError, set_kung myif.inputs.foo = 1 yield assert_equal, myif.inputs.foo, 1 set_bar = lambda: setattr(myif.inputs, 'bar', 1) - yield assert_raises, IOError, set_bar + yield assert_raises, nib.TraitError, set_bar yield assert_equal, myif.inputs.foo, 1 myif.inputs.kung = 2 yield assert_equal, myif.inputs.kung, 2.0 - -def test_deprecation(): - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings('always', '', UserWarning) - - class DeprecationSpec1(nib.TraitedSpec): - foo = nib.traits.Int(deprecated='0.1') - spec_instance = DeprecationSpec1() - set_foo = lambda: setattr(spec_instance, 'foo', 1) - yield assert_raises, nib.TraitError, set_foo - yield assert_equal, len(w), 0, 'no warnings, just errors' - - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings('always', '', UserWarning) - - class DeprecationSpec1numeric(nib.TraitedSpec): - foo = nib.traits.Int(deprecated='0.1') - spec_instance = DeprecationSpec1numeric() - set_foo = lambda: setattr(spec_instance, 'foo', 1) - yield assert_raises, nib.TraitError, set_foo - yield assert_equal, len(w), 0, 'no warnings, just errors' - - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings('always', '', UserWarning) - - class DeprecationSpec2(nib.TraitedSpec): - foo = nib.traits.Int(deprecated='100', new_name='bar') - spec_instance = DeprecationSpec2() - set_foo = lambda: setattr(spec_instance, 'foo', 1) - yield assert_raises, nib.TraitError, set_foo - yield assert_equal, len(w), 0, 'no warnings, just errors' - - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings('always', '', UserWarning) - - class DeprecationSpec3(nib.TraitedSpec): - foo = nib.traits.Int(deprecated='1000', new_name='bar') - bar = nib.traits.Int() - spec_instance = DeprecationSpec3() - not_raised = True - try: - spec_instance.foo = 1 - except nib.TraitError: - not_raised = False - yield assert_true, not_raised - yield assert_equal, len(w), 1, 'deprecated warning 1 %s' % [w1.message for w1 in w] - - with warnings.catch_warnings(record=True) as w: - warnings.filterwarnings('always', '', UserWarning) - - class DeprecationSpec3(nib.TraitedSpec): - foo = nib.traits.Int(deprecated='1000', new_name='bar') - bar = nib.traits.Int() - spec_instance = DeprecationSpec3() - not_raised = True - try: - spec_instance.foo = 1 - except nib.TraitError: - not_raised = False - yield assert_true, not_raised - yield assert_equal, spec_instance.foo, Undefined - yield assert_equal, spec_instance.bar, 1 - yield assert_equal, len(w), 1, 'deprecated warning 2 %s' % [w1.message for w1 in w] +# Now warnings are sent to the log file. Therefore, these tests +# need be rewritten to check the log file. +# +# def test_deprecation(): +# with warnings.catch_warnings(record=True) as w: +# warnings.filterwarnings('always', '', UserWarning) +# +# class DeprecationSpec1(nib.BaseInputSpec): +# foo = nib.traits.Int(deprecated='0.1') +# spec_instance = DeprecationSpec1() +# set_foo = lambda: setattr(spec_instance, 'foo', 1) +# yield assert_raises, nib.TraitError, set_foo +# yield assert_equal, len(w), 0, 'no warnings, just errors' +# +# with warnings.catch_warnings(record=True) as w: +# warnings.filterwarnings('always', '', UserWarning) +# +# class DeprecationSpec1numeric(nib.BaseInputSpec): +# foo = nib.traits.Int(deprecated='0.1') +# spec_instance = DeprecationSpec1numeric() +# set_foo = lambda: setattr(spec_instance, 'foo', 1) +# yield assert_raises, nib.TraitError, set_foo +# yield assert_equal, len(w), 0, 'no warnings, just errors' +# +# with warnings.catch_warnings(record=True) as w: +# warnings.filterwarnings('always', '', UserWarning) +# +# class DeprecationSpec2(nib.BaseInputSpec): +# foo = nib.traits.Int(deprecated='100', new_name='bar') +# spec_instance = DeprecationSpec2() +# set_foo = lambda: setattr(spec_instance, 'foo', 1) +# yield assert_raises, nib.TraitError, set_foo +# yield assert_equal, len(w), 0, 'no warnings, just errors' +# +# with warnings.catch_warnings(record=True) as w: +# warnings.filterwarnings('always', '', UserWarning) +# +# class DeprecationSpec3(nib.BaseInputSpec): +# foo = nib.traits.Int(deprecated='1000', new_name='bar') +# bar = nib.traits.Int() +# spec_instance = DeprecationSpec3() +# yield assert_true, spec_instance._check_deprecated('foo', 1) +# +# with warnings.catch_warnings(record=True) as w: +# warnings.filterwarnings('always', '', UserWarning) +# +# class DeprecationSpec3(nib.BaseInputSpec): +# foo = nib.traits.Int(deprecated='1000', new_name='bar') +# bar = nib.traits.Int() +# spec_instance = DeprecationSpec3() +# not_raised = True +# try: +# spec_instance.foo = 1 +# except nib.TraitError: +# not_raised = False +# yield assert_true, not_raised +# yield assert_equal, spec_instance.foo, Undefined +# yield assert_equal, spec_instance.bar, 1 +# yield assert_equal, len(w), 1, 'deprecated warning 2 %s' % [w1.message for w1 in w] def test_namesource(): @@ -219,21 +217,37 @@ def test_namesource(): os.chdir(tmpd) class spec2(nib.CommandLineInputSpec): - moo = nib.File(name_source=['doo'], hash_files=False, argstr="%s", - position=2) doo = nib.File(exists=True, argstr="%s", position=1) - goo = traits.Int(argstr="%d", position=4) - poo = nib.File(name_source=['goo'], hash_files=False, argstr="%s", position=3) + goo = traits.Int(argstr="-n %d", position=3) + moo = nib.GenFile(template='{doo}_generated', keep_extension=True, + hash_files=False, argstr="%s", position=2) class TestName(nib.CommandLine): - _cmd = "mycommand" - input_spec = spec2 + _cmd = 'cp' + _input_spec = spec2 + testobj = TestName() testobj.inputs.doo = tmp_infile - testobj.inputs.goo = 99 yield assert_true, '%s_generated' % nme in testobj.cmdline - testobj.inputs.moo = "my_%s_template" - yield assert_true, 'my_%s_template' % nme in testobj.cmdline + testobj.inputs.goo = 99 + testobj.inputs.moo = "my_file.txt" + yield assert_true, 'my_file.txt' in testobj.cmdline + + class spec2(nib.CommandLineInputSpec): + doo = nib.File(exists=True, argstr="%s", position=1) + goo = traits.Int(argstr="%d", position=4) + moo = nib.GenFile(template='{doo}_generated', keep_extension=True, + hash_files=False, argstr="%s", position=2) + poo = nib.GenFile(template='file{goo:02d}.txt', hash_files=False, argstr="%s", position=3) + + class TestName(nib.CommandLine): + _cmd = 'ls' + _input_spec = spec2 + + testobj = TestName() + testobj.inputs.goo = 5 + yield assert_true, 'file05.txt' in testobj.cmdline + os.chdir(pwd) teardown_file(tmpd) @@ -246,14 +260,14 @@ def test_chained_namesource(): class spec2(nib.CommandLineInputSpec): doo = nib.File(exists=True, argstr="%s", position=1) - moo = nib.File(name_source=['doo'], hash_files=False, argstr="%s", - position=2, name_template='%s_mootpl') - poo = nib.File(name_source=['moo'], hash_files=False, - argstr="%s", position=3) + moo = nib.GenFile(template='{doo}_mootpl', hash_files=False, argstr="%s", + position=2) + poo = nib.GenFile(template='{moo}_generated', hash_files=False, + argstr="%s", position=3) class TestName(nib.CommandLine): - _cmd = "mycommand" - input_spec = spec2 + _cmd = "ls" # An existing command is necessary + _input_spec = spec2 testobj = TestName() testobj.inputs.doo = tmp_infile @@ -273,26 +287,28 @@ def test_cycle_namesource1(): os.chdir(tmpd) class spec3(nib.CommandLineInputSpec): - moo = nib.File(name_source=['doo'], hash_files=False, argstr="%s", - position=1, name_template='%s_mootpl') - poo = nib.File(name_source=['moo'], hash_files=False, - argstr="%s", position=2) - doo = nib.File(name_source=['poo'], hash_files=False, - argstr="%s", position=3) + doo = nib.GenFile(template='{poo}_tpl', hash_files=False, + argstr="%s", position=1) + moo = nib.GenFile(template='{doo}_mootpl', hash_files=False, + argstr="%s", position=2) + poo = nib.GenFile(template='{moo}_generated', hash_files=False, + argstr="%s", position=3) class TestCycle(nib.CommandLine): - _cmd = "mycommand" - input_spec = spec3 + _cmd = 'cp' + _input_spec = spec3 # Check that an exception is raised - to0 = TestCycle() - not_raised = True + to0 = TestCycle(command='ls') + oldrec = sys.getrecursionlimit() + raised = False try: + sys.setrecursionlimit(100) # Set this to fail early to0.cmdline - except nib.NipypeInterfaceError: - not_raised = False - yield assert_false, not_raised - + except RuntimeError: + raised = True + sys.setrecursionlimit(oldrec) + yield assert_true, raised os.chdir(pwd) teardown_file(tmpd) @@ -304,32 +320,31 @@ def test_cycle_namesource2(): os.chdir(tmpd) class spec3(nib.CommandLineInputSpec): - moo = nib.File(name_source=['doo'], hash_files=False, argstr="%s", - position=1, name_template='%s_mootpl') - poo = nib.File(name_source=['moo'], hash_files=False, - argstr="%s", position=2) - doo = nib.File(name_source=['poo'], hash_files=False, - argstr="%s", position=3) + doo = nib.GenFile(template='{poo}_tpl', hash_files=False, + argstr="%s", position=1) + moo = nib.GenFile(template='{doo}_mootpl', hash_files=False, + argstr="%s", position=2) + poo = nib.GenFile(template='{moo}_generated', hash_files=False, + argstr="%s", position=3) class TestCycle(nib.CommandLine): - _cmd = "mycommand" - input_spec = spec3 + _cmd = 'ls' + _input_spec = spec3 # Check that loop can be broken by setting one of the inputs - to1 = TestCycle() + to1 = TestCycle(command='ls') to1.inputs.poo = tmp_infile - not_raised = True + raised = False try: res = to1.cmdline - except nib.NipypeInterfaceError: - not_raised = False - print(res) + except RuntimeError: + raised = True - yield assert_true, not_raised + yield assert_false, raised yield assert_true, '%s' % tmp_infile in res - yield assert_true, '%s_generated' % nme in res - yield assert_true, '%s_generated_mootpl' % nme in res + yield assert_true, '%s_tpl' % nme in res + yield assert_true, '%s_tpl_mootpl' % nme in res os.chdir(pwd) teardown_file(tmpd) @@ -350,7 +365,7 @@ def test_TraitedSpec_withFile(): tmpd, nme = os.path.split(tmp_infile) yield assert_true, os.path.exists(tmp_infile) - class spec2(nib.TraitedSpec): + class spec2(nib.BaseInputSpec): moo = nib.File(exists=True) doo = nib.traits.List(nib.File(exists=True)) infields = spec2(moo=tmp_infile, doo=[tmp_infile]) @@ -367,20 +382,20 @@ def test_TraitedSpec_withNoFileHashing(): os.chdir(tmpd) yield assert_true, os.path.exists(tmp_infile) - class spec2(nib.TraitedSpec): + class spec2(nib.BaseInputSpec): moo = nib.File(exists=True, hash_files=False) doo = nib.traits.List(nib.File(exists=True)) infields = spec2(moo=nme, doo=[tmp_infile]) hashval = infields.get_hashval(hash_method='content') yield assert_equal, hashval[1], '8da4669ff5d72f670a46ea3e7a203215' - class spec3(nib.TraitedSpec): + class spec3(nib.BaseInputSpec): moo = nib.File(exists=True, name_source="doo") doo = nib.traits.List(nib.File(exists=True)) infields = spec3(moo=nme, doo=[tmp_infile]) hashval1 = infields.get_hashval(hash_method='content') - class spec4(nib.TraitedSpec): + class spec4(nib.BaseInputSpec): moo = nib.File(exists=True) doo = nib.traits.List(nib.File(exists=True)) infields = spec4(moo=nme, doo=[tmp_infile]) @@ -391,31 +406,11 @@ class spec4(nib.TraitedSpec): teardown_file(tmpd) -def test_Interface(): - yield assert_equal, nib.Interface.input_spec, None - yield assert_equal, nib.Interface.output_spec, None - yield assert_raises, NotImplementedError, nib.Interface - yield assert_raises, NotImplementedError, nib.Interface.help - yield assert_raises, NotImplementedError, nib.Interface._inputs_help - yield assert_raises, NotImplementedError, nib.Interface._outputs_help - yield assert_raises, NotImplementedError, nib.Interface._outputs - - class DerivedInterface(nib.Interface): - def __init__(self): - pass - - nif = DerivedInterface() - yield assert_raises, NotImplementedError, nif.run - yield assert_raises, NotImplementedError, nif.aggregate_outputs - yield assert_raises, NotImplementedError, nif._list_outputs - yield assert_raises, NotImplementedError, nif._get_filecopy_info - - def test_BaseInterface(): yield assert_equal, nib.BaseInterface.help(), None - yield assert_equal, nib.BaseInterface._get_filecopy_info(), [] + yield assert_equal, nib.BaseInputSpec().get_filecopy_info(), [] - class InputSpec(nib.TraitedSpec): + class InputSpec(nib.BaseInputSpec): foo = nib.traits.Int(desc='a random int') goo = nib.traits.Int(desc='a random int', mandatory=True) moo = nib.traits.Int(desc='a random int', mandatory=False) @@ -427,165 +422,155 @@ class OutputSpec(nib.TraitedSpec): foo = nib.traits.Int(desc='a random int') class DerivedInterface(nib.BaseInterface): - input_spec = InputSpec + _input_spec = InputSpec yield assert_equal, DerivedInterface.help(), None - yield assert_true, 'moo' in ''.join(DerivedInterface._inputs_help()) - yield assert_equal, DerivedInterface()._outputs(), None - yield assert_equal, DerivedInterface._get_filecopy_info()[0]['key'], 'woo' - yield assert_true, DerivedInterface._get_filecopy_info()[0]['copy'] - yield assert_equal, DerivedInterface._get_filecopy_info()[1]['key'], 'zoo' - yield assert_false, DerivedInterface._get_filecopy_info()[1]['copy'] + yield assert_equal, DerivedInterface().inputs.get_filecopy_info()[0]['key'], 'woo' + yield assert_true, DerivedInterface().inputs.get_filecopy_info()[0]['copy'] + yield assert_equal, DerivedInterface().inputs.get_filecopy_info()[1]['key'], 'zoo' + yield assert_false, DerivedInterface().inputs.get_filecopy_info()[1]['copy'] yield assert_equal, DerivedInterface().inputs.foo, Undefined - yield assert_raises, ValueError, DerivedInterface()._check_mandatory_inputs - yield assert_equal, DerivedInterface(goo=1)._check_mandatory_inputs(), None + yield assert_raises, ValueError, DerivedInterface().inputs.check_inputs + yield assert_equal, DerivedInterface(goo=1).inputs.check_inputs(), None yield assert_raises, ValueError, DerivedInterface().run yield assert_raises, NotImplementedError, DerivedInterface(goo=1).run class DerivedInterface2(DerivedInterface): - output_spec = OutputSpec - - def _run_interface(self, runtime): - return runtime + _output_spec = OutputSpec yield assert_equal, DerivedInterface2.help(), None - yield assert_equal, DerivedInterface2()._outputs().foo, Undefined + yield assert_equal, DerivedInterface2().outputs.foo, Undefined yield assert_raises, NotImplementedError, DerivedInterface2(goo=1).run - nib.BaseInterface.input_spec = None + nib.BaseInterface._input_spec = None yield assert_raises, Exception, nib.BaseInterface -def assert_not_raises(fn, *args, **kwargs): - fn(*args, **kwargs) - return True - - def test_input_version(): - class InputSpec(nib.TraitedSpec): + class InputSpec(nib.BaseInputSpec): foo = nib.traits.Int(desc='a random int', min_ver='0.9') class DerivedInterface1(nib.BaseInterface): - input_spec = InputSpec + _input_spec = InputSpec obj = DerivedInterface1() - yield assert_not_raises, obj._check_version_requirements, obj.inputs + yield assert_equal, obj.check_version(), [] config.set('execution', 'stop_on_unknown_version', True) - yield assert_raises, Exception, obj._check_version_requirements, obj.inputs - + yield assert_raises, Exception, lambda: obj.check_version() config.set_default_config() - class InputSpec(nib.TraitedSpec): + class InputSpec(nib.BaseInputSpec): foo = nib.traits.Int(desc='a random int', min_ver='0.9') class DerivedInterface1(nib.BaseInterface): - input_spec = InputSpec - _version = '0.8' + _input_spec = InputSpec + version = '0.8' obj = DerivedInterface1() obj.inputs.foo = 1 - yield assert_raises, Exception, obj._check_version_requirements + yield assert_raises, Exception, lambda: obj.check_version() - class InputSpec(nib.TraitedSpec): + class InputSpec(nib.BaseInputSpec): foo = nib.traits.Int(desc='a random int', min_ver='0.9') class DerivedInterface1(nib.BaseInterface): - input_spec = InputSpec - _version = '0.10' + _input_spec = InputSpec + version = '0.10' obj = DerivedInterface1() - yield assert_not_raises, obj._check_version_requirements, obj.inputs + yield assert_equal, obj.check_version(), [] - class InputSpec(nib.TraitedSpec): + class InputSpec(nib.BaseInputSpec): foo = nib.traits.Int(desc='a random int', min_ver='0.9') class DerivedInterface1(nib.BaseInterface): - input_spec = InputSpec - _version = '0.9' + _input_spec = InputSpec + version = '0.9' obj = DerivedInterface1() obj.inputs.foo = 1 not_raised = True - yield assert_not_raises, obj._check_version_requirements, obj.inputs + yield assert_equal, obj.check_version(), [] - class InputSpec(nib.TraitedSpec): + class InputSpec(nib.BaseInputSpec): foo = nib.traits.Int(desc='a random int', max_ver='0.7') class DerivedInterface2(nib.BaseInterface): - input_spec = InputSpec - _version = '0.8' + _input_spec = InputSpec + version = '0.8' obj = DerivedInterface2() obj.inputs.foo = 1 - yield assert_raises, Exception, obj._check_version_requirements + yield assert_raises, Exception, lambda: obj.check_version() - class InputSpec(nib.TraitedSpec): + class InputSpec(nib.BaseInputSpec): foo = nib.traits.Int(desc='a random int', max_ver='0.9') class DerivedInterface1(nib.BaseInterface): - input_spec = InputSpec - _version = '0.9' + _input_spec = InputSpec + version = '0.9' obj = DerivedInterface1() obj.inputs.foo = 1 not_raised = True - yield assert_not_raises, obj._check_version_requirements, obj.inputs + yield assert_equal, obj.check_version(), [] def test_output_version(): - class InputSpec(nib.TraitedSpec): + class InputSpec(nib.BaseInputSpec): foo = nib.traits.Int(desc='a random int') class OutputSpec(nib.TraitedSpec): foo = nib.traits.Int(desc='a random int', min_ver='0.9') class DerivedInterface1(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec - _version = '0.10' - obj = DerivedInterface1() - yield assert_equal, obj._check_version_requirements(obj._outputs()), [] - - class InputSpec(nib.TraitedSpec): - foo = nib.traits.Int(desc='a random int') - - class OutputSpec(nib.TraitedSpec): - foo = nib.traits.Int(desc='a random int', min_ver='0.11') - - class DerivedInterface1(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec - _version = '0.10' + _input_spec = InputSpec + _output_spec = OutputSpec + version = '0.10' obj = DerivedInterface1() - yield assert_equal, obj._check_version_requirements(obj._outputs()), ['foo'] - - class InputSpec(nib.TraitedSpec): - foo = nib.traits.Int(desc='a random int') - - class OutputSpec(nib.TraitedSpec): - foo = nib.traits.Int(desc='a random int', min_ver='0.11') - - class DerivedInterface1(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec - _version = '0.10' - - def _run_interface(self, runtime): - return runtime - - def _list_outputs(self): - return {'foo': 1} - obj = DerivedInterface1() - yield assert_raises, KeyError, obj.run + res = obj.check_version() + yield assert_equal, res, [] + +# TODO Enable checking version on outputs +# class InputSpec(nib.BaseInputSpec): +# foo = nib.traits.Int(desc='a random int') +# +# class OutputSpec(nib.TraitedSpec): +# foo = nib.traits.Int(desc='a random int', min_ver='0.11') +# +# class DerivedInterface1(nib.BaseInterface): +# _input_spec = InputSpec +# _output_spec = OutputSpec +# version = '0.10' +# obj = DerivedInterface1() +# yield assert_equal, obj.check_version(), ['foo'] +# +# class InputSpec(nib.BaseInputSpec): +# foo = nib.traits.Int(desc='a random int') +# +# class OutputSpec(nib.TraitedSpec): +# foo = nib.traits.Int(desc='a random int', min_ver='0.11') +# +# class DerivedInterface1(nib.BaseInterface): +# _input_spec = InputSpec +# _output_spec = OutputSpec +# version = '0.10' +# +# def _run_interface(self, runtime): +# self.outputs.foo = 1 +# return runtime +# +# obj = DerivedInterface1() +# yield assert_raises, KeyError, obj.run def test_Commandline(): yield assert_raises, Exception, nib.CommandLine ci = nib.CommandLine(command='which') - yield assert_equal, ci.cmd, 'which' + yield assert_equal, ci.cmdline, 'which' yield assert_equal, ci.inputs.args, Undefined ci2 = nib.CommandLine(command='which', args='ls') yield assert_equal, ci2.cmdline, 'which ls' ci3 = nib.CommandLine(command='echo') - ci3.inputs.environ = {'MYENV': 'foo'} + ci3.environ['MYENV'] = 'foo' res = ci3.run() yield assert_equal, res.runtime.environ['MYENV'], 'foo' - yield assert_equal, res.outputs, None + yield assert_equal, res.outputs.get_traitsfree(), {} class CommandLineInputSpec1(nib.CommandLineInputSpec): foo = nib.traits.Str(argstr='%s', desc='a str') @@ -596,8 +581,8 @@ class CommandLineInputSpec1(nib.CommandLineInputSpec): noo = nib.traits.Int(argstr='-x %d', desc='an int') roo = nib.traits.Str(desc='not on command line') soo = nib.traits.Bool(argstr="-soo") - nib.CommandLine.input_spec = CommandLineInputSpec1 - ci4 = nib.CommandLine(command='cmd') + nib.CommandLine._input_spec = CommandLineInputSpec1 + ci4 = nib.CommandLine(command='ls') ci4.inputs.foo = 'foo' ci4.inputs.goo = True ci4.inputs.hoo = ['a', 'b'] @@ -605,30 +590,28 @@ class CommandLineInputSpec1(nib.CommandLineInputSpec): ci4.inputs.noo = 0 ci4.inputs.roo = 'hello' ci4.inputs.soo = False - cmd = ci4._parse_inputs() + cmd = ci4.inputs.parse_args() yield assert_equal, cmd[0], '-g' yield assert_equal, cmd[-1], '-i 1 -i 2 -i 3' yield assert_true, 'hello' not in ' '.join(cmd) yield assert_true, '-soo' not in ' '.join(cmd) ci4.inputs.soo = True - cmd = ci4._parse_inputs() + cmd = ci4.inputs.parse_args() yield assert_true, '-soo' in ' '.join(cmd) class CommandLineInputSpec2(nib.CommandLineInputSpec): - foo = nib.File(argstr='%s', desc='a str', genfile=True) - nib.CommandLine.input_spec = CommandLineInputSpec2 - ci5 = nib.CommandLine(command='cmd') - yield assert_raises, NotImplementedError, ci5._parse_inputs + foo = nib.File('filename', argstr='%s', usedefault=True, desc='a str') - class DerivedClass(nib.CommandLine): - input_spec = CommandLineInputSpec2 + nib.CommandLine._input_spec = CommandLineInputSpec2 + ci5 = nib.CommandLine(command='ls') + yield assert_equal, 'ls filename', ci5.cmdline - def _gen_filename(self, name): - return 'filename' + class DerivedClass(nib.CommandLine): + _input_spec = CommandLineInputSpec2 - ci6 = DerivedClass(command='cmd') - yield assert_equal, ci6._parse_inputs()[0], 'filename' - nib.CommandLine.input_spec = nib.CommandLineInputSpec + ci6 = DerivedClass(command='ls') + yield assert_equal, ci6.inputs.parse_args()[0], 'filename' + nib.CommandLine._input_spec = nib.CommandLineInputSpec def test_Commandline_environ(): @@ -638,10 +621,14 @@ def test_Commandline_environ(): res = ci3.run() yield assert_equal, res.runtime.environ['DISPLAY'], ':1' config.set('execution', 'display_variable', ':3') + ci3 = nib.CommandLine(command='echo') + ci3.environ.pop('DISPLAY', None) + res = ci3.run() + yield assert_false, 'DISPLAY' in ci3.environ + ci3.environ['DISPLAY'] = ':3' res = ci3.run() - yield assert_false, 'DISPLAY' in ci3.inputs.environ yield assert_equal, res.runtime.environ['DISPLAY'], ':3' - ci3.inputs.environ = {'DISPLAY': ':2'} + ci3.environ = {'DISPLAY': ':2'} res = ci3.run() yield assert_equal, res.runtime.environ['DISPLAY'], ':2' @@ -653,17 +640,17 @@ def test_CommandLine_output(): os.chdir(tmpd) yield assert_true, os.path.exists(tmp_infile) ci = nib.CommandLine(command='ls -l') - ci.inputs.terminal_output = 'allatonce' + ci.terminal_output = 'allatonce' res = ci.run() yield assert_equal, res.runtime.merged, '' yield assert_true, name in res.runtime.stdout ci = nib.CommandLine(command='ls -l') - ci.inputs.terminal_output = 'file' + ci.terminal_output = 'file' res = ci.run() yield assert_true, 'stdout.nipype' in res.runtime.stdout yield assert_equal, type(res.runtime.stdout), type('hi') ci = nib.CommandLine(command='ls -l') - ci.inputs.terminal_output = 'none' + ci.terminal_output = 'none' res = ci.run() yield assert_equal, res.runtime.stdout, '' ci = nib.CommandLine(command='ls -l') @@ -682,17 +669,17 @@ def test_global_CommandLine_output(): res = ci.run() yield assert_true, name in res.runtime.stdout yield assert_true, os.path.exists(tmp_infile) - nib.CommandLine.set_default_terminal_output('allatonce') ci = nib.CommandLine(command='ls -l') + ci.terminal_output = 'allatonce' res = ci.run() yield assert_equal, res.runtime.merged, '' yield assert_true, name in res.runtime.stdout - nib.CommandLine.set_default_terminal_output('file') ci = nib.CommandLine(command='ls -l') + ci.terminal_output = 'file' res = ci.run() yield assert_true, 'stdout.nipype' in res.runtime.stdout - nib.CommandLine.set_default_terminal_output('none') ci = nib.CommandLine(command='ls -l') + ci.terminal_output = 'none' res = ci.run() yield assert_equal, res.runtime.stdout, '' os.chdir(pwd) diff --git a/nipype/interfaces/base/traits_extension.py b/nipype/interfaces/base/traits_extension.py new file mode 100644 index 0000000000..6e721577cc --- /dev/null +++ b/nipype/interfaces/base/traits_extension.py @@ -0,0 +1,769 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +"""This module contains Trait classes that we've pulled from the +traits source and fixed due to various bugs. File and Directory are +redefined as the release version had dependencies on TraitsUI, which +we do not want Nipype to depend on. At least not yet. + +Undefined class was missing the __len__ operator, causing edit_traits +and configure_traits to fail on List objects. Even though we don't +require TraitsUI, this bug was the only thing preventing us from +popping up GUIs which users like. + +These bugs have been in Traits v3.3.0 and v3.2.1. We have reported +all of these bugs and they've been fixed in enthought svn repository +(usually by Robert Kern). + +""" +import os +import os.path as op +import re +import itertools as itools +# perform all external trait imports here +import traits +if traits.__version__ < '3.7.0': + raise ImportError('Traits version 3.7.0 or higher must be installed') +import traits.api as traits +from traits.trait_handlers import TraitDictObject, TraitListObject +from traits.trait_errors import TraitError +from traits.trait_base import _Undefined + +from ...external.six import string_types +from ...utils.filemanip import split_filename +from ... import logging +IFLOGGER = logging.getLogger('interface') + + +class BaseFile(traits.BaseStr): + """ Defines a trait whose value must be the name of a file. + """ + + # A description of the type of value this trait accepts: + info_text = 'a file name' + + def __init__(self, value='', filter=None, auto_set=False, + entries=0, **metadata): + """ Creates a File trait. + + Parameters + ---------- + value : string + The default value for the trait + filter : string + A wildcard string to filter filenames in the file dialog box used by + the attribute trait editor. + auto_set : boolean + Indicates whether the file editor updates the trait value after + every key stroke. + exists : boolean + Indicates whether the trait value must be an existing file or + not. + + Default Value + ------------- + *value* or '' + """ + self.filter = filter + self.auto_set = auto_set + self.entries = entries + + # Fix: get exists through metadata. Otherwise it won't be + # available to be queried + self.exists = metadata.get('exists', False) + + if self.exists: + self.info_text = 'an existing file name' + + super(BaseFile, self).__init__(value, **metadata) + + def validate(self, obj, name, value): + """ Validates that a specified value is valid for this trait. + + Note: The 'fast validator' version performs this check in C. + """ + validated_value = super(BaseFile, self).validate(obj, name, value) + if not self.exists: + return validated_value + elif op.isfile(value): + return validated_value + self.error(obj, name, value) + + +class File(traits.BaseFile): + """ Defines a trait whose value must be the name of a file using a C-level + fast validator. + """ + + def __init__(self, value='', filter=None, auto_set=False, + entries=0, **metadata): + """ Creates a File trait. + + Parameters + ---------- + value : string + The default value for the trait + filter : string + A wildcard string to filter filenames in the file dialog box used by + the attribute trait editor. + auto_set : boolean + Indicates whether the file editor updates the trait value after + every key stroke. + exists : boolean + Indicates whether the trait value must be an existing file or + not. + + Default Value + ------------- + *value* or '' + """ + exists = metadata.get('exists', False) + if not exists: + # Define the C-level fast validator to use: + fast_validate = (11, str) + + super(File, self).__init__(value, filter, auto_set, entries, **metadata) + + +class GenFile(File): + """ A file which default name is automatically generated from other + traits. + + >>> # The traits start undefined + >>> from nipype.interfaces.base import GenFile, Undefined, BaseInputSpec + >>> class A(BaseInputSpec): + ... src = File(exists=False) + ... foo = GenFile(template='{src}_foo', keep_extension=True) + >>> a = A() + >>> a.src + + >>> a.foo + + + >>> # If the source trait is set, foo can be sourced ... + >>> a.src = '/software/temp/src.txt' + >>> a.foo + 'src_foo.txt' + + >>> # ... and updates with the update of src ... + >>> a.src = '/software/temp/foo.txt' + >>> a.foo + 'foo_foo.txt' + + >>> # ... util it is explicitly set. + >>> a.foo = '/software/temp/goo.txt' + >>> a.foo + '/software/temp/goo.txt' + + >>> # Setting it Undefined will restore the sourcing behavior + >>> a.foo = Undefined + >>> a.foo + 'foo_foo.txt' + + """ + + def __init__(self, value='', template=None, **metadata): + """ Creates a GenFile trait. """ + + if template is None or not isinstance(template, string_types): + raise TraitError('GenFile requires a valid template argument') + + self.name_source = list(_parse_name_source(template)) + # Remove range indexing tokens (not allowed by string.Formatter) + for _, itoken, _ in self.name_source: + if itoken: + template = template.replace(itoken, '') + + self.template = template + self.keep_ext = metadata.get('keep_extension', False) + self.exists = metadata.get('exists', False) + super(GenFile, self).__init__(value, **metadata) + + + def validate(self, obj, name, value): + """ Validates that a specified value is valid for this trait. + + Note: The 'fast validator' version performs this check in C. + """ + # Allow unsetting the input + if not isdefined(value): + return value + + validated_value = super(GenFile, self).validate(obj, name, value) + if not self.exists: + return validated_value + elif op.isfile(value): + return validated_value + + self.error(obj, name, value) + + def get(self, obj, name): + # Compute expected name iff trait is not set + template = self.template + value = self.get_value(obj, name) + if not value or not isdefined(value) or value is None: + srcvals = {} + ext = '' + final_nsrcs = [] + for nsrc_list, indexing, fstr in self.name_source: + for nel in nsrc_list: + srcvalue = getattr(obj, nel) + if isdefined(srcvalue): + nsrc = nel + break + + if not isdefined(srcvalue): + return Undefined + + template = template.replace('|'.join(nsrc_list), nsrc) + IFLOGGER.debug('replacing %s with %s. Result=%s', '|'.join(nsrc_list), nsrc, template) + final_nsrcs.append(nsrc) + + if isinstance(srcvalue, tuple): + vallist = list(tuple) + + if not isinstance(srcvalue, list): + vallist = [srcvalue] + + outvals = [] + + isfile = obj.trait(nsrc).is_trait_type((File, MultiPath, GenMultiFile)) + for val in vallist: + if isfile: + _, val, ext = split_filename(val) + elif indexing: + # eval should be safe since we only + # accept indexing elements with format [n:n] + val = eval('val%s' % indexing) # pylint: disable=W0123 + if isdefined(val): + outvals.append(val) + + if not outvals: + continue + + if isinstance(srcvalue, list): + srcvals.update({nsrc: outvals}) + elif isinstance(srcvalue, tuple): + srcvals.update({nsrc: tuple(outvals)}) + else: + srcvals.update({nsrc: outvals[0]}) + + # Check that no source is missing + IFLOGGER.debug('Final sources: %s and values %s', final_nsrcs, srcvals) + missing = list(set(final_nsrcs) - set(srcvals.keys())) + if not missing: + retval = template.format(**srcvals) + if self.keep_ext: + retval += ext + return retval + else: + return Undefined + return self.get_value(obj, name) + + def set(self, obj, name, value): + """Implement set so that the trait is modifiable""" + self.set_value(obj, name, value) + + +class MultiPath(traits.List): + """ Abstract class - shared functionality of input and output MultiPath + """ + + def validate(self, obj, name, value): + if not isdefined(value) or \ + (isinstance(value, list) and len(value) == 0): + return Undefined + newvalue = value + + if not isinstance(value, list) \ + or (self.inner_traits() and + isinstance(self.inner_traits()[0].trait_type, + traits.List) and not + isinstance(self.inner_traits()[0].trait_type, + InputMultiPath) and + isinstance(value, list) and + value and not + isinstance(value[0], list)): + newvalue = [value] + value = super(MultiPath, self).validate(obj, name, newvalue) + + if len(value) > 0: + return value + + self.error(obj, name, value) + + +class GenMultiFile(traits.List): + """ Traits to generate lists of files. + + >>> # The traits start undefined + >>> from nipype.interfaces.base import GenFile, Undefined, traits, BaseInputSpec + >>> class A(BaseInputSpec): + ... src = InputMultiPath(File(exists=False)) + ... foo = GenMultiFile(template='{src}_foo', keep_extension=True) + >>> a = A() + >>> a.src + + >>> a.foo + + + >>> # If the source trait is set, foo can be sourced ... + >>> a.src = ['/software/temp/src1.txt', '/software/temp/src2.txt'] + >>> a.foo + ['src1_foo.txt', 'src2_foo.txt'] + + >>> # ... and updates with the update of src ... + >>> a.src = ['/software/temp/foo1.txt', '/software/temp/foo2.txt'] + >>> a.foo + ['foo1_foo.txt', 'foo2_foo.txt'] + + >>> # ... util it is explicitly set. + >>> a.foo = ['/software/temp/goo1.txt', '/software/temp/goo2.txt'] + >>> a.foo + ['/software/temp/goo1.txt', '/software/temp/goo2.txt'] + + >>> # Setting it Undefined will restore the sourcing behavior + >>> a.foo = Undefined + >>> a.foo + ['foo1_foo.txt', 'foo2_foo.txt'] + + >>> # It works with several replacements and defining ranges + >>> class B(BaseInputSpec): + ... src = File(exists=False) + ... num = traits.Int() + ... foo = GenMultiFile(template='{src}_foo_{num:03d}', range_source='num', + ... keep_extension=True) + >>> a = B() + >>> a.src = '/software/temp/source.txt' + >>> a.num = 3 + >>> a.foo + ['source_foo_000.txt', 'source_foo_001.txt', 'source_foo_002.txt'] + + >>> # And altogether with InputMultiPaths + >>> class B(BaseInputSpec): + ... src = InputMultiPath(File(exists=False)) + ... num = traits.Int() + ... foo = GenMultiFile(template='{src}_foo_{num:03d}', range_source='num', + ... keep_extension=True) + >>> a = B() + >>> a.src = ['/software/temp/source.txt', '/software/temp/alt.txt'] + >>> a.num = 2 + >>> a.foo + ['source_foo_000.txt', 'source_foo_001.txt', 'alt_foo_000.txt', 'alt_foo_001.txt'] + + + """ + def __init__(self, template=None, keep_extension=False, range_source=None, **metadata): + if template is None or not isinstance(template, string_types): + raise TraitError('GenMultiFile requires a valid template argument') + + self.name_source = list(_parse_name_source(template)) + # Remove range indexing tokens (not allowed by string.Formatter) + for _, itoken, _ in self.name_source: + if itoken: + template = template.replace(itoken, '') + self.template = template + self.keep_ext = keep_extension + self.range_source = None + if range_source is not None: + if not isinstance(range_source, string_types): + raise TraitError( + 'range_source is not valid (found %s).' % range_source) + + try: + range_source, offset = range_source.split('+') + self.offset = int(offset) + except ValueError: + self.offset = 0 + + if range_source not in [n for nsrc in self.name_source for n in nsrc[0]]: + raise TraitError( + 'range_source field should also be found in the' + ' template (valid fields = %s).' % self.name_source) + self.range_source = range_source + + super(GenMultiFile, self).__init__(**metadata) + + def validate(self, obj, name, value): + if not isdefined(value) or \ + (isinstance(value, list) and len(value) == 0): + return Undefined + newvalue = value + + if not isinstance(value, list) \ + or (self.inner_traits() and + isinstance(self.inner_traits()[0].trait_type, + traits.List) and not + isinstance(self.inner_traits()[0].trait_type, + InputMultiPath) and + isinstance(value, list) and + value and not + isinstance(value[0], list)): + newvalue = [value] + value = super(GenMultiFile, self).validate(obj, name, newvalue) + + if len(value) > 0: + return value + + self.error(obj, name, value) + + def get(self, obj, name): + template = self.template + # Compute expected name iff trait is not set + value = self.get_value(obj, name) + if not value or not isdefined(value) or value is None: + srcvals = {} + ext = '' + + final_nsrcs = [] + for nsrc_list, indexing, fstr in self.name_source: + for nel in nsrc_list: + srcvalue = getattr(obj, nel) + if isdefined(srcvalue): + nsrc = nel + break + + if not isdefined(srcvalue): + return Undefined + + template = template.replace('|'.join(nsrc_list), nsrc) + IFLOGGER.debug('replacing %s with %s. Result=%s', '|'.join(nsrc_list), nsrc, template) + final_nsrcs.append(nsrc) + + IFLOGGER.debug('Autogenerating output for: %s (%s=%s)', name, nsrc, srcvalue) + IFLOGGER.debug('range_source=%s', self.range_source) + if self.range_source is not None and nsrc == self.range_source: + srcvalue = range(self.offset, int(srcvalue) + self.offset) + vallist = srcvalue + IFLOGGER.debug('Generating range of outputs: %s', vallist) + + + + if isinstance(srcvalue, tuple): + vallist = list(srcvalue) + + if not isinstance(srcvalue, list): + vallist = [srcvalue] + else: + vallist = srcvalue + + outvals = [] + + isfile = obj.trait(nsrc).is_trait_type(( + File, MultiPath, GenMultiFile)) + for val in vallist: + if isfile: + _, val, ext = split_filename(val) + + if isdefined(val): + outvals.append(val) + + if outvals: + srcvals.update({nsrc: outvals}) + + IFLOGGER.debug('Final sources: %s and values %s', final_nsrcs, srcvals) + # Check that no source is missing + missing = list(set(final_nsrcs) - set(srcvals.keys())) + if not missing: + results = [] + combs = list(itools.product(*tuple(srcvals[k] for k in final_nsrcs))) + + # Get the formatting dictionaries ready + dlist = [{final_nsrcs[i]: v for i, v in enumerate(kvalues)} + for kvalues in combs] + # ... and create a formatted entry for each of them + for fmtdict in dlist: + retval = template.format(**fmtdict) + if self.keep_ext: + retval += ext + results.append(retval) + + if results: + if len(results) == 1: + return results[0] + return results + + return Undefined + + if len(value) == 0: + return Undefined + elif len(value) == 1: + return value[0] + else: + return value + + def set(self, obj, name, value): + self.set_value(obj, name, value) + + +class OutputMultiPath(MultiPath): + """ Implements a user friendly traits that accepts one or more + paths to files or directories. This is the output version which + return a single string whenever possible (when it was set to a + single value or a list of length 1). Default value of this trait + is _Undefined. It does not accept empty lists. + + XXX This should only be used as a final resort. We should stick to + established Traits to the extent possible. + + XXX This needs to be vetted by somebody who understands traits + + >>> from nipype.interfaces.base import OutputMultiPath, BaseInputSpec + >>> class A(BaseInputSpec): + ... foo = OutputMultiPath(File(exists=False)) + >>> a = A() + >>> a.foo + + + >>> a.foo = '/software/temp/foo.txt' + >>> a.foo + '/software/temp/foo.txt' + + >>> a.foo = ['/software/temp/foo.txt'] + >>> a.foo + '/software/temp/foo.txt' + + >>> a.foo = ['/software/temp/foo.txt', '/software/temp/goo.txt'] + >>> a.foo + ['/software/temp/foo.txt', '/software/temp/goo.txt'] + + """ + + def get(self, obj, name): + value = self.get_value(obj, name) + if len(value) == 0: + return Undefined + elif len(value) == 1: + return value[0] + else: + return value + + def set(self, obj, name, value): + self.set_value(obj, name, value) + + +class InputMultiPath(MultiPath): + """ Implements a user friendly traits that accepts one or more + paths to files or directories. This is the input version which + always returns a list. Default value of this trait + is _Undefined. It does not accept empty lists. + + XXX This should only be used as a final resort. We should stick to + established Traits to the extent possible. + + XXX This needs to be vetted by somebody who understands traits + + >>> from nipype.interfaces.base import InputMultiPath, BaseInputSpec + >>> class A(BaseInputSpec): + ... foo = InputMultiPath(File(exists=False)) + >>> a = A() + >>> a.foo + + + >>> a.foo = '/software/temp/foo.txt' + >>> a.foo + ['/software/temp/foo.txt'] + + >>> a.foo = ['/software/temp/foo.txt'] + >>> a.foo + ['/software/temp/foo.txt'] + + >>> a.foo = ['/software/temp/foo.txt', '/software/temp/goo.txt'] + >>> a.foo + ['/software/temp/foo.txt', '/software/temp/goo.txt'] + + """ + pass + + +# ------------------------------------------------------------------------------- +# 'BaseDirectory' and 'Directory' traits: +# ------------------------------------------------------------------------------- + + +class BaseDirectory (traits.BaseStr): + """ Defines a trait whose value must be the name of a directory. + """ + + # A description of the type of value this trait accepts: + info_text = 'a directory name' + + def __init__(self, value='', auto_set=False, entries=0, + exists=False, **metadata): + """ Creates a BaseDirectory trait. + + Parameters + ---------- + value : string + The default value for the trait + auto_set : boolean + Indicates whether the directory editor updates the trait value + after every key stroke. + exists : boolean + Indicates whether the trait value must be an existing directory or + not. + + Default Value + ------------- + *value* or '' + + """ + self.entries = entries + self.auto_set = auto_set + self.exists = exists + + if exists: + self.info_text = 'an existing directory name' + + super(BaseDirectory, self).__init__(value, **metadata) + + def validate(self, obj, name, value): + """ Validates that a specified value is valid for this trait. + + Note: The 'fast validator' version performs this check in C. + """ + validated_value = super(BaseDirectory, self).validate(obj, name, value) + if not self.exists: + return validated_value + + if op.isdir(value): + return validated_value + + self.error(obj, name, value) + + +class Directory (BaseDirectory): + """ Defines a trait whose value must be the name of a directory using a + C-level fast validator. + """ + + def __init__(self, value='', auto_set=False, entries=0, + exists=False, **metadata): + """ Creates a Directory trait. + + Parameters + ---------- + value : string + The default value for the trait + auto_set : boolean + Indicates whether the directory editor updates the trait value + after every key stroke. + exists : boolean + Indicates whether the trait value must be an existing directory or + not. + + Default Value + ------------- + *value* or '' + """ + # Define the C-level fast validator to use if the directory existence + # test is not required: + if not exists: + self.fast_validate = (11, str) + + super(Directory, self).__init__(value, auto_set, entries, exists, + **metadata) + +class Command(traits.BaseStr): + """ Defines a trait whose value must be an executable command + """ + + # A description of the type of value this trait accepts: + info_text = 'an executable file' + + def __init__(self, value='', path='', **metadata): + metadata['path'] = path + super(Command, self).__init__(value, **metadata) + + + def validate(self, obj, name, value): + """ Validates that a specified value is valid for this trait. + + Note: The 'fast validator' version performs this check in C. + """ + validated_value = super(Command, self).validate(obj, name, value) + env = getattr(obj, 'environ', None) + # IFLOGGER.debug('Environ now: %s', env) + valid, path = _exists_in_path(validated_value.split()[0], env) + obj.trait(name).path = path + + if valid: + return validated_value + raise TraitError( + 'The \'%s\' trait of an interface must be an executable ' + 'file, but \'%s\' was not found in the system\'s PATH.' % + (name, value)) + + + +# The functions that pop-up the Traits GUIs, edit_traits and +# configure_traits, were failing because all of our inputs default to +# Undefined deep and down in traits/ui/wx/list_editor.py it checks for +# the len() of the elements of the list. The _Undefined class in traits +# does not define the __len__ method and would error. I tried defining +# our own Undefined and even sublassing Undefined, but both of those +# failed with a TraitError in our initializer when we assign the +# Undefined to the inputs because of an incompatible type: + +# TraitError: The 'vertical_gradient' trait of a BetInputSpec instance must be a float, but a value of was specified. + +# So... in order to keep the same type but add the missing method, I +# monkey patched. +########################################################################## +# Apply monkeypatch here +_Undefined.__len__ = lambda cls: 0 +########################################################################## + +Undefined = _Undefined() + +def isdefined(obj): + """Checks if a certain trait was set""" + return not isinstance(obj, _Undefined) + +def has_metadata(trait, metadata, value=None, recursive=True): + """ + Checks if a given trait has a metadata (and optionally if it is set to particular value) + """ + count = 0 + if hasattr(trait, "_metadata") and metadata in list(trait._metadata.keys()) and (trait._metadata[metadata] == value or value is None): + count += 1 + if recursive: + if hasattr(trait, 'inner_traits'): + for inner_trait in trait.inner_traits(): + count += has_metadata(inner_trait.trait_type, metadata, recursive) + if hasattr(trait, 'handlers') and trait.handlers is not None: + for handler in trait.handlers: + count += has_metadata(handler, metadata, recursive) + + return count > 0 + +def _parse_name_source(name_source): + """Parse template strings""" + format_str = [i[1:-1] for i in re.findall(r'\{.*?\}', name_source)] + + for fchunk in format_str: + indexing = [i for i in re.findall(r'\[[0-9]*:[0-9]*\]', fchunk)] + # Only one complex indexing replacement is allowed + if indexing: + indexing = indexing[0] + + name = fchunk.split('.')[0].split('!')[0].split(':')[0].split('[')[0] + yield (name.split('|'), indexing, fchunk) + +def _exists_in_path(cmd, environ=None): + """ + Based on a code snippet from + http://orip.org/2009/08/python-checking-if-executable-exists-in.html + """ + # Read environ from variable, use system's environ as failback + if environ is None: + environ = {} + + input_environ = environ.get("PATH", os.environ.get("PATH", "")) + extensions = os.environ.get("PATHEXT", "").split(os.pathsep) + for directory in input_environ.split(os.pathsep): + base = op.join(directory, cmd) + options = [base] + [(base + ext) for ext in extensions] + for filename in options: + if op.exists(filename): + return True, filename + return False, None diff --git a/nipype/interfaces/c3.py b/nipype/interfaces/c3.py index 8246a68786..346119ce06 100644 --- a/nipype/interfaces/c3.py +++ b/nipype/interfaces/c3.py @@ -39,8 +39,8 @@ class C3dAffineTool(SEMLikeCommandLine): >>> c3.cmdline 'c3d_affine_tool -src cmatrix.mat -fsl2ras -oitk affine.txt' """ - input_spec = C3dAffineToolInputSpec - output_spec = C3dAffineToolOutputSpec + _input_spec = C3dAffineToolInputSpec + _output_spec = C3dAffineToolOutputSpec _cmd = 'c3d_affine_tool' _outputs_filenames = {'itk_transform': 'affine.txt'} diff --git a/nipype/interfaces/camino/calib.py b/nipype/interfaces/camino/calib.py index a56e501e7c..211c3d19e5 100644 --- a/nipype/interfaces/camino/calib.py +++ b/nipype/interfaces/camino/calib.py @@ -117,15 +117,14 @@ class SFPICOCalibData(StdOutCommandLine): data is generated for calculating the LUT. # doctest: +SKIP """ _cmd = 'sfpicocalibdata' - input_spec = SFPICOCalibDataInputSpec - output_spec = SFPICOCalibDataOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['PICOCalib'] = os.path.abspath(self._gen_outfilename()) - outputs['calib_info'] = os.path.abspath(self.inputs.info_file) - return outputs - + _input_spec = SFPICOCalibDataInputSpec + _output_spec = SFPICOCalibDataOutputSpec + + def _post_run(self): + + self.outputs.PICOCalib = os.path.abspath(self._gen_outfilename()) + self.outputs.calib_info = os.path.abspath(self.inputs.info_file) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.scheme_file) return name + '_PICOCalib.Bfloat' @@ -224,14 +223,13 @@ class SFLUTGen(StdOutCommandLine): >>> lutgen.run() # doctest: +SKIP """ _cmd = 'sflutgen' - input_spec = SFLUTGenInputSpec - output_spec = SFLUTGenOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['lut_one_fibre'] = self.inputs.outputstem + '_oneFibreSurfaceCoeffs.Bdouble' - outputs['lut_two_fibres'] = self.inputs.outputstem + '_twoFibreSurfaceCoeffs.Bdouble' - return outputs - + _input_spec = SFLUTGenInputSpec + _output_spec = SFLUTGenOutputSpec + + def _post_run(self): + + self.outputs.lut_one_fibre = self.inputs.outputstem + '_oneFibreSurfaceCoeffs.Bdouble' + self.outputs.lut_two_fibres = self.inputs.outputstem + '_twoFibreSurfaceCoeffs.Bdouble' + def _gen_outfilename(self): return '/dev/null' diff --git a/nipype/interfaces/camino/connectivity.py b/nipype/interfaces/camino/connectivity.py index 3a41c801e2..58ab8feddd 100644 --- a/nipype/interfaces/camino/connectivity.py +++ b/nipype/interfaces/camino/connectivity.py @@ -129,16 +129,15 @@ class Conmat(CommandLine): >>> conmat.run() # doctest: +SKIP """ _cmd = 'conmat' - input_spec = ConmatInputSpec - output_spec = ConmatOutputSpec + _input_spec = ConmatInputSpec + _output_spec = ConmatOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + output_root = self._gen_outputroot() - outputs['conmat_sc'] = os.path.abspath(output_root + "sc.csv") - outputs['conmat_ts'] = os.path.abspath(output_root + "ts.csv") - return outputs - + self.outputs.conmat_sc = os.path.abspath(output_root + "sc.csv") + self.outputs.conmat_ts = os.path.abspath(output_root + "ts.csv") + def _gen_outfilename(self): return self._gen_outputroot() diff --git a/nipype/interfaces/camino/convert.py b/nipype/interfaces/camino/convert.py index cdde8a2b88..27f1e6a8d3 100644 --- a/nipype/interfaces/camino/convert.py +++ b/nipype/interfaces/camino/convert.py @@ -53,14 +53,13 @@ class Image2Voxel(StdOutCommandLine): >>> img2vox.run() # doctest: +SKIP """ _cmd = 'image2voxel' - input_spec = Image2VoxelInputSpec - output_spec = Image2VoxelOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['voxel_order'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = Image2VoxelInputSpec + _output_spec = Image2VoxelOutputSpec + def _post_run(self): + + self.outputs.voxel_order = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + '.B' + self.inputs.out_type @@ -111,14 +110,13 @@ class FSL2Scheme(StdOutCommandLine): """ _cmd = 'fsl2scheme' - input_spec = FSL2SchemeInputSpec - output_spec = FSL2SchemeOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['scheme'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = FSL2SchemeInputSpec + _output_spec = FSL2SchemeOutputSpec + def _post_run(self): + + self.outputs.scheme = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.bvec_file) return name + '.scheme' @@ -167,14 +165,13 @@ class VtkStreamlines(StdOutCommandLine): >>> vtk.run() # doctest: +SKIP """ _cmd = 'vtkstreamlines' - input_spec = VtkStreamlinesInputSpec - output_spec = VtkStreamlinesOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['vtk'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = VtkStreamlinesInputSpec + _output_spec = VtkStreamlinesOutputSpec + def _post_run(self): + + self.outputs.vtk = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + '.vtk' @@ -272,8 +269,8 @@ class ProcStreamlines(StdOutCommandLine): >>> proc.run() # doctest: +SKIP """ _cmd = 'procstreamlines' - input_spec = ProcStreamlinesInputSpec - output_spec = ProcStreamlinesOutputSpec + _input_spec = ProcStreamlinesInputSpec + _output_spec = ProcStreamlinesOutputSpec def _format_arg(self, name, spec, value): if name == 'outputroot': @@ -298,12 +295,11 @@ def _get_actual_outputroot(self, outputroot): actual_outputroot = os.path.join('procstream_outfiles', outputroot) return actual_outputroot - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['proc'] = os.path.abspath(self._gen_outfilename()) - outputs['outputroot_files'] = self.outputroot_files - return outputs - + def _post_run(self): + + self.outputs.proc = os.path.abspath(self._gen_outfilename()) + self.outputs.outputroot_files = self.outputroot_files + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + '_proc' @@ -348,14 +344,13 @@ class TractShredder(StdOutCommandLine): >>> shred.run() # doctest: +SKIP """ _cmd = 'tractshredder' - input_spec = TractShredderInputSpec - output_spec = TractShredderOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['shredded'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = TractShredderInputSpec + _output_spec = TractShredderOutputSpec + def _post_run(self): + + self.outputs.shredded = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + "_shredded" @@ -387,17 +382,16 @@ class DT2NIfTI(CommandLine): Reads Camino diffusion tensors, and converts them to NIFTI format as three .nii files. """ _cmd = 'dt2nii' - input_spec = DT2NIfTIInputSpec - output_spec = DT2NIfTIOutputSpec + _input_spec = DT2NIfTIInputSpec + _output_spec = DT2NIfTIOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + output_root = self._gen_outputroot() - outputs["dt"] = os.path.abspath(output_root + "dt.nii") - outputs["exitcode"] = os.path.abspath(output_root + "exitcode.nii") - outputs["lns0"] = os.path.abspath(output_root + "lns0.nii") - return outputs - + self.outputs.dt = os.path.abspath(output_root + "dt.nii") + self.outputs.exitcode = os.path.abspath(output_root + "exitcode.nii") + self.outputs.lns0 = os.path.abspath(output_root + "lns0.nii") + def _gen_outfilename(self): return self._gen_outputroot() @@ -470,14 +464,13 @@ class NIfTIDT2Camino(CommandLine): """ _cmd = 'niftidt2camino' - input_spec = NIfTIDT2CaminoInputSpec - output_spec = NIfTIDT2CaminoOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs["out_file"] = self._gen_filename('out_file') - return outputs + _input_spec = NIfTIDT2CaminoInputSpec + _output_spec = NIfTIDT2CaminoOutputSpec + def _post_run(self): + + self.outputs.out_file = self._gen_filename('out_file') + def _gen_filename(self, name): if name == 'out_file': _, filename, _ = split_filename(self.inputs.in_file) @@ -624,14 +617,13 @@ class AnalyzeHeader(StdOutCommandLine): >>> hdr.run() # doctest: +SKIP """ _cmd = 'analyzeheader' - input_spec = AnalyzeHeaderInputSpec - output_spec = AnalyzeHeaderOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['header'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = AnalyzeHeaderInputSpec + _output_spec = AnalyzeHeaderOutputSpec + def _post_run(self): + + self.outputs.header = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + ".hdr" @@ -678,14 +670,13 @@ class Shredder(StdOutCommandLine): >>> shred.run() # doctest: +SKIP """ _cmd = 'shredder' - input_spec = ShredderInputSpec - output_spec = ShredderOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['shredded_file'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = ShredderInputSpec + _output_spec = ShredderOutputSpec + def _post_run(self): + + self.outputs.shredded_file = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + "_shredded" diff --git a/nipype/interfaces/camino/dti.py b/nipype/interfaces/camino/dti.py index 8402fcf45f..ab2d329765 100644 --- a/nipype/interfaces/camino/dti.py +++ b/nipype/interfaces/camino/dti.py @@ -58,14 +58,13 @@ class DTIFit(StdOutCommandLine): >>> fit.run() # doctest: +SKIP """ _cmd = 'dtfit' - input_spec = DTIFitInputSpec - output_spec = DTIFitOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['tensor_fitted'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = DTIFitInputSpec + _output_spec = DTIFitOutputSpec + def _post_run(self): + + self.outputs.tensor_fitted = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + '_DT.Bdouble' @@ -144,14 +143,13 @@ class DTMetric(CommandLine): >>> dtmetric.run() # doctest: +SKIP """ _cmd = 'dtshape' - input_spec = DTMetricInputSpec - output_spec = DTMetricOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['metric_stats'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = DTMetricInputSpec + _output_spec = DTMetricOutputSpec + def _post_run(self): + + self.outputs.metric_stats = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): return self._gen_outputfile() @@ -248,14 +246,13 @@ class ModelFit(StdOutCommandLine): >>> fit.run() # doctest: +SKIP """ _cmd = 'modelfit' - input_spec = ModelFitInputSpec - output_spec = ModelFitOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['fitted_data'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = ModelFitInputSpec + _output_spec = ModelFitOutputSpec + def _post_run(self): + + self.outputs.fitted_data = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + '_fit.Bdouble' @@ -330,14 +327,13 @@ class DTLUTGen(StdOutCommandLine): >>> dtl.run() # doctest: +SKIP """ _cmd = 'dtlutgen' - input_spec = DTLUTGenInputSpec - output_spec = DTLUTGenOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['dtLUT'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = DTLUTGenInputSpec + _output_spec = DTLUTGenOutputSpec + def _post_run(self): + + self.outputs.dtLUT = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.scheme_file) return name + '.dat' @@ -394,14 +390,13 @@ class PicoPDFs(StdOutCommandLine): >>> pdf.run() # doctest: +SKIP """ _cmd = 'picopdfs' - input_spec = PicoPDFsInputSpec - output_spec = PicoPDFsOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['pdfs'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = PicoPDFsInputSpec + _output_spec = PicoPDFsOutputSpec + def _post_run(self): + + self.outputs.pdfs = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + '_pdfs.Bdouble' @@ -561,18 +556,17 @@ class Track(CommandLine): _cmd = 'track' - input_spec = TrackInputSpec - output_spec = TrackOutputSpec + _input_spec = TrackInputSpec + _output_spec = TrackOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + if isdefined(self.inputs.out_file): out_file_path = os.path.abspath(self.inputs.out_file) else: out_file_path = os.path.abspath(self._gen_outfilename()) - outputs['tracked'] = out_file_path - return outputs - + self.outputs.tracked = out_file_path + def _gen_filename(self, name): if name is 'out_file': return self._gen_outfilename() @@ -627,7 +621,7 @@ class TrackPICo(Track): >>> track.run() # doctest: +SKIP """ - input_spec = TrackPICoInputSpec + _input_spec = TrackPICoInputSpec def __init__(self, command=None, **inputs): inputs["inputmodel"] = "pico" @@ -668,7 +662,7 @@ class TrackBedpostxDeter(Track): >>> track.run() # doctest: +SKIP """ - input_spec = TrackBedpostxDeterInputSpec + _input_spec = TrackBedpostxDeterInputSpec def __init__(self, command=None, **inputs): inputs["inputmodel"] = "bedpostx_dyad" @@ -718,7 +712,7 @@ class TrackBedpostxProba(Track): >>> track.run() # doctest: +SKIP """ - input_spec = TrackBedpostxProbaInputSpec + _input_spec = TrackBedpostxProbaInputSpec def __init__(self, command=None, **inputs): inputs["inputmodel"] = "bedpostx_dyad" @@ -764,7 +758,7 @@ class TrackBayesDirac(Track): >>> track.run() # doctest: +SKIP """ - input_spec = TrackBayesDiracInputSpec + _input_spec = TrackBayesDiracInputSpec def __init__(self, command=None, **inputs): inputs["inputmodel"] = "bayesdirac" @@ -818,7 +812,7 @@ class TrackBootstrap(Track): >>> track.run() # doctest: +SKIP """ - input_spec = TrackBootstrapInputSpec + _input_spec = TrackBootstrapInputSpec def __init__(self, command=None, **inputs): return super(TrackBootstrap, self).__init__(command, **inputs) @@ -869,14 +863,13 @@ class ComputeMeanDiffusivity(StdOutCommandLine): >>> md.run() # doctest: +SKIP """ _cmd = 'md' - input_spec = ComputeMeanDiffusivityInputSpec - output_spec = ComputeMeanDiffusivityOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs["md"] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = ComputeMeanDiffusivityInputSpec + _output_spec = ComputeMeanDiffusivityOutputSpec + def _post_run(self): + + self.outputs.md = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + "_MD.img" # Need to change to self.inputs.outputdatatype @@ -931,14 +924,13 @@ class ComputeFractionalAnisotropy(StdOutCommandLine): >>> fa.run() # doctest: +SKIP """ _cmd = 'fa' - input_spec = ComputeFractionalAnisotropyInputSpec - output_spec = ComputeFractionalAnisotropyOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['fa'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = ComputeFractionalAnisotropyInputSpec + _output_spec = ComputeFractionalAnisotropyOutputSpec + def _post_run(self): + + self.outputs.fa = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + '_FA.Bdouble' # Need to change to self.inputs.outputdatatype @@ -995,14 +987,13 @@ class ComputeTensorTrace(StdOutCommandLine): >>> trace.run() # doctest: +SKIP """ _cmd = 'trd' - input_spec = ComputeTensorTraceInputSpec - output_spec = ComputeTensorTraceOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['trace'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = ComputeTensorTraceInputSpec + _output_spec = ComputeTensorTraceOutputSpec + def _post_run(self): + + self.outputs.trace = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + '_TrD.img' # Need to change to self.inputs.outputdatatype @@ -1055,14 +1046,13 @@ class ComputeEigensystem(StdOutCommandLine): >>> dteig.run() # doctest: +SKIP """ _cmd = 'dteig' - input_spec = ComputeEigensystemInputSpec - output_spec = ComputeEigensystemOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs["eigen"] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = ComputeEigensystemInputSpec + _output_spec = ComputeEigensystemOutputSpec + def _post_run(self): + + self.outputs.eigen = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) datatype = self.inputs.outputdatatype diff --git a/nipype/interfaces/camino/odf.py b/nipype/interfaces/camino/odf.py index e39bc81117..3a0dbaafb0 100644 --- a/nipype/interfaces/camino/odf.py +++ b/nipype/interfaces/camino/odf.py @@ -79,14 +79,13 @@ class QBallMX(StdOutCommandLine): >>> qballcoeffs.run() # doctest: +SKIP """ _cmd = 'qballmx' - input_spec = QBallMXInputSpec - output_spec = QBallMXOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['qmat'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = QBallMXInputSpec + _output_spec = QBallMXOutputSpec + def _post_run(self): + + self.outputs.qmat = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.scheme_file) return name + '_qmat.Bdouble' @@ -156,14 +155,13 @@ class LinRecon(StdOutCommandLine): >>> qballcoeffs.run() # doctest: +SKIP """ _cmd = 'linrecon' - input_spec = LinReconInputSpec - output_spec = LinReconOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['recon_data'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = LinReconInputSpec + _output_spec = LinReconOutputSpec + def _post_run(self): + + self.outputs.recon_data = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.scheme_file) return name + '_recondata.Bdouble' @@ -280,14 +278,13 @@ class MESD(StdOutCommandLine): >>> mesd.run() # doctest: +SKIP """ _cmd = 'mesd' - input_spec = MESDInputSpec - output_spec = MESDOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['mesd_data'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = MESDInputSpec + _output_spec = MESDOutputSpec + def _post_run(self): + + self.outputs.mesd_data = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.scheme_file) return name + '_MESD.Bdouble' @@ -427,14 +424,13 @@ class SFPeaks(StdOutCommandLine): >>> sf_peaks.run() # doctest: +SKIP """ _cmd = 'sfpeaks' - input_spec = SFPeaksInputSpec - output_spec = SFPeaksOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['peaks'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = SFPeaksInputSpec + _output_spec = SFPeaksOutputSpec + def _post_run(self): + + self.outputs.peaks = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) return name + '_peaks.Bdouble' diff --git a/nipype/interfaces/camino/tests/test_auto_AnalyzeHeader.py b/nipype/interfaces/camino/tests/test_auto_AnalyzeHeader.py index 324fe35d1b..74046fe720 100644 --- a/nipype/interfaces/camino/tests/test_auto_AnalyzeHeader.py +++ b/nipype/interfaces/camino/tests/test_auto_AnalyzeHeader.py @@ -17,15 +17,9 @@ def test_AnalyzeHeader_inputs(): ), description=dict(argstr='-description %s', ), - environ=dict(nohash=True, - usedefault=True, - ), greylevels=dict(argstr='-gl %s', units='NA', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='< %s', mandatory=True, position=1, @@ -44,8 +38,8 @@ def test_AnalyzeHeader_inputs(): units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), picoseed=dict(argstr='-picoseed %s', units='mm', @@ -74,13 +68,11 @@ def test_AnalyzeHeader_inputs(): scheme_file=dict(argstr='%s', position=2, ), - terminal_output=dict(nohash=True, - ), voxel_dims=dict(argstr='-voxeldims %s', units='mm', ), ) - inputs = AnalyzeHeader.input_spec() + inputs = AnalyzeHeader._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -90,7 +82,7 @@ def test_AnalyzeHeader_inputs(): def test_AnalyzeHeader_outputs(): output_map = dict(header=dict(), ) - outputs = AnalyzeHeader.output_spec() + outputs = AnalyzeHeader._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_ComputeEigensystem.py b/nipype/interfaces/camino/tests/test_auto_ComputeEigensystem.py index d62e37c212..9447698f04 100644 --- a/nipype/interfaces/camino/tests/test_auto_ComputeEigensystem.py +++ b/nipype/interfaces/camino/tests/test_auto_ComputeEigensystem.py @@ -6,12 +6,6 @@ def test_ComputeEigensystem_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='< %s', mandatory=True, position=1, @@ -24,16 +18,14 @@ def test_ComputeEigensystem_inputs(): maxcomponents=dict(argstr='-maxcomponents %d', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), outputdatatype=dict(argstr='-outputdatatype %s', usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ComputeEigensystem.input_spec() + inputs = ComputeEigensystem._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +35,7 @@ def test_ComputeEigensystem_inputs(): def test_ComputeEigensystem_outputs(): output_map = dict(eigen=dict(), ) - outputs = ComputeEigensystem.output_spec() + outputs = ComputeEigensystem._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_ComputeFractionalAnisotropy.py b/nipype/interfaces/camino/tests/test_auto_ComputeFractionalAnisotropy.py index 0a022eb1c3..419537a2c8 100644 --- a/nipype/interfaces/camino/tests/test_auto_ComputeFractionalAnisotropy.py +++ b/nipype/interfaces/camino/tests/test_auto_ComputeFractionalAnisotropy.py @@ -6,12 +6,6 @@ def test_ComputeFractionalAnisotropy_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='< %s', mandatory=True, position=1, @@ -21,18 +15,16 @@ def test_ComputeFractionalAnisotropy_inputs(): inputmodel=dict(argstr='-inputmodel %s', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), outputdatatype=dict(argstr='-outputdatatype %s', ), scheme_file=dict(argstr='%s', position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ComputeFractionalAnisotropy.input_spec() + inputs = ComputeFractionalAnisotropy._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_ComputeFractionalAnisotropy_inputs(): def test_ComputeFractionalAnisotropy_outputs(): output_map = dict(fa=dict(), ) - outputs = ComputeFractionalAnisotropy.output_spec() + outputs = ComputeFractionalAnisotropy._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_ComputeMeanDiffusivity.py b/nipype/interfaces/camino/tests/test_auto_ComputeMeanDiffusivity.py index 213ff038fc..c0b293d61d 100644 --- a/nipype/interfaces/camino/tests/test_auto_ComputeMeanDiffusivity.py +++ b/nipype/interfaces/camino/tests/test_auto_ComputeMeanDiffusivity.py @@ -6,12 +6,6 @@ def test_ComputeMeanDiffusivity_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='< %s', mandatory=True, position=1, @@ -29,10 +23,8 @@ def test_ComputeMeanDiffusivity_inputs(): scheme_file=dict(argstr='%s', position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ComputeMeanDiffusivity.input_spec() + inputs = ComputeMeanDiffusivity._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_ComputeMeanDiffusivity_inputs(): def test_ComputeMeanDiffusivity_outputs(): output_map = dict(md=dict(), ) - outputs = ComputeMeanDiffusivity.output_spec() + outputs = ComputeMeanDiffusivity._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_ComputeTensorTrace.py b/nipype/interfaces/camino/tests/test_auto_ComputeTensorTrace.py index b7d7561cdb..277f33dba1 100644 --- a/nipype/interfaces/camino/tests/test_auto_ComputeTensorTrace.py +++ b/nipype/interfaces/camino/tests/test_auto_ComputeTensorTrace.py @@ -6,12 +6,6 @@ def test_ComputeTensorTrace_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='< %s', mandatory=True, position=1, @@ -21,18 +15,16 @@ def test_ComputeTensorTrace_inputs(): inputmodel=dict(argstr='-inputmodel %s', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), outputdatatype=dict(argstr='-outputdatatype %s', ), scheme_file=dict(argstr='%s', position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ComputeTensorTrace.input_spec() + inputs = ComputeTensorTrace._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_ComputeTensorTrace_inputs(): def test_ComputeTensorTrace_outputs(): output_map = dict(trace=dict(), ) - outputs = ComputeTensorTrace.output_spec() + outputs = ComputeTensorTrace._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_Conmat.py b/nipype/interfaces/camino/tests/test_auto_Conmat.py index c5aa705c6c..0b4c9d18ea 100644 --- a/nipype/interfaces/camino/tests/test_auto_Conmat.py +++ b/nipype/interfaces/camino/tests/test_auto_Conmat.py @@ -6,12 +6,6 @@ def test_Conmat_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', mandatory=True, ), @@ -26,8 +20,6 @@ def test_Conmat_inputs(): ), targetname_file=dict(argstr='-targetnamefile %s', ), - terminal_output=dict(nohash=True, - ), tract_prop=dict(argstr='-tractstat %s', units='NA', xor=['tract_stat'], @@ -38,7 +30,7 @@ def test_Conmat_inputs(): xor=['tract_prop'], ), ) - inputs = Conmat.input_spec() + inputs = Conmat._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -49,7 +41,7 @@ def test_Conmat_outputs(): output_map = dict(conmat_sc=dict(), conmat_ts=dict(), ) - outputs = Conmat.output_spec() + outputs = Conmat._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_DT2NIfTI.py b/nipype/interfaces/camino/tests/test_auto_DT2NIfTI.py index 9bc58fecdd..0fab23a4a1 100644 --- a/nipype/interfaces/camino/tests/test_auto_DT2NIfTI.py +++ b/nipype/interfaces/camino/tests/test_auto_DT2NIfTI.py @@ -6,16 +6,10 @@ def test_DT2NIfTI_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), header_file=dict(argstr='-header %s', mandatory=True, position=3, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', mandatory=True, position=1, @@ -24,10 +18,8 @@ def test_DT2NIfTI_inputs(): genfile=True, position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DT2NIfTI.input_spec() + inputs = DT2NIfTI._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_DT2NIfTI_outputs(): exitcode=dict(), lns0=dict(), ) - outputs = DT2NIfTI.output_spec() + outputs = DT2NIfTI._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_DTIFit.py b/nipype/interfaces/camino/tests/test_auto_DTIFit.py index 8607d3d7ae..9387b1be7a 100644 --- a/nipype/interfaces/camino/tests/test_auto_DTIFit.py +++ b/nipype/interfaces/camino/tests/test_auto_DTIFit.py @@ -8,12 +8,6 @@ def test_DTIFit_inputs(): ), bgmask=dict(argstr='-bgmask %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=1, @@ -22,17 +16,15 @@ def test_DTIFit_inputs(): position=3, ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), scheme_file=dict(argstr='%s', mandatory=True, position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DTIFit.input_spec() + inputs = DTIFit._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_DTIFit_inputs(): def test_DTIFit_outputs(): output_map = dict(tensor_fitted=dict(), ) - outputs = DTIFit.output_spec() + outputs = DTIFit._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_DTLUTGen.py b/nipype/interfaces/camino/tests/test_auto_DTLUTGen.py index 6cae7fee81..df41d710dc 100644 --- a/nipype/interfaces/camino/tests/test_auto_DTLUTGen.py +++ b/nipype/interfaces/camino/tests/test_auto_DTLUTGen.py @@ -10,16 +10,10 @@ def test_DTLUTGen_inputs(): ), bingham=dict(argstr='-bingham', ), - environ=dict(nohash=True, - usedefault=True, - ), frange=dict(argstr='-frange %s', position=1, units='NA', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inversion=dict(argstr='-inversion %d', units='NA', ), @@ -28,8 +22,8 @@ def test_DTLUTGen_inputs(): units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), samples=dict(argstr='-samples %d', units='NA', @@ -44,15 +38,13 @@ def test_DTLUTGen_inputs(): step=dict(argstr='-step %f', units='NA', ), - terminal_output=dict(nohash=True, - ), trace=dict(argstr='-trace %G', units='NA', ), watson=dict(argstr='-watson', ), ) - inputs = DTLUTGen.input_spec() + inputs = DTLUTGen._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -62,7 +54,7 @@ def test_DTLUTGen_inputs(): def test_DTLUTGen_outputs(): output_map = dict(dtLUT=dict(), ) - outputs = DTLUTGen.output_spec() + outputs = DTLUTGen._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_DTMetric.py b/nipype/interfaces/camino/tests/test_auto_DTMetric.py index d4cec76afb..6f02b97f5e 100644 --- a/nipype/interfaces/camino/tests/test_auto_DTMetric.py +++ b/nipype/interfaces/camino/tests/test_auto_DTMetric.py @@ -11,12 +11,6 @@ def test_DTMetric_inputs(): eigen_data=dict(argstr='-inputfile %s', mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputdatatype=dict(argstr='-inputdatatype %s', usedefault=True, ), @@ -29,10 +23,8 @@ def test_DTMetric_inputs(): outputfile=dict(argstr='-outputfile %s', genfile=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DTMetric.input_spec() + inputs = DTMetric._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_DTMetric_inputs(): def test_DTMetric_outputs(): output_map = dict(metric_stats=dict(), ) - outputs = DTMetric.output_spec() + outputs = DTMetric._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_FSL2Scheme.py b/nipype/interfaces/camino/tests/test_auto_FSL2Scheme.py index b182c5a862..4f8cddfe5c 100644 --- a/nipype/interfaces/camino/tests/test_auto_FSL2Scheme.py +++ b/nipype/interfaces/camino/tests/test_auto_FSL2Scheme.py @@ -20,33 +20,25 @@ def test_FSL2Scheme_inputs(): diffusiontime=dict(argstr='-diffusiontime %f', units='NA', ), - environ=dict(nohash=True, - usedefault=True, - ), flipx=dict(argstr='-flipx', ), flipy=dict(argstr='-flipy', ), flipz=dict(argstr='-flipz', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), interleave=dict(argstr='-interleave', ), numscans=dict(argstr='-numscans %d', units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, - ), - terminal_output=dict(nohash=True, + usedefault=True, ), usegradmod=dict(argstr='-usegradmod', ), ) - inputs = FSL2Scheme.input_spec() + inputs = FSL2Scheme._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -56,7 +48,7 @@ def test_FSL2Scheme_inputs(): def test_FSL2Scheme_outputs(): output_map = dict(scheme=dict(), ) - outputs = FSL2Scheme.output_spec() + outputs = FSL2Scheme._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_Image2Voxel.py b/nipype/interfaces/camino/tests/test_auto_Image2Voxel.py index 57da324d6c..2c4fe9ef30 100644 --- a/nipype/interfaces/camino/tests/test_auto_Image2Voxel.py +++ b/nipype/interfaces/camino/tests/test_auto_Image2Voxel.py @@ -6,28 +6,20 @@ def test_Image2Voxel_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-4dimage %s', mandatory=True, position=1, ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), out_type=dict(argstr='-outputdatatype %s', position=2, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Image2Voxel.input_spec() + inputs = Image2Voxel._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +29,7 @@ def test_Image2Voxel_inputs(): def test_Image2Voxel_outputs(): output_map = dict(voxel_order=dict(), ) - outputs = Image2Voxel.output_spec() + outputs = Image2Voxel._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_ImageStats.py b/nipype/interfaces/camino/tests/test_auto_ImageStats.py index 2fd6293a24..ab21504950 100644 --- a/nipype/interfaces/camino/tests/test_auto_ImageStats.py +++ b/nipype/interfaces/camino/tests/test_auto_ImageStats.py @@ -6,12 +6,6 @@ def test_ImageStats_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='-images %s', mandatory=True, position=-1, @@ -26,10 +20,8 @@ def test_ImageStats_inputs(): mandatory=True, units='NA', ), - terminal_output=dict(nohash=True, - ), ) - inputs = ImageStats.input_spec() + inputs = ImageStats._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_ImageStats_inputs(): def test_ImageStats_outputs(): output_map = dict(out_file=dict(), ) - outputs = ImageStats.output_spec() + outputs = ImageStats._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_LinRecon.py b/nipype/interfaces/camino/tests/test_auto_LinRecon.py index 311bd70fdf..1dd6cb2f28 100644 --- a/nipype/interfaces/camino/tests/test_auto_LinRecon.py +++ b/nipype/interfaces/camino/tests/test_auto_LinRecon.py @@ -8,12 +8,6 @@ def test_LinRecon_inputs(): ), bgmask=dict(argstr='-bgmask %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=1, @@ -23,8 +17,8 @@ def test_LinRecon_inputs(): normalize=dict(argstr='-normalize', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), qball_mat=dict(argstr='%s', mandatory=True, @@ -34,10 +28,8 @@ def test_LinRecon_inputs(): mandatory=True, position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = LinRecon.input_spec() + inputs = LinRecon._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_LinRecon_inputs(): def test_LinRecon_outputs(): output_map = dict(recon_data=dict(), ) - outputs = LinRecon.output_spec() + outputs = LinRecon._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_MESD.py b/nipype/interfaces/camino/tests/test_auto_MESD.py index 018d820a96..125b81c391 100644 --- a/nipype/interfaces/camino/tests/test_auto_MESD.py +++ b/nipype/interfaces/camino/tests/test_auto_MESD.py @@ -8,15 +8,9 @@ def test_MESD_inputs(): ), bgmask=dict(argstr='-bgmask %s', ), - environ=dict(nohash=True, - usedefault=True, - ), fastmesd=dict(argstr='-fastmesd', requires=['mepointset'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', mandatory=True, position=1, @@ -36,16 +30,14 @@ def test_MESD_inputs(): units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), scheme_file=dict(argstr='-schemefile %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = MESD.input_spec() + inputs = MESD._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_MESD_inputs(): def test_MESD_outputs(): output_map = dict(mesd_data=dict(), ) - outputs = MESD.output_spec() + outputs = MESD._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_ModelFit.py b/nipype/interfaces/camino/tests/test_auto_ModelFit.py index f56a605962..27c1c5db50 100644 --- a/nipype/interfaces/camino/tests/test_auto_ModelFit.py +++ b/nipype/interfaces/camino/tests/test_auto_ModelFit.py @@ -12,16 +12,10 @@ def test_ModelFit_inputs(): ), cfthresh=dict(argstr='-csfthresh %G', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedbvalue=dict(argstr='-fixedbvalue %s', ), fixedmodq=dict(argstr='-fixedmod %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', mandatory=True, ), @@ -33,8 +27,8 @@ def test_ModelFit_inputs(): noisemap=dict(argstr='-noisemap %s', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), outlier=dict(argstr='-outliermap %s', ), @@ -49,10 +43,8 @@ def test_ModelFit_inputs(): ), tau=dict(argstr='-tau %G', ), - terminal_output=dict(nohash=True, - ), ) - inputs = ModelFit.input_spec() + inputs = ModelFit._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -62,7 +54,7 @@ def test_ModelFit_inputs(): def test_ModelFit_outputs(): output_map = dict(fitted_data=dict(), ) - outputs = ModelFit.output_spec() + outputs = ModelFit._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_NIfTIDT2Camino.py b/nipype/interfaces/camino/tests/test_auto_NIfTIDT2Camino.py index dd710905b2..3cbd6834f8 100644 --- a/nipype/interfaces/camino/tests/test_auto_NIfTIDT2Camino.py +++ b/nipype/interfaces/camino/tests/test_auto_NIfTIDT2Camino.py @@ -8,12 +8,6 @@ def test_NIfTIDT2Camino_inputs(): ), bgmask=dict(argstr='-bgmask %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', mandatory=True, position=1, @@ -21,8 +15,8 @@ def test_NIfTIDT2Camino_inputs(): lns0_file=dict(argstr='-lns0 %s', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), s0_file=dict(argstr='-s0 %s', ), @@ -30,12 +24,10 @@ def test_NIfTIDT2Camino_inputs(): ), scaleslope=dict(argstr='-scaleslope %s', ), - terminal_output=dict(nohash=True, - ), uppertriangular=dict(argstr='-uppertriangular %s', ), ) - inputs = NIfTIDT2Camino.input_spec() + inputs = NIfTIDT2Camino._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_NIfTIDT2Camino_inputs(): def test_NIfTIDT2Camino_outputs(): output_map = dict(out_file=dict(), ) - outputs = NIfTIDT2Camino.output_spec() + outputs = NIfTIDT2Camino._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_PicoPDFs.py b/nipype/interfaces/camino/tests/test_auto_PicoPDFs.py index 4f4a0b75be..4081f2beab 100644 --- a/nipype/interfaces/camino/tests/test_auto_PicoPDFs.py +++ b/nipype/interfaces/camino/tests/test_auto_PicoPDFs.py @@ -8,12 +8,6 @@ def test_PicoPDFs_inputs(): ), directmap=dict(argstr='-directmap', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='< %s', mandatory=True, position=1, @@ -32,17 +26,15 @@ def test_PicoPDFs_inputs(): units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), pdf=dict(argstr='-pdf %s', position=4, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = PicoPDFs.input_spec() + inputs = PicoPDFs._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_PicoPDFs_inputs(): def test_PicoPDFs_outputs(): output_map = dict(pdfs=dict(), ) - outputs = PicoPDFs.output_spec() + outputs = PicoPDFs._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_ProcStreamlines.py b/nipype/interfaces/camino/tests/test_auto_ProcStreamlines.py index 99ecff3624..284f23fdc4 100644 --- a/nipype/interfaces/camino/tests/test_auto_ProcStreamlines.py +++ b/nipype/interfaces/camino/tests/test_auto_ProcStreamlines.py @@ -18,16 +18,10 @@ def test_ProcStreamlines_inputs(): ), endpointfile=dict(argstr='-endpointfile %s', ), - environ=dict(nohash=True, - usedefault=True, - ), exclusionfile=dict(argstr='-exclusionfile %s', ), gzip=dict(argstr='-gzip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', mandatory=True, position=1, @@ -53,8 +47,8 @@ def test_ProcStreamlines_inputs(): noresample=dict(argstr='-noresample', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), outputacm=dict(argstr='-outputacm', requires=['outputroot', 'seedfile'], @@ -88,8 +82,6 @@ def test_ProcStreamlines_inputs(): ), targetfile=dict(argstr='-targetfile %s', ), - terminal_output=dict(nohash=True, - ), truncateinexclusion=dict(argstr='-truncateinexclusion', ), truncateloops=dict(argstr='-truncateloops', @@ -100,7 +92,7 @@ def test_ProcStreamlines_inputs(): waypointfile=dict(argstr='-waypointfile %s', ), ) - inputs = ProcStreamlines.input_spec() + inputs = ProcStreamlines._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -111,7 +103,7 @@ def test_ProcStreamlines_outputs(): output_map = dict(outputroot_files=dict(), proc=dict(), ) - outputs = ProcStreamlines.output_spec() + outputs = ProcStreamlines._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_QBallMX.py b/nipype/interfaces/camino/tests/test_auto_QBallMX.py index 9a4b2375c8..1b4716b7a7 100644 --- a/nipype/interfaces/camino/tests/test_auto_QBallMX.py +++ b/nipype/interfaces/camino/tests/test_auto_QBallMX.py @@ -9,18 +9,12 @@ def test_QBallMX_inputs(): basistype=dict(argstr='-basistype %s', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), order=dict(argstr='-order %d', units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), rbfpointset=dict(argstr='-rbfpointset %d', units='NA', @@ -34,10 +28,8 @@ def test_QBallMX_inputs(): smoothingsigma=dict(argstr='-smoothingsigma %f', units='NA', ), - terminal_output=dict(nohash=True, - ), ) - inputs = QBallMX.input_spec() + inputs = QBallMX._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_QBallMX_inputs(): def test_QBallMX_outputs(): output_map = dict(qmat=dict(), ) - outputs = QBallMX.output_spec() + outputs = QBallMX._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_SFLUTGen.py b/nipype/interfaces/camino/tests/test_auto_SFLUTGen.py index 6d59c40c3e..ca2aa907c9 100644 --- a/nipype/interfaces/camino/tests/test_auto_SFLUTGen.py +++ b/nipype/interfaces/camino/tests/test_auto_SFLUTGen.py @@ -11,12 +11,6 @@ def test_SFLUTGen_inputs(): ), directmap=dict(argstr='-directmap', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', mandatory=True, ), @@ -30,8 +24,8 @@ def test_SFLUTGen_inputs(): units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), outputstem=dict(argstr='-outputstem %s', usedefault=True, @@ -39,10 +33,8 @@ def test_SFLUTGen_inputs(): pdf=dict(argstr='-pdf %s', usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = SFLUTGen.input_spec() + inputs = SFLUTGen._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +45,7 @@ def test_SFLUTGen_outputs(): output_map = dict(lut_one_fibre=dict(), lut_two_fibres=dict(), ) - outputs = SFLUTGen.output_spec() + outputs = SFLUTGen._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_SFPICOCalibData.py b/nipype/interfaces/camino/tests/test_auto_SFPICOCalibData.py index 4adfe50709..2e99baa730 100644 --- a/nipype/interfaces/camino/tests/test_auto_SFPICOCalibData.py +++ b/nipype/interfaces/camino/tests/test_auto_SFPICOCalibData.py @@ -6,12 +6,6 @@ def test_SFPICOCalibData_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), info_file=dict(argstr='-infooutputfile %s', genfile=True, hash_files=False, @@ -24,8 +18,8 @@ def test_SFPICOCalibData_inputs(): units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), scheme_file=dict(argstr='-schemefile %s', mandatory=True, @@ -36,8 +30,6 @@ def test_SFPICOCalibData_inputs(): snr=dict(argstr='-snr %f', units='NA', ), - terminal_output=dict(nohash=True, - ), trace=dict(argstr='-trace %f', units='NA', ), @@ -60,7 +52,7 @@ def test_SFPICOCalibData_inputs(): units='NA', ), ) - inputs = SFPICOCalibData.input_spec() + inputs = SFPICOCalibData._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -71,7 +63,7 @@ def test_SFPICOCalibData_outputs(): output_map = dict(PICOCalib=dict(), calib_info=dict(), ) - outputs = SFPICOCalibData.output_spec() + outputs = SFPICOCalibData._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_SFPeaks.py b/nipype/interfaces/camino/tests/test_auto_SFPeaks.py index 69c85404c1..49067b8027 100644 --- a/nipype/interfaces/camino/tests/test_auto_SFPeaks.py +++ b/nipype/interfaces/camino/tests/test_auto_SFPeaks.py @@ -9,12 +9,6 @@ def test_SFPeaks_inputs(): density=dict(argstr='-density %d', units='NA', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', mandatory=True, ), @@ -33,8 +27,8 @@ def test_SFPeaks_inputs(): units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), pdthresh=dict(argstr='-pdthresh %f', units='NA', @@ -53,10 +47,8 @@ def test_SFPeaks_inputs(): stdsfrommean=dict(argstr='-stdsfrommean %f', units='NA', ), - terminal_output=dict(nohash=True, - ), ) - inputs = SFPeaks.input_spec() + inputs = SFPeaks._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -66,7 +58,7 @@ def test_SFPeaks_inputs(): def test_SFPeaks_outputs(): output_map = dict(peaks=dict(), ) - outputs = SFPeaks.output_spec() + outputs = SFPeaks._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_Shredder.py b/nipype/interfaces/camino/tests/test_auto_Shredder.py index 7f36415c0c..b97f46acbf 100644 --- a/nipype/interfaces/camino/tests/test_auto_Shredder.py +++ b/nipype/interfaces/camino/tests/test_auto_Shredder.py @@ -10,12 +10,6 @@ def test_Shredder_inputs(): position=2, units='NA', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='< %s', mandatory=True, position=-2, @@ -25,17 +19,15 @@ def test_Shredder_inputs(): units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), space=dict(argstr='%d', position=3, units='NA', ), - terminal_output=dict(nohash=True, - ), ) - inputs = Shredder.input_spec() + inputs = Shredder._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_Shredder_inputs(): def test_Shredder_outputs(): output_map = dict(shredded=dict(), ) - outputs = Shredder.output_spec() + outputs = Shredder._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_Track.py b/nipype/interfaces/camino/tests/test_auto_Track.py index a8fd980b79..7aabc48119 100644 --- a/nipype/interfaces/camino/tests/test_auto_Track.py +++ b/nipype/interfaces/camino/tests/test_auto_Track.py @@ -18,14 +18,8 @@ def test_Track_inputs(): data_dims=dict(argstr='-datadims %s', units='voxels', ), - environ=dict(nohash=True, - usedefault=True, - ), gzip=dict(argstr='-gzip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', position=1, ), @@ -59,8 +53,6 @@ def test_Track_inputs(): stepsize=dict(argstr='-stepsize %f', requires=['tracker'], ), - terminal_output=dict(nohash=True, - ), tracker=dict(argstr='-tracker %s', usedefault=True, ), @@ -68,7 +60,7 @@ def test_Track_inputs(): units='mm', ), ) - inputs = Track.input_spec() + inputs = Track._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -78,7 +70,7 @@ def test_Track_inputs(): def test_Track_outputs(): output_map = dict(tracked=dict(), ) - outputs = Track.output_spec() + outputs = Track._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_TrackBallStick.py b/nipype/interfaces/camino/tests/test_auto_TrackBallStick.py index 1d563f873c..4472984b04 100644 --- a/nipype/interfaces/camino/tests/test_auto_TrackBallStick.py +++ b/nipype/interfaces/camino/tests/test_auto_TrackBallStick.py @@ -18,14 +18,8 @@ def test_TrackBallStick_inputs(): data_dims=dict(argstr='-datadims %s', units='voxels', ), - environ=dict(nohash=True, - usedefault=True, - ), gzip=dict(argstr='-gzip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', position=1, ), @@ -59,8 +53,6 @@ def test_TrackBallStick_inputs(): stepsize=dict(argstr='-stepsize %f', requires=['tracker'], ), - terminal_output=dict(nohash=True, - ), tracker=dict(argstr='-tracker %s', usedefault=True, ), @@ -68,7 +60,7 @@ def test_TrackBallStick_inputs(): units='mm', ), ) - inputs = TrackBallStick.input_spec() + inputs = TrackBallStick._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -78,7 +70,7 @@ def test_TrackBallStick_inputs(): def test_TrackBallStick_outputs(): output_map = dict(tracked=dict(), ) - outputs = TrackBallStick.output_spec() + outputs = TrackBallStick._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_TrackBayesDirac.py b/nipype/interfaces/camino/tests/test_auto_TrackBayesDirac.py index f2c2aecede..ab0497466e 100644 --- a/nipype/interfaces/camino/tests/test_auto_TrackBayesDirac.py +++ b/nipype/interfaces/camino/tests/test_auto_TrackBayesDirac.py @@ -24,18 +24,12 @@ def test_TrackBayesDirac_inputs(): ), datamodel=dict(argstr='-datamodel %s', ), - environ=dict(nohash=True, - usedefault=True, - ), extpriordatatype=dict(argstr='-extpriordatatype %s', ), extpriorfile=dict(argstr='-extpriorfile %s', ), gzip=dict(argstr='-gzip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', position=1, ), @@ -79,8 +73,6 @@ def test_TrackBayesDirac_inputs(): stepsize=dict(argstr='-stepsize %f', requires=['tracker'], ), - terminal_output=dict(nohash=True, - ), tracker=dict(argstr='-tracker %s', usedefault=True, ), @@ -88,7 +80,7 @@ def test_TrackBayesDirac_inputs(): units='mm', ), ) - inputs = TrackBayesDirac.input_spec() + inputs = TrackBayesDirac._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -98,7 +90,7 @@ def test_TrackBayesDirac_inputs(): def test_TrackBayesDirac_outputs(): output_map = dict(tracked=dict(), ) - outputs = TrackBayesDirac.output_spec() + outputs = TrackBayesDirac._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_TrackBedpostxDeter.py b/nipype/interfaces/camino/tests/test_auto_TrackBedpostxDeter.py index 9f9e40d284..7f7c8a8c3f 100644 --- a/nipype/interfaces/camino/tests/test_auto_TrackBedpostxDeter.py +++ b/nipype/interfaces/camino/tests/test_auto_TrackBedpostxDeter.py @@ -21,14 +21,8 @@ def test_TrackBedpostxDeter_inputs(): data_dims=dict(argstr='-datadims %s', units='voxels', ), - environ=dict(nohash=True, - usedefault=True, - ), gzip=dict(argstr='-gzip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', position=1, ), @@ -65,8 +59,6 @@ def test_TrackBedpostxDeter_inputs(): stepsize=dict(argstr='-stepsize %f', requires=['tracker'], ), - terminal_output=dict(nohash=True, - ), tracker=dict(argstr='-tracker %s', usedefault=True, ), @@ -74,7 +66,7 @@ def test_TrackBedpostxDeter_inputs(): units='mm', ), ) - inputs = TrackBedpostxDeter.input_spec() + inputs = TrackBedpostxDeter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -84,7 +76,7 @@ def test_TrackBedpostxDeter_inputs(): def test_TrackBedpostxDeter_outputs(): output_map = dict(tracked=dict(), ) - outputs = TrackBedpostxDeter.output_spec() + outputs = TrackBedpostxDeter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_TrackBedpostxProba.py b/nipype/interfaces/camino/tests/test_auto_TrackBedpostxProba.py index 40f01d1b37..8ac2bb0331 100644 --- a/nipype/interfaces/camino/tests/test_auto_TrackBedpostxProba.py +++ b/nipype/interfaces/camino/tests/test_auto_TrackBedpostxProba.py @@ -21,14 +21,8 @@ def test_TrackBedpostxProba_inputs(): data_dims=dict(argstr='-datadims %s', units='voxels', ), - environ=dict(nohash=True, - usedefault=True, - ), gzip=dict(argstr='-gzip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', position=1, ), @@ -68,8 +62,6 @@ def test_TrackBedpostxProba_inputs(): stepsize=dict(argstr='-stepsize %f', requires=['tracker'], ), - terminal_output=dict(nohash=True, - ), tracker=dict(argstr='-tracker %s', usedefault=True, ), @@ -77,7 +69,7 @@ def test_TrackBedpostxProba_inputs(): units='mm', ), ) - inputs = TrackBedpostxProba.input_spec() + inputs = TrackBedpostxProba._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -87,7 +79,7 @@ def test_TrackBedpostxProba_inputs(): def test_TrackBedpostxProba_outputs(): output_map = dict(tracked=dict(), ) - outputs = TrackBedpostxProba.output_spec() + outputs = TrackBedpostxProba._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_TrackBootstrap.py b/nipype/interfaces/camino/tests/test_auto_TrackBootstrap.py index 091fa6bd90..19ce772af9 100644 --- a/nipype/interfaces/camino/tests/test_auto_TrackBootstrap.py +++ b/nipype/interfaces/camino/tests/test_auto_TrackBootstrap.py @@ -23,14 +23,8 @@ def test_TrackBootstrap_inputs(): data_dims=dict(argstr='-datadims %s', units='voxels', ), - environ=dict(nohash=True, - usedefault=True, - ), gzip=dict(argstr='-gzip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', position=1, ), @@ -72,8 +66,6 @@ def test_TrackBootstrap_inputs(): stepsize=dict(argstr='-stepsize %f', requires=['tracker'], ), - terminal_output=dict(nohash=True, - ), tracker=dict(argstr='-tracker %s', usedefault=True, ), @@ -81,7 +73,7 @@ def test_TrackBootstrap_inputs(): units='mm', ), ) - inputs = TrackBootstrap.input_spec() + inputs = TrackBootstrap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -91,7 +83,7 @@ def test_TrackBootstrap_inputs(): def test_TrackBootstrap_outputs(): output_map = dict(tracked=dict(), ) - outputs = TrackBootstrap.output_spec() + outputs = TrackBootstrap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_TrackDT.py b/nipype/interfaces/camino/tests/test_auto_TrackDT.py index 0376ff7d55..e4de064dce 100644 --- a/nipype/interfaces/camino/tests/test_auto_TrackDT.py +++ b/nipype/interfaces/camino/tests/test_auto_TrackDT.py @@ -18,14 +18,8 @@ def test_TrackDT_inputs(): data_dims=dict(argstr='-datadims %s', units='voxels', ), - environ=dict(nohash=True, - usedefault=True, - ), gzip=dict(argstr='-gzip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', position=1, ), @@ -59,8 +53,6 @@ def test_TrackDT_inputs(): stepsize=dict(argstr='-stepsize %f', requires=['tracker'], ), - terminal_output=dict(nohash=True, - ), tracker=dict(argstr='-tracker %s', usedefault=True, ), @@ -68,7 +60,7 @@ def test_TrackDT_inputs(): units='mm', ), ) - inputs = TrackDT.input_spec() + inputs = TrackDT._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -78,7 +70,7 @@ def test_TrackDT_inputs(): def test_TrackDT_outputs(): output_map = dict(tracked=dict(), ) - outputs = TrackDT.output_spec() + outputs = TrackDT._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_TrackPICo.py b/nipype/interfaces/camino/tests/test_auto_TrackPICo.py index c95a7e8812..edb1b005e8 100644 --- a/nipype/interfaces/camino/tests/test_auto_TrackPICo.py +++ b/nipype/interfaces/camino/tests/test_auto_TrackPICo.py @@ -18,14 +18,8 @@ def test_TrackPICo_inputs(): data_dims=dict(argstr='-datadims %s', units='voxels', ), - environ=dict(nohash=True, - usedefault=True, - ), gzip=dict(argstr='-gzip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-inputfile %s', position=1, ), @@ -64,8 +58,6 @@ def test_TrackPICo_inputs(): stepsize=dict(argstr='-stepsize %f', requires=['tracker'], ), - terminal_output=dict(nohash=True, - ), tracker=dict(argstr='-tracker %s', usedefault=True, ), @@ -73,7 +65,7 @@ def test_TrackPICo_inputs(): units='mm', ), ) - inputs = TrackPICo.input_spec() + inputs = TrackPICo._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -83,7 +75,7 @@ def test_TrackPICo_inputs(): def test_TrackPICo_outputs(): output_map = dict(tracked=dict(), ) - outputs = TrackPICo.output_spec() + outputs = TrackPICo._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_TractShredder.py b/nipype/interfaces/camino/tests/test_auto_TractShredder.py index d18ec2e9ca..eef2907b71 100644 --- a/nipype/interfaces/camino/tests/test_auto_TractShredder.py +++ b/nipype/interfaces/camino/tests/test_auto_TractShredder.py @@ -10,12 +10,6 @@ def test_TractShredder_inputs(): position=2, units='NA', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='< %s', mandatory=True, position=-2, @@ -25,17 +19,15 @@ def test_TractShredder_inputs(): units='NA', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), space=dict(argstr='%d', position=3, units='NA', ), - terminal_output=dict(nohash=True, - ), ) - inputs = TractShredder.input_spec() + inputs = TractShredder._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_TractShredder_inputs(): def test_TractShredder_outputs(): output_map = dict(shredded=dict(), ) - outputs = TractShredder.output_spec() + outputs = TractShredder._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/tests/test_auto_VtkStreamlines.py b/nipype/interfaces/camino/tests/test_auto_VtkStreamlines.py index 805f4709cb..9aa6f894cf 100644 --- a/nipype/interfaces/camino/tests/test_auto_VtkStreamlines.py +++ b/nipype/interfaces/camino/tests/test_auto_VtkStreamlines.py @@ -8,12 +8,6 @@ def test_VtkStreamlines_inputs(): ), colourorient=dict(argstr='-colourorient', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr=' < %s', mandatory=True, position=-2, @@ -26,8 +20,8 @@ def test_VtkStreamlines_inputs(): interpolatescalars=dict(argstr='-interpolatescalars', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), scalar_file=dict(argstr='-scalarfile %s', position=3, @@ -38,14 +32,12 @@ def test_VtkStreamlines_inputs(): target_file=dict(argstr='-targetfile %s', position=2, ), - terminal_output=dict(nohash=True, - ), voxeldims=dict(argstr='-voxeldims %s', position=4, units='mm', ), ) - inputs = VtkStreamlines.input_spec() + inputs = VtkStreamlines._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_VtkStreamlines_inputs(): def test_VtkStreamlines_outputs(): output_map = dict(vtk=dict(), ) - outputs = VtkStreamlines.output_spec() + outputs = VtkStreamlines._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino/utils.py b/nipype/interfaces/camino/utils.py index 19fe6ac768..c69ec736d7 100644 --- a/nipype/interfaces/camino/utils.py +++ b/nipype/interfaces/camino/utils.py @@ -52,14 +52,13 @@ class ImageStats(CommandLine): >>> imstats.run() # doctest: +SKIP """ _cmd = 'imagestats' - input_spec = ImageStatsInputSpec - output_spec = ImageStatsOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = ImageStatsInputSpec + _output_spec = ImageStatsOutputSpec + def _post_run(self): + + self.outputs.out_file = os.path.abspath(self._gen_outfilename()) + def _gen_outfilename(self): output_root = self.inputs.output_root first_file = self.inputs.in_files[0] diff --git a/nipype/interfaces/camino2trackvis/convert.py b/nipype/interfaces/camino2trackvis/convert.py index 9075a06ee2..b609916b4f 100644 --- a/nipype/interfaces/camino2trackvis/convert.py +++ b/nipype/interfaces/camino2trackvis/convert.py @@ -70,14 +70,13 @@ class Camino2Trackvis(CommandLine): """ _cmd = 'camino_to_trackvis' - input_spec = Camino2TrackvisInputSpec - output_spec = Camino2TrackvisOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['trackvis'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = Camino2TrackvisInputSpec + _output_spec = Camino2TrackvisOutputSpec + def _post_run(self): + + self.outputs.trackvis = os.path.abspath(self._gen_outfilename()) + def _gen_filename(self, name): if name is 'out_file': return self._gen_outfilename() @@ -121,14 +120,13 @@ class Trackvis2CaminoOutputSpec(TraitedSpec): class Trackvis2Camino(CommandLine): _cmd = 'trackvis_to_camino' - input_spec = Trackvis2CaminoInputSpec - output_spec = Trackvis2CaminoOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['camino'] = os.path.abspath(self._gen_outfilename()) - return outputs + _input_spec = Trackvis2CaminoInputSpec + _output_spec = Trackvis2CaminoOutputSpec + def _post_run(self): + + self.outputs.camino = os.path.abspath(self._gen_outfilename()) + def _gen_filename(self, name): if name is 'out_file': return self._gen_outfilename() diff --git a/nipype/interfaces/camino2trackvis/tests/test_auto_Camino2Trackvis.py b/nipype/interfaces/camino2trackvis/tests/test_auto_Camino2Trackvis.py index 4feaae6bf3..c7f044866f 100644 --- a/nipype/interfaces/camino2trackvis/tests/test_auto_Camino2Trackvis.py +++ b/nipype/interfaces/camino2trackvis/tests/test_auto_Camino2Trackvis.py @@ -11,12 +11,6 @@ def test_Camino2Trackvis_inputs(): position=4, sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, position=1, @@ -32,8 +26,6 @@ def test_Camino2Trackvis_inputs(): genfile=True, position=2, ), - terminal_output=dict(nohash=True, - ), voxel_dims=dict(argstr='-x %s', mandatory=True, position=5, @@ -44,7 +36,7 @@ def test_Camino2Trackvis_inputs(): position=6, ), ) - inputs = Camino2Trackvis.input_spec() + inputs = Camino2Trackvis._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -54,7 +46,7 @@ def test_Camino2Trackvis_inputs(): def test_Camino2Trackvis_outputs(): output_map = dict(trackvis=dict(), ) - outputs = Camino2Trackvis.output_spec() + outputs = Camino2Trackvis._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/camino2trackvis/tests/test_auto_Trackvis2Camino.py b/nipype/interfaces/camino2trackvis/tests/test_auto_Trackvis2Camino.py index fe24f0f99b..821ab67960 100644 --- a/nipype/interfaces/camino2trackvis/tests/test_auto_Trackvis2Camino.py +++ b/nipype/interfaces/camino2trackvis/tests/test_auto_Trackvis2Camino.py @@ -9,12 +9,6 @@ def test_Trackvis2Camino_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, position=1, @@ -23,10 +17,8 @@ def test_Trackvis2Camino_inputs(): genfile=True, position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Trackvis2Camino.input_spec() + inputs = Trackvis2Camino._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_Trackvis2Camino_inputs(): def test_Trackvis2Camino_outputs(): output_map = dict(camino=dict(), ) - outputs = Trackvis2Camino.output_spec() + outputs = Trackvis2Camino._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/cmtk/cmtk.py b/nipype/interfaces/cmtk/cmtk.py index f527cccc0a..7e56191a88 100644 --- a/nipype/interfaces/cmtk/cmtk.py +++ b/nipype/interfaces/cmtk/cmtk.py @@ -21,7 +21,7 @@ import networkx as nx import scipy.io as sio -from ..base import (BaseInterface, BaseInterfaceInputSpec, traits, +from ..base import (BaseInterface, BaseInputSpec, traits, File, TraitedSpec, InputMultiPath, Directory, OutputMultiPath, isdefined) from ...utils.filemanip import split_filename @@ -455,8 +455,8 @@ class CreateMatrix(BaseInterface): >>> conmap.run() # doctest: +SKIP """ - input_spec = CreateMatrixInputSpec - output_spec = CreateMatrixOutputSpec + _input_spec = CreateMatrixInputSpec + _output_spec = CreateMatrixOutputSpec def _run_interface(self, runtime): if isdefined(self.inputs.out_matrix_file): @@ -496,8 +496,8 @@ def _run_interface(self, runtime): matrix_file, matrix_mat_file, endpoint_name, self.inputs.count_region_intersections) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + if isdefined(self.inputs.out_matrix_file): path, name, _ = split_filename(self.inputs.out_matrix_file) out_matrix_file = op.abspath(name + '.pck') @@ -506,8 +506,8 @@ def _list_outputs(self): out_matrix_file = op.abspath(self._gen_outfilename('.pck')) out_intersection_matrix_file = op.abspath(self._gen_outfilename('_intersections.pck')) - outputs['matrix_file'] = out_matrix_file - outputs['intersection_matrix_file'] = out_intersection_matrix_file + self.outputs.matrix_file = out_matrix_file + self.outputs.intersection_matrix_file = out_intersection_matrix_file matrix_mat_file = op.abspath(self.inputs.out_matrix_mat_file) path, name, ext = split_filename(matrix_mat_file) @@ -515,59 +515,58 @@ def _list_outputs(self): ext = '.mat' matrix_mat_file = matrix_mat_file + ext - outputs['matrix_mat_file'] = matrix_mat_file + self.outputs.matrix_mat_file = matrix_mat_file if isdefined(self.inputs.out_mean_fiber_length_matrix_mat_file): - outputs['mean_fiber_length_matrix_mat_file'] = op.abspath(self.inputs.out_mean_fiber_length_matrix_mat_file) + self.outputs.mean_fiber_length_matrix_mat_file = op.abspath(self.inputs.out_mean_fiber_length_matrix_mat_file) else: - outputs['mean_fiber_length_matrix_mat_file'] = op.abspath(self._gen_outfilename('_mean_fiber_length.mat')) + self.outputs.mean_fiber_length_matrix_mat_file = op.abspath(self._gen_outfilename('_mean_fiber_length.mat')) if isdefined(self.inputs.out_median_fiber_length_matrix_mat_file): - outputs['median_fiber_length_matrix_mat_file'] = op.abspath(self.inputs.out_median_fiber_length_matrix_mat_file) + self.outputs.median_fiber_length_matrix_mat_file = op.abspath(self.inputs.out_median_fiber_length_matrix_mat_file) else: - outputs['median_fiber_length_matrix_mat_file'] = op.abspath(self._gen_outfilename('_median_fiber_length.mat')) + self.outputs.median_fiber_length_matrix_mat_file = op.abspath(self._gen_outfilename('_median_fiber_length.mat')) if isdefined(self.inputs.out_fiber_length_std_matrix_mat_file): - outputs['fiber_length_std_matrix_mat_file'] = op.abspath(self.inputs.out_fiber_length_std_matrix_mat_file) + self.outputs.fiber_length_std_matrix_mat_file = op.abspath(self.inputs.out_fiber_length_std_matrix_mat_file) else: - outputs['fiber_length_std_matrix_mat_file'] = op.abspath(self._gen_outfilename('_fiber_length_std.mat')) + self.outputs.fiber_length_std_matrix_mat_file = op.abspath(self._gen_outfilename('_fiber_length_std.mat')) if isdefined(self.inputs.out_intersection_matrix_mat_file): - outputs['intersection_matrix_mat_file'] = op.abspath(self.inputs.out_intersection_matrix_mat_file) + self.outputs.intersection_matrix_mat_file = op.abspath(self.inputs.out_intersection_matrix_mat_file) else: - outputs['intersection_matrix_mat_file'] = op.abspath(self._gen_outfilename('_intersections.mat')) + self.outputs.intersection_matrix_mat_file = op.abspath(self._gen_outfilename('_intersections.mat')) if isdefined(self.inputs.out_endpoint_array_name): endpoint_name = self.inputs.out_endpoint_array_name - outputs['endpoint_file'] = op.abspath(self.inputs.out_endpoint_array_name + '_endpoints.npy') - outputs['endpoint_file_mm'] = op.abspath(self.inputs.out_endpoint_array_name + '_endpointsmm.npy') - outputs['fiber_length_file'] = op.abspath(self.inputs.out_endpoint_array_name + '_final_fiberslength.npy') - outputs['fiber_label_file'] = op.abspath(self.inputs.out_endpoint_array_name + '_filtered_fiberslabel.npy') - outputs['fiber_labels_noorphans'] = op.abspath(self.inputs.out_endpoint_array_name + '_final_fiberslabels.npy') + self.outputs.endpoint_file = op.abspath(self.inputs.out_endpoint_array_name + '_endpoints.npy') + self.outputs.endpoint_file_mm = op.abspath(self.inputs.out_endpoint_array_name + '_endpointsmm.npy') + self.outputs.fiber_length_file = op.abspath(self.inputs.out_endpoint_array_name + '_final_fiberslength.npy') + self.outputs.fiber_label_file = op.abspath(self.inputs.out_endpoint_array_name + '_filtered_fiberslabel.npy') + self.outputs.fiber_labels_noorphans = op.abspath(self.inputs.out_endpoint_array_name + '_final_fiberslabels.npy') else: _, endpoint_name, _ = split_filename(self.inputs.tract_file) - outputs['endpoint_file'] = op.abspath(endpoint_name + '_endpoints.npy') - outputs['endpoint_file_mm'] = op.abspath(endpoint_name + '_endpointsmm.npy') - outputs['fiber_length_file'] = op.abspath(endpoint_name + '_final_fiberslength.npy') - outputs['fiber_label_file'] = op.abspath(endpoint_name + '_filtered_fiberslabel.npy') - outputs['fiber_labels_noorphans'] = op.abspath(endpoint_name + '_final_fiberslabels.npy') + self.outputs.endpoint_file = op.abspath(endpoint_name + '_endpoints.npy') + self.outputs.endpoint_file_mm = op.abspath(endpoint_name + '_endpointsmm.npy') + self.outputs.fiber_length_file = op.abspath(endpoint_name + '_final_fiberslength.npy') + self.outputs.fiber_label_file = op.abspath(endpoint_name + '_filtered_fiberslabel.npy') + self.outputs.fiber_labels_noorphans = op.abspath(endpoint_name + '_final_fiberslabels.npy') if self.inputs.count_region_intersections: - outputs['matrix_files'] = [out_matrix_file, out_intersection_matrix_file] - outputs['matlab_matrix_files'] = [outputs['matrix_mat_file'], - outputs['mean_fiber_length_matrix_mat_file'], outputs['median_fiber_length_matrix_mat_file'], - outputs['fiber_length_std_matrix_mat_file'], outputs['intersection_matrix_mat_file']] + self.outputs.matrix_files = [out_matrix_file, out_intersection_matrix_file] + self.outputs.matlab_matrix_files = [self.outputs.matrix_mat_file, + self.outputs.mean_fiber_length_matrix_mat_file, self.outputs.median_fiber_length_matrix_mat_file, + self.outputs.fiber_length_std_matrix_mat_file, self.outputs.intersection_matrix_mat_file] else: - outputs['matrix_files'] = [out_matrix_file] - outputs['matlab_matrix_files'] = [outputs['matrix_mat_file'], - outputs['mean_fiber_length_matrix_mat_file'], outputs['median_fiber_length_matrix_mat_file'], - outputs['fiber_length_std_matrix_mat_file']] - - outputs['filtered_tractography'] = op.abspath(endpoint_name + '_streamline_final.trk') - outputs['filtered_tractography_by_intersections'] = op.abspath(endpoint_name + '_intersections_streamline_final.trk') - outputs['filtered_tractographies'] = [outputs['filtered_tractography'], outputs['filtered_tractography_by_intersections']] - outputs['stats_file'] = op.abspath(endpoint_name + '_statistics.mat') - return outputs - + self.outputs.matrix_files = [out_matrix_file] + self.outputs.matlab_matrix_files = [self.outputs.matrix_mat_file, + self.outputs.mean_fiber_length_matrix_mat_file, self.outputs.median_fiber_length_matrix_mat_file, + self.outputs.fiber_length_std_matrix_mat_file] + + self.outputs.filtered_tractography = op.abspath(endpoint_name + '_streamline_final.trk') + self.outputs.filtered_tractography_by_intersections = op.abspath(endpoint_name + '_intersections_streamline_final.trk') + self.outputs.filtered_tractographies = [self.outputs.filtered_tractography, self.outputs.filtered_tractography_by_intersections] + self.outputs.stats_file = op.abspath(endpoint_name + '_statistics.mat') + def _gen_outfilename(self, ext): if ext.endswith("mat") and isdefined(self.inputs.out_matrix_mat_file): _, name, _ = split_filename(self.inputs.out_matrix_mat_file) @@ -578,7 +577,7 @@ def _gen_outfilename(self, ext): return name + ext -class ROIGenInputSpec(BaseInterfaceInputSpec): +class ROIGenInputSpec(BaseInputSpec): aparc_aseg_file = File(exists=True, mandatory=True, desc='Freesurfer aparc+aseg file') LUT_file = File(exists=True, xor=['use_freesurfer_LUT'], desc='Custom lookup table (cf. FreeSurferColorLUT.txt)') use_freesurfer_LUT = traits.Bool(xor=['LUT_file'], desc='Boolean value; Set to True to use default Freesurfer LUT, False for custom LUT') @@ -614,8 +613,8 @@ class ROIGen(BaseInterface): >>> labelDict # doctest: +SKIP """ - input_spec = ROIGenInputSpec - output_spec = ROIGenOutputSpec + _input_spec = ROIGenInputSpec + _output_spec = ROIGenOutputSpec def _run_interface(self, runtime): aparc_aseg_file = self.inputs.aparc_aseg_file @@ -718,18 +717,16 @@ def _run_interface(self, runtime): file.close() return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): if isdefined(self.inputs.out_roi_file): - outputs['roi_file'] = op.abspath(self.inputs.out_roi_file) + self.outputs.roi_file = op.abspath(self.inputs.out_roi_file) else: - outputs['roi_file'] = op.abspath(self._gen_outfilename('nii')) + self.outputs.roi_file = op.abspath(self._gen_outfilename('nii')) if isdefined(self.inputs.out_dict_file): - outputs['dict_file'] = op.abspath(self.inputs.out_dict_file) + self.outputs.dict_file = op.abspath(self.inputs.out_dict_file) else: - outputs['dict_file'] = op.abspath(self._gen_outfilename('pck')) - return outputs - + self.outputs.dict_file = op.abspath(self._gen_outfilename('pck')) + def _gen_outfilename(self, ext): _, name, _ = split_filename(self.inputs.aparc_aseg_file) if self.inputs.use_freesurfer_LUT: @@ -756,7 +753,7 @@ def create_nodes(roi_file, resolution_network_file, out_filename): return out_filename -class CreateNodesInputSpec(BaseInterfaceInputSpec): +class CreateNodesInputSpec(BaseInputSpec): roi_file = File(exists=True, mandatory=True, desc='Region of interest file') resolution_network_file = File(exists=True, mandatory=True, desc='Parcellation file from Connectome Mapping Toolkit') out_filename = File('nodenetwork.pck', usedefault=True, desc='Output gpickled network with the nodes defined.') @@ -780,8 +777,8 @@ class CreateNodes(BaseInterface): >>> mknode.run() # doctest: +SKIP """ - input_spec = CreateNodesInputSpec - output_spec = CreateNodesOutputSpec + _input_spec = CreateNodesInputSpec + _output_spec = CreateNodesOutputSpec def _run_interface(self, runtime): iflogger.info('Creating nodes...') @@ -789,7 +786,6 @@ def _run_interface(self, runtime): iflogger.info('Saving node network to {path}'.format(path=op.abspath(self.inputs.out_filename))) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['node_network'] = op.abspath(self.inputs.out_filename) - return outputs + def _post_run(self): + self.outputs.node_network = op.abspath(self.inputs.out_filename) + \ No newline at end of file diff --git a/nipype/interfaces/cmtk/convert.py b/nipype/interfaces/cmtk/convert.py index 33ee7616b9..2bc051c8b3 100644 --- a/nipype/interfaces/cmtk/convert.py +++ b/nipype/interfaces/cmtk/convert.py @@ -14,7 +14,7 @@ import warnings import networkx as nx -from nipype.interfaces.base import (BaseInterface, BaseInterfaceInputSpec, traits, +from nipype.interfaces.base import (BaseInterface, BaseInputSpec, traits, File, TraitedSpec, InputMultiPath, isdefined) from nipype.utils.filemanip import split_filename from nipype.utils.misc import package_check @@ -28,7 +28,7 @@ import cfflib as cf -class CFFConverterInputSpec(BaseInterfaceInputSpec): +class CFFConverterInputSpec(BaseInputSpec): graphml_networks = InputMultiPath(File(exists=True), desc='list of graphML networks') gpickled_networks = InputMultiPath(File(exists=True), desc='list of gpickled Networkx graphs') @@ -75,8 +75,8 @@ class CFFConverter(BaseInterface): >>> cvt.run() # doctest: +SKIP """ - input_spec = CFFConverterInputSpec - output_spec = CFFConverterOutputSpec + _input_spec = CFFConverterInputSpec + _output_spec = CFFConverterOutputSpec def _run_interface(self, runtime): a = cf.connectome() @@ -197,16 +197,14 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): _, name, ext = split_filename(self.inputs.out_file) if not ext == '.cff': ext = '.cff' - outputs['connectome_file'] = op.abspath(name + ext) - return outputs + self.outputs.connectome_file = op.abspath(name + ext) + - -class MergeCNetworksInputSpec(BaseInterfaceInputSpec): +class MergeCNetworksInputSpec(BaseInputSpec): in_files = InputMultiPath(File(exists=True), mandatory=True, desc='List of CFF files to extract networks from') out_file = File('merged_network_connectome.cff', usedefault=True, desc='Output CFF file with all the networks added') @@ -227,8 +225,8 @@ class MergeCNetworks(BaseInterface): >>> mrg.run() # doctest: +SKIP """ - input_spec = MergeCNetworksInputSpec - output_spec = MergeCNetworksOutputSpec + _input_spec = MergeCNetworksInputSpec + _output_spec = MergeCNetworksOutputSpec def _run_interface(self, runtime): extracted_networks = [] @@ -259,10 +257,9 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): _, name, ext = split_filename(self.inputs.out_file) if not ext == '.cff': ext = '.cff' - outputs['connectome_file'] = op.abspath(name + ext) - return outputs + self.outputs.connectome_file = op.abspath(name + ext) + \ No newline at end of file diff --git a/nipype/interfaces/cmtk/nbs.py b/nipype/interfaces/cmtk/nbs.py index 8fd539691f..5553bfd636 100644 --- a/nipype/interfaces/cmtk/nbs.py +++ b/nipype/interfaces/cmtk/nbs.py @@ -7,7 +7,7 @@ import numpy as np import networkx as nx -from ..base import (BaseInterface, BaseInterfaceInputSpec, traits, +from ..base import (BaseInterface, BaseInputSpec, traits, File, TraitedSpec, InputMultiPath, OutputMultiPath, isdefined) from ...utils.misc import package_check @@ -36,7 +36,7 @@ def ntwks_to_matrices(in_files, edge_key): return matrix -class NetworkBasedStatisticInputSpec(BaseInterfaceInputSpec): +class NetworkBasedStatisticInputSpec(BaseInputSpec): in_group1 = InputMultiPath(File(exists=True), mandatory=True, desc='Networks for the first group of subjects') in_group2 = InputMultiPath(File(exists=True), mandatory=True, desc='Networks for the second group of subjects') node_position_network = File(desc='An optional network used to position the nodes for the output networks') @@ -72,8 +72,8 @@ class NetworkBasedStatistic(BaseInterface): >>> nbs.inputs.in_group2 = ['pat1.pck', 'pat2.pck'] # doctest: +SKIP >>> nbs.run() # doctest: +SKIP """ - input_spec = NetworkBasedStatisticInputSpec - output_spec = NetworkBasedStatisticOutputSpec + _input_spec = NetworkBasedStatisticInputSpec + _output_spec = NetworkBasedStatisticOutputSpec def _run_interface(self, runtime): THRESH = self.inputs.threshold @@ -127,8 +127,8 @@ def _run_interface(self, runtime): iflogger.info('Saving output p-value network as {out}'.format(out=pval_path)) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + THRESH = self.inputs.threshold K = self.inputs.number_of_permutations @@ -138,10 +138,9 @@ def _list_outputs(self): path = op.abspath('NBS_Result_' + details) pval_path = op.abspath('NBS_P_vals_' + details) - outputs['nbs_network'] = path - outputs['nbs_pval_network'] = pval_path - outputs['network_files'] = [path, pval_path] - return outputs - + self.outputs.nbs_network = path + self.outputs.nbs_pval_network = pval_path + self.outputs.network_files = [path, pval_path] + def _gen_outfilename(self, name, ext): return name + '.' + ext diff --git a/nipype/interfaces/cmtk/nx.py b/nipype/interfaces/cmtk/nx.py index 64b817a746..3a43c7da3b 100644 --- a/nipype/interfaces/cmtk/nx.py +++ b/nipype/interfaces/cmtk/nx.py @@ -19,7 +19,7 @@ import networkx as nx import scipy.io as sio -from ..base import (BaseInterface, BaseInterfaceInputSpec, traits, File, +from ..base import (BaseInterface, BaseInputSpec, traits, File, TraitedSpec, InputMultiPath, OutputMultiPath, isdefined) from ...utils.filemanip import split_filename from ...utils.misc import package_check @@ -343,7 +343,7 @@ def add_edge_data(edge_array, ntwk, above=0, below=0): return edge_ntwk -class NetworkXMetricsInputSpec(BaseInterfaceInputSpec): +class NetworkXMetricsInputSpec(BaseInputSpec): in_file = File(exists=True, mandatory=True, desc='Input network') out_k_core = File('k_core', usedefault=True, desc='Computed k-core network stored as a NetworkX pickle.') out_k_shell = File('k_shell', usedefault=True, desc='Computed k-shell network stored as a NetworkX pickle.') @@ -384,8 +384,8 @@ class NetworkXMetrics(BaseInterface): >>> nxmetrics.inputs.in_file = 'subj1.pck' >>> nxmetrics.run() # doctest: +SKIP """ - input_spec = NetworkXMetricsInputSpec - output_spec = NetworkXMetricsOutputSpec + _input_spec = NetworkXMetricsInputSpec + _output_spec = NetworkXMetricsOutputSpec def _run_interface(self, runtime): global gpickled, nodentwks, edgentwks, kntwks, matlab @@ -482,28 +482,27 @@ def _run_interface(self, runtime): dicts.append(out_file) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - outputs["k_core"] = op.abspath(self._gen_outfilename(self.inputs.out_k_core, 'pck')) - outputs["k_shell"] = op.abspath(self._gen_outfilename(self.inputs.out_k_shell, 'pck')) - outputs["k_crust"] = op.abspath(self._gen_outfilename(self.inputs.out_k_crust, 'pck')) - outputs["gpickled_network_files"] = gpickled - outputs["k_networks"] = kntwks - outputs["node_measure_networks"] = nodentwks - outputs["edge_measure_networks"] = edgentwks - outputs["matlab_dict_measures"] = dicts - outputs["global_measures_matlab"] = op.abspath(self._gen_outfilename('globalmetrics', 'mat')) - outputs["node_measures_matlab"] = op.abspath(self._gen_outfilename('nodemetrics', 'mat')) - outputs["edge_measures_matlab"] = op.abspath(self._gen_outfilename('edgemetrics', 'mat')) - outputs["matlab_matrix_files"] = [outputs["global_measures_matlab"], outputs["node_measures_matlab"], outputs["edge_measures_matlab"]] - outputs["pickled_extra_measures"] = op.abspath(self._gen_outfilename(self.inputs.out_pickled_extra_measures, 'pck')) - return outputs - + def _post_run(self): + + self.outputs.k_core = op.abspath(self._gen_outfilename(self.inputs.out_k_core, 'pck')) + self.outputs.k_shell = op.abspath(self._gen_outfilename(self.inputs.out_k_shell, 'pck')) + self.outputs.k_crust = op.abspath(self._gen_outfilename(self.inputs.out_k_crust, 'pck')) + self.outputs.gpickled_network_files = gpickled + self.outputs.k_networks = kntwks + self.outputs.node_measure_networks = nodentwks + self.outputs.edge_measure_networks = edgentwks + self.outputs.matlab_dict_measures = dicts + self.outputs.global_measures_matlab = op.abspath(self._gen_outfilename('globalmetrics', 'mat')) + self.outputs.node_measures_matlab = op.abspath(self._gen_outfilename('nodemetrics', 'mat')) + self.outputs.edge_measures_matlab = op.abspath(self._gen_outfilename('edgemetrics', 'mat')) + self.outputs.matlab_matrix_files = [self.outputs.global_measures_matlab, self.outputs.node_measures_matlab, self.outputs.edge_measures_matlab] + self.outputs.pickled_extra_measures = op.abspath(self._gen_outfilename(self.inputs.out_pickled_extra_measures, 'pck')) + def _gen_outfilename(self, name, ext): return name + '.' + ext -class AverageNetworksInputSpec(BaseInterfaceInputSpec): +class AverageNetworksInputSpec(BaseInputSpec): in_files = InputMultiPath(File(exists=True), mandatory=True, desc='Networks for a group of subjects') resolution_network_file = File(exists=True, desc='Parcellation files from Connectome Mapping Toolkit. This is not necessary' ', but if included, the interface will output the statistical maps as networkx graphs.') @@ -534,8 +533,8 @@ class AverageNetworks(BaseInterface): >>> avg.run() # doctest: +SKIP """ - input_spec = AverageNetworksInputSpec - output_spec = AverageNetworksOutputSpec + _input_spec = AverageNetworksInputSpec + _output_spec = AverageNetworksOutputSpec def _run_interface(self, runtime): if isdefined(self.inputs.resolution_network_file): @@ -547,20 +546,19 @@ def _run_interface(self, runtime): network_name, matlab_network_list = average_networks(self.inputs.in_files, ntwk_res_file, self.inputs.group_id) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + if not isdefined(self.inputs.out_gpickled_groupavg): - outputs["gpickled_groupavg"] = op.abspath(self._gen_outfilename(self.inputs.group_id + '_average', 'pck')) + self.outputs.gpickled_groupavg = op.abspath(self._gen_outfilename(self.inputs.group_id + '_average', 'pck')) else: - outputs["gpickled_groupavg"] = op.abspath(self.inputs.out_gpickled_groupavg) + self.outputs.gpickled_groupavg = op.abspath(self.inputs.out_gpickled_groupavg) if not isdefined(self.inputs.out_gexf_groupavg): - outputs["gexf_groupavg"] = op.abspath(self._gen_outfilename(self.inputs.group_id + '_average', 'gexf')) + self.outputs.gexf_groupavg = op.abspath(self._gen_outfilename(self.inputs.group_id + '_average', 'gexf')) else: - outputs["gexf_groupavg"] = op.abspath(self.inputs.out_gexf_groupavg) - - outputs["matlab_groupavgs"] = matlab_network_list - return outputs + self.outputs.gexf_groupavg = op.abspath(self.inputs.out_gexf_groupavg) + self.outputs.matlab_groupavgs = matlab_network_list + def _gen_outfilename(self, name, ext): return name + '.' + ext diff --git a/nipype/interfaces/cmtk/parcellation.py b/nipype/interfaces/cmtk/parcellation.py index 80b0e72ab0..02f9dd4cd6 100644 --- a/nipype/interfaces/cmtk/parcellation.py +++ b/nipype/interfaces/cmtk/parcellation.py @@ -20,7 +20,7 @@ import nibabel as nb import networkx as nx -from ..base import (BaseInterface, BaseInterfaceInputSpec, traits, +from ..base import (BaseInterface, BaseInputSpec, traits, File, TraitedSpec, Directory, isdefined) from ...utils.misc import package_check from ... import logging @@ -513,7 +513,7 @@ def extract(Z, shape, position, fill): return R -class ParcellateInputSpec(BaseInterfaceInputSpec): +class ParcellateInputSpec(BaseInputSpec): subject_id = traits.String(mandatory=True, desc='Subject ID') parcellation_name = traits.Enum('scale500', ['scale33', 'scale60', 'scale125', 'scale250', 'scale500'], usedefault=True) freesurfer_dir = Directory(exists=True, desc='Freesurfer main directory') @@ -564,8 +564,8 @@ class Parcellate(BaseInterface): >>> parcellate.run() # doctest: +SKIP """ - input_spec = ParcellateInputSpec - output_spec = ParcellateOutputSpec + _input_spec = ParcellateInputSpec + _output_spec = ParcellateOutputSpec def _run_interface(self, runtime): if self.inputs.subjects_dir: @@ -581,26 +581,24 @@ def _run_interface(self, runtime): crop_and_move_datasets(self.inputs.subject_id, self.inputs.subjects_dir, self.inputs.freesurfer_dir, self.inputs.parcellation_name, self.inputs.out_roi_file, self.inputs.dilation) return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): if isdefined(self.inputs.out_roi_file): - outputs['roi_file'] = op.abspath(self.inputs.out_roi_file) + self.outputs.roi_file = op.abspath(self.inputs.out_roi_file) else: - outputs['roi_file'] = op.abspath( + self.outputs.roi_file = op.abspath( self._gen_outfilename('nii.gz', 'ROI')) if self.inputs.dilation is True: - outputs['roiv_file'] = op.abspath(self._gen_outfilename( + self.outputs.roiv_file = op.abspath(self._gen_outfilename( 'nii.gz', 'ROIv')) - outputs['white_matter_mask_file'] = op.abspath('fsmask_1mm.nii.gz') - outputs['cc_unknown_file'] = op.abspath('cc_unknown.nii.gz') - outputs['ribbon_file'] = op.abspath('ribbon.nii.gz') - outputs['aseg_file'] = op.abspath('aseg.nii.gz') - outputs['roi_file_in_structural_space'] = op.abspath( + self.outputs.white_matter_mask_file = op.abspath('fsmask_1mm.nii.gz') + self.outputs.cc_unknown_file = op.abspath('cc_unknown.nii.gz') + self.outputs.ribbon_file = op.abspath('ribbon.nii.gz') + self.outputs.aseg_file = op.abspath('aseg.nii.gz') + self.outputs.roi_file_in_structural_space = op.abspath( 'ROI_HR_th.nii.gz') if self.inputs.dilation is True: - outputs['dilated_roi_file_in_structural_space'] = op.abspath( + self.outputs.dilated_roi_file_in_structural_space = op.abspath( 'ROIv_HR_th.nii.gz') - return outputs - + def _gen_outfilename(self, ext, prefix='ROI'): return prefix + '_' + self.inputs.parcellation_name + '.' + ext diff --git a/nipype/interfaces/cmtk/tests/test_auto_AverageNetworks.py b/nipype/interfaces/cmtk/tests/test_auto_AverageNetworks.py index e4d649585e..b9f8a9a29a 100644 --- a/nipype/interfaces/cmtk/tests/test_auto_AverageNetworks.py +++ b/nipype/interfaces/cmtk/tests/test_auto_AverageNetworks.py @@ -6,16 +6,13 @@ def test_AverageNetworks_inputs(): input_map = dict(group_id=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(mandatory=True, ), out_gexf_groupavg=dict(), out_gpickled_groupavg=dict(), resolution_network_file=dict(), ) - inputs = AverageNetworks.input_spec() + inputs = AverageNetworks._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -27,7 +24,7 @@ def test_AverageNetworks_outputs(): gpickled_groupavg=dict(), matlab_groupavgs=dict(), ) - outputs = AverageNetworks.output_spec() + outputs = AverageNetworks._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/cmtk/tests/test_auto_CFFConverter.py b/nipype/interfaces/cmtk/tests/test_auto_CFFConverter.py index 261a0babaa..ab5ae3a683 100644 --- a/nipype/interfaces/cmtk/tests/test_auto_CFFConverter.py +++ b/nipype/interfaces/cmtk/tests/test_auto_CFFConverter.py @@ -13,9 +13,6 @@ def test_CFFConverter_inputs(): gifti_surfaces=dict(), gpickled_networks=dict(), graphml_networks=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), license=dict(), nifti_volumes=dict(), out_file=dict(usedefault=True, @@ -31,7 +28,7 @@ def test_CFFConverter_inputs(): title=dict(), tract_files=dict(), ) - inputs = CFFConverter.input_spec() + inputs = CFFConverter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +38,7 @@ def test_CFFConverter_inputs(): def test_CFFConverter_outputs(): output_map = dict(connectome_file=dict(), ) - outputs = CFFConverter.output_spec() + outputs = CFFConverter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/cmtk/tests/test_auto_CreateMatrix.py b/nipype/interfaces/cmtk/tests/test_auto_CreateMatrix.py index c986c02c7b..63c1bd27f1 100644 --- a/nipype/interfaces/cmtk/tests/test_auto_CreateMatrix.py +++ b/nipype/interfaces/cmtk/tests/test_auto_CreateMatrix.py @@ -27,7 +27,7 @@ def test_CreateMatrix_inputs(): tract_file=dict(mandatory=True, ), ) - inputs = CreateMatrix.input_spec() + inputs = CreateMatrix._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -54,7 +54,7 @@ def test_CreateMatrix_outputs(): median_fiber_length_matrix_mat_file=dict(), stats_file=dict(), ) - outputs = CreateMatrix.output_spec() + outputs = CreateMatrix._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/cmtk/tests/test_auto_CreateNodes.py b/nipype/interfaces/cmtk/tests/test_auto_CreateNodes.py index c5d9fe4163..11aca21a80 100644 --- a/nipype/interfaces/cmtk/tests/test_auto_CreateNodes.py +++ b/nipype/interfaces/cmtk/tests/test_auto_CreateNodes.py @@ -4,17 +4,14 @@ def test_CreateNodes_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - out_filename=dict(usedefault=True, + input_map = dict(out_filename=dict(usedefault=True, ), resolution_network_file=dict(mandatory=True, ), roi_file=dict(mandatory=True, ), ) - inputs = CreateNodes.input_spec() + inputs = CreateNodes._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -24,7 +21,7 @@ def test_CreateNodes_inputs(): def test_CreateNodes_outputs(): output_map = dict(node_network=dict(), ) - outputs = CreateNodes.output_spec() + outputs = CreateNodes._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/cmtk/tests/test_auto_MergeCNetworks.py b/nipype/interfaces/cmtk/tests/test_auto_MergeCNetworks.py index 73654ced71..10881720e0 100644 --- a/nipype/interfaces/cmtk/tests/test_auto_MergeCNetworks.py +++ b/nipype/interfaces/cmtk/tests/test_auto_MergeCNetworks.py @@ -4,15 +4,12 @@ def test_MergeCNetworks_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - in_files=dict(mandatory=True, + input_map = dict(in_files=dict(mandatory=True, ), out_file=dict(usedefault=True, ), ) - inputs = MergeCNetworks.input_spec() + inputs = MergeCNetworks._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -22,7 +19,7 @@ def test_MergeCNetworks_inputs(): def test_MergeCNetworks_outputs(): output_map = dict(connectome_file=dict(), ) - outputs = MergeCNetworks.output_spec() + outputs = MergeCNetworks._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/cmtk/tests/test_auto_NetworkBasedStatistic.py b/nipype/interfaces/cmtk/tests/test_auto_NetworkBasedStatistic.py index 70857e1b98..e92478fad5 100644 --- a/nipype/interfaces/cmtk/tests/test_auto_NetworkBasedStatistic.py +++ b/nipype/interfaces/cmtk/tests/test_auto_NetworkBasedStatistic.py @@ -6,9 +6,6 @@ def test_NetworkBasedStatistic_inputs(): input_map = dict(edge_key=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_group1=dict(mandatory=True, ), in_group2=dict(mandatory=True, @@ -23,7 +20,7 @@ def test_NetworkBasedStatistic_inputs(): threshold=dict(usedefault=True, ), ) - inputs = NetworkBasedStatistic.input_spec() + inputs = NetworkBasedStatistic._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +32,7 @@ def test_NetworkBasedStatistic_outputs(): nbs_pval_network=dict(), network_files=dict(), ) - outputs = NetworkBasedStatistic.output_spec() + outputs = NetworkBasedStatistic._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/cmtk/tests/test_auto_NetworkXMetrics.py b/nipype/interfaces/cmtk/tests/test_auto_NetworkXMetrics.py index e26c389974..50400c9a2c 100644 --- a/nipype/interfaces/cmtk/tests/test_auto_NetworkXMetrics.py +++ b/nipype/interfaces/cmtk/tests/test_auto_NetworkXMetrics.py @@ -6,9 +6,6 @@ def test_NetworkXMetrics_inputs(): input_map = dict(compute_clique_related_measures=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(mandatory=True, ), out_edge_metrics_matlab=dict(genfile=True, @@ -28,7 +25,7 @@ def test_NetworkXMetrics_inputs(): treat_as_weighted_graph=dict(usedefault=True, ), ) - inputs = NetworkXMetrics.input_spec() + inputs = NetworkXMetrics._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +47,7 @@ def test_NetworkXMetrics_outputs(): node_measures_matlab=dict(), pickled_extra_measures=dict(), ) - outputs = NetworkXMetrics.output_spec() + outputs = NetworkXMetrics._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/cmtk/tests/test_auto_Parcellate.py b/nipype/interfaces/cmtk/tests/test_auto_Parcellate.py index eff984ea54..7fe54a5f6f 100644 --- a/nipype/interfaces/cmtk/tests/test_auto_Parcellate.py +++ b/nipype/interfaces/cmtk/tests/test_auto_Parcellate.py @@ -7,9 +7,6 @@ def test_Parcellate_inputs(): input_map = dict(dilation=dict(usedefault=True, ), freesurfer_dir=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), out_roi_file=dict(genfile=True, ), parcellation_name=dict(usedefault=True, @@ -18,7 +15,7 @@ def test_Parcellate_inputs(): ), subjects_dir=dict(), ) - inputs = Parcellate.input_spec() + inputs = Parcellate._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +32,7 @@ def test_Parcellate_outputs(): roiv_file=dict(), white_matter_mask_file=dict(), ) - outputs = Parcellate.output_spec() + outputs = Parcellate._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/cmtk/tests/test_auto_ROIGen.py b/nipype/interfaces/cmtk/tests/test_auto_ROIGen.py index 2869299324..eeca82d68f 100644 --- a/nipype/interfaces/cmtk/tests/test_auto_ROIGen.py +++ b/nipype/interfaces/cmtk/tests/test_auto_ROIGen.py @@ -10,9 +10,6 @@ def test_ROIGen_inputs(): ), freesurfer_dir=dict(requires=['use_freesurfer_LUT'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), out_dict_file=dict(genfile=True, ), out_roi_file=dict(genfile=True, @@ -20,7 +17,7 @@ def test_ROIGen_inputs(): use_freesurfer_LUT=dict(xor=['LUT_file'], ), ) - inputs = ROIGen.input_spec() + inputs = ROIGen._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -31,7 +28,7 @@ def test_ROIGen_outputs(): output_map = dict(dict_file=dict(), roi_file=dict(), ) - outputs = ROIGen.output_spec() + outputs = ROIGen._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dcm2nii.py b/nipype/interfaces/dcm2nii.py index b78d925517..172790ce2b 100644 --- a/nipype/interfaces/dcm2nii.py +++ b/nipype/interfaces/dcm2nii.py @@ -32,7 +32,7 @@ class Dcm2niiInputSpec(CommandLineInputSpec): gzip_output = traits.Bool(False, argstr='-g', usedefault=True) id_in_filename = traits.Bool(False, argstr='-i', usedefault=True) nii_output = traits.Bool(True, argstr='-n', usedefault=True) - output_dir = Directory(exists=True, argstr='-o %s', genfile=True) + output_dir = Directory('.', exists=True, argstr='-o %s', usedefault=True) protocol_in_filename = traits.Bool(True, argstr='-p', usedefault=True) reorient = traits.Bool(argstr='-r') spm_analyze = traits.Bool(argstr='-s', xor=['nii_output']) @@ -63,8 +63,8 @@ class Dcm2nii(CommandLine): 'dcm2nii -a y -c y -b config.ini -v y -d y -e y -g y -i n -n y -o . -p y -x n -f n functional_1.dcm' """ - input_spec = Dcm2niiInputSpec - output_spec = Dcm2niiOutputSpec + _input_spec = Dcm2niiInputSpec + _output_spec = Dcm2niiOutputSpec _cmd = 'dcm2nii' def _format_arg(self, opt, spec, val): @@ -159,15 +159,14 @@ def _parse_stdout(self, stdout): skip = False return files, reoriented_files, reoriented_and_cropped_files, bvecs, bvals - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['converted_files'] = self.output_files - outputs['reoriented_files'] = self.reoriented_files - outputs['reoriented_and_cropped_files'] = self.reoriented_and_cropped_files - outputs['bvecs'] = self.bvecs - outputs['bvals'] = self.bvals - return outputs - + def _post_run(self): + + self.outputs.converted_files = self.output_files + self.outputs.reoriented_files = self.reoriented_files + self.outputs.reoriented_and_cropped_files = self.reoriented_and_cropped_files + self.outputs.bvecs = self.bvecs + self.outputs.bvals = self.bvals + def _gen_filename(self, name): if name == 'output_dir': return os.getcwd() diff --git a/nipype/interfaces/dcmstack.py b/nipype/interfaces/dcmstack.py index a06065fa41..0112548584 100644 --- a/nipype/interfaces/dcmstack.py +++ b/nipype/interfaces/dcmstack.py @@ -53,10 +53,10 @@ class NiftiGeneratorBaseInputSpec(TraitedSpec): class NiftiGeneratorBase(BaseInterface): - '''Base class for interfaces that produce Nifti files, potentially with - embedded meta data.''' + """Base class for interfaces that produce Nifti files, potentially with + embedded meta data.""" def _get_out_path(self, meta, idx=None): - '''Return the output path for the gernerated Nifti.''' + """Return the output path for the gernerated Nifti.""" if self.inputs.out_format: out_fmt = self.inputs.out_format else: @@ -112,7 +112,7 @@ class DcmStackOutputSpec(TraitedSpec): class DcmStack(NiftiGeneratorBase): - '''Create one Nifti file from a set of DICOM files. Can optionally embed + """Create one Nifti file from a set of DICOM files. Can optionally embed meta data. Example @@ -124,9 +124,9 @@ class DcmStack(NiftiGeneratorBase): >>> stacker.run() # doctest: +SKIP >>> result.outputs.out_file # doctest: +SKIP '/path/to/cwd/sequence.nii.gz' - ''' - input_spec = DcmStackInputSpec - output_spec = DcmStackOutputSpec + """ + _input_spec = DcmStackInputSpec + _output_spec = DcmStackOutputSpec def _get_filelist(self, trait_input): if isinstance(trait_input, string_types): @@ -161,21 +161,19 @@ def _run_interface(self, runtime): nb.save(nii, self.out_path) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_file"] = self.out_path - return outputs - + def _post_run(self): + self.outputs.out_file = self.out_path + class GroupAndStackOutputSpec(TraitedSpec): out_list = traits.List(desc="List of output nifti files") class GroupAndStack(DcmStack): - '''Create (potentially) multiple Nifti files for a set of DICOM files. - ''' - input_spec = DcmStackInputSpec - output_spec = GroupAndStackOutputSpec + """Create (potentially) multiple Nifti files for a set of DICOM files. + """ + _input_spec = DcmStackInputSpec + _output_spec = GroupAndStackOutputSpec def _run_interface(self, runtime): src_paths = self._get_filelist(self.inputs.dicom_files) @@ -193,11 +191,9 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_list"] = self.out_list - return outputs - + def _post_run(self): + self.outputs.out_list = self.out_list + class LookupMetaInputSpec(TraitedSpec): in_file = File(mandatory=True, @@ -213,7 +209,7 @@ class LookupMetaInputSpec(TraitedSpec): class LookupMeta(BaseInterface): - '''Lookup meta data values from a Nifti with embedded meta data. + """Lookup meta data values from a Nifti with embedded meta data. Example ------- @@ -228,9 +224,9 @@ class LookupMeta(BaseInterface): 9500.0 >>> result.outputs.TE # doctest: +SKIP 95.0 - ''' - input_spec = LookupMetaInputSpec - output_spec = DynamicTraitedSpec + """ + _input_spec = LookupMetaInputSpec + _output_spec = DynamicTraitedSpec def _make_name_map(self): if isinstance(self.inputs.meta_keys, list): @@ -251,8 +247,7 @@ def _outputs(self): # Not sure why this is needed for out_name in list(self._meta_keys.values()): _ = getattr(outputs, out_name) - return outputs - + def _run_interface(self, runtime): # If the 'meta_keys' input is a list, covert it to a dict self._make_name_map() @@ -263,11 +258,9 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): outputs.update(self.result) - return outputs - + class CopyMetaInputSpec(TraitedSpec): src_file = File(mandatory=True, exists=True) @@ -284,10 +277,10 @@ class CopyMetaOutputSpec(TraitedSpec): class CopyMeta(BaseInterface): - '''Copy meta data from one Nifti file to another. Useful for preserving - meta data after some processing steps.''' - input_spec = CopyMetaInputSpec - output_spec = CopyMetaOutputSpec + """Copy meta data from one Nifti file to another. Useful for preserving + meta data after some processing steps.""" + _input_spec = CopyMetaInputSpec + _output_spec = CopyMetaOutputSpec def _run_interface(self, runtime): src_nii = nb.load(self.inputs.src_file) @@ -320,11 +313,9 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['dest_file'] = self.out_path - return outputs - + def _post_run(self): + self.outputs.dest_file = self.out_path + class MergeNiftiInputSpec(NiftiGeneratorBaseInputSpec): in_files = traits.List(mandatory=True, @@ -351,10 +342,10 @@ def key_func(src_nii): class MergeNifti(NiftiGeneratorBase): - '''Merge multiple Nifti files into one. Merges together meta data - extensions as well.''' - input_spec = MergeNiftiInputSpec - output_spec = MergeNiftiOutputSpec + """Merge multiple Nifti files into one. Merges together meta data + extensions as well.""" + _input_spec = MergeNiftiInputSpec + _output_spec = MergeNiftiOutputSpec def _run_interface(self, runtime): niis = [nb.load(fn) @@ -378,11 +369,9 @@ def _run_interface(self, runtime): nb.save(merged.nii_img, self.out_path) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = self.out_path - return outputs - + def _post_run(self): + self.outputs.out_file = self.out_path + class SplitNiftiInputSpec(NiftiGeneratorBaseInputSpec): in_file = File(exists=True, mandatory=True, desc="Nifti file to split") @@ -396,12 +385,12 @@ class SplitNiftiOutputSpec(TraitedSpec): class SplitNifti(NiftiGeneratorBase): - ''' + """ Split one Nifti file into many along the specified dimension. Each result has an updated meta data extension as well. - ''' - input_spec = SplitNiftiInputSpec - output_spec = SplitNiftiOutputSpec + """ + _input_spec = SplitNiftiInputSpec + _output_spec = SplitNiftiOutputSpec def _run_interface(self, runtime): self.out_list = [] @@ -420,7 +409,6 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_list'] = self.out_list - return outputs + def _post_run(self): + self.outputs.out_list = self.out_list + \ No newline at end of file diff --git a/nipype/interfaces/diffusion_toolkit/dti.py b/nipype/interfaces/diffusion_toolkit/dti.py index 554f2bf38a..25db245884 100644 --- a/nipype/interfaces/diffusion_toolkit/dti.py +++ b/nipype/interfaces/diffusion_toolkit/dti.py @@ -62,8 +62,8 @@ class DTIRecon(CommandLine): """Use dti_recon to generate tensors and other maps """ - input_spec = DTIReconInputSpec - output_spec = DTIReconOutputSpec + _input_spec = DTIReconInputSpec + _output_spec = DTIReconOutputSpec _cmd = 'dti_recon' @@ -87,26 +87,25 @@ def _format_arg(self, name, spec, value): return super(DTIRecon, self)._format_arg("bvecs", spec, new_val) return super(DTIRecon, self)._format_arg(name, spec, value) - def _list_outputs(self): + def _post_run(self): out_prefix = self.inputs.out_prefix output_type = self.inputs.output_type - outputs = self.output_spec().get() - outputs['ADC'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_adc.' + output_type)) - outputs['B0'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_b0.' + output_type)) - outputs['L1'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_e1.' + output_type)) - outputs['L2'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_e2.' + output_type)) - outputs['L3'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_e3.' + output_type)) - outputs['exp'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_exp.' + output_type)) - outputs['FA'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_fa.' + output_type)) - outputs['FA_color'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_fa_color.' + output_type)) - outputs['tensor'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_tensor.' + output_type)) - outputs['V1'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_v1.' + output_type)) - outputs['V2'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_v2.' + output_type)) - outputs['V3'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_v3.' + output_type)) - - return outputs - + + self.outputs.ADC = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_adc.' + output_type)) + self.outputs.B0 = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_b0.' + output_type)) + self.outputs.L1 = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_e1.' + output_type)) + self.outputs.L2 = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_e2.' + output_type)) + self.outputs.L3 = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_e3.' + output_type)) + self.outputs.exp = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_exp.' + output_type)) + self.outputs.FA = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_fa.' + output_type)) + self.outputs.FA_color = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_fa_color.' + output_type)) + self.outputs.tensor = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_tensor.' + output_type)) + self.outputs.V1 = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_v1.' + output_type)) + self.outputs.V2 = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_v2.' + output_type)) + self.outputs.V3 = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_v3.' + output_type)) + + class DTITrackerInputSpec(CommandLineInputSpec): tensor_file = File(exists=True, desc="reconstructed tensor file") @@ -152,8 +151,8 @@ class DTITrackerOutputSpec(TraitedSpec): class DTITracker(CommandLine): - input_spec = DTITrackerInputSpec - output_spec = DTITrackerOutputSpec + _input_spec = DTITrackerInputSpec + _output_spec = DTITrackerOutputSpec _cmd = 'dti_tracker' @@ -163,10 +162,10 @@ def _run_interface(self, runtime): return super(DTITracker, self)._run_interface(runtime) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['track_file'] = os.path.abspath(self.inputs.output_file) + def _post_run(self): + + self.outputs.track_file = os.path.abspath(self.inputs.output_file) if isdefined(self.inputs.output_mask) and self.inputs.output_mask: - outputs['mask_file'] = os.path.abspath(self.inputs.output_mask) + self.outputs.mask_file = os.path.abspath(self.inputs.output_mask) - return outputs + \ No newline at end of file diff --git a/nipype/interfaces/diffusion_toolkit/odf.py b/nipype/interfaces/diffusion_toolkit/odf.py index b2f0b2c6a7..35cc9f38ca 100644 --- a/nipype/interfaces/diffusion_toolkit/odf.py +++ b/nipype/interfaces/diffusion_toolkit/odf.py @@ -58,8 +58,8 @@ class HARDIMatOutputSpec(TraitedSpec): class HARDIMat(CommandLine): """Use hardi_mat to calculate a reconstruction matrix from a gradient table """ - input_spec = HARDIMatInputSpec - output_spec = HARDIMatOutputSpec + _input_spec = HARDIMatInputSpec + _output_spec = HARDIMatOutputSpec _cmd = 'hardi_mat' @@ -85,11 +85,10 @@ def _format_arg(self, name, spec, value): return super(HARDIMat, self)._format_arg("bvecs", spec, new_val) return super(HARDIMat, self)._format_arg(name, spec, value) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = os.path.abspath(self.inputs.out_file) - return outputs - + def _post_run(self): + + self.outputs.out_file = os.path.abspath(self.inputs.out_file) + class ODFReconInputSpec(CommandLineInputSpec): DWI = File(desc='Input raw data', argstr='%s', exists=True, mandatory=True, position=1) @@ -133,25 +132,24 @@ class ODFRecon(CommandLine): """Use odf_recon to generate tensors and other maps """ - input_spec = ODFReconInputSpec - output_spec = ODFReconOutputSpec + _input_spec = ODFReconInputSpec + _output_spec = ODFReconOutputSpec _cmd = 'odf_recon' - def _list_outputs(self): + def _post_run(self): out_prefix = self.inputs.out_prefix output_type = self.inputs.output_type - outputs = self.output_spec().get() - outputs['B0'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_b0.' + output_type)) - outputs['DWI'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_dwi.' + output_type)) - outputs['max'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_max.' + output_type)) - outputs['ODF'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_odf.' + output_type)) + + self.outputs.B0 = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_b0.' + output_type)) + self.outputs.DWI = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_dwi.' + output_type)) + self.outputs.max = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_max.' + output_type)) + self.outputs.ODF = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_odf.' + output_type)) if isdefined(self.inputs.output_entropy): - outputs['entropy'] = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_entropy.' + output_type)) - - return outputs + self.outputs.entropy = os.path.abspath(fname_presuffix("", prefix=out_prefix, suffix='_entropy.' + output_type)) + class ODFTrackerInputSpec(CommandLineInputSpec): max = File(exists=True, mandatory=True) @@ -215,8 +213,8 @@ class ODFTracker(CommandLine): """Use odf_tracker to generate track file """ - input_spec = ODFTrackerInputSpec - output_spec = ODFTrackerOutputSpec + _input_spec = ODFTrackerInputSpec + _output_spec = ODFTrackerOutputSpec _cmd = 'odf_tracker' @@ -229,7 +227,7 @@ def _run_interface(self, runtime): return super(ODFTracker, self)._run_interface(runtime) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['track_file'] = os.path.abspath(self.inputs.out_file) - return outputs + def _post_run(self): + + self.outputs.track_file = os.path.abspath(self.inputs.out_file) + \ No newline at end of file diff --git a/nipype/interfaces/diffusion_toolkit/postproc.py b/nipype/interfaces/diffusion_toolkit/postproc.py index 60d5b11115..ca6f478269 100644 --- a/nipype/interfaces/diffusion_toolkit/postproc.py +++ b/nipype/interfaces/diffusion_toolkit/postproc.py @@ -45,16 +45,15 @@ class SplineFilter(CommandLine): >>> filt.inputs.step_length = 0.5 >>> filt.run() # doctest: +SKIP """ - input_spec = SplineFilterInputSpec - output_spec = SplineFilterOutputSpec + _input_spec = SplineFilterInputSpec + _output_spec = SplineFilterOutputSpec _cmd = "spline_filter" - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['smoothed_track_file'] = os.path.abspath(self.inputs.output_file) - return outputs - + def _post_run(self): + + self.outputs.smoothed_track_file = os.path.abspath(self.inputs.output_file) + class TrackMergeInputSpec(CommandLineInputSpec): track_files = InputMultiPath(File(exists=True), desc="file containing tracks to be filtered", position=0, argstr="%s...", mandatory=True) @@ -85,12 +84,12 @@ class TrackMerge(CommandLine): >>> mrg.inputs.track_files = ['track1.trk','track2.trk'] >>> mrg.run() # doctest: +SKIP """ - input_spec = TrackMergeInputSpec - output_spec = TrackMergeOutputSpec + _input_spec = TrackMergeInputSpec + _output_spec = TrackMergeOutputSpec _cmd = "track_merge" - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['track_file'] = os.path.abspath(self.inputs.output_file) - return outputs + def _post_run(self): + + self.outputs.track_file = os.path.abspath(self.inputs.output_file) + \ No newline at end of file diff --git a/nipype/interfaces/diffusion_toolkit/tests/test_auto_DTIRecon.py b/nipype/interfaces/diffusion_toolkit/tests/test_auto_DTIRecon.py index 907df7eb13..9fe1eaf350 100644 --- a/nipype/interfaces/diffusion_toolkit/tests/test_auto_DTIRecon.py +++ b/nipype/interfaces/diffusion_toolkit/tests/test_auto_DTIRecon.py @@ -17,12 +17,6 @@ def test_DTIRecon_inputs(): bvecs=dict(argstr='-gm %s', mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_orientation_vectors=dict(argstr='-iop %f', ), n_averages=dict(argstr='-nex %s', @@ -36,10 +30,8 @@ def test_DTIRecon_inputs(): output_type=dict(argstr='-ot %s', usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DTIRecon.input_spec() + inputs = DTIRecon._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -60,7 +52,7 @@ def test_DTIRecon_outputs(): exp=dict(), tensor=dict(), ) - outputs = DTIRecon.output_spec() + outputs = DTIRecon._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/diffusion_toolkit/tests/test_auto_DTITracker.py b/nipype/interfaces/diffusion_toolkit/tests/test_auto_DTITracker.py index d21a6ecb34..113162b033 100644 --- a/nipype/interfaces/diffusion_toolkit/tests/test_auto_DTITracker.py +++ b/nipype/interfaces/diffusion_toolkit/tests/test_auto_DTITracker.py @@ -10,12 +10,6 @@ def test_DTITracker_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_data_prefix=dict(argstr='%s', position=0, usedefault=True, @@ -58,12 +52,10 @@ def test_DTITracker_inputs(): swap_zx=dict(argstr='-szx', ), tensor_file=dict(), - terminal_output=dict(nohash=True, - ), tracking_method=dict(argstr='-%s', ), ) - inputs = DTITracker.input_spec() + inputs = DTITracker._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -74,7 +66,7 @@ def test_DTITracker_outputs(): output_map = dict(mask_file=dict(), track_file=dict(), ) - outputs = DTITracker.output_spec() + outputs = DTITracker._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/diffusion_toolkit/tests/test_auto_HARDIMat.py b/nipype/interfaces/diffusion_toolkit/tests/test_auto_HARDIMat.py index 725bbef73a..ba105216c1 100644 --- a/nipype/interfaces/diffusion_toolkit/tests/test_auto_HARDIMat.py +++ b/nipype/interfaces/diffusion_toolkit/tests/test_auto_HARDIMat.py @@ -12,12 +12,6 @@ def test_HARDIMat_inputs(): mandatory=True, position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_info=dict(argstr='-info %s', ), image_orientation_vectors=dict(argstr='-iop %f', @@ -34,10 +28,8 @@ def test_HARDIMat_inputs(): ), reference_file=dict(argstr='-ref %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = HARDIMat.input_spec() + inputs = HARDIMat._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_HARDIMat_inputs(): def test_HARDIMat_outputs(): output_map = dict(out_file=dict(), ) - outputs = HARDIMat.output_spec() + outputs = HARDIMat._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/diffusion_toolkit/tests/test_auto_ODFRecon.py b/nipype/interfaces/diffusion_toolkit/tests/test_auto_ODFRecon.py index 641fb1ad93..5142b06be0 100644 --- a/nipype/interfaces/diffusion_toolkit/tests/test_auto_ODFRecon.py +++ b/nipype/interfaces/diffusion_toolkit/tests/test_auto_ODFRecon.py @@ -12,14 +12,8 @@ def test_ODFRecon_inputs(): ), dsi=dict(argstr='-dsi', ), - environ=dict(nohash=True, - usedefault=True, - ), filter=dict(argstr='-f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_orientation_vectors=dict(argstr='-iop %f', ), matrix=dict(argstr='-mat %s', @@ -51,10 +45,8 @@ def test_ODFRecon_inputs(): ), subtract_background=dict(argstr='-bg', ), - terminal_output=dict(nohash=True, - ), ) - inputs = ODFRecon.input_spec() + inputs = ODFRecon._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -68,7 +60,7 @@ def test_ODFRecon_outputs(): entropy=dict(), max=dict(), ) - outputs = ODFRecon.output_spec() + outputs = ODFRecon._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/diffusion_toolkit/tests/test_auto_ODFTracker.py b/nipype/interfaces/diffusion_toolkit/tests/test_auto_ODFTracker.py index ba57c26e02..998428f830 100644 --- a/nipype/interfaces/diffusion_toolkit/tests/test_auto_ODFTracker.py +++ b/nipype/interfaces/diffusion_toolkit/tests/test_auto_ODFTracker.py @@ -14,12 +14,6 @@ def test_ODFTracker_inputs(): ), dsi=dict(argstr='-dsi', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_orientation_vectors=dict(argstr='-iop %f', ), input_data_prefix=dict(argstr='%s', @@ -68,12 +62,10 @@ def test_ODFTracker_inputs(): ), swap_zx=dict(argstr='-szx', ), - terminal_output=dict(nohash=True, - ), voxel_order=dict(argstr='-vorder %s', ), ) - inputs = ODFTracker.input_spec() + inputs = ODFTracker._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -83,7 +75,7 @@ def test_ODFTracker_inputs(): def test_ODFTracker_outputs(): output_map = dict(track_file=dict(), ) - outputs = ODFTracker.output_spec() + outputs = ODFTracker._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/diffusion_toolkit/tests/test_auto_SplineFilter.py b/nipype/interfaces/diffusion_toolkit/tests/test_auto_SplineFilter.py index 8079634c80..82f35cd635 100644 --- a/nipype/interfaces/diffusion_toolkit/tests/test_auto_SplineFilter.py +++ b/nipype/interfaces/diffusion_toolkit/tests/test_auto_SplineFilter.py @@ -6,12 +6,6 @@ def test_SplineFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), output_file=dict(argstr='%s', position=2, usedefault=True, @@ -20,14 +14,12 @@ def test_SplineFilter_inputs(): mandatory=True, position=1, ), - terminal_output=dict(nohash=True, - ), track_file=dict(argstr='%s', mandatory=True, position=0, ), ) - inputs = SplineFilter.input_spec() + inputs = SplineFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +29,7 @@ def test_SplineFilter_inputs(): def test_SplineFilter_outputs(): output_map = dict(smoothed_track_file=dict(), ) - outputs = SplineFilter.output_spec() + outputs = SplineFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/diffusion_toolkit/tests/test_auto_TrackMerge.py b/nipype/interfaces/diffusion_toolkit/tests/test_auto_TrackMerge.py index 5eaa8f1224..35f7636242 100644 --- a/nipype/interfaces/diffusion_toolkit/tests/test_auto_TrackMerge.py +++ b/nipype/interfaces/diffusion_toolkit/tests/test_auto_TrackMerge.py @@ -6,24 +6,16 @@ def test_TrackMerge_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), output_file=dict(argstr='%s', position=-1, usedefault=True, ), - terminal_output=dict(nohash=True, - ), track_files=dict(argstr='%s...', mandatory=True, position=0, ), ) - inputs = TrackMerge.input_spec() + inputs = TrackMerge._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -33,7 +25,7 @@ def test_TrackMerge_inputs(): def test_TrackMerge_outputs(): output_map = dict(track_file=dict(), ) - outputs = TrackMerge.output_spec() + outputs = TrackMerge._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/base.py b/nipype/interfaces/dipy/base.py index d760172710..f5bdbd1f38 100644 --- a/nipype/interfaces/dipy/base.py +++ b/nipype/interfaces/dipy/base.py @@ -3,7 +3,7 @@ import os.path as op import numpy as np from nipype.interfaces.base import (traits, File, isdefined, - BaseInterface, BaseInterfaceInputSpec) + BaseInterface, BaseInputSpec) from ... import logging IFLOGGER = logging.getLogger('interface') @@ -41,7 +41,7 @@ def __init__(self, **inputs): super(DipyBaseInterface, self).__init__(**inputs) -class DipyBaseInterfaceInputSpec(BaseInterfaceInputSpec): +class DipyBaseInputSpec(BaseInputSpec): in_file = File(exists=True, mandatory=True, desc=('input diffusion data')) in_bval = File(exists=True, mandatory=True, desc=('input b-values table')) in_bvec = File(exists=True, mandatory=True, desc=('input b-vectors table')) @@ -54,7 +54,7 @@ class DipyDiffusionInterface(DipyBaseInterface): """ A base interface for py:mod:`dipy` computations """ - input_spec = DipyBaseInterfaceInputSpec + _input_spec = DipyBaseInputSpec def _get_gradient_table(self): bval = np.loadtxt(self.inputs.in_bval) diff --git a/nipype/interfaces/dipy/preprocess.py b/nipype/interfaces/dipy/preprocess.py index 143f239e6c..c344360c57 100644 --- a/nipype/interfaces/dipy/preprocess.py +++ b/nipype/interfaces/dipy/preprocess.py @@ -49,8 +49,8 @@ class Resample(DipyBaseInterface): >>> reslice.inputs.in_file = 'diffusion.nii' >>> reslice.run() # doctest: +SKIP """ - input_spec = ResampleInputSpec - output_spec = ResampleOutputSpec + _input_spec = ResampleInputSpec + _output_spec = ResampleOutputSpec def _run_interface(self, runtime): order = self.inputs.interp @@ -66,11 +66,9 @@ def _run_interface(self, runtime): IFLOGGER.info('Resliced image saved as {i}'.format(i=out_file)) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = op.abspath(self._gen_outfilename()) - return outputs - + def _post_run(self): + self.outputs.out_file = op.abspath(self._gen_outfilename()) + def _gen_outfilename(self): fname, fext = op.splitext(op.basename(self.inputs.in_file)) if fext == '.gz': @@ -120,8 +118,8 @@ class Denoise(DipyBaseInterface): >>> denoise.inputs.in_file = 'diffusion.nii' >>> denoise.run() # doctest: +SKIP """ - input_spec = DenoiseInputSpec - output_spec = DenoiseOutputSpec + _input_spec = DenoiseInputSpec + _output_spec = DenoiseOutputSpec def _run_interface(self, runtime): out_file = op.abspath(self._gen_outfilename()) @@ -158,11 +156,9 @@ def _run_interface(self, runtime): 'SNR={s}').format(i=out_file, s=str(s))) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = op.abspath(self._gen_outfilename()) - return outputs - + def _post_run(self): + self.outputs.out_file = op.abspath(self._gen_outfilename()) + def _gen_outfilename(self): fname, fext = op.splitext(op.basename(self.inputs.in_file)) if fext == '.gz': diff --git a/nipype/interfaces/dipy/reconstruction.py b/nipype/interfaces/dipy/reconstruction.py index 6a01eacbf0..6f6c939686 100644 --- a/nipype/interfaces/dipy/reconstruction.py +++ b/nipype/interfaces/dipy/reconstruction.py @@ -9,13 +9,13 @@ import nibabel as nb from nipype.interfaces.base import TraitedSpec, File, traits, isdefined -from .base import DipyDiffusionInterface, DipyBaseInterfaceInputSpec +from .base import DipyDiffusionInterface, DipyBaseInputSpec from nipype import logging IFLOGGER = logging.getLogger('interface') -class RESTOREInputSpec(DipyBaseInterfaceInputSpec): +class RESTOREInputSpec(DipyBaseInputSpec): in_mask = File(exists=True, desc=('input mask in which compute tensors')) noise_mask = File( exists=True, desc=('input mask in which compute noise variance')) @@ -60,8 +60,8 @@ class RESTORE(DipyDiffusionInterface): """ - input_spec = RESTOREInputSpec - output_spec = RESTOREOutputSpec + _input_spec = RESTOREInputSpec + _output_spec = RESTOREOutputSpec def _run_interface(self, runtime): from scipy.special import gamma @@ -144,14 +144,12 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): for k in outputs.keys(): outputs[k] = self._gen_filename(k) - return outputs + - -class EstimateResponseSHInputSpec(DipyBaseInterfaceInputSpec): +class EstimateResponseSHInputSpec(DipyBaseInputSpec): in_evals = File( exists=True, mandatory=True, desc=('input eigenvalues file')) in_mask = File( @@ -197,8 +195,8 @@ class EstimateResponseSH(DipyDiffusionInterface): """ - input_spec = EstimateResponseSHInputSpec - output_spec = EstimateResponseSHOutputSpec + _input_spec = EstimateResponseSHInputSpec + _output_spec = EstimateResponseSHOutputSpec def _run_interface(self, runtime): from dipy.core.gradients import GradientTable @@ -266,14 +264,12 @@ def _run_interface(self, runtime): None).to_filename(op.abspath(self.inputs.out_mask)) return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): outputs['response'] = op.abspath(self.inputs.response) outputs['out_mask'] = op.abspath(self.inputs.out_mask) - return outputs - + -class CSDInputSpec(DipyBaseInterfaceInputSpec): +class CSDInputSpec(DipyBaseInputSpec): in_mask = File(exists=True, desc=('input mask in which compute tensors')) response = File(exists=True, desc=('single fiber estimated response')) sh_order = traits.Int(8, exists=True, usedefault=True, @@ -310,8 +306,8 @@ class CSD(DipyDiffusionInterface): >>> csd.inputs.in_bvec = 'bvecs' >>> res = csd.run() # doctest: +SKIP """ - input_spec = CSDInputSpec - output_spec = CSDOutputSpec + _input_spec = CSDInputSpec + _output_spec = CSDOutputSpec def _run_interface(self, runtime): from dipy.reconst.csdeconv import ConstrainedSphericalDeconvModel @@ -360,9 +356,8 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): outputs['model'] = self._gen_filename('csdmodel', ext='.pklz') if self.inputs.save_fods: outputs['out_fods'] = self._gen_filename('fods') - return outputs + \ No newline at end of file diff --git a/nipype/interfaces/dipy/simulate.py b/nipype/interfaces/dipy/simulate.py index f4eb174a22..b6399dbd0f 100644 --- a/nipype/interfaces/dipy/simulate.py +++ b/nipype/interfaces/dipy/simulate.py @@ -14,14 +14,14 @@ import nibabel as nb -from ..base import (traits, TraitedSpec, BaseInterfaceInputSpec, +from ..base import (traits, TraitedSpec, BaseInputSpec, File, InputMultiPath, isdefined) from .base import DipyBaseInterface from ... import logging IFLOGGER = logging.getLogger('interface') -class SimulateMultiTensorInputSpec(BaseInterfaceInputSpec): +class SimulateMultiTensorInputSpec(BaseInputSpec): in_dirs = InputMultiPath(File(exists=True), mandatory=True, desc='list of fibers (principal directions)') in_frac = InputMultiPath(File(exists=True), mandatory=True, @@ -86,8 +86,8 @@ class SimulateMultiTensor(DipyBaseInterface): >>> sim.inputs.in_bval = 'bvals' >>> sim.run() # doctest: +SKIP """ - input_spec = SimulateMultiTensorInputSpec - output_spec = SimulateMultiTensorOutputSpec + _input_spec = SimulateMultiTensorInputSpec + _output_spec = SimulateMultiTensorOutputSpec def _run_interface(self, runtime): from dipy.core.gradients import gradient_table @@ -246,15 +246,13 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - outputs['out_mask'] = op.abspath(self.inputs.out_mask) - outputs['out_bvec'] = op.abspath(self.inputs.out_bvec) - outputs['out_bval'] = op.abspath(self.inputs.out_bval) - - return outputs + def _post_run(self): + self.outputs.out_file = op.abspath(self.inputs.out_file) + self.outputs.out_mask = op.abspath(self.inputs.out_mask) + self.outputs.out_bvec = op.abspath(self.inputs.out_bvec) + self.outputs.out_bval = op.abspath(self.inputs.out_bval) + def _compute_voxel(args): """ diff --git a/nipype/interfaces/dipy/tensors.py b/nipype/interfaces/dipy/tensors.py index c7d02c681c..d5e48b40fd 100644 --- a/nipype/interfaces/dipy/tensors.py +++ b/nipype/interfaces/dipy/tensors.py @@ -8,13 +8,13 @@ import nibabel as nb from ..base import TraitedSpec, File, isdefined -from .base import DipyDiffusionInterface, DipyBaseInterfaceInputSpec +from .base import DipyDiffusionInterface, DipyBaseInputSpec from ... import logging IFLOGGER = logging.getLogger('interface') -class DTIInputSpec(DipyBaseInterfaceInputSpec): +class DTIInputSpec(DipyBaseInputSpec): mask_file = File(exists=True, desc='An optional white matter mask') @@ -37,8 +37,8 @@ class DTI(DipyDiffusionInterface): >>> dti.inputs.in_bval = 'bvals' >>> dti.run() # doctest: +SKIP """ - input_spec = DTIInputSpec - output_spec = DTIOutputSpec + _input_spec = DTIInputSpec + _output_spec = DTIOutputSpec def _run_interface(self, runtime): from dipy.reconst import dti @@ -62,13 +62,11 @@ def _run_interface(self, runtime): IFLOGGER.info('DTI parameters image saved as {i}'.format(i=out_file)) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = self._gen_filename('dti') - return outputs + def _post_run(self): + self.outputs.out_file = self._gen_filename('dti') + - -class TensorModeInputSpec(DipyBaseInterfaceInputSpec): +class TensorModeInputSpec(DipyBaseInputSpec): mask_file = File(exists=True, desc='An optional white matter mask') @@ -100,8 +98,8 @@ class TensorMode(DipyDiffusionInterface): >>> mode.inputs.in_bval = 'bvals' >>> mode.run() # doctest: +SKIP """ - input_spec = TensorModeInputSpec - output_spec = TensorModeOutputSpec + _input_spec = TensorModeInputSpec + _output_spec = TensorModeOutputSpec def _run_interface(self, runtime): from dipy.reconst import dti @@ -132,7 +130,6 @@ def _run_interface(self, runtime): IFLOGGER.info('Tensor mode image saved as {i}'.format(i=out_file)) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = self._gen_filename('mode') - return outputs + def _post_run(self): + self.outputs.out_file = self._gen_filename('mode') + \ No newline at end of file diff --git a/nipype/interfaces/dipy/tests/test_auto_CSD.py b/nipype/interfaces/dipy/tests/test_auto_CSD.py index d99aac4527..59ec23a790 100644 --- a/nipype/interfaces/dipy/tests/test_auto_CSD.py +++ b/nipype/interfaces/dipy/tests/test_auto_CSD.py @@ -6,9 +6,6 @@ def test_CSD_inputs(): input_map = dict(b0_thres=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(mandatory=True, ), in_bvec=dict(mandatory=True, @@ -26,7 +23,7 @@ def test_CSD_inputs(): usedefault=True, ), ) - inputs = CSD.input_spec() + inputs = CSD._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +34,7 @@ def test_CSD_outputs(): output_map = dict(model=dict(), out_fods=dict(), ) - outputs = CSD.output_spec() + outputs = CSD._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tests/test_auto_DTI.py b/nipype/interfaces/dipy/tests/test_auto_DTI.py index eb35d6a9e2..015337b899 100644 --- a/nipype/interfaces/dipy/tests/test_auto_DTI.py +++ b/nipype/interfaces/dipy/tests/test_auto_DTI.py @@ -6,9 +6,6 @@ def test_DTI_inputs(): input_map = dict(b0_thres=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(mandatory=True, ), in_bvec=dict(mandatory=True, @@ -18,7 +15,7 @@ def test_DTI_inputs(): mask_file=dict(), out_prefix=dict(), ) - inputs = DTI.input_spec() + inputs = DTI._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +25,7 @@ def test_DTI_inputs(): def test_DTI_outputs(): output_map = dict(out_file=dict(), ) - outputs = DTI.output_spec() + outputs = DTI._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tests/test_auto_Denoise.py b/nipype/interfaces/dipy/tests/test_auto_Denoise.py index 6a400231c4..c23451602b 100644 --- a/nipype/interfaces/dipy/tests/test_auto_Denoise.py +++ b/nipype/interfaces/dipy/tests/test_auto_Denoise.py @@ -16,7 +16,7 @@ def test_Denoise_inputs(): signal_mask=dict(), snr=dict(), ) - inputs = Denoise.input_spec() + inputs = Denoise._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -26,7 +26,7 @@ def test_Denoise_inputs(): def test_Denoise_outputs(): output_map = dict(out_file=dict(), ) - outputs = Denoise.output_spec() + outputs = Denoise._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tests/test_auto_DipyBaseInterface.py b/nipype/interfaces/dipy/tests/test_auto_DipyBaseInterface.py index ce3bd17584..13a81681aa 100644 --- a/nipype/interfaces/dipy/tests/test_auto_DipyBaseInterface.py +++ b/nipype/interfaces/dipy/tests/test_auto_DipyBaseInterface.py @@ -4,13 +4,18 @@ def test_DipyBaseInterface_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - ) - inputs = DipyBaseInterface.input_spec() + input_map = dict() + inputs = DipyBaseInterface._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_DipyBaseInterface_outputs(): + output_map = dict() + outputs = DipyBaseInterface._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/dipy/tests/test_auto_DipyDiffusionInterface.py b/nipype/interfaces/dipy/tests/test_auto_DipyDiffusionInterface.py index e785433355..6987b2d1f1 100644 --- a/nipype/interfaces/dipy/tests/test_auto_DipyDiffusionInterface.py +++ b/nipype/interfaces/dipy/tests/test_auto_DipyDiffusionInterface.py @@ -6,9 +6,6 @@ def test_DipyDiffusionInterface_inputs(): input_map = dict(b0_thres=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(mandatory=True, ), in_bvec=dict(mandatory=True, @@ -17,9 +14,17 @@ def test_DipyDiffusionInterface_inputs(): ), out_prefix=dict(), ) - inputs = DipyDiffusionInterface.input_spec() + inputs = DipyDiffusionInterface._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_DipyDiffusionInterface_outputs(): + output_map = dict() + outputs = DipyDiffusionInterface._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/dipy/tests/test_auto_EstimateResponseSH.py b/nipype/interfaces/dipy/tests/test_auto_EstimateResponseSH.py index 95e702bd50..7778c21c12 100644 --- a/nipype/interfaces/dipy/tests/test_auto_EstimateResponseSH.py +++ b/nipype/interfaces/dipy/tests/test_auto_EstimateResponseSH.py @@ -11,9 +11,6 @@ def test_EstimateResponseSH_inputs(): ), fa_thresh=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(mandatory=True, ), in_bvec=dict(mandatory=True, @@ -34,7 +31,7 @@ def test_EstimateResponseSH_inputs(): roi_radius=dict(usedefault=True, ), ) - inputs = EstimateResponseSH.input_spec() + inputs = EstimateResponseSH._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +42,7 @@ def test_EstimateResponseSH_outputs(): output_map = dict(out_mask=dict(), response=dict(), ) - outputs = EstimateResponseSH.output_spec() + outputs = EstimateResponseSH._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tests/test_auto_RESTORE.py b/nipype/interfaces/dipy/tests/test_auto_RESTORE.py index c06bc74573..018eee72ba 100644 --- a/nipype/interfaces/dipy/tests/test_auto_RESTORE.py +++ b/nipype/interfaces/dipy/tests/test_auto_RESTORE.py @@ -6,9 +6,6 @@ def test_RESTORE_inputs(): input_map = dict(b0_thres=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(mandatory=True, ), in_bvec=dict(mandatory=True, @@ -19,7 +16,7 @@ def test_RESTORE_inputs(): noise_mask=dict(), out_prefix=dict(), ) - inputs = RESTORE.input_spec() + inputs = RESTORE._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +32,7 @@ def test_RESTORE_outputs(): rd=dict(), trace=dict(), ) - outputs = RESTORE.output_spec() + outputs = RESTORE._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tests/test_auto_Resample.py b/nipype/interfaces/dipy/tests/test_auto_Resample.py index 06c462dd2d..09a68c17f2 100644 --- a/nipype/interfaces/dipy/tests/test_auto_Resample.py +++ b/nipype/interfaces/dipy/tests/test_auto_Resample.py @@ -11,7 +11,7 @@ def test_Resample_inputs(): ), vox_size=dict(), ) - inputs = Resample.input_spec() + inputs = Resample._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -21,7 +21,7 @@ def test_Resample_inputs(): def test_Resample_outputs(): output_map = dict(out_file=dict(), ) - outputs = Resample.output_spec() + outputs = Resample._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tests/test_auto_SimulateMultiTensor.py b/nipype/interfaces/dipy/tests/test_auto_SimulateMultiTensor.py index 5bc7a2928f..49a18bf7c2 100644 --- a/nipype/interfaces/dipy/tests/test_auto_SimulateMultiTensor.py +++ b/nipype/interfaces/dipy/tests/test_auto_SimulateMultiTensor.py @@ -13,9 +13,6 @@ def test_SimulateMultiTensor_inputs(): diff_sf=dict(usedefault=True, ), gradients=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(), in_bvec=dict(), in_dirs=dict(mandatory=True, @@ -40,7 +37,7 @@ def test_SimulateMultiTensor_inputs(): snr=dict(usedefault=True, ), ) - inputs = SimulateMultiTensor.input_spec() + inputs = SimulateMultiTensor._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +50,7 @@ def test_SimulateMultiTensor_outputs(): out_file=dict(), out_mask=dict(), ) - outputs = SimulateMultiTensor.output_spec() + outputs = SimulateMultiTensor._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tests/test_auto_StreamlineTractography.py b/nipype/interfaces/dipy/tests/test_auto_StreamlineTractography.py index b4c4dae679..a6f8ced948 100644 --- a/nipype/interfaces/dipy/tests/test_auto_StreamlineTractography.py +++ b/nipype/interfaces/dipy/tests/test_auto_StreamlineTractography.py @@ -7,9 +7,6 @@ def test_StreamlineTractography_inputs(): input_map = dict(gfa_thresh=dict(mandatory=True, usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(mandatory=True, ), in_model=dict(), @@ -34,7 +31,7 @@ def test_StreamlineTractography_inputs(): seed_mask=dict(), tracking_mask=dict(), ) - inputs = StreamlineTractography.input_spec() + inputs = StreamlineTractography._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +44,7 @@ def test_StreamlineTractography_outputs(): out_seeds=dict(), tracks=dict(), ) - outputs = StreamlineTractography.output_spec() + outputs = StreamlineTractography._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tests/test_auto_TensorMode.py b/nipype/interfaces/dipy/tests/test_auto_TensorMode.py index 53f77d5d33..8b74e504e3 100644 --- a/nipype/interfaces/dipy/tests/test_auto_TensorMode.py +++ b/nipype/interfaces/dipy/tests/test_auto_TensorMode.py @@ -6,9 +6,6 @@ def test_TensorMode_inputs(): input_map = dict(b0_thres=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(mandatory=True, ), in_bvec=dict(mandatory=True, @@ -18,7 +15,7 @@ def test_TensorMode_inputs(): mask_file=dict(), out_prefix=dict(), ) - inputs = TensorMode.input_spec() + inputs = TensorMode._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +25,7 @@ def test_TensorMode_inputs(): def test_TensorMode_outputs(): output_map = dict(out_file=dict(), ) - outputs = TensorMode.output_spec() + outputs = TensorMode._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tests/test_auto_TrackDensityMap.py b/nipype/interfaces/dipy/tests/test_auto_TrackDensityMap.py index 187c4c0d49..da7b455710 100644 --- a/nipype/interfaces/dipy/tests/test_auto_TrackDensityMap.py +++ b/nipype/interfaces/dipy/tests/test_auto_TrackDensityMap.py @@ -5,9 +5,6 @@ def test_TrackDensityMap_inputs(): input_map = dict(data_dims=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(mandatory=True, ), out_filename=dict(usedefault=True, @@ -17,7 +14,7 @@ def test_TrackDensityMap_inputs(): reference=dict(), voxel_dims=dict(), ) - inputs = TrackDensityMap.input_spec() + inputs = TrackDensityMap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -27,7 +24,7 @@ def test_TrackDensityMap_inputs(): def test_TrackDensityMap_outputs(): output_map = dict(out_file=dict(), ) - outputs = TrackDensityMap.output_spec() + outputs = TrackDensityMap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/dipy/tracks.py b/nipype/interfaces/dipy/tracks.py index 1b0ad6f381..623aab240c 100644 --- a/nipype/interfaces/dipy/tracks.py +++ b/nipype/interfaces/dipy/tracks.py @@ -11,14 +11,14 @@ import nibabel as nb import nibabel.trackvis as nbt -from ..base import (TraitedSpec, BaseInterfaceInputSpec, +from ..base import (TraitedSpec, BaseInputSpec, File, isdefined, traits) from .base import DipyBaseInterface from ... import logging IFLOGGER = logging.getLogger('interface') -class TrackDensityMapInputSpec(BaseInterfaceInputSpec): +class TrackDensityMapInputSpec(BaseInputSpec): in_file = File(exists=True, mandatory=True, desc='The input TrackVis track file') reference = File(exists=True, @@ -53,8 +53,8 @@ class TrackDensityMap(DipyBaseInterface): >>> trk2tdi.run() # doctest: +SKIP """ - input_spec = TrackDensityMapInputSpec - output_spec = TrackDensityMapOutputSpec + _input_spec = TrackDensityMapInputSpec + _output_spec = TrackDensityMapOutputSpec def _run_interface(self, runtime): from numpy import min_scalar_type @@ -97,13 +97,11 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = op.abspath(self.inputs.out_filename) - return outputs + def _post_run(self): + self.outputs.out_file = op.abspath(self.inputs.out_filename) + - -class StreamlineTractographyInputSpec(BaseInterfaceInputSpec): +class StreamlineTractographyInputSpec(BaseInputSpec): in_file = File(exists=True, mandatory=True, desc=('input diffusion data')) in_model = File(exists=True, desc=('input f/d-ODF model extracted from.')) tracking_mask = File(exists=True, @@ -157,8 +155,8 @@ class StreamlineTractography(DipyBaseInterface): >>> track.inputs.tracking_mask = 'dilated_wm_mask.nii' >>> res = track.run() # doctest: +SKIP """ - input_spec = StreamlineTractographyInputSpec - output_spec = StreamlineTractographyOutputSpec + _input_spec = StreamlineTractographyInputSpec + _output_spec = StreamlineTractographyOutputSpec def _run_interface(self, runtime): from dipy.reconst.peaks import peaks_from_model @@ -272,8 +270,7 @@ def _run_interface(self, runtime): trkfilev.to_file(self._gen_filename('tracked', ext='.trk')) return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): outputs['tracks'] = self._gen_filename('tracked', ext='.trk') outputs['gfa'] = self._gen_filename('gfa') if self._save_peaks: @@ -285,8 +282,7 @@ def _list_outputs(self): outputs['out_seeds'] = self._gen_filename('seeds', ext='.txt') - return outputs - + def _gen_filename(self, name, ext=None): fname, fext = op.splitext(op.basename(self.inputs.in_file)) if fext == '.gz': diff --git a/nipype/interfaces/dynamic_slicer.py b/nipype/interfaces/dynamic_slicer.py index 1c26ef4acf..a0ad9fe82e 100644 --- a/nipype/interfaces/dynamic_slicer.py +++ b/nipype/interfaces/dynamic_slicer.py @@ -13,13 +13,23 @@ class SlicerCommandLineInputSpec(DynamicTraitedSpec, CommandLineInputSpec): module = traits.Str(desc="name of the Slicer command line module you want to use") + def _format_arg(self, name, spec, value): + if name in [output_node.getElementsByTagName('name')[0].firstChild.nodeValue for output_node in self._outputs_nodes]: + if isinstance(value, bool): + fname = self._gen_filename(name) + else: + fname = value + return spec.argstr % fname + return super(SlicerCommandLineInputSpec, self)._format_arg(name, spec, value) + + class SlicerCommandLine(CommandLine): """Experimental Slicer wrapper. Work in progress. """ _cmd = "Slicer3" - input_spec = SlicerCommandLineInputSpec - output_spec = DynamicTraitedSpec + _input_spec = SlicerCommandLineInputSpec + _output_spec = DynamicTraitedSpec def _grab_xml(self, module): cmd = CommandLine(command="Slicer3", args="--launch %s --xml" % module) @@ -128,26 +138,17 @@ def _gen_filename_from_param(self, param): ext = {'image': '.nii', 'transform': '.txt', 'file': ''}[param.nodeName] return base + ext - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + for output_node in self._outputs_nodes: name = output_node.getElementsByTagName('name')[0].firstChild.nodeValue - outputs[name] = getattr(self.inputs, name) + setattr(self.outputs, name, getattr(self.inputs, name)) if isdefined(outputs[name]) and isinstance(outputs[name], bool): if outputs[name]: - outputs[name] = self._gen_filename(name) + setattr(self.outputs, name, self._gen_filename(name)) else: - outputs[name] = Undefined - return outputs + setattr(self.outputs, name, Undefined) - def _format_arg(self, name, spec, value): - if name in [output_node.getElementsByTagName('name')[0].firstChild.nodeValue for output_node in self._outputs_nodes]: - if isinstance(value, bool): - fname = self._gen_filename(name) - else: - fname = value - return spec.argstr % fname - return super(SlicerCommandLine, self)._format_arg(name, spec, value) # test = SlicerCommandLine(module="BRAINSFit") # test.inputs.fixedVolume = "/home/filo/workspace/fmri_tumour/data/pilot1/10_co_COR_3D_IR_PREP.nii" diff --git a/nipype/interfaces/elastix/registration.py b/nipype/interfaces/elastix/registration.py index b72123c321..0cc3ec5958 100644 --- a/nipype/interfaces/elastix/registration.py +++ b/nipype/interfaces/elastix/registration.py @@ -62,20 +62,19 @@ class Registration(CommandLine): """ _cmd = 'elastix' - input_spec = RegistrationInputSpec - output_spec = RegistrationOutputSpec - - def _list_outputs(self): - outputs = self._outputs().get() + _input_spec = RegistrationInputSpec + _output_spec = RegistrationOutputSpec + def _post_run(self): + out_dir = op.abspath(self.inputs.output_path) opts = ['WriteResultImage', 'ResultImageFormat'] regex = re.compile(r'^\((\w+)\s(.+)\)$') - outputs['transform'] = [] - outputs['warped_files'] = [] - outputs['warped_files_flags'] = [] + self.outputs.transform = [] + self.outputs.warped_files = [] + self.outputs.warped_files_flags = [] for i, params in enumerate(self.inputs.parameters): config = {} @@ -89,7 +88,7 @@ def _list_outputs(self): value = self._cast(m.group(2).strip()) config[m.group(1).strip()] = value - outputs['transform'].append(op.join(out_dir, + self.outputs.transform.append(op.join(out_dir, 'TransformParameters.%01d.txt' % i)) warped_file = None @@ -97,14 +96,13 @@ def _list_outputs(self): warped_file = op.join(out_dir, 'result.%01d.%s' % (i, config['ResultImageFormat'])) - outputs['warped_files'].append(warped_file) - outputs['warped_files_flags'].append(config['WriteResultImage']) - - if outputs['warped_files_flags'][-1]: - outputs['warped_file'] = outputs['warped_files'][-1] + self.outputs.warped_files.append(warped_file) + self.outputs.warped_files_flags.append(config['WriteResultImage']) - return outputs + if self.outputs.warped_files_flags[-1]: + self.outputs.warped_file = self.outputs.warped_files[-1] + def _cast(self, val): if val.startswith('"') and val.endswith('"'): if val == '"true"': @@ -154,15 +152,13 @@ class ApplyWarp(CommandLine): """ _cmd = 'transformix' - input_spec = ApplyWarpInputSpec - output_spec = ApplyWarpOutputSpec + _input_spec = ApplyWarpInputSpec + _output_spec = ApplyWarpOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): out_dir = op.abspath(self.inputs.output_path) - outputs['warped_file'] = op.join(out_dir, 'result.nii.gz') - return outputs - + self.outputs.warped_file = op.join(out_dir, 'result.nii.gz') + class AnalyzeWarpInputSpec(ElastixBaseInputSpec): transform_file = File(exists=True, mandatory=True, argstr='-tp %s', @@ -194,17 +190,15 @@ class AnalyzeWarp(CommandLine): """ _cmd = 'transformix -def all -jac all -jacmat all' - input_spec = AnalyzeWarpInputSpec - output_spec = AnalyzeWarpOutputSpec + _input_spec = AnalyzeWarpInputSpec + _output_spec = AnalyzeWarpOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): out_dir = op.abspath(self.inputs.output_path) - outputs['disp_field'] = op.join(out_dir, 'deformationField.nii.gz') - outputs['jacdet_map'] = op.join(out_dir, 'spatialJacobian.nii.gz') - outputs['jacmat_map'] = op.join(out_dir, 'fullSpatialJacobian.nii.gz') - return outputs - + self.outputs.disp_field = op.join(out_dir, 'deformationField.nii.gz') + self.outputs.jacdet_map = op.join(out_dir, 'spatialJacobian.nii.gz') + self.outputs.jacmat_map = op.join(out_dir, 'fullSpatialJacobian.nii.gz') + class PointsWarpInputSpec(ElastixBaseInputSpec): points_file = File(exists=True, argstr='-def %s', mandatory=True, @@ -235,14 +229,13 @@ class PointsWarp(CommandLine): """ _cmd = 'transformix' - input_spec = PointsWarpInputSpec - output_spec = PointsWarpOutputSpec + _input_spec = PointsWarpInputSpec + _output_spec = PointsWarpOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): out_dir = op.abspath(self.inputs.output_path) fname, ext = op.splitext(op.basename(self.inputs.points_file)) - outputs['warped_file'] = op.join(out_dir, 'outputpoints%s' % ext) - return outputs + self.outputs.warped_file = op.join(out_dir, 'outputpoints%s' % ext) + \ No newline at end of file diff --git a/nipype/interfaces/elastix/tests/test_auto_AnalyzeWarp.py b/nipype/interfaces/elastix/tests/test_auto_AnalyzeWarp.py index a298b4ade6..0d9772818f 100644 --- a/nipype/interfaces/elastix/tests/test_auto_AnalyzeWarp.py +++ b/nipype/interfaces/elastix/tests/test_auto_AnalyzeWarp.py @@ -6,12 +6,6 @@ def test_AnalyzeWarp_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), num_threads=dict(argstr='-threads %01d', nohash=True, ), @@ -19,13 +13,11 @@ def test_AnalyzeWarp_inputs(): mandatory=True, usedefault=True, ), - terminal_output=dict(nohash=True, - ), transform_file=dict(argstr='-tp %s', mandatory=True, ), ) - inputs = AnalyzeWarp.input_spec() + inputs = AnalyzeWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +29,7 @@ def test_AnalyzeWarp_outputs(): jacdet_map=dict(), jacmat_map=dict(), ) - outputs = AnalyzeWarp.output_spec() + outputs = AnalyzeWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/elastix/tests/test_auto_ApplyWarp.py b/nipype/interfaces/elastix/tests/test_auto_ApplyWarp.py index 1d6addb92a..873d36a20b 100644 --- a/nipype/interfaces/elastix/tests/test_auto_ApplyWarp.py +++ b/nipype/interfaces/elastix/tests/test_auto_ApplyWarp.py @@ -6,12 +6,6 @@ def test_ApplyWarp_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), moving_image=dict(argstr='-in %s', mandatory=True, ), @@ -22,13 +16,11 @@ def test_ApplyWarp_inputs(): mandatory=True, usedefault=True, ), - terminal_output=dict(nohash=True, - ), transform_file=dict(argstr='-tp %s', mandatory=True, ), ) - inputs = ApplyWarp.input_spec() + inputs = ApplyWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_ApplyWarp_inputs(): def test_ApplyWarp_outputs(): output_map = dict(warped_file=dict(), ) - outputs = ApplyWarp.output_spec() + outputs = ApplyWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/elastix/tests/test_auto_EditTransform.py b/nipype/interfaces/elastix/tests/test_auto_EditTransform.py index 9b5c082299..3e0a4c7481 100644 --- a/nipype/interfaces/elastix/tests/test_auto_EditTransform.py +++ b/nipype/interfaces/elastix/tests/test_auto_EditTransform.py @@ -4,10 +4,7 @@ def test_EditTransform_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - interpolation=dict(argstr='FinalBSplineInterpolationOrder', + input_map = dict(interpolation=dict(argstr='FinalBSplineInterpolationOrder', usedefault=True, ), output_file=dict(), @@ -19,7 +16,7 @@ def test_EditTransform_inputs(): transform_file=dict(mandatory=True, ), ) - inputs = EditTransform.input_spec() + inputs = EditTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -29,7 +26,7 @@ def test_EditTransform_inputs(): def test_EditTransform_outputs(): output_map = dict(output_file=dict(), ) - outputs = EditTransform.output_spec() + outputs = EditTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/elastix/tests/test_auto_PointsWarp.py b/nipype/interfaces/elastix/tests/test_auto_PointsWarp.py index de12ae5698..d35a439586 100644 --- a/nipype/interfaces/elastix/tests/test_auto_PointsWarp.py +++ b/nipype/interfaces/elastix/tests/test_auto_PointsWarp.py @@ -6,12 +6,6 @@ def test_PointsWarp_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), num_threads=dict(argstr='-threads %01d', nohash=True, ), @@ -22,13 +16,11 @@ def test_PointsWarp_inputs(): points_file=dict(argstr='-def %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), transform_file=dict(argstr='-tp %s', mandatory=True, ), ) - inputs = PointsWarp.input_spec() + inputs = PointsWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_PointsWarp_inputs(): def test_PointsWarp_outputs(): output_map = dict(warped_file=dict(), ) - outputs = PointsWarp.output_spec() + outputs = PointsWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/elastix/tests/test_auto_Registration.py b/nipype/interfaces/elastix/tests/test_auto_Registration.py index 4bbe547488..b779a8abd2 100644 --- a/nipype/interfaces/elastix/tests/test_auto_Registration.py +++ b/nipype/interfaces/elastix/tests/test_auto_Registration.py @@ -6,17 +6,11 @@ def test_Registration_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fixed_image=dict(argstr='-f %s', mandatory=True, ), fixed_mask=dict(argstr='-fMask %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initial_transform=dict(argstr='-t0 %s', ), moving_image=dict(argstr='-m %s', @@ -34,10 +28,8 @@ def test_Registration_inputs(): parameters=dict(argstr='-p %s...', mandatory=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Registration.input_spec() + inputs = Registration._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +42,7 @@ def test_Registration_outputs(): warped_files=dict(), warped_files_flags=dict(), ) - outputs = Registration.output_spec() + outputs = Registration._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/elastix/utils.py b/nipype/interfaces/elastix/utils.py index ab034dac07..feaf7b5c12 100644 --- a/nipype/interfaces/elastix/utils.py +++ b/nipype/interfaces/elastix/utils.py @@ -10,13 +10,13 @@ import os.path as op import re -from ..base import (BaseInterface, BaseInterfaceInputSpec, isdefined, +from ..base import (BaseInterface, BaseInputSpec, isdefined, TraitedSpec, File, traits, InputMultiPath) from ... import logging logger = logging.getLogger('interface') -class EditTransformInputSpec(BaseInterfaceInputSpec): +class EditTransformInputSpec(BaseInputSpec): transform_file = File(exists=True, mandatory=True, desc='transform-parameter file, only 1') reference_image = File(exists=True, @@ -56,8 +56,8 @@ class EditTransform(BaseInterface): """ - input_spec = EditTransformInputSpec - output_spec = EditTransformOutputSpec + _input_spec = EditTransformInputSpec + _output_spec = EditTransformOutputSpec _out_file = '' _pattern = '\((?P%s\s\"?)([-\.\s\w]+)(\"?\))' @@ -130,11 +130,10 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['output_file'] = getattr(self, '_out_file') - return outputs - + def _post_run(self): + + self.outputs.output_file = getattr(self, '_out_file') + def _get_outfile(self): val = getattr(self, '_out_file') if val is not None and val != '': diff --git a/nipype/interfaces/freesurfer/base.py b/nipype/interfaces/freesurfer/base.py index 54d1bb2c41..f1009359ba 100644 --- a/nipype/interfaces/freesurfer/base.py +++ b/nipype/interfaces/freesurfer/base.py @@ -94,7 +94,7 @@ class FSCommand(CommandLine): Every FS command accepts 'subjects_dir' input. """ - input_spec = FSTraitedSpec + _input_spec = FSTraitedSpec _subjects_dir = None @@ -109,7 +109,7 @@ def __init__(self, **inputs): def _subjects_dir_update(self): if self.inputs.subjects_dir: - self.inputs.environ.update({'SUBJECTS_DIR': + self.environ.update({'SUBJECTS_DIR': self.inputs.subjects_dir}) @classmethod @@ -128,7 +128,7 @@ def run(self, **inputs): def _gen_fname(self, basename, fname=None, cwd=None, suffix='_fs', use_ext=True): - '''Define a generic mapping for a single outfile + """Define a generic mapping for a single outfile The filename is potentially autogenerated by suffixing inputs.infile @@ -142,7 +142,7 @@ def _gen_fname(self, basename, fname=None, cwd=None, suffix='_fs', prefix paths with cwd, otherwise os.getcwd() suffix : string default suffix - ''' + """ if basename == '': msg = 'Unable to generate filename for command %s. ' % self.cmd msg += 'basename is not set!' diff --git a/nipype/interfaces/freesurfer/model.py b/nipype/interfaces/freesurfer/model.py index ed40041249..af692330d8 100644 --- a/nipype/interfaces/freesurfer/model.py +++ b/nipype/interfaces/freesurfer/model.py @@ -94,22 +94,21 @@ class MRISPreproc(FSCommand): """ _cmd = 'mris_preproc' - input_spec = MRISPreprocInputSpec - output_spec = MRISPreprocOutputSpec + _input_spec = MRISPreprocInputSpec + _output_spec = MRISPreprocOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() outfile = self.inputs.out_file - outputs['out_file'] = outfile + self.outputs.out_file = outfile if not isdefined(outfile): - outputs['out_file'] = os.path.join(os.getcwd(), + self.outputs.out_file = os.path.join(os.getcwd(), 'concat_%s_%s.mgz' % (self.inputs.hemi, self.inputs.target)) - return outputs def _gen_filename(self, name): if name == 'out_file': - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -268,8 +267,8 @@ class GLMFit(FSCommand): """ _cmd = 'mri_glmfit' - input_spec = GLMFitInputSpec - output_spec = GLMFitOutputSpec + _input_spec = GLMFitInputSpec + _output_spec = GLMFitOutputSpec def _format_arg(self, name, spec, value): if name == "surf": @@ -277,27 +276,27 @@ def _format_arg(self, name, spec, value): return spec.argstr % (_si.subject_id, _si.hemi, _si.surf_geo) return super(GLMFit, self)._format_arg(name, spec, value) - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + # Get the top-level output directory if not isdefined(self.inputs.glm_dir): glmdir = os.getcwd() else: glmdir = os.path.abspath(self.inputs.glm_dir) - outputs["glm_dir"] = glmdir + self.outputs.glm_dir = glmdir # Assign the output files that always get created - outputs["beta_file"] = os.path.join(glmdir, "beta.mgh") - outputs["error_var_file"] = os.path.join(glmdir, "rvar.mgh") - outputs["error_stddev_file"] = os.path.join(glmdir, "rstd.mgh") - outputs["mask_file"] = os.path.join(glmdir, "mask.mgh") - outputs["fwhm_file"] = os.path.join(glmdir, "fwhm.dat") - outputs["dof_file"] = os.path.join(glmdir, "dof.dat") + self.outputs.beta_file = os.path.join(glmdir, "beta.mgh") + self.outputs.error_var_file = os.path.join(glmdir, "rvar.mgh") + self.outputs.error_stddev_file = os.path.join(glmdir, "rstd.mgh") + self.outputs.mask_file = os.path.join(glmdir, "mask.mgh") + self.outputs.fwhm_file = os.path.join(glmdir, "fwhm.dat") + self.outputs.dof_file = os.path.join(glmdir, "dof.dat") # Assign the conditional outputs if isdefined(self.inputs.save_residual) and self.inputs.save_residual: - outputs["error_file"] = os.path.join(glmdir, "eres.mgh") + self.outputs.error_file = os.path.join(glmdir, "eres.mgh") if isdefined(self.inputs.save_estimate) and self.inputs.save_estimate: - outputs["estimate_file"] = os.path.join(glmdir, "yhat.mgh") + self.outputs.estimate_file = os.path.join(glmdir, "yhat.mgh") # Get the contrast directory name(s) if isdefined(self.inputs.contrast): @@ -311,20 +310,19 @@ def _list_outputs(self): contrasts = ["osgm"] # Add in the contrast images - outputs["sig_file"] = [os.path.join(glmdir, c, "sig.mgh") for c in contrasts] - outputs["ftest_file"] = [os.path.join(glmdir, c, "F.mgh") for c in contrasts] - outputs["gamma_file"] = [os.path.join(glmdir, c, "gamma.mgh") for c in contrasts] - outputs["gamma_var_file"] = [os.path.join(glmdir, c, "gammavar.mgh") for c in contrasts] + self.outputs.sig_file = [os.path.join(glmdir, c, "sig.mgh") for c in contrasts] + self.outputs.ftest_file = [os.path.join(glmdir, c, "F.mgh") for c in contrasts] + self.outputs.gamma_file = [os.path.join(glmdir, c, "gamma.mgh") for c in contrasts] + self.outputs.gamma_var_file = [os.path.join(glmdir, c, "gammavar.mgh") for c in contrasts] # Add in the PCA results, if relevant if isdefined(self.inputs.pca) and self.inputs.pca: pcadir = os.path.join(glmdir, "pca-eres") - outputs["spatial_eigenvectors"] = os.path.join(pcadir, "v.mgh") - outputs["frame_eigenvectors"] = os.path.join(pcadir, "u.mtx") - outputs["singluar_values"] = os.path.join(pcadir, "sdiag.mat") - outputs["svd_stats_file"] = os.path.join(pcadir, "stats.dat") + self.outputs.spatial_eigenvectors = os.path.join(pcadir, "v.mgh") + self.outputs.frame_eigenvectors = os.path.join(pcadir, "u.mtx") + self.outputs.singluar_values = os.path.join(pcadir, "sdiag.mat") + self.outputs.svd_stats_file = os.path.join(pcadir, "stats.dat") - return outputs def _gen_filename(self, name): if name == 'glm_dir': @@ -357,9 +355,10 @@ class BinarizeInputSpec(FSTraitedSpec): ventricles = traits.Bool(argstr='--ventricles', desc='set match vals those for aseg ventricles+choroid (not 4th)') wm_ven_csf = traits.Bool(argstr='--wm+vcsf', xor=['min', 'max'], - desc='WM and ventricular CSF, including choroid (not 4th)') - binary_file = File(argstr='--o %s', genfile=True, - desc='binary output volume') + desc='WM and ventricular CSF, including choroid (not 4th)') + binary_file = File( + argstr='--o %s', name_source='in_file', name_template='_bin', + keep_extension=True, desc='binary output volume') out_type = traits.Enum('nii', 'nii.gz', 'mgz', argstr='', desc='output file type') count_file = traits.Either(traits.Bool, File, @@ -406,18 +405,18 @@ class Binarize(FSCommand): Examples -------- - >>> binvol = Binarize(in_file='structural.nii', min=10, binary_file='foo_out.nii') + >>> binvol = Binarize(in_file='structural.nii', min=10) >>> binvol.cmdline - 'mri_binarize --o foo_out.nii --i structural.nii --min 10.000000' + 'mri_binarize --o structural_bin.nii --i structural.nii --min 10.000000' """ _cmd = 'mri_binarize' - input_spec = BinarizeInputSpec - output_spec = BinarizeOutputSpec + _input_spec = BinarizeInputSpec + _output_spec = BinarizeOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() outfile = self.inputs.binary_file if not isdefined(outfile): if isdefined(self.inputs.out_type): @@ -430,23 +429,22 @@ def _list_outputs(self): outfile = fname_presuffix(self.inputs.in_file, newpath=os.getcwd(), suffix='_thresh') - outputs['binary_file'] = os.path.abspath(outfile) + self.outputs.binary_file = os.path.abspath(outfile) value = self.inputs.count_file if isdefined(value): if isinstance(value, bool): if value: - outputs['count_file'] = fname_presuffix(self.inputs.in_file, + self.outputs.count_file = fname_presuffix(self.inputs.in_file, suffix='_count.txt', newpath=os.getcwd(), use_ext=False) else: - outputs['count_file'] = value - return outputs + self.outputs.count_file = value def _format_arg(self, name, spec, value): if name == 'count_file': if isinstance(value, bool): - fname = self._list_outputs()[name] + fname = getattr(self.outputs, name) else: fname = value return spec.argstr % fname @@ -456,7 +454,7 @@ def _format_arg(self, name, spec, value): def _gen_filename(self, name): if name == 'binary_file': - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -522,21 +520,20 @@ class Concatenate(FSCommand): """ _cmd = 'mri_concat' - input_spec = ConcatenateInputSpec - output_spec = ConcatenateOutputSpec + _input_spec = ConcatenateInputSpec + _output_spec = ConcatenateOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() if not isdefined(self.inputs.concatenated_file): - outputs['concatenated_file'] = os.path.join(os.getcwd(), + self.outputs.concatenated_file = os.path.join(os.getcwd(), 'concat_output.nii.gz') else: - outputs['concatenated_file'] = self.inputs.concatenated_file - return outputs + self.outputs.concatenated_file = self.inputs.concatenated_file def _gen_filename(self, name): if name == 'concatenated_file': - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -630,15 +627,15 @@ class SegStats(FSCommand): """ _cmd = 'mri_segstats' - input_spec = SegStatsInputSpec - output_spec = SegStatsOutputSpec + _input_spec = SegStatsInputSpec + _output_spec = SegStatsOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() if isdefined(self.inputs.summary_file): - outputs['summary_file'] = os.path.abspath(self.inputs.summary_file) + self.outputs.summary_file = os.path.abspath(self.inputs.summary_file) else: - outputs['summary_file'] = os.path.join(os.getcwd(), 'summary.stats') + self.outputs.summary_file = os.path.join(os.getcwd(), 'summary.stats') suffices = dict(avgwf_txt_file='_avgwf.txt', avgwf_file='_avgwf.nii.gz', sf_avg_file='sfavg.txt') if isdefined(self.inputs.segmentation_file): @@ -651,17 +648,16 @@ def _list_outputs(self): value = getattr(self.inputs, name) if isdefined(value): if isinstance(value, bool): - outputs[name] = fname_presuffix(src, suffix=suffix, + setattr(self.outputs, name, fname_presuffix(src, suffix=suffix, newpath=os.getcwd(), - use_ext=False) + use_ext=False)) else: - outputs[name] = os.path.abspath(value) - return outputs + setattr(self.outputs, name, os.path.abspath(value)) def _format_arg(self, name, spec, value): if name in ['avgwf_txt_file', 'avgwf_file', 'sf_avg_file']: if isinstance(value, bool): - fname = self._list_outputs()[name] + fname = getattr(self.outputs, name) else: fname = value return spec.argstr % fname @@ -669,7 +665,7 @@ def _format_arg(self, name, spec, value): def _gen_filename(self, name): if name == 'summary_file': - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -749,11 +745,11 @@ class Label2Vol(FSCommand): """ _cmd = 'mri_label2vol' - input_spec = Label2VolInputSpec - output_spec = Label2VolOutputSpec + _input_spec = Label2VolInputSpec + _output_spec = Label2VolOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() outfile = self.inputs.vol_label_file if not isdefined(outfile): for key in ['label_file', 'annot_file', 'seg_file']: @@ -767,12 +763,11 @@ def _list_outputs(self): outfile = fname_presuffix(src, suffix='_vol.nii.gz', newpath=os.getcwd(), use_ext=False) - outputs['vol_label_file'] = outfile - return outputs + self.outputs.vol_label_file = outfile def _gen_filename(self, name): if name == 'vol_label_file': - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -827,18 +822,16 @@ class MS_LDA(FSCommand): """ _cmd = 'mri_ms_LDA' - input_spec = MS_LDAInputSpec - output_spec = MS_LDAOutputSpec + _input_spec = MS_LDAInputSpec + _output_spec = MS_LDAOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): if isdefined(self.inputs.output_synth): - outputs['vol_synth_file'] = os.path.abspath(self.inputs.output_synth) + self.outputs.vol_synth_file = os.path.abspath(self.inputs.output_synth) else: - outputs['vol_synth_file'] = os.path.abspath(self.inputs.vol_synth_file) + self.outputs.vol_synth_file = os.path.abspath(self.inputs.vol_synth_file) if not isdefined(self.inputs.use_weights) or self.inputs.use_weights is False: - outputs['weight_file'] = os.path.abspath(self.inputs.weight_file) - return outputs + self.outputs.weight_file = os.path.abspath(self.inputs.weight_file) def _verify_weights_file_exists(self): if not os.path.exists(os.path.abspath(self.inputs.weight_file)): diff --git a/nipype/interfaces/freesurfer/preprocess.py b/nipype/interfaces/freesurfer/preprocess.py index 4eeb049be3..b8c56267a9 100644 --- a/nipype/interfaces/freesurfer/preprocess.py +++ b/nipype/interfaces/freesurfer/preprocess.py @@ -63,14 +63,13 @@ class ParseDICOMDir(FSCommand): """ _cmd = 'mri_parse_sdcmdir' - input_spec = ParseDICOMDirInputSpec - output_spec = ParseDICOMDirOutputSpec + _input_spec = ParseDICOMDirInputSpec + _output_spec = ParseDICOMDirOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() if isdefined(self.inputs.dicom_info_file): - outputs['dicom_info_file'] = os.path.join(os.getcwd(), self.inputs.dicom_info_file) - return outputs + self.outputs.dicom_info_file = os.path.join(os.getcwd(), self.inputs.dicom_info_file) class UnpackSDICOMDirInputSpec(FSTraitedSpec): @@ -125,7 +124,7 @@ class UnpackSDICOMDir(FSCommand): 'unpacksdcmdir -generic -targ . -run 5 mprage nii struct -src .' """ _cmd = 'unpacksdcmdir' - input_spec = UnpackSDICOMDirInputSpec + _input_spec = UnpackSDICOMDirInputSpec class MRIConvertInputSpec(FSTraitedSpec): @@ -346,8 +345,8 @@ class MRIConvert(FSCommand): """ _cmd = 'mri_convert' - input_spec = MRIConvertInputSpec - output_spec = MRIConvertOutputSpec + _input_spec = MRIConvertInputSpec + _output_spec = MRIConvertOutputSpec filemap = dict(cor='cor', mgh='mgh', mgz='mgz', minc='mnc', afni='brik', brik='brik', bshort='bshort', @@ -374,8 +373,8 @@ def _get_outfilename(self): use_ext=False) return os.path.abspath(outfile) - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + outfile = self._get_outfilename() if isdefined(self.inputs.split) and self.inputs.split: size = load(self.inputs.in_file).shape @@ -411,8 +410,7 @@ def _list_outputs(self): outfiles.append(fname_presuffix(outfile, suffix='%03d' % (i + 1))) outfile = outfiles - outputs['out_file'] = outfile - return outputs + self.outputs.out_file = outfile def _gen_filename(self, name): if name == 'out_file': @@ -455,7 +453,7 @@ class DICOMConvert(FSCommand): """ _cmd = 'mri_convert' - input_spec = DICOMConvertInputSpec + _input_spec = DICOMConvertInputSpec def _get_dicomfiles(self): """validate fsl bet options @@ -573,8 +571,8 @@ class Resample(FSCommand): """ _cmd = 'mri_convert' - input_spec = ResampleInputSpec - output_spec = ResampleOutputSpec + _input_spec = ResampleInputSpec + _output_spec = ResampleOutputSpec def _get_outfilename(self): if isdefined(self.inputs.resampled_file): @@ -585,10 +583,9 @@ def _get_outfilename(self): suffix='_resample') return outfile - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['resampled_file'] = self._get_outfilename() - return outputs + def _post_run(self): + + self.outputs.resampled_file = self._get_outfilename() def _gen_filename(self, name): if name == 'resampled_file': @@ -619,7 +616,7 @@ class ReconAllInputSpec(CommandLineInputSpec): flags = traits.Str(argstr='%s', desc='additional parameters') -class ReconAllIOutputSpec(FreeSurferSource.output_spec): +class ReconAllIOutputSpec(FreeSurferSource._output_spec): subjects_dir = Directory(exists=True, desc='Freesurfer subjects directory.') subject_id = traits.Str(desc='Subject name for whom to retrieve data') @@ -644,8 +641,8 @@ class ReconAll(CommandLine): _cmd = 'recon-all' _additional_metadata = ['loc', 'altkey'] - input_spec = ReconAllInputSpec - output_spec = ReconAllIOutputSpec + _input_spec = ReconAllInputSpec + _output_spec = ReconAllIOutputSpec _can_resume = True _steps = [ @@ -736,7 +733,7 @@ def _gen_filename(self, name): return self._gen_subjects_dir() return None - def _list_outputs(self): + def _post_run(self): """ See io.FreeSurferSource.outputs for the list of outputs returned """ @@ -750,14 +747,12 @@ def _list_outputs(self): else: hemi = 'both' - outputs = self._outputs().get() outputs.update(FreeSurferSource(subject_id=self.inputs.subject_id, subjects_dir=subjects_dir, hemi=hemi)._list_outputs()) - outputs['subject_id'] = self.inputs.subject_id - outputs['subjects_dir'] = subjects_dir - return outputs + self.outputs.subject_id = self.inputs.subject_id + self.outputs.subjects_dir = subjects_dir def _is_resuming(self): subjects_dir = self.inputs.subjects_dir @@ -865,28 +860,28 @@ class BBRegister(FSCommand): """ _cmd = 'bbregister' - input_spec = BBRegisterInputSpec - output_spec = BBRegisterOutputSpec + _input_spec = BBRegisterInputSpec + _output_spec = BBRegisterOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() _in = self.inputs if isdefined(_in.out_reg_file): - outputs['out_reg_file'] = op.abspath(_in.out_reg_file) + self.outputs.out_reg_file = op.abspath(_in.out_reg_file) elif _in.source_file: suffix = '_bbreg_%s.dat' % _in.subject_id - outputs['out_reg_file'] = fname_presuffix(_in.source_file, + self.outputs.out_reg_file = fname_presuffix(_in.source_file, suffix=suffix, use_ext=False) if isdefined(_in.registered_file): if isinstance(_in.registered_file, bool): - outputs['registered_file'] = fname_presuffix(_in.source_file, + self.outputs.registered_file = fname_presuffix(_in.source_file, suffix='_bbreg') else: - outputs['registered_file'] = op.abspath(_in.registered_file) + self.outputs.registered_file = op.abspath(_in.registered_file) if isdefined(_in.out_fsl_file): if isinstance(_in.out_fsl_file, bool): @@ -894,18 +889,17 @@ def _list_outputs(self): out_fsl_file = fname_presuffix(_in.source_file, suffix=suffix, use_ext=False) - outputs['out_fsl_file'] = out_fsl_file + self.outputs.out_fsl_file = out_fsl_file else: - outputs['out_fsl_file'] = op.abspath(_in.out_fsl_file) + self.outputs.out_fsl_file = op.abspath(_in.out_fsl_file) - outputs['min_cost_file'] = outputs['out_reg_file'] + '.mincost' - return outputs + self.outputs.min_cost_file = self.outputs.out_reg_file + '.mincost' def _format_arg(self, name, spec, value): if name in ['registered_file', 'out_fsl_file']: if isinstance(value, bool): - fname = self._list_outputs()[name] + fname = getattr(self.outputs, name) else: fname = value return spec.argstr % fname @@ -914,7 +908,7 @@ def _format_arg(self, name, spec, value): def _gen_filename(self, name): if name == 'out_reg_file': - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -999,8 +993,8 @@ class ApplyVolTransform(FSCommand): """ _cmd = 'mri_vol2vol' - input_spec = ApplyVolTransformInputSpec - output_spec = ApplyVolTransformOutputSpec + _input_spec = ApplyVolTransformInputSpec + _output_spec = ApplyVolTransformOutputSpec def _get_outfile(self): outfile = self.inputs.transformed_file @@ -1017,10 +1011,9 @@ def _get_outfile(self): suffix='_warped') return outfile - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['transformed_file'] = os.path.abspath(self._get_outfile()) - return outputs + def _post_run(self): + + self.outputs.transformed_file = os.path.abspath(self._get_outfile()) def _gen_filename(self, name): if name == 'transformed_file': @@ -1079,21 +1072,20 @@ class Smooth(FSCommand): """ _cmd = 'mris_volsmooth' - input_spec = SmoothInputSpec - output_spec = SmoothOutputSpec + _input_spec = SmoothInputSpec + _output_spec = SmoothOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() outfile = self.inputs.smoothed_file if not isdefined(outfile): outfile = self._gen_fname(self.inputs.in_file, suffix='_smooth') - outputs['smoothed_file'] = outfile - return outputs + self.outputs.smoothed_file = outfile def _gen_filename(self, name): if name == 'smoothed_file': - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -1189,25 +1181,25 @@ class RobustRegister(FSCommand): """ _cmd = 'mri_robust_register' - input_spec = RobustRegisterInputSpec - output_spec = RobustRegisterOutputSpec + _input_spec = RobustRegisterInputSpec + _output_spec = RobustRegisterOutputSpec def _format_arg(self, name, spec, value): for option in ["registered_file", "weights_file", "half_source", "half_targ", "half_weights", "half_source_xfm", "half_targ_xfm"]: if name == option: if isinstance(value, bool): - fname = self._list_outputs()[name] + fname = getattr(self.outputs, name) else: fname = value return spec.argstr % fname return super(RobustRegister, self)._format_arg(name, spec, value) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_reg_file'] = self.inputs.out_reg_file + def _post_run(self): + + self.outputs.out_reg_file = self.inputs.out_reg_file if not isdefined(self.inputs.out_reg_file) and self.inputs.source_file: - outputs['out_reg_file'] = fname_presuffix(self.inputs.source_file, + self.outputs.out_reg_file = fname_presuffix(self.inputs.source_file, suffix='_robustreg.lta', use_ext=False) prefices = dict(src=self.inputs.source_file, trg=self.inputs.target_file) suffices = dict(registered_file=("src", "_robustreg", True), @@ -1221,17 +1213,16 @@ def _list_outputs(self): value = getattr(self.inputs, name) if isdefined(value): if isinstance(value, bool): - outputs[name] = fname_presuffix(prefices[sufftup[0]], + setattr(self.outputs, name, fname_presuffix(prefices[sufftup[0]], suffix=sufftup[1], newpath=os.getcwd(), - use_ext=sufftup[2]) + use_ext=sufftup[2])) else: - outputs[name] = value - return outputs + setattr(self.outputs, name, value) def _gen_filename(self, name): if name == 'out_reg_file': - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -1269,8 +1260,8 @@ class FitMSParams(FSCommand): """ _cmd = "mri_ms_fitparms" - input_spec = FitMSParamsInputSpec - output_spec = FitMSParamsOutputSpec + _input_spec = FitMSParamsInputSpec + _output_spec = FitMSParamsOutputSpec def _format_arg(self, name, spec, value): if name == "in_files": @@ -1288,16 +1279,15 @@ def _format_arg(self, name, spec, value): return cmd return super(FitMSParams, self)._format_arg(name, spec, value) - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + if not isdefined(self.inputs.out_dir): out_dir = self._gen_filename("out_dir") else: out_dir = self.inputs.out_dir - outputs["t1_image"] = os.path.join(out_dir, "T1.mgz") - outputs["pd_image"] = os.path.join(out_dir, "PD.mgz") - outputs["t2star_image"] = os.path.join(out_dir, "T2star.mgz") - return outputs + self.outputs.t1_image = os.path.join(out_dir, "T1.mgz") + self.outputs.pd_image = os.path.join(out_dir, "PD.mgz") + self.outputs.t2star_image = os.path.join(out_dir, "T2star.mgz") def _gen_filename(self, name): if name == "out_dir": @@ -1342,19 +1332,18 @@ class SynthesizeFLASH(FSCommand): """ _cmd = "mri_synthesize" - input_spec = SynthesizeFLASHInputSpec - output_spec = SynthesizeFLASHOutputSpec + _input_spec = SynthesizeFLASHInputSpec + _output_spec = SynthesizeFLASHOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() if isdefined(self.inputs.out_file): - outputs["out_file"] = self.inputs.out_file + self.outputs.out_file = self.inputs.out_file else: - outputs["out_file"] = self._gen_fname("synth-flash_%02d.mgz" % self.inputs.flip_angle, + self.outputs.out_file = self._gen_fname("synth-flash_%02d.mgz" % self.inputs.flip_angle, suffix="") - return outputs def _gen_filename(self, name): if name == "out_file": - return self._list_outputs()["out_file"] + return self.outputs.out_file return None diff --git a/nipype/interfaces/freesurfer/tests/test_auto_ApplyMask.py b/nipype/interfaces/freesurfer/tests/test_auto_ApplyMask.py index 23bff662ce..e654198d67 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_ApplyMask.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_ApplyMask.py @@ -6,12 +6,6 @@ def test_ApplyMask_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-3, @@ -29,8 +23,6 @@ def test_ApplyMask_inputs(): position=-1, ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), use_abs=dict(argstr='-abs', ), xfm_file=dict(argstr='-xform %s', @@ -40,7 +32,7 @@ def test_ApplyMask_inputs(): xfm_target=dict(argstr='-lta_dst %s', ), ) - inputs = ApplyMask.input_spec() + inputs = ApplyMask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +42,7 @@ def test_ApplyMask_inputs(): def test_ApplyMask_outputs(): output_map = dict(out_file=dict(), ) - outputs = ApplyMask.output_spec() + outputs = ApplyMask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_ApplyVolTransform.py b/nipype/interfaces/freesurfer/tests/test_auto_ApplyVolTransform.py index 0912bc80dd..6bf0628812 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_ApplyVolTransform.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_ApplyVolTransform.py @@ -6,9 +6,6 @@ def test_ApplyVolTransform_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fs_target=dict(argstr='--fstarg', mandatory=True, requires=['reg_file'], @@ -18,9 +15,6 @@ def test_ApplyVolTransform_inputs(): mandatory=True, xor=('reg_file', 'fsl_reg_file', 'xfm_reg_file', 'reg_header', 'subject'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), interp=dict(argstr='--interp %s', ), inverse=dict(argstr='--inv', @@ -62,8 +56,6 @@ def test_ApplyVolTransform_inputs(): mandatory=True, xor=('target_file', 'tal', 'fs_target'), ), - terminal_output=dict(nohash=True, - ), transformed_file=dict(argstr='--o %s', genfile=True, ), @@ -72,7 +64,7 @@ def test_ApplyVolTransform_inputs(): xor=('reg_file', 'fsl_reg_file', 'xfm_reg_file', 'reg_header', 'subject'), ), ) - inputs = ApplyVolTransform.input_spec() + inputs = ApplyVolTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -82,7 +74,7 @@ def test_ApplyVolTransform_inputs(): def test_ApplyVolTransform_outputs(): output_map = dict(transformed_file=dict(), ) - outputs = ApplyVolTransform.output_spec() + outputs = ApplyVolTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_BBRegister.py b/nipype/interfaces/freesurfer/tests/test_auto_BBRegister.py index cb3444c2f0..528fe7afc2 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_BBRegister.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_BBRegister.py @@ -9,14 +9,8 @@ def test_BBRegister_inputs(): contrast_type=dict(argstr='--%s', mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), epi_mask=dict(argstr='--epi-mask', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), init=dict(argstr='--init-%s', mandatory=True, xor=['init_reg_file'], @@ -50,10 +44,8 @@ def test_BBRegister_inputs(): mandatory=True, ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), ) - inputs = BBRegister.input_spec() + inputs = BBRegister._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -66,7 +58,7 @@ def test_BBRegister_outputs(): out_reg_file=dict(), registered_file=dict(), ) - outputs = BBRegister.output_spec() + outputs = BBRegister._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_Binarize.py b/nipype/interfaces/freesurfer/tests/test_auto_Binarize.py index b22d6a98e6..d148f06285 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_Binarize.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_Binarize.py @@ -15,24 +15,20 @@ def test_Binarize_inputs(): bin_val_not=dict(argstr='--binvalnot %d', ), binary_file=dict(argstr='--o %s', - genfile=True, + keep_extension=True, + name_source='in_file', + name_template='_bin', ), count_file=dict(argstr='--count %s', ), dilate=dict(argstr='--dilate %d', ), - environ=dict(nohash=True, - usedefault=True, - ), erode=dict(argstr='--erode %d', ), erode2d=dict(argstr='--erode2d %d', ), frame_no=dict(argstr='--frame %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--i %s', copyfile=False, mandatory=True, @@ -60,8 +56,6 @@ def test_Binarize_inputs(): rmin=dict(argstr='--rmin %f', ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), ventricles=dict(argstr='--ventricles', ), wm=dict(argstr='--wm', @@ -74,7 +68,7 @@ def test_Binarize_inputs(): zero_slice_edge=dict(argstr='--zero-slice-edges', ), ) - inputs = Binarize.input_spec() + inputs = Binarize._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -85,7 +79,7 @@ def test_Binarize_outputs(): output_map = dict(binary_file=dict(), count_file=dict(), ) - outputs = Binarize.output_spec() + outputs = Binarize._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_Concatenate.py b/nipype/interfaces/freesurfer/tests/test_auto_Concatenate.py index 1a5e51758e..21f86b2b73 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_Concatenate.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_Concatenate.py @@ -13,14 +13,8 @@ def test_Concatenate_inputs(): concatenated_file=dict(argstr='--o %s', genfile=True, ), - environ=dict(nohash=True, - usedefault=True, - ), gmean=dict(argstr='--gmean %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='--i %s...', mandatory=True, ), @@ -47,12 +41,10 @@ def test_Concatenate_inputs(): stats=dict(argstr='--%s', ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), vote=dict(argstr='--vote', ), ) - inputs = Concatenate.input_spec() + inputs = Concatenate._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -62,7 +54,7 @@ def test_Concatenate_inputs(): def test_Concatenate_outputs(): output_map = dict(concatenated_file=dict(), ) - outputs = Concatenate.output_spec() + outputs = Concatenate._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_DICOMConvert.py b/nipype/interfaces/freesurfer/tests/test_auto_DICOMConvert.py index 1551f3e44c..6111b46459 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_DICOMConvert.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_DICOMConvert.py @@ -11,13 +11,7 @@ def test_DICOMConvert_inputs(): dicom_dir=dict(mandatory=True, ), dicom_info=dict(), - environ=dict(nohash=True, - usedefault=True, - ), file_mapping=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), ignore_single_slice=dict(requires=['dicom_info'], ), out_type=dict(usedefault=True, @@ -28,12 +22,18 @@ def test_DICOMConvert_inputs(): ), subject_id=dict(), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), ) - inputs = DICOMConvert.input_spec() + inputs = DICOMConvert._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_DICOMConvert_outputs(): + output_map = dict() + outputs = DICOMConvert._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/freesurfer/tests/test_auto_ExtractMainComponent.py b/nipype/interfaces/freesurfer/tests/test_auto_ExtractMainComponent.py index 617a696a2b..3c5edd9436 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_ExtractMainComponent.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_ExtractMainComponent.py @@ -6,12 +6,6 @@ def test_ExtractMainComponent_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=1, @@ -21,10 +15,8 @@ def test_ExtractMainComponent_inputs(): name_template='%s.maincmp', position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ExtractMainComponent.input_spec() + inputs = ExtractMainComponent._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_ExtractMainComponent_inputs(): def test_ExtractMainComponent_outputs(): output_map = dict(out_file=dict(), ) - outputs = ExtractMainComponent.output_spec() + outputs = ExtractMainComponent._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_FSCommand.py b/nipype/interfaces/freesurfer/tests/test_auto_FSCommand.py index f463310c33..be9b409a13 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_FSCommand.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_FSCommand.py @@ -6,19 +6,19 @@ def test_FSCommand_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), ) - inputs = FSCommand.input_spec() + inputs = FSCommand._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_FSCommand_outputs(): + output_map = dict() + outputs = FSCommand._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/freesurfer/tests/test_auto_FitMSParams.py b/nipype/interfaces/freesurfer/tests/test_auto_FitMSParams.py index e54c0ddcc7..2fa15ddf04 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_FitMSParams.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_FitMSParams.py @@ -6,13 +6,7 @@ def test_FitMSParams_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), flip_list=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='%s', mandatory=True, position=-2, @@ -23,12 +17,10 @@ def test_FitMSParams_inputs(): ), subjects_dir=dict(), te_list=dict(), - terminal_output=dict(nohash=True, - ), tr_list=dict(), xfm_list=dict(), ) - inputs = FitMSParams.input_spec() + inputs = FitMSParams._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_FitMSParams_outputs(): t1_image=dict(), t2star_image=dict(), ) - outputs = FitMSParams.output_spec() + outputs = FitMSParams._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_GLMFit.py b/nipype/interfaces/freesurfer/tests/test_auto_GLMFit.py index 41f09cb1a8..4d51982f29 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_GLMFit.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_GLMFit.py @@ -29,9 +29,6 @@ def test_GLMFit_inputs(): diag=dict(), diag_cluster=dict(argstr='--diag-cluster', ), - environ=dict(nohash=True, - usedefault=True, - ), fixed_fx_dof=dict(argstr='--ffxdof %d', xor=['fixed_fx_dof_file'], ), @@ -51,9 +48,6 @@ def test_GLMFit_inputs(): genfile=True, ), hemi=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--y %s', copyfile=False, mandatory=True, @@ -117,8 +111,6 @@ def test_GLMFit_inputs(): ), synth=dict(argstr='--synth', ), - terminal_output=dict(nohash=True, - ), uniform=dict(argstr='--uniform %f %f', ), var_fwhm=dict(argstr='--var-fwhm %f', @@ -137,7 +129,7 @@ def test_GLMFit_inputs(): xor=('weight_file', 'weight_inv', 'weight_sqrt'), ), ) - inputs = GLMFit.input_spec() + inputs = GLMFit._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -163,7 +155,7 @@ def test_GLMFit_outputs(): spatial_eigenvectors=dict(), svd_stats_file=dict(), ) - outputs = GLMFit.output_spec() + outputs = GLMFit._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_ImageInfo.py b/nipype/interfaces/freesurfer/tests/test_auto_ImageInfo.py index 5d409f2966..dab102c1d8 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_ImageInfo.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_ImageInfo.py @@ -6,20 +6,12 @@ def test_ImageInfo_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', position=1, ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), ) - inputs = ImageInfo.input_spec() + inputs = ImageInfo._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_ImageInfo_outputs(): ph_enc_dir=dict(), vox_sizes=dict(), ) - outputs = ImageInfo.output_spec() + outputs = ImageInfo._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_Label2Vol.py b/nipype/interfaces/freesurfer/tests/test_auto_Label2Vol.py index 4ed1bb441c..59a9b74b68 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_Label2Vol.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_Label2Vol.py @@ -16,9 +16,6 @@ def test_Label2Vol_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fill_thresh=dict(argstr='--fillthresh %.f', ), hemi=dict(argstr='--hemi %s', @@ -26,9 +23,6 @@ def test_Label2Vol_inputs(): identity=dict(argstr='--identity', xor=('reg_file', 'reg_header', 'identity'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), invert_mtx=dict(argstr='--invertmtx', ), label_file=dict(argstr='--label %s...', @@ -66,13 +60,11 @@ def test_Label2Vol_inputs(): template_file=dict(argstr='--temp %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), vol_label_file=dict(argstr='--o %s', genfile=True, ), ) - inputs = Label2Vol.input_spec() + inputs = Label2Vol._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -82,7 +74,7 @@ def test_Label2Vol_inputs(): def test_Label2Vol_outputs(): output_map = dict(vol_label_file=dict(), ) - outputs = Label2Vol.output_spec() + outputs = Label2Vol._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MRIConvert.py b/nipype/interfaces/freesurfer/tests/test_auto_MRIConvert.py index ad6fd9e55c..2207dca6b2 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MRIConvert.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MRIConvert.py @@ -34,9 +34,6 @@ def test_MRIConvert_inputs(): ), drop_n=dict(argstr='--ndrop %d', ), - environ=dict(nohash=True, - usedefault=True, - ), fill_parcellation=dict(argstr='--fill_parcellation', ), force_ras=dict(argstr='--force_ras_good', @@ -47,9 +44,6 @@ def test_MRIConvert_inputs(): ), fwhm=dict(argstr='--fwhm %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_center=dict(argstr='--in_center %s', ), in_file=dict(argstr='--input_volume %s', @@ -168,8 +162,6 @@ def test_MRIConvert_inputs(): template_info=dict(), template_type=dict(argstr='--template_type %s', ), - terminal_output=dict(nohash=True, - ), ti=dict(argstr='-ti %d', ), tr=dict(argstr='-tr %d', @@ -183,7 +175,7 @@ def test_MRIConvert_inputs(): zero_outlines=dict(argstr='--zero_outlines', ), ) - inputs = MRIConvert.input_spec() + inputs = MRIConvert._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -193,7 +185,7 @@ def test_MRIConvert_inputs(): def test_MRIConvert_outputs(): output_map = dict(out_file=dict(), ) - outputs = MRIConvert.output_spec() + outputs = MRIConvert._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MRIMarchingCubes.py b/nipype/interfaces/freesurfer/tests/test_auto_MRIMarchingCubes.py index 44c4725e8e..6521f49d23 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MRIMarchingCubes.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MRIMarchingCubes.py @@ -10,12 +10,6 @@ def test_MRIMarchingCubes_inputs(): position=-1, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=1, @@ -29,10 +23,8 @@ def test_MRIMarchingCubes_inputs(): position=-2, ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), ) - inputs = MRIMarchingCubes.input_spec() + inputs = MRIMarchingCubes._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_MRIMarchingCubes_inputs(): def test_MRIMarchingCubes_outputs(): output_map = dict(surface=dict(), ) - outputs = MRIMarchingCubes.output_spec() + outputs = MRIMarchingCubes._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MRIPretess.py b/nipype/interfaces/freesurfer/tests/test_auto_MRIPretess.py index ce3e7a244b..4b1fb1b93b 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MRIPretess.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MRIPretess.py @@ -6,12 +6,6 @@ def test_MRIPretess_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_filled=dict(argstr='%s', mandatory=True, position=-4, @@ -34,12 +28,10 @@ def test_MRIPretess_inputs(): position=-1, ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), test=dict(argstr='-test', ), ) - inputs = MRIPretess.input_spec() + inputs = MRIPretess._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -49,7 +41,7 @@ def test_MRIPretess_inputs(): def test_MRIPretess_outputs(): output_map = dict(out_file=dict(), ) - outputs = MRIPretess.output_spec() + outputs = MRIPretess._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MRISPreproc.py b/nipype/interfaces/freesurfer/tests/test_auto_MRISPreproc.py index 306ca4cd8e..5fa79164bf 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MRISPreproc.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MRISPreproc.py @@ -6,9 +6,6 @@ def test_MRISPreproc_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fsgd_file=dict(argstr='--fsgd %s', xor=('subjects', 'fsgd_file', 'subject_file'), ), @@ -21,9 +18,6 @@ def test_MRISPreproc_inputs(): hemi=dict(argstr='--hemi %s', mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), num_iters=dict(argstr='--niters %d', xor=['fwhm'], ), @@ -60,12 +54,10 @@ def test_MRISPreproc_inputs(): target=dict(argstr='--target %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), vol_measure_file=dict(argstr='--iv %s %s...', ), ) - inputs = MRISPreproc.input_spec() + inputs = MRISPreproc._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -75,7 +67,7 @@ def test_MRISPreproc_inputs(): def test_MRISPreproc_outputs(): output_map = dict(out_file=dict(), ) - outputs = MRISPreproc.output_spec() + outputs = MRISPreproc._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MRITessellate.py b/nipype/interfaces/freesurfer/tests/test_auto_MRITessellate.py index 3aea6fb331..7005f18928 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MRITessellate.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MRITessellate.py @@ -6,12 +6,6 @@ def test_MRITessellate_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-3, @@ -25,14 +19,12 @@ def test_MRITessellate_inputs(): position=-1, ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), tesselate_all_voxels=dict(argstr='-a', ), use_real_RAS_coordinates=dict(argstr='-n', ), ) - inputs = MRITessellate.input_spec() + inputs = MRITessellate._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_MRITessellate_inputs(): def test_MRITessellate_outputs(): output_map = dict(surface=dict(), ) - outputs = MRITessellate.output_spec() + outputs = MRITessellate._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MRIsConvert.py b/nipype/interfaces/freesurfer/tests/test_auto_MRIsConvert.py index 86c949f645..d621e9c46f 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MRIsConvert.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MRIsConvert.py @@ -10,14 +10,8 @@ def test_MRIsConvert_inputs(): ), dataarray_num=dict(argstr='--da_num %d', ), - environ=dict(nohash=True, - usedefault=True, - ), functional_file=dict(argstr='-f %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -30,10 +24,12 @@ def test_MRIsConvert_inputs(): ), origname=dict(argstr='-o %s', ), - out_datatype=dict(xor=['out_file'], + out_datatype=dict(mandatory=True, + xor=['out_file'], ), out_file=dict(argstr='%s', genfile=True, + mandatory=True, position=-1, xor=['out_datatype'], ), @@ -50,14 +46,12 @@ def test_MRIsConvert_inputs(): subjects_dir=dict(), talairachxfm_subjid=dict(argstr='-t %s', ), - terminal_output=dict(nohash=True, - ), vertex=dict(argstr='-v', ), xyz_ascii=dict(argstr='-a', ), ) - inputs = MRIsConvert.input_spec() + inputs = MRIsConvert._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -67,7 +61,7 @@ def test_MRIsConvert_inputs(): def test_MRIsConvert_outputs(): output_map = dict(converted=dict(), ) - outputs = MRIsConvert.output_spec() + outputs = MRIsConvert._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MS_LDA.py b/nipype/interfaces/freesurfer/tests/test_auto_MS_LDA.py index 30264881c8..f28c15db71 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MS_LDA.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MS_LDA.py @@ -8,12 +8,6 @@ def test_MS_LDA_inputs(): ), conform=dict(argstr='-conform', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), images=dict(argstr='%s', copyfile=False, mandatory=True, @@ -30,8 +24,6 @@ def test_MS_LDA_inputs(): shift=dict(argstr='-shift %d', ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), use_weights=dict(argstr='-W', ), vol_synth_file=dict(argstr='-synth %s', @@ -41,7 +33,7 @@ def test_MS_LDA_inputs(): mandatory=True, ), ) - inputs = MS_LDA.input_spec() + inputs = MS_LDA._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_MS_LDA_outputs(): output_map = dict(vol_synth_file=dict(), weight_file=dict(), ) - outputs = MS_LDA.output_spec() + outputs = MS_LDA._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_MakeAverageSubject.py b/nipype/interfaces/freesurfer/tests/test_auto_MakeAverageSubject.py index 5dd694a707..cce1ceb323 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_MakeAverageSubject.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_MakeAverageSubject.py @@ -6,12 +6,6 @@ def test_MakeAverageSubject_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), out_name=dict(argstr='--out %s', usedefault=True, ), @@ -20,10 +14,8 @@ def test_MakeAverageSubject_inputs(): mandatory=True, sep=' ', ), - terminal_output=dict(nohash=True, - ), ) - inputs = MakeAverageSubject.input_spec() + inputs = MakeAverageSubject._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -33,7 +25,7 @@ def test_MakeAverageSubject_inputs(): def test_MakeAverageSubject_outputs(): output_map = dict(average_subject_name=dict(), ) - outputs = MakeAverageSubject.output_spec() + outputs = MakeAverageSubject._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_OneSampleTTest.py b/nipype/interfaces/freesurfer/tests/test_auto_OneSampleTTest.py index b33ecf5856..7bb8273d26 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_OneSampleTTest.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_OneSampleTTest.py @@ -29,9 +29,6 @@ def test_OneSampleTTest_inputs(): diag=dict(), diag_cluster=dict(argstr='--diag-cluster', ), - environ=dict(nohash=True, - usedefault=True, - ), fixed_fx_dof=dict(argstr='--ffxdof %d', xor=['fixed_fx_dof_file'], ), @@ -51,9 +48,6 @@ def test_OneSampleTTest_inputs(): genfile=True, ), hemi=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--y %s', copyfile=False, mandatory=True, @@ -117,8 +111,6 @@ def test_OneSampleTTest_inputs(): ), synth=dict(argstr='--synth', ), - terminal_output=dict(nohash=True, - ), uniform=dict(argstr='--uniform %f %f', ), var_fwhm=dict(argstr='--var-fwhm %f', @@ -137,7 +129,7 @@ def test_OneSampleTTest_inputs(): xor=('weight_file', 'weight_inv', 'weight_sqrt'), ), ) - inputs = OneSampleTTest.input_spec() + inputs = OneSampleTTest._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -163,7 +155,7 @@ def test_OneSampleTTest_outputs(): spatial_eigenvectors=dict(), svd_stats_file=dict(), ) - outputs = OneSampleTTest.output_spec() + outputs = OneSampleTTest._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_ParseDICOMDir.py b/nipype/interfaces/freesurfer/tests/test_auto_ParseDICOMDir.py index a2afa891d9..050f618f28 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_ParseDICOMDir.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_ParseDICOMDir.py @@ -12,21 +12,13 @@ def test_ParseDICOMDir_inputs(): dicom_info_file=dict(argstr='--o %s', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), sortbyrun=dict(argstr='--sortbyrun', ), subjects_dir=dict(), summarize=dict(argstr='--summarize', ), - terminal_output=dict(nohash=True, - ), ) - inputs = ParseDICOMDir.input_spec() + inputs = ParseDICOMDir._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_ParseDICOMDir_inputs(): def test_ParseDICOMDir_outputs(): output_map = dict(dicom_info_file=dict(), ) - outputs = ParseDICOMDir.output_spec() + outputs = ParseDICOMDir._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_ReconAll.py b/nipype/interfaces/freesurfer/tests/test_auto_ReconAll.py index 2ed5d7929f..ce63fc324f 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_ReconAll.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_ReconAll.py @@ -15,16 +15,10 @@ def test_ReconAll_inputs(): position=0, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), flags=dict(argstr='%s', ), hemi=dict(argstr='-hemi %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), openmp=dict(argstr='-openmp %d', ), subject_id=dict(argstr='-subjid %s', @@ -34,13 +28,11 @@ def test_ReconAll_inputs(): genfile=True, hash_files=False, ), - terminal_output=dict(nohash=True, - ), use_T2=dict(argstr='-T2pial', min_ver='5.3.0', ), ) - inputs = ReconAll.input_spec() + inputs = ReconAll._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -127,7 +119,7 @@ def test_ReconAll_outputs(): loc='stats', ), ) - outputs = ReconAll.output_spec() + outputs = ReconAll._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_Resample.py b/nipype/interfaces/freesurfer/tests/test_auto_Resample.py index befb0b9d01..61ccaaab7c 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_Resample.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_Resample.py @@ -6,12 +6,6 @@ def test_Resample_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, position=-2, @@ -21,13 +15,11 @@ def test_Resample_inputs(): position=-1, ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), voxel_size=dict(argstr='-vs %.2f %.2f %.2f', mandatory=True, ), ) - inputs = Resample.input_spec() + inputs = Resample._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +29,7 @@ def test_Resample_inputs(): def test_Resample_outputs(): output_map = dict(resampled_file=dict(), ) - outputs = Resample.output_spec() + outputs = Resample._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_RobustRegister.py b/nipype/interfaces/freesurfer/tests/test_auto_RobustRegister.py index 9c52782acc..524b65b823 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_RobustRegister.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_RobustRegister.py @@ -10,9 +10,6 @@ def test_RobustRegister_inputs(): mandatory=True, xor=['outlier_sens'], ), - environ=dict(nohash=True, - usedefault=True, - ), est_int_scale=dict(argstr='--iscale', ), force_double=dict(argstr='--doubleprec', @@ -31,9 +28,6 @@ def test_RobustRegister_inputs(): ), high_iterations=dict(argstr='--highit %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_xfm_file=dict(argstr='--transform', ), init_orient=dict(argstr='--initorient', @@ -72,8 +66,6 @@ def test_RobustRegister_inputs(): target_file=dict(argstr='--dst %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), trans_only=dict(argstr='--transonly', ), weights_file=dict(argstr='--weights %s', @@ -81,7 +73,7 @@ def test_RobustRegister_inputs(): write_vo2vox=dict(argstr='--vox2vox', ), ) - inputs = RobustRegister.input_spec() + inputs = RobustRegister._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -98,7 +90,7 @@ def test_RobustRegister_outputs(): registered_file=dict(), weights_file=dict(), ) - outputs = RobustRegister.output_spec() + outputs = RobustRegister._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py b/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py index 8a08a621f8..23c9f063b6 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_SampleToSurface.py @@ -13,9 +13,6 @@ def test_SampleToSurface_inputs(): cortex_mask=dict(argstr='--cortex', xor=['mask_label'], ), - environ=dict(nohash=True, - usedefault=True, - ), fix_tk_reg=dict(argstr='--fixtkreg', ), float2int_method=dict(argstr='--float2int %s', @@ -32,9 +29,6 @@ def test_SampleToSurface_inputs(): ico_order=dict(argstr='--icoorder %d', requires=['target_subject'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), interp_method=dict(argstr='--interp %s', ), mask_label=dict(argstr='--mask %s', @@ -99,12 +93,10 @@ def test_SampleToSurface_inputs(): ), target_subject=dict(argstr='--trgsubject %s', ), - terminal_output=dict(nohash=True, - ), vox_file=dict(argstr='--nvox %s', ), ) - inputs = SampleToSurface.input_spec() + inputs = SampleToSurface._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -116,7 +108,7 @@ def test_SampleToSurface_outputs(): out_file=dict(), vox_file=dict(), ) - outputs = SampleToSurface.output_spec() + outputs = SampleToSurface._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_SegStats.py b/nipype/interfaces/freesurfer/tests/test_auto_SegStats.py index 2a69e99de3..6d7191fa8d 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_SegStats.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_SegStats.py @@ -27,9 +27,6 @@ def test_SegStats_inputs(): default_color_table=dict(argstr='--ctab-default', xor=('color_table_file', 'default_color_table', 'gca_color_table'), ), - environ=dict(nohash=True, - usedefault=True, - ), etiv=dict(argstr='--etiv', ), etiv_only=dict(), @@ -42,9 +39,6 @@ def test_SegStats_inputs(): gca_color_table=dict(argstr='--ctab-gca %s', xor=('color_table_file', 'default_color_table', 'gca_color_table'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--i %s', ), mask_erode=dict(argstr='--maskerode %d', @@ -80,14 +74,12 @@ def test_SegStats_inputs(): mandatory=True, xor=('segmentation_file', 'annot', 'surf_label'), ), - terminal_output=dict(nohash=True, - ), vox=dict(argstr='--vox %s', ), wm_vol_from_surf=dict(argstr='--surf-wm-vol', ), ) - inputs = SegStats.input_spec() + inputs = SegStats._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -100,7 +92,7 @@ def test_SegStats_outputs(): sf_avg_file=dict(), summary_file=dict(), ) - outputs = SegStats.output_spec() + outputs = SegStats._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_Smooth.py b/nipype/interfaces/freesurfer/tests/test_auto_Smooth.py index 16fefa2873..1091f09806 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_Smooth.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_Smooth.py @@ -6,12 +6,6 @@ def test_Smooth_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--i %s', mandatory=True, ), @@ -37,12 +31,10 @@ def test_Smooth_inputs(): requires=['reg_file'], xor=['num_iters'], ), - terminal_output=dict(nohash=True, - ), vol_fwhm=dict(argstr='--vol-fwhm %f', ), ) - inputs = Smooth.input_spec() + inputs = Smooth._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_Smooth_inputs(): def test_Smooth_outputs(): output_map = dict(smoothed_file=dict(), ) - outputs = Smooth.output_spec() + outputs = Smooth._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_SmoothTessellation.py b/nipype/interfaces/freesurfer/tests/test_auto_SmoothTessellation.py index 2ba9b80134..53afb2375a 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_SmoothTessellation.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_SmoothTessellation.py @@ -12,18 +12,12 @@ def test_SmoothTessellation_inputs(): ), disable_estimates=dict(argstr='-nw', ), - environ=dict(nohash=True, - usedefault=True, - ), gaussian_curvature_norm_steps=dict(argstr='%d ', position=4, ), gaussian_curvature_smoothing_steps=dict(argstr='%d', position=5, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=1, @@ -45,15 +39,13 @@ def test_SmoothTessellation_inputs(): snapshot_writing_iterations=dict(argstr='-w %d', ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), use_gaussian_curvature_smoothing=dict(argstr='-g', position=3, ), use_momentum=dict(argstr='-m', ), ) - inputs = SmoothTessellation.input_spec() + inputs = SmoothTessellation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -63,7 +55,7 @@ def test_SmoothTessellation_inputs(): def test_SmoothTessellation_outputs(): output_map = dict(surface=dict(), ) - outputs = SmoothTessellation.output_spec() + outputs = SmoothTessellation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_Surface2VolTransform.py b/nipype/interfaces/freesurfer/tests/test_auto_Surface2VolTransform.py index 7da293e7bd..878453c109 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_Surface2VolTransform.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_Surface2VolTransform.py @@ -6,15 +6,9 @@ def test_Surface2VolTransform_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), hemi=dict(argstr='--hemi %s', mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), mkmask=dict(argstr='--mkmask', xor=['source_file'], ), @@ -38,8 +32,6 @@ def test_Surface2VolTransform_inputs(): ), template_file=dict(argstr='--template %s', ), - terminal_output=dict(nohash=True, - ), transformed_file=dict(argstr='--outvol %s', hash_files=False, name_source=['source_file'], @@ -51,7 +43,7 @@ def test_Surface2VolTransform_inputs(): name_template='%s_asVol_vertex.nii', ), ) - inputs = Surface2VolTransform.input_spec() + inputs = Surface2VolTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -62,7 +54,7 @@ def test_Surface2VolTransform_outputs(): output_map = dict(transformed_file=dict(), vertexvol_file=dict(), ) - outputs = Surface2VolTransform.output_spec() + outputs = Surface2VolTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_SurfaceSmooth.py b/nipype/interfaces/freesurfer/tests/test_auto_SurfaceSmooth.py index 92d145cfc9..8de3a83ce2 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_SurfaceSmooth.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_SurfaceSmooth.py @@ -9,18 +9,12 @@ def test_SurfaceSmooth_inputs(): cortex=dict(argstr='--cortex', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), fwhm=dict(argstr='--fwhm %.4f', xor=['smooth_iters'], ), hemi=dict(argstr='--hemi %s', mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--sval %s', mandatory=True, ), @@ -36,10 +30,8 @@ def test_SurfaceSmooth_inputs(): mandatory=True, ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), ) - inputs = SurfaceSmooth.input_spec() + inputs = SurfaceSmooth._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -49,7 +41,7 @@ def test_SurfaceSmooth_inputs(): def test_SurfaceSmooth_outputs(): output_map = dict(out_file=dict(), ) - outputs = SurfaceSmooth.output_spec() + outputs = SurfaceSmooth._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_SurfaceSnapshots.py b/nipype/interfaces/freesurfer/tests/test_auto_SurfaceSnapshots.py index 46411c9fca..d2e4fb27a0 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_SurfaceSnapshots.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_SurfaceSnapshots.py @@ -16,9 +16,6 @@ def test_SurfaceSnapshots_inputs(): ), demean_overlay=dict(argstr='-zm', ), - environ=dict(nohash=True, - usedefault=True, - ), hemi=dict(argstr='%s', mandatory=True, position=2, @@ -26,9 +23,6 @@ def test_SurfaceSnapshots_inputs(): identity_reg=dict(argstr='-overlay-reg-identity', xor=['overlay_reg', 'identity_reg', 'mni152_reg'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), invert_overlay=dict(argstr='-invphaseflag 1', ), label_file=dict(argstr='-label %s', @@ -88,12 +82,10 @@ def test_SurfaceSnapshots_inputs(): tcl_script=dict(argstr='%s', genfile=True, ), - terminal_output=dict(nohash=True, - ), truncate_overlay=dict(argstr='-truncphaseflag 1', ), ) - inputs = SurfaceSnapshots.input_spec() + inputs = SurfaceSnapshots._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -103,7 +95,7 @@ def test_SurfaceSnapshots_inputs(): def test_SurfaceSnapshots_outputs(): output_map = dict(snapshots=dict(), ) - outputs = SurfaceSnapshots.output_spec() + outputs = SurfaceSnapshots._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_SurfaceTransform.py b/nipype/interfaces/freesurfer/tests/test_auto_SurfaceTransform.py index 250f697402..421467edbd 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_SurfaceTransform.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_SurfaceTransform.py @@ -6,15 +6,9 @@ def test_SurfaceTransform_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), hemi=dict(argstr='--hemi %s', mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), out_file=dict(argstr='--tval %s', genfile=True, ), @@ -44,10 +38,8 @@ def test_SurfaceTransform_inputs(): ), target_type=dict(argstr='--tfmt %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = SurfaceTransform.input_spec() + inputs = SurfaceTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -57,7 +49,7 @@ def test_SurfaceTransform_inputs(): def test_SurfaceTransform_outputs(): output_map = dict(out_file=dict(), ) - outputs = SurfaceTransform.output_spec() + outputs = SurfaceTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_SynthesizeFLASH.py b/nipype/interfaces/freesurfer/tests/test_auto_SynthesizeFLASH.py index fc213c7411..5b3ab0a4ae 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_SynthesizeFLASH.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_SynthesizeFLASH.py @@ -6,9 +6,6 @@ def test_SynthesizeFLASH_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fixed_weighting=dict(argstr='-w', position=1, ), @@ -16,9 +13,6 @@ def test_SynthesizeFLASH_inputs(): mandatory=True, position=3, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), out_file=dict(argstr='%s', genfile=True, ), @@ -35,14 +29,12 @@ def test_SynthesizeFLASH_inputs(): mandatory=True, position=4, ), - terminal_output=dict(nohash=True, - ), tr=dict(argstr='%.2f', mandatory=True, position=2, ), ) - inputs = SynthesizeFLASH.input_spec() + inputs = SynthesizeFLASH._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_SynthesizeFLASH_inputs(): def test_SynthesizeFLASH_outputs(): output_map = dict(out_file=dict(), ) - outputs = SynthesizeFLASH.output_spec() + outputs = SynthesizeFLASH._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_Tkregister2.py b/nipype/interfaces/freesurfer/tests/test_auto_Tkregister2.py index 150bfac675..ac5498dbd9 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_Tkregister2.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_Tkregister2.py @@ -6,9 +6,6 @@ def test_Tkregister2_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fsl_in_matrix=dict(argstr='--fsl %s', ), fsl_out=dict(argstr='--fslregout %s', @@ -19,9 +16,6 @@ def test_Tkregister2_inputs(): fstarg=dict(argstr='--fstarg', xor=['target_image'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), moving_image=dict(argstr='--mov %s', mandatory=True, ), @@ -42,12 +36,10 @@ def test_Tkregister2_inputs(): target_image=dict(argstr='--targ %s', xor=['fstarg'], ), - terminal_output=dict(nohash=True, - ), xfm=dict(argstr='--xfm %s', ), ) - inputs = Tkregister2.input_spec() + inputs = Tkregister2._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +50,7 @@ def test_Tkregister2_outputs(): output_map = dict(fsl_file=dict(), reg_file=dict(), ) - outputs = Tkregister2.output_spec() + outputs = Tkregister2._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/freesurfer/tests/test_auto_UnpackSDICOMDir.py b/nipype/interfaces/freesurfer/tests/test_auto_UnpackSDICOMDir.py index 40e1c65378..8e494f6249 100644 --- a/nipype/interfaces/freesurfer/tests/test_auto_UnpackSDICOMDir.py +++ b/nipype/interfaces/freesurfer/tests/test_auto_UnpackSDICOMDir.py @@ -12,12 +12,6 @@ def test_UnpackSDICOMDir_inputs(): ), dir_structure=dict(argstr='-%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), log_file=dict(argstr='-log %s', ), no_info_dump=dict(argstr='-noinfodump', @@ -42,12 +36,18 @@ def test_UnpackSDICOMDir_inputs(): spm_zeropad=dict(argstr='-nspmzeropad %d', ), subjects_dir=dict(), - terminal_output=dict(nohash=True, - ), ) - inputs = UnpackSDICOMDir.input_spec() + inputs = UnpackSDICOMDir._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_UnpackSDICOMDir_outputs(): + output_map = dict() + outputs = UnpackSDICOMDir._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/freesurfer/utils.py b/nipype/interfaces/freesurfer/utils.py index 49ae5f72e8..30e8e15cf3 100644 --- a/nipype/interfaces/freesurfer/utils.py +++ b/nipype/interfaces/freesurfer/utils.py @@ -48,9 +48,8 @@ class SampleToSurfaceInputSpec(FSTraitedSpec): reg_header = traits.Bool(argstr="--regheader %s", requires=["subject_id"], mandatory=True, xor=reg_xors, desc="register based on header geometry") - mni152reg = traits.Bool(argstr="--mni152reg", - mandatory=True, xor=reg_xors, - desc="source volume is in MNI152 space") + mni152reg = traits.Bool(False, argstr="--mni152reg", mandatory=True, + xor=reg_xors, desc="source volume is in MNI152 space") apply_rot = traits.Tuple(traits.Float, traits.Float, traits.Float, argstr="--rot %.3f %.3f %.3f", @@ -150,8 +149,8 @@ class SampleToSurface(FSCommand): """ _cmd = "mri_vol2surf" - input_spec = SampleToSurfaceInputSpec - output_spec = SampleToSurfaceOutputSpec + _input_spec = SampleToSurfaceInputSpec + _output_spec = SampleToSurfaceOutputSpec filemap = dict(cor='cor', mgh='mgh', mgz='mgz', minc='mnc', afni='brik', brik='brik', bshort='bshort', @@ -199,12 +198,11 @@ def _get_outfilename(self, opt="out_file"): use_ext=False) return outfile - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_file"] = os.path.abspath(self._get_outfilename()) + def _post_run(self): + self.outputs.out_file = os.path.abspath(self._get_outfilename()) hitsfile = self.inputs.hits_file if isdefined(hitsfile): - outputs["hits_file"] = hitsfile + self.outputs.hits_file = hitsfile if isinstance(hitsfile, bool): hitsfile = self._get_outfilename("hits_file") voxfile = self.inputs.vox_file @@ -215,12 +213,11 @@ def _list_outputs(self): prefix=self.inputs.hemi + ".", suffix="_vox.txt", use_ext=False) - outputs["vox_file"] = voxfile - return outputs + self.outputs.vox_file = voxfile def _gen_filename(self, name): if name == "out_file": - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -271,26 +268,24 @@ class SurfaceSmooth(FSCommand): """ _cmd = "mri_surf2surf" - input_spec = SurfaceSmoothInputSpec - output_spec = SurfaceSmoothOutputSpec + _input_spec = SurfaceSmoothInputSpec + _output_spec = SurfaceSmoothOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_file"] = self.inputs.out_file - if not isdefined(outputs["out_file"]): + def _post_run(self): + self.outputs.out_file = self.inputs.out_file + if not isdefined(self.outputs.out_file): in_file = self.inputs.in_file if isdefined(self.inputs.fwhm): kernel = self.inputs.fwhm else: kernel = self.inputs.smooth_iters - outputs["out_file"] = fname_presuffix(in_file, + self.outputs.out_file = fname_presuffix(in_file, suffix="_smooth%d" % kernel, newpath=os.getcwd()) - return outputs def _gen_filename(self, name): if name == "out_file": - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -349,13 +344,12 @@ class SurfaceTransform(FSCommand): """ _cmd = "mri_surf2surf" - input_spec = SurfaceTransformInputSpec - output_spec = SurfaceTransformOutputSpec + _input_spec = SurfaceTransformInputSpec + _output_spec = SurfaceTransformOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_file"] = self.inputs.out_file - if not isdefined(outputs["out_file"]): + def _post_run(self): + self.outputs.out_file = self.inputs.out_file + if not isdefined(self.outputs.out_file): if isdefined(self.inputs.source_file): source = self.inputs.source_file else: @@ -374,17 +368,16 @@ def _list_outputs(self): if isdefined(self.inputs.target_type): ext = "." + filemap[self.inputs.target_type] use_ext = False - outputs["out_file"] = fname_presuffix(source, + self.outputs.out_file = fname_presuffix(source, suffix=".%s%s" % (self.inputs.target_subject, ext), newpath=os.getcwd(), use_ext=use_ext) else: - outputs["out_file"] = os.path.abspath(self.inputs.out_file) - return outputs + self.outputs.out_file = os.path.abspath(self.inputs.out_file) def _gen_filename(self, name): if name == "out_file": - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -448,8 +441,8 @@ class Surface2VolTransform(FSCommand): """ _cmd = 'mri_surf2vol' - input_spec = Surface2VolTransformInputSpec - output_spec = Surface2VolTransformOutputSpec + _input_spec = Surface2VolTransformInputSpec + _output_spec = Surface2VolTransformOutputSpec class ApplyMaskInputSpec(FSTraitedSpec): @@ -483,24 +476,22 @@ class ApplyMask(FSCommand): """ _cmd = "mri_mask" - input_spec = ApplyMaskInputSpec - output_spec = ApplyMaskOutputSpec - - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_file"] = self.inputs.out_file - if not isdefined(outputs["out_file"]): - outputs["out_file"] = fname_presuffix(self.inputs.in_file, + _input_spec = ApplyMaskInputSpec + _output_spec = ApplyMaskOutputSpec + + def _post_run(self): + self.outputs.out_file = self.inputs.out_file + if not isdefined(self.outputs.out_file): + self.outputs.out_file = fname_presuffix(self.inputs.in_file, suffix="_masked", newpath=os.getcwd(), use_ext=True) else: - outputs["out_file"] = os.path.abspath(outputs["out_file"]) - return outputs + self.outputs.out_file = os.path.abspath(self.outputs.out_file) def _gen_filename(self, name): if name == "out_file": - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -607,8 +598,8 @@ class SurfaceSnapshots(FSCommand): """ _cmd = "tksurfer" - input_spec = SurfaceSnapshotsInputSpec - output_spec = SurfaceSnapshotsOutputSpec + _input_spec = SurfaceSnapshotsInputSpec + _output_spec = SurfaceSnapshotsOutputSpec def _format_arg(self, name, spec, value): if name == "tcl_script": @@ -692,8 +683,7 @@ def _write_tcl_script(self): fid.write("\n".join(script)) fid.close() - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): if not isdefined(self.inputs.screenshot_stem): stem = "%s_%s_%s" % (self.inputs.subject_id, self.inputs.hemi, self.inputs.surface) else: @@ -706,8 +696,7 @@ def _list_outputs(self): if self.inputs.six_images: snapshots.extend(["%s-pos.tif", "%s-ant.tif"]) snapshots = [self._gen_fname(f % stem, suffix="") for f in snapshots] - outputs["snapshots"] = snapshots - return outputs + self.outputs.snapshots = snapshots def _gen_filename(self, name): if name == "tcl_script": @@ -738,8 +727,8 @@ class ImageInfoOutputSpec(TraitedSpec): class ImageInfo(FSCommand): _cmd = "mri_info" - input_spec = ImageInfoInputSpec - output_spec = ImageInfoOutputSpec + _input_spec = ImageInfoInputSpec + _output_spec = ImageInfoOutputSpec def info_regexp(self, info, field, delim="\n"): m = re.search("%s\s*:\s+(.+?)%s" % (field, delim), info) @@ -776,7 +765,6 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None): outputs.file_format = ftype outputs.data_type = dtype - return outputs class MRIsConvertInputSpec(FSTraitedSpec): @@ -845,18 +833,17 @@ class MRIsConvert(FSCommand): >>> mris.run() # doctest: +SKIP """ _cmd = 'mris_convert' - input_spec = MRIsConvertInputSpec - output_spec = MRIsConvertOutputSpec + _input_spec = MRIsConvertInputSpec + _output_spec = MRIsConvertOutputSpec def _format_arg(self, name, spec, value): if name == "out_file" and not os.path.isabs(value): value = os.path.abspath(value) return super(MRIsConvert, self)._format_arg(name, spec, value) - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs["converted"] = os.path.abspath(self._gen_outfilename()) - return outputs + + def _post_run(self): + + self.outputs.converted = os.path.abspath(self._gen_outfilename()) def _gen_filename(self, name): if name is 'out_file': @@ -918,13 +905,12 @@ class MRITessellate(FSCommand): >>> tess.run() # doctest: +SKIP """ _cmd = 'mri_tessellate' - input_spec = MRITessellateInputSpec - output_spec = MRITessellateOutputSpec + _input_spec = MRITessellateInputSpec + _output_spec = MRITessellateOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['surface'] = os.path.abspath(self._gen_outfilename()) - return outputs + self.outputs.surface = os.path.abspath(self._gen_outfilename()) def _gen_filename(self, name): if name is 'out_file': @@ -988,13 +974,12 @@ class MRIPretess(FSCommand): >>> pretess.run() # doctest: +SKIP """ _cmd = 'mri_pretess' - input_spec = MRIPretessInputSpec - output_spec = MRIPretessOutputSpec + _input_spec = MRIPretessInputSpec + _output_spec = MRIPretessOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = os.path.abspath(self._gen_outfilename()) - return outputs + def _post_run(self): + + self.outputs.out_file = os.path.abspath(self._gen_outfilename()) def _gen_filename(self, name): if name is 'out_file': @@ -1045,13 +1030,12 @@ class MRIMarchingCubes(FSCommand): >>> mc.run() # doctest: +SKIP """ _cmd = 'mri_mc' - input_spec = MRIMarchingCubesInputSpec - output_spec = MRIMarchingCubesOutputSpec + _input_spec = MRIMarchingCubesInputSpec + _output_spec = MRIMarchingCubesOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['surface'] = self._gen_outfilename() - return outputs + self.outputs.surface = self._gen_outfilename() def _gen_filename(self, name): if name is 'out_file': @@ -1116,13 +1100,12 @@ class SmoothTessellation(FSCommand): >>> smooth.run() # doctest: +SKIP """ _cmd = 'mris_smooth' - input_spec = SmoothTessellationInputSpec - output_spec = SmoothTessellationOutputSpec + _input_spec = SmoothTessellationInputSpec + _output_spec = SmoothTessellationOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['surface'] = self._gen_outfilename() - return outputs + def _post_run(self): + + self.outputs.surface = self._gen_outfilename() def _gen_filename(self, name): if name is 'out_file': @@ -1173,13 +1156,12 @@ class MakeAverageSubject(FSCommand): """ _cmd = 'make_average_subject' - input_spec = MakeAverageSubjectInputSpec - output_spec = MakeAverageSubjectOutputSpec + _input_spec = MakeAverageSubjectInputSpec + _output_spec = MakeAverageSubjectOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['average_subject_name'] = self.inputs.out_name - return outputs + self.outputs.average_subject_name = self.inputs.out_name class ExtractMainComponentInputSpec(CommandLineInputSpec): @@ -1208,8 +1190,8 @@ class ExtractMainComponent(CommandLine): """ _cmd = 'mris_extract_main_component' - input_spec = ExtractMainComponentInputSpec - output_spec = ExtractMainComponentOutputSpec + _input_spec = ExtractMainComponentInputSpec + _output_spec = ExtractMainComponentOutputSpec class Tkregister2InputSpec(FSTraitedSpec): @@ -1283,15 +1265,13 @@ class Tkregister2(FSCommand): >>> tk2.run() # doctest: +SKIP """ _cmd = "tkregister2" - input_spec = Tkregister2InputSpec - output_spec = Tkregister2OutputSpec + _input_spec = Tkregister2InputSpec + _output_spec = Tkregister2OutputSpec - def _list_outputs(self): - outputs = self._outputs().get() - outputs['reg_file'] = os.path.abspath(self.inputs.reg_file) + def _post_run(self): + self.outputs.reg_file = os.path.abspath(self.inputs.reg_file) if isdefined(self.inputs.fsl_out): - outputs['fsl_file'] = os.path.abspath(self.inputs.fsl_out) - return outputs + self.outputs.fsl_file = os.path.abspath(self.inputs.fsl_out) def _gen_outfilename(self): if isdefined(self.inputs.out_file): diff --git a/nipype/interfaces/fsl/base.py b/nipype/interfaces/fsl/base.py index b4fedddc7d..3e7caa6235 100644 --- a/nipype/interfaces/fsl/base.py +++ b/nipype/interfaces/fsl/base.py @@ -25,19 +25,22 @@ """ -from builtins import object - -from glob import glob import os -import warnings +from glob import glob +from builtins import object +from ..base import traits, CommandLine, CommandLineInputSpec +from ... import logging -from ...utils.filemanip import fname_presuffix, split_filename, copyfile -from ..base import (traits, isdefined, - CommandLine, CommandLineInputSpec, TraitedSpec, - File, Directory, InputMultiPath, OutputMultiPath) +IFLOGGER = logging.getLogger('interface') -warn = warnings.warn +FSLDIR = os.getenv('FSLDIR') +if FSLDIR is None: + IFLOGGER.warn('FSLDIR environment variable is not set') +FSLOUTPUTTYPE = os.getenv('FSLOUTPUTTYPE') +if FSLOUTPUTTYPE is None: + IFLOGGER.warn('FSLOUTPUTTYPE environment variable is not set, using NIFTI') + FSLOUTPUTTYPE = 'NIFTI' class Info(object): """Handle fsl output type and version information. @@ -70,60 +73,19 @@ def version(): """ # find which fsl being used....and get version from # /path/to/fsl/etc/fslversion - try: - basedir = os.environ['FSLDIR'] - except KeyError: - return None - out = open('%s/etc/fslversion' % (basedir)).read() - return out.strip('\n') - - @classmethod - def output_type_to_ext(cls, output_type): - """Get the file extension for the given output type. - - Parameters - ---------- - output_type : {'NIFTI', 'NIFTI_GZ', 'NIFTI_PAIR', 'NIFTI_PAIR_GZ'} - String specifying the output type. - - Returns - ------- - extension : str - The file extension for the output type. - """ - - try: - return cls.ftypes[output_type] - except KeyError: - msg = 'Invalid FSLOUTPUTTYPE: ', output_type - raise KeyError(msg) - - @classmethod - def output_type(cls): - """Get the global FSL output file type FSLOUTPUTTYPE. - - This returns the value of the environment variable - FSLOUTPUTTYPE. An exception is raised if it is not defined. - - Returns - ------- - fsl_ftype : string - Represents the current environment setting of FSLOUTPUTTYPE - """ - try: - return os.environ['FSLOUTPUTTYPE'] - except KeyError: - warnings.warn(('FSL environment variables not set. setting output ' - 'type to NIFTI')) - return 'NIFTI' + out = None + if FSLDIR is not None: + with open('%s/etc/fslversion' % FSLDIR, 'r') as vfile: + out = vfile.read().strip('\n') + return out @staticmethod def standard_image(img_name=None): - '''Grab an image from the standard location. + """Grab an image from the standard location. Returns a list of standard images if called without arguments. - Could be made more fancy to allow for more relocatability''' + Could be made more fancy to allow for more relocatability""" try: fsldir = os.environ['FSLDIR'] except KeyError: @@ -142,126 +104,46 @@ class FSLCommandInputSpec(CommandLineInputSpec): All command support specifying FSLOUTPUTTYPE dynamically via output_type. - Example - ------- - fsl.ExtractRoi(tmin=42, tsize=1, output_type='NIFTI') - """ - output_type = traits.Enum('NIFTI', list(Info.ftypes.keys()), - desc='FSL output type') + Example:: + fsl.ExtractRoi(tmin=42, tsize=1, output_type='NIFTI') -class FSLCommand(CommandLine): - """Base support for FSL commands. """ + output_type = traits.Trait(FSLOUTPUTTYPE, Info.ftypes, usedefault=True, + desc='FSL output type') - input_spec = FSLCommandInputSpec - _output_type = None + # This is the easiest way to manage both synchronized + def _output_type_changed(self, new): + self.environ.update({'FSLOUTPUTTYPE': new}) - def __init__(self, **inputs): - super(FSLCommand, self).__init__(**inputs) - self.inputs.on_trait_change(self._output_update, 'output_type') - - if self._output_type is None: - self._output_type = Info.output_type() - - if not isdefined(self.inputs.output_type): - self.inputs.output_type = self._output_type - else: - self._output_update() +class FSLCommand(CommandLine): # pylint: disable=W0223 + """Base support for FSL commands.""" - def _output_update(self): - self._output_type = self.inputs.output_type - self.inputs.environ.update({'FSLOUTPUTTYPE': self.inputs.output_type}) - - @classmethod - def set_default_output_type(cls, output_type): - """Set the default output type for FSL classes. - - This method is used to set the default output type for all fSL - subclasses. However, setting this will not update the output - type for any existing instances. For these, assign the - .inputs.output_type. - """ + _input_spec = FSLCommandInputSpec - if output_type in Info.ftypes: - cls._output_type = output_type - else: - raise AttributeError('Invalid FSL output_type: %s' % output_type) + def __init__(self, **inputs): + super(FSLCommand, self).__init__(**inputs) + self.inputs.output_type = FSLOUTPUTTYPE + self.environ.update({'FSLOUTPUTTYPE': FSLOUTPUTTYPE}) @property def version(self): return Info.version() - def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True, - ext=None): - """Generate a filename based on the given parameters. - - The filename will take the form: cwd/basename. - If change_ext is True, it will use the extentions specified in - intputs.output_type. - - Parameters - ---------- - basename : str - Filename to base the new filename on. - cwd : str - Path to prefix to the new filename. (default is os.getcwd()) - suffix : str - Suffix to add to the `basename`. (defaults is '' ) - change_ext : bool - Flag to change the filename extension to the FSL output type. - (default True) - - Returns - ------- - fname : str - New filename based on given parameters. - - """ - - if basename == '': - msg = 'Unable to generate filename for command %s. ' % self.cmd - msg += 'basename is not set!' - raise ValueError(msg) - if cwd is None: - cwd = os.getcwd() - if ext is None: - ext = Info.output_type_to_ext(self.inputs.output_type) - if change_ext: - if suffix: - suffix = ''.join((suffix, ext)) - else: - suffix = ext - if suffix is None: - suffix = '' - fname = fname_presuffix(basename, suffix=suffix, - use_ext=False, newpath=cwd) - return fname - - def _overload_extension(self, value, name=None): - return value + Info.output_type_to_ext(self.inputs.output_type) - - -def check_fsl(): - ver = Info.version() - if ver: - return 0 - else: - return 1 - def no_fsl(): """Checks if FSL is NOT installed used with skipif to skip tests that will fail if FSL is not installed""" + return Info.version() is None - if Info.version() is None: - return True - else: - return False - +def check_fsl(): + """Same as the previous. One of these should disappear """ + return Info.version() is not None def no_fsl_course_data(): """check if fsl_course data is present""" - return not ('FSL_COURSE_DATA' in os.environ and os.path.isdir(os.path.abspath(os.environ['FSL_COURSE_DATA']))) + if os.getenv('FSL_COURSE_DATA') is None: + return False + return os.path.isdir(os.path.abspath(os.getenv('FSL_COURSE_DATA'))) diff --git a/nipype/interfaces/fsl/dti.py b/nipype/interfaces/fsl/dti.py index 84e44e4f7a..8522b90951 100644 --- a/nipype/interfaces/fsl/dti.py +++ b/nipype/interfaces/fsl/dti.py @@ -6,8 +6,8 @@ Change directory to provide relative paths for doctests >>> import os - >>> filepath = os.path.dirname( os.path.realpath( __file__ ) ) - >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data')) + >>> filepath = op.dirname( op.realpath( __file__ ) ) + >>> datadir = op.realpath(op.join(filepath, '../../testing/data')) >>> os.chdir(datadir) """ @@ -15,22 +15,23 @@ from builtins import range import os +import os.path as op import shutil -import warnings from ... import LooseVersion -from ..base import (TraitedSpec, isdefined, File, Directory, - InputMultiPath, OutputMultiPath, traits) +from ..base import (TraitedSpec, isdefined, File, GenFile, GenMultiFile, Directory, + InputMultiPath, OutputMultiPath, traits, Undefined) from ..fsl.base import (FSLCommand, FSLCommandInputSpec, Info) from ...utils.filemanip import fname_presuffix, split_filename, copyfile -warn = warnings.warn +from ... import logging +IFLOGGER = logging.getLogger('interface') class DTIFitInputSpec(FSLCommandInputSpec): dwi = File(exists=True, desc='diffusion weighted image data file', argstr='-k %s', position=0, mandatory=True) - base_name = traits.Str("dtifit_", desc='base_name that all output files will start with', + base_name = traits.Str('dtifit_', desc='base_name that all output files will start with', argstr='-o %s', position=1, usedefault=True) mask = File(exists=True, desc='bet binary mask file', argstr='-m %s', position=2, mandatory=True) @@ -44,7 +45,7 @@ class DTIFitInputSpec(FSLCommandInputSpec): max_y = traits.Int(argstr='-Y %d', desc='max y') min_x = traits.Int(argstr='-x %d', desc='min x') max_x = traits.Int(argstr='-X %d', desc='max x') - save_tensor = traits.Bool(desc='save the elements of the tensor', + save_tensor = traits.Bool(False, usedefault=True, desc='save the elements of the tensor', argstr='--save_tensor') sse = traits.Bool(desc='output sum of squared errors', argstr='--sse') cni = File(exists=True, desc='input counfound regressors', argstr='--cni=%s') @@ -53,20 +54,43 @@ class DTIFitInputSpec(FSLCommandInputSpec): gradnonlin = File(exists=True, argstr='--gradnonlin=%s', desc='gradient non linearities') + # Auto-generated outputs + out_v1 = GenFile(template='{base_name}V1{output_type_}', + keep_extension=False, desc='1st eigenvector') + out_v2 = GenFile(template='{base_name}V2{output_type_}', + keep_extension=False, desc='2nd eigenvector') + out_v3 = GenFile(template='{base_name}V3{output_type_}', + keep_extension=False, desc='3rd eigenvector') + out_l1 = GenFile(template='{base_name}L1{output_type_}', + keep_extension=False, desc='1st eigenvalue') + out_l2 = GenFile(template='{base_name}L2{output_type_}', + keep_extension=False, desc='2nd eigenvalue') + out_l3 = GenFile(template='{base_name}L3{output_type_}', + keep_extension=False, desc='3rd eigenvalue') + out_md = GenFile(template='{base_name}MD{output_type_}', + keep_extension=False, desc='mean diffusivity') + out_fa = GenFile(template='{base_name}FA{output_type_}', + keep_extension=False, desc='fractional anisotropy') + out_mo = GenFile(template='{base_name}MO{output_type_}', + keep_extension=False, desc='mode of anisotropy') + out_s0 = GenFile(template='{base_name}S0{output_type_}', + keep_extension=False, desc='raw T2 signal with no diffusion weighting') + tensor = GenFile(template='{base_name}tensor{output_type_}', + keep_extension=False, desc='path/name of file with the 4D tensor volume') + class DTIFitOutputSpec(TraitedSpec): - V1 = File(exists=True, desc='path/name of file with the 1st eigenvector') - V2 = File(exists=True, desc='path/name of file with the 2nd eigenvector') - V3 = File(exists=True, desc='path/name of file with the 3rd eigenvector') - L1 = File(exists=True, desc='path/name of file with the 1st eigenvalue') - L2 = File(exists=True, desc='path/name of file with the 2nd eigenvalue') - L3 = File(exists=True, desc='path/name of file with the 3rd eigenvalue') - MD = File(exists=True, desc='path/name of file with the mean diffusivity') - FA = File(exists=True, desc='path/name of file with the fractional anisotropy') - MO = File(exists=True, desc='path/name of file with the mode of anisotropy') - S0 = File(exists=True, desc='path/name of file with the raw T2 signal with no ' + - 'diffusion weighting') - tensor = File(exists=True, desc='path/name of file with the 4D tensor volume') + out_v1 = File(exists=True, desc='1st eigenvector') + out_v2 = File(exists=True, desc='2nd eigenvector') + out_v3 = File(exists=True, desc='3rd eigenvector') + out_l1 = File(exists=True, desc='1st eigenvalue') + out_l2 = File(exists=True, desc='2nd eigenvalue') + out_l3 = File(exists=True, desc='3rd eigenvalue') + out_md = File(exists=True, desc='mean diffusivity') + out_fa = File(exists=True, desc='fractional anisotropy') + out_mo = File(exists=True, desc='mode of anisotropy') + out_s0 = File(exists=True, desc='raw T2 signal with no diffusion weighting') + tensor = File(desc='path/name of file with the 4D tensor volume') class DTIFit(FSLCommand): @@ -89,17 +113,12 @@ class DTIFit(FSLCommand): """ _cmd = 'dtifit' - input_spec = DTIFitInputSpec - output_spec = DTIFitOutputSpec + _input_spec = DTIFitInputSpec + _output_spec = DTIFitOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - for k in list(outputs.keys()): - if k not in ('outputtype', 'environ', 'args'): - if k != 'tensor' or (isdefined(self.inputs.save_tensor) and - self.inputs.save_tensor): - outputs[k] = self._gen_fname(self.inputs.base_name, suffix='_' + k) - return outputs + def _post_run(self): + if not self.inputs.save_tensor: + self.outputs.tensor = Undefined class FSLXCommandInputSpec(FSLCommandInputSpec): @@ -114,7 +133,7 @@ class FSLXCommandInputSpec(FSLCommandInputSpec): logdir = Directory('.', argstr='--logdir=%s', usedefault=True) n_fibres = traits.Range( - usedefault=True, low=1, default=2, argstr='--nfibres=%d', + usedefault=True, low=1, value=2, argstr='--nfibres=%d', desc=('Maximum number of fibres to fit in each voxel'), mandatory=True) model = traits.Enum(1, 2, 3, argstr='--model=%d', desc=('use monoexponential (1, default, required for ' @@ -154,7 +173,7 @@ class FSLXCommandInputSpec(FSLCommandInputSpec): cnlinear = traits.Bool(argstr='--cnonlinear', xor=_xor_inputs2, desc=('Initialise with constrained nonlinear ' 'fitting')) - rician = traits.Bool(argstr='--rician', desc=('use Rician noise modeling')) + rician = traits.Bool(False, usedefault=True, argstr='--rician', desc='use Rician noise modeling') _xor_inputs3 = ['f0_noard', 'f0_ard'] f0_noard = traits.Bool(argstr='--f0', xor=_xor_inputs3, @@ -167,75 +186,54 @@ class FSLXCommandInputSpec(FSLCommandInputSpec): desc=('use the actual directory name given ' '(do not add + to make a new directory)')) + mean_dsamples = GenFile(template='mean_dsamples{output_type_}', keep_extension=False, + desc='Mean of distribution on diffusivity d') + mean_S0samples = GenFile(template='mean_S0samples{output_type_}', keep_extension=False, + desc='Mean of distribution on T2w baseline signal intensity S0') + mean_tausamples = GenFile(template='mean_tausamples{output_type_}', keep_extension=False, + desc='Mean of distribution on tau samples (only with rician noise)') + dyads = GenMultiFile(template='dyads{n_fibres:d}{output_type_}', range_source='n_fibres+1', + keep_extension=False, desc='Mean of PDD distribution in vector form.') + fsamples = GenMultiFile(template='f{n_fibres:d}samples{output_type_}', range_source='n_fibres+1', + keep_extension=False, desc='Samples from the distribution on f anisotropy') + mean_fsamples = GenMultiFile(template='mean_f{n_fibres:d}samples{output_type_}', range_source='n_fibres+1', + keep_extension=False, desc='Mean of distribution on f anisotropy') + phsamples = GenMultiFile(template='ph{n_fibres:d}samples{output_type_}', range_source='n_fibres+1', + keep_extension=False, desc='phi samples, per fiber') + thsamples = GenMultiFile(template='th{n_fibres:d}samples{output_type_}', range_source='n_fibres+1', + keep_extension=False, desc='theta samples, per fiber') + class FSLXCommandOutputSpec(TraitedSpec): - dyads = OutputMultiPath(File(exists=True), desc=('Mean of PDD distribution' - ' in vector form.')) - fsamples = OutputMultiPath(File(exists=True), desc=('Samples from the ' - 'distribution on f anisotropy')) mean_dsamples = File(exists=True, desc='Mean of distribution on diffusivity d') - mean_fsamples = OutputMultiPath(File(exists=True), desc=('Mean of ' - 'distribution on f anisotropy')) - mean_S0samples = File(exists=True, desc=('Mean of distribution on T2w' - 'baseline signal intensity S0')) - mean_tausamples = File(exists=True, desc=('Mean of distribution on ' - 'tau samples (only with rician noise)')) - phsamples = OutputMultiPath(File(exists=True), desc=('phi samples, per fiber')) - thsamples = OutputMultiPath(File(exists=True), desc=('theta samples, per fiber')) + mean_S0samples = File( + exists=True, desc='Mean of distribution on T2w baseline signal intensity S0') + mean_tausamples = File( + exists=True, desc='Mean of distribution on tau samples (only with rician noise)') + dyads = OutputMultiPath(File(exists=True), desc='Mean of PDD distribution in vector form.') + fsamples = OutputMultiPath(File(exists=True), + desc='Samples from the distribution on f anisotropy') + mean_fsamples = OutputMultiPath(File(exists=True), + desc='Mean of distribution on f anisotropy') + phsamples = OutputMultiPath(File(exists=True), desc='phi samples, per fiber') + thsamples = OutputMultiPath(File(exists=True), desc='theta samples, per fiber') class FSLXCommand(FSLCommand): """ Base support for ``xfibres`` and ``bedpostx`` """ - input_spec = FSLXCommandInputSpec - output_spec = FSLXCommandOutputSpec + _input_spec = FSLXCommandInputSpec + _output_spec = FSLXCommandOutputSpec def _run_interface(self, runtime): - self._out_dir = os.getcwd() runtime = super(FSLXCommand, self)._run_interface(runtime) if runtime.stderr: self.raise_exception(runtime) - return runtime - - def _list_outputs(self, out_dir=None): - outputs = self.output_spec().get() - n_fibres = self.inputs.n_fibres - if not out_dir: - if isdefined(self.inputs.logdir): - out_dir = os.path.abspath(self.inputs.logdir) - else: - out_dir = os.path.abspath('logdir') - - multi_out = ['dyads', 'fsamples', 'mean_fsamples', - 'phsamples', 'thsamples'] - single_out = ['mean_dsamples', 'mean_S0samples'] - - for k in single_out: - outputs[k] = self._gen_fname(k, cwd=out_dir) - - if isdefined(self.inputs.rician) and self.inputs.rician: - outputs['mean_tausamples'] = self._gen_fname('mean_tausamples', - cwd=out_dir) - - for k in multi_out: - outputs[k] = [] - - for i in range(1, n_fibres + 1): - outputs['fsamples'].append(self._gen_fname('f%dsamples' % i, - cwd=out_dir)) - outputs['mean_fsamples'].append(self._gen_fname(('mean_f%d' - 'samples') % i, cwd=out_dir)) - - for i in range(1, n_fibres + 1): - outputs['dyads'].append(self._gen_fname('dyads%d' % i, - cwd=out_dir)) - outputs['phsamples'].append(self._gen_fname('ph%dsamples' % i, - cwd=out_dir)) - outputs['thsamples'].append(self._gen_fname('th%dsamples' % i, - cwd=out_dir)) - return outputs + if not self.inputs.rician: + self.outputs.mean_tausamples = Undefined + return runtime class BEDPOSTX5InputSpec(FSLXCommandInputSpec): @@ -267,27 +265,13 @@ class BEDPOSTX5InputSpec(FSLXCommandInputSpec): 'nonlinearities, default off')) use_gpu = traits.Bool(False, desc='Use the GPU version of bedpostx') + # Add dyads dispersion + dyads_dispersion = GenMultiFile( + template='{n_fibres:d}{output_type_}', keep_extension=False, range_source='n_fibres+1', + desc='Dispersion') -class BEDPOSTX5OutputSpec(TraitedSpec): - mean_dsamples = File(exists=True, desc='Mean of distribution on diffusivity d') - mean_fsamples = OutputMultiPath(File(exists=True), desc=('Mean of ' - 'distribution on f anisotropy')) - mean_S0samples = File(exists=True, desc=('Mean of distribution on T2w' - 'baseline signal intensity S0')) - mean_phsamples = OutputMultiPath(File(exists=True), desc=('Mean of ' - 'distribution on phi')) - mean_thsamples = OutputMultiPath(File(exists=True), desc=('Mean of ' - 'distribution on theta')) - merged_thsamples = OutputMultiPath(File(exists=True), desc=('Samples from ' - 'the distribution on theta')) - merged_phsamples = OutputMultiPath(File(exists=True), desc=('Samples from ' - 'the distribution on phi')) - merged_fsamples = OutputMultiPath(File(exists=True), - desc=('Samples from the distribution on ' - 'anisotropic volume fraction')) - dyads = OutputMultiPath(File(exists=True), desc=('Mean of PDD distribution' - ' in vector form.')) - dyads_dispersion = OutputMultiPath(File(exists=True), desc=('Dispersion')) +class BEDPOSTX5OutputSpec(FSLXCommandOutputSpec): + dyads_dispersion = OutputMultiPath(File(exists=True), desc='Dispersion') class BEDPOSTX5(FSLXCommand): @@ -310,7 +294,7 @@ class BEDPOSTX5(FSLXCommand): >>> from nipype.interfaces import fsl >>> bedp = fsl.BEDPOSTX5(bvecs='bvecs', bvals='bvals', dwi='diffusion.nii', - ... mask='mask.nii', n_fibres=1) + ... mask='mask.nii', n_fibres=1) >>> bedp.cmdline 'bedpostx bedpostx --forcedir -n 1' @@ -318,8 +302,8 @@ class BEDPOSTX5(FSLXCommand): _cmd = 'bedpostx' _default_cmd = _cmd - input_spec = BEDPOSTX5InputSpec - output_spec = BEDPOSTX5OutputSpec + _input_spec = BEDPOSTX5InputSpec + _output_spec = BEDPOSTX5OutputSpec _can_resume = True def __init__(self, **inputs): @@ -334,63 +318,26 @@ def _cuda_update(self): def _run_interface(self, runtime): - subjectdir = os.path.abspath(self.inputs.out_dir) - if not os.path.exists(subjectdir): + subjectdir = op.abspath(self.inputs.out_dir) + if not op.exists(subjectdir): os.makedirs(subjectdir) _, _, ext = split_filename(self.inputs.mask) copyfile(self.inputs.mask, - os.path.join(subjectdir, + op.join(subjectdir, 'nodif_brain_mask' + ext)) _, _, ext = split_filename(self.inputs.dwi) copyfile(self.inputs.dwi, - os.path.join(subjectdir, 'data' + ext)) + op.join(subjectdir, 'data' + ext)) copyfile(self.inputs.bvals, - os.path.join(subjectdir, 'bvals')) + op.join(subjectdir, 'bvals')) copyfile(self.inputs.bvecs, - os.path.join(subjectdir, 'bvecs')) + op.join(subjectdir, 'bvecs')) retval = super(BEDPOSTX5, self)._run_interface(runtime) self._out_dir = subjectdir + '.bedpostX' return retval - def _list_outputs(self): - outputs = self.output_spec().get() - n_fibres = self.inputs.n_fibres - - multi_out = ['merged_thsamples', 'merged_fsamples', - 'merged_phsamples', 'mean_phsamples', - 'mean_thsamples', 'mean_fsamples', - 'dyads_dispersion', 'dyads'] - - single_out = ['mean_dsamples', 'mean_S0samples'] - - for k in single_out: - outputs[k] = self._gen_fname(k, cwd=self._out_dir) - - for k in multi_out: - outputs[k] = [] - - for i in range(1, n_fibres + 1): - outputs['merged_thsamples'].append(self._gen_fname('merged_th%dsamples' % i, - cwd=self._out_dir)) - outputs['merged_fsamples'].append(self._gen_fname('merged_f%dsamples' % i, - cwd=self._out_dir)) - outputs['merged_phsamples'].append(self._gen_fname('merged_ph%dsamples' % i, - cwd=self._out_dir)) - - outputs['mean_thsamples'].append(self._gen_fname('mean_th%dsamples' % i, - cwd=self._out_dir)) - outputs['mean_phsamples'].append(self._gen_fname('mean_ph%dsamples' % i, - cwd=self._out_dir)) - outputs['mean_fsamples'].append(self._gen_fname('mean_f%dsamples' % i, - cwd=self._out_dir)) - outputs['dyads'].append(self._gen_fname('dyads%d' % i, - cwd=self._out_dir)) - outputs['dyads_dispersion'].append(self._gen_fname('dyads%d_dispersion' % i, - cwd=self._out_dir)) - return outputs - class XFibres5InputSpec(FSLXCommandInputSpec): gradnonlin = File(exists=True, argstr='--gradnonlin=%s', @@ -403,8 +350,8 @@ class XFibres5(FSLXCommand): parameters """ _cmd = 'xfibres' - input_spec = XFibres5InputSpec - output_spec = FSLXCommandOutputSpec + _input_spec = XFibres5InputSpec + _output_spec = FSLXCommandOutputSpec class XFibres4InputSpec(FSLCommandInputSpec): @@ -413,7 +360,7 @@ class XFibres4InputSpec(FSLCommandInputSpec): gradnonlin = File(exists=True, argstr="--gradnonlin=%s") bvecs = File(exists=True, argstr="--bvecs=%s", mandatory=True) bvals = File(exists=True, argstr="--bvals=%s", mandatory=True) - logdir = Directory("logdir", argstr="--logdir=%s", usedefault=True) + logdir = Directory('logdir', argstr="--logdir=%s", usedefault=True) n_fibres = traits.Range(low=1, argstr="--nfibres=%d", desc="Maximum nukmber of fibres to fit in each voxel") fudge = traits.Int(argstr="--fudge=%d", @@ -466,40 +413,36 @@ class XFibres4(FSLCommand): """ - _cmd = "xfibres" - input_spec = XFibres4InputSpec - output_spec = XFibres4OutputSpec + _cmd = 'xfibres' + _input_spec = XFibres4InputSpec + _output_spec = XFibres4OutputSpec def __init__(self, **inputs): - warnings.warn(('Deprecated: Please use XFIBERS5 instead. This ' - 'interface will be removed in version 0.11.'), - DeprecationWarning) + IFLOGGER.warn('Deprecated: Please use XFIBERS5 instead. This ' + 'interface will be removed in version 0.11.') super(XFibres4, self).__init__(**inputs) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs["mean_dsamples"] = self._gen_fname("mean_dsamples", - cwd=self.inputs.logdir) - outputs["mean_S0samples"] = self._gen_fname("mean_S0samples", - cwd=self.inputs.logdir) - outputs["dyads"] = [] - outputs["fsamples"] = [] - outputs["mean_fsamples"] = [] - outputs["phsamples"] = [] - outputs["thsamples"] = [] + def _post_run(self): + self.outputs.mean_dsamples = self._gen_fname('mean_dsamples', + self.inputs.logdir) + self.outputs.mean_S0samples = self._gen_fname('mean_S0samples', + self.inputs.logdir) + self.outputs.dyads = [] + self.outputs.fsamples = [] + self.outputs.mean_fsamples = [] + self.outputs.phsamples = [] + self.outputs.thsamples = [] for i in range(1, self.inputs.n_fibres + 1): - outputs["dyads"].append(self._gen_fname("dyads%d" % i, - cwd=self.inputs.logdir)) - outputs["fsamples"].append(self._gen_fname("f%dsamples" % i, - cwd=self.inputs.logdir)) - outputs["mean_fsamples"].append(self._gen_fname("mean_f%dsamples" % i, - cwd=self.inputs.logdir)) - outputs["phsamples"].append(self._gen_fname("ph%dsamples" % i, - cwd=self.inputs.logdir)) - outputs["thsamples"].append(self._gen_fname("th%dsamples" % i, - cwd=self.inputs.logdir)) - - return outputs + self.outputs.dyads.append(self._gen_fname('dyads%d' % i, + self.inputs.logdir)) + self.outputs.fsamples.append(self._gen_fname('f%dsamples' % i, + self.inputs.logdir)) + self.outputs.mean_fsamples.append(self._gen_fname('mean_f%dsamples' % i, + self.inputs.logdir)) + self.outputs.phsamples.append(self._gen_fname('ph%dsamples' % i, + self.inputs.logdir)) + self.outputs.thsamples.append(self._gen_fname('th%dsamples' % i, + self.inputs.logdir)) class BEDPOSTX4InputSpec(XFibres4InputSpec): @@ -572,37 +515,37 @@ class BEDPOSTX4(FSLCommand): """ _cmd = 'bedpostx' - input_spec = BEDPOSTX4InputSpec - output_spec = BEDPOSTX4OutputSpec + _input_spec = BEDPOSTX4InputSpec + _output_spec = BEDPOSTX4OutputSpec _can_resume = True def __init__(self, **inputs): - warnings.warn(('Deprecated: Please use BEDPOSTX5 or ' - 'create_bedpostx_pipeline instead. This interface will ' - 'be removed in version 0.11.'), DeprecationWarning) + IFLOGGER.warn('Deprecated: Please use BEDPOSTX5 or ' + 'create_bedpostx_pipeline instead. This interface will ' + 'be removed in version 0.11.') super(BEDPOSTX4, self).__init__(**inputs) def _get_bedpostx_dir(self): - return os.path.join(os.getcwd(), self.inputs.bpx_directory) + return op.join(os.getcwd(), self.inputs.bpx_directory) def _run_interface(self, runtime, correct_return_codes=[0]): # create the subject specific bpx_directory bpx_directory = self._get_bedpostx_dir() - if not os.path.exists(bpx_directory): + if not op.exists(bpx_directory): os.makedirs(bpx_directory) _, _, ext = split_filename(self.inputs.mask) shutil.copyfile(self.inputs.mask, - os.path.join(self.inputs.bpx_directory, + op.join(self.inputs.bpx_directory, 'nodif_brain_mask' + ext)) _, _, ext = split_filename(self.inputs.dwi) shutil.copyfile(self.inputs.dwi, - os.path.join(self.inputs.bpx_directory, 'data' + ext)) + op.join(self.inputs.bpx_directory, 'data' + ext)) shutil.copyfile(self.inputs.bvals, - os.path.join(self.inputs.bpx_directory, 'bvals')) + op.join(self.inputs.bpx_directory, 'bvals')) shutil.copyfile(self.inputs.bvecs, - os.path.join(self.inputs.bpx_directory, 'bvecs')) + op.join(self.inputs.bpx_directory, 'bvecs')) runtime = super(BEDPOSTX4, self)._run_interface(runtime, correct_return_codes) @@ -610,44 +553,35 @@ def _run_interface(self, runtime, correct_return_codes=[0]): self.raise_exception(runtime) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - bpx_directory = self._get_bedpostx_dir() - outputs['bpx_out_directory'] = os.path.join(bpx_directory + '.bedpostX') - outputs['xfms_directory'] = os.path.join(bpx_directory + '.bedpostX', - 'xfms') + def _post_run(self): + bpx_out_dir = op.abspath(self._get_bedpostx_dir() + '.bedpostX') + self.outputs.bpx_out_directory = bpx_out_dir + self.outputs.xfms_directory = op.join(bpx_out_dir, 'xfms') - for k in list(outputs.keys()): - if k not in ('outputtype', 'environ', 'args', 'bpx_out_directory', + for k, _ in list(self.outputs.items()): + if k in ('outputtype', 'environ', 'args', 'bpx_out_directory', 'xfms_directory'): - outputs[k] = [] - - for n in range(self.inputs.fibres): - outputs['merged_thsamples'].append(self._gen_fname( - 'merged_th' + repr(n + 1) + 'samples', - suffix='', cwd=outputs['bpx_out_directory'])) - outputs['merged_phsamples'].append(self._gen_fname( - 'merged_ph' + repr(n + 1) + 'samples', - suffix='', cwd=outputs['bpx_out_directory'])) - outputs['merged_fsamples'].append(self._gen_fname( - 'merged_f' + repr(n + 1) + 'samples', - suffix='', cwd=outputs['bpx_out_directory'])) - outputs['mean_thsamples'].append(self._gen_fname( - 'mean_th' + repr(n + 1) + 'samples', - suffix='', cwd=outputs['bpx_out_directory'])) - outputs['mean_phsamples'].append(self._gen_fname( - 'mean_ph' + repr(n + 1) + 'samples', - suffix='', cwd=outputs['bpx_out_directory'])) - outputs['mean_fsamples'].append(self._gen_fname( - 'mean_f' + repr(n + 1) + 'samples', - suffix='', cwd=outputs['bpx_out_directory'])) - outputs['dyads'].append(self._gen_fname( - 'dyads' + repr(n + 1), - suffix='', cwd=outputs['bpx_out_directory'])) - return outputs - - -if (Info.version() and LooseVersion(Info.version()) >= LooseVersion('5.0.0')): + continue + setattr(self.outputs, k, []) + + for i in [repr(n + 1) for n in range(self.inputs.fibres)]: + self.outputs.merged_thsamples.append( + self._gen_fname('merged_th' + repr(i + 1) + 'samples', bpx_out_dir)) + + self.outputs.merged_phsamples.append(self._gen_fname( + 'merged_ph' + repr(i + 1) + 'samples', bpx_out_dir), suffix='') + self.outputs.merged_fsamples.append(self._gen_fname( + 'merged_f' + repr(i + 1) + 'samples', bpx_out_dir), suffix='') + self.outputs.mean_thsamples.append(self._gen_fname( + 'mean_th' + repr(i + 1) + 'samples', bpx_out_dir), suffix='') + self.outputs.mean_phsamples.append(self._gen_fname( + 'mean_ph' + repr(i + 1) + 'samples', bpx_out_dir), suffix='') + self.outputs.mean_fsamples.append(self._gen_fname( + 'mean_f' + repr(i + 1) + 'samples', bpx_out_dir), suffix='') + self.outputs.dyads.append(self._gen_fname( + 'dyads' + repr(i + 1), bpx_out_dir), suffix='') + +if Info.version() and (LooseVersion(Info.version()) >= LooseVersion('5.0.0')): CurrentXFibres = XFibres5 CurrentBEDPOST = BEDPOSTX5 else: @@ -667,7 +601,7 @@ class ProbTrackXBaseInputSpec(FSLCommandInputSpec): thsamples = InputMultiPath(File(exists=True), mandatory=True) phsamples = InputMultiPath(File(exists=True), mandatory=True) fsamples = InputMultiPath(File(exists=True), mandatory=True) - samples_base_name = traits.Str("merged", desc='the rootname/base_name for samples files', + samples_base_name = traits.Str('merged', desc='the rootname/base_name for samples files', argstr='--samples=%s', usedefault=True) mask = File(exists=True, desc='bet binary mask file in diffusion space', argstr='-m %s', mandatory=True) @@ -732,9 +666,26 @@ class ProbTrackXBaseInputSpec(FSLCommandInputSpec): "Level 2 is required to output particle files.", argstr="--verbose=%d") + def _format_arg(self, name, spec=None, value=None): + if spec is None: + spec = self.traits()[name] + + if value is None: + value = getattr(self, name) + + if name == 'target_masks' and isdefined(value): + fname = 'targets.txt' + return super(ProbTrackXBaseInputSpec, self)._format_arg(name, spec, [fname]) + elif name == 'seed' and isinstance(value, list): + fname = 'seeds.txt' + return super(ProbTrackXBaseInputSpec, self)._format_arg(name, spec, fname) + else: + return super(ProbTrackXBaseInputSpec, self)._format_arg(name, spec, value) + + class ProbTrackXInputSpec(ProbTrackXBaseInputSpec): - mode = traits.Enum("simple", "two_mask_symm", "seedmask", + mode = traits.Enum('simple', 'two_mask_symm', 'seedmask', desc='options: simple (single seed voxel), seedmask (mask of seed voxels), ' + 'twomask_symm (two bet binary masks) ', argstr='--mode=%s', genfile=True) @@ -776,35 +727,35 @@ class ProbTrackX(FSLCommand): """ _cmd = 'probtrackx' - input_spec = ProbTrackXInputSpec - output_spec = ProbTrackXOutputSpec + _input_spec = ProbTrackXInputSpec + _output_spec = ProbTrackXOutputSpec def __init__(self, **inputs): - warnings.warn("Deprecated: Please use create_bedpostx_pipeline instead", DeprecationWarning) - return super(ProbTrackX, self).__init__(**inputs) + IFLOGGER.warn('Deprecated: Please use create_bedpostx_pipeline instead') + super(ProbTrackX, self).__init__(**inputs) def _run_interface(self, runtime): for i in range(1, len(self.inputs.thsamples) + 1): _, _, ext = split_filename(self.inputs.thsamples[i - 1]) copyfile(self.inputs.thsamples[i - 1], - self.inputs.samples_base_name + "_th%dsamples" % i + ext, + self.inputs.samples_base_name + '_th%dsamples' % i + ext, copy=False) _, _, ext = split_filename(self.inputs.thsamples[i - 1]) copyfile(self.inputs.phsamples[i - 1], - self.inputs.samples_base_name + "_ph%dsamples" % i + ext, + self.inputs.samples_base_name + '_ph%dsamples' % i + ext, copy=False) _, _, ext = split_filename(self.inputs.thsamples[i - 1]) copyfile(self.inputs.fsamples[i - 1], - self.inputs.samples_base_name + "_f%dsamples" % i + ext, + self.inputs.samples_base_name + '_f%dsamples' % i + ext, copy=False) if isdefined(self.inputs.target_masks): - f = open("targets.txt", "w") + f = open('targets.txt', 'w') for target in self.inputs.target_masks: f.write("%s\n" % target) f.close() if isinstance(self.inputs.seed, list): - f = open("seeds.txt", "w") + f = open('seeds.txt', 'w') for seed in self.inputs.seed: if isinstance(seed, list): f.write("%s\n" % (" ".join([str(s) for s in seed]))) @@ -817,59 +768,48 @@ def _run_interface(self, runtime): self.raise_exception(runtime) return runtime - def _format_arg(self, name, spec, value): - if name == 'target_masks' and isdefined(value): - fname = "targets.txt" - return super(ProbTrackX, self)._format_arg(name, spec, [fname]) - elif name == 'seed' and isinstance(value, list): - fname = "seeds.txt" - return super(ProbTrackX, self)._format_arg(name, spec, fname) - else: - return super(ProbTrackX, self)._format_arg(name, spec, value) - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): if not isdefined(self.inputs.out_dir): - out_dir = self._gen_filename("out_dir") + out_dir = self._gen_filename('out_dir') else: out_dir = self.inputs.out_dir - outputs['log'] = os.path.abspath(os.path.join(out_dir, 'probtrackx.log')) - # utputs['way_total'] = os.path.abspath(os.path.join(out_dir, 'waytotal')) + self.outputs.log = op.abspath(op.join(out_dir, 'probtrackx.log')) + # utputs['way_total'] = op.abspath(op.join(out_dir, 'waytotal')) if isdefined(self.inputs.opd is True): if isinstance(self.inputs.seed, list) and isinstance(self.inputs.seed[0], list): - outputs['fdt_paths'] = [] + self.outputs.fdt_paths = [] for seed in self.inputs.seed: - outputs['fdt_paths'].append( - os.path.abspath( - self._gen_fname("fdt_paths_%s" % ("_".join([str(s) for s in seed])), - cwd=out_dir, suffix=''))) + self.outputs.fdt_paths.append( + op.abspath( + self._gen_fname('fdt_paths_%s' % ('_'.join([str(s) for s in seed])), + out_dir, suffix=''))) else: - outputs['fdt_paths'] = os.path.abspath(self._gen_fname("fdt_paths", - cwd=out_dir, suffix='')) + self.outputs.fdt_paths = op.abspath(self._gen_fname('fdt_paths', + out_dir, suffix='')) # handle seeds-to-target output files if isdefined(self.inputs.target_masks): - outputs['targets'] = [] + self.outputs.targets = [] for target in self.inputs.target_masks: - outputs['targets'].append(os.path.abspath( - self._gen_fname('seeds_to_' + os.path.split(target)[1], - cwd=out_dir, + self.outputs.targets.append(op.abspath( + self._gen_fname('seeds_to_' + op.split(target)[1], + out_dir, suffix=''))) if isdefined(self.inputs.verbose) and self.inputs.verbose == 2: - outputs['particle_files'] = [os.path.abspath( - os.path.join(out_dir, 'particle%d' % i)) + self.outputs.particle_files = [op.abspath( + op.join(out_dir, 'particle%d' % i)) for i in range(self.inputs.n_samples)] - return outputs def _gen_filename(self, name): - if name == "out_dir": + if name == 'out_dir': return os.getcwd() - elif name == "mode": + elif name == 'mode': if isinstance(self.inputs.seed, list) and isinstance(self.inputs.seed[0], list): - return "simple" + return 'simple' else: - return "seedmask" + return 'seedmask' class ProbTrackX2InputSpec(ProbTrackXBaseInputSpec): @@ -877,8 +817,8 @@ class ProbTrackX2InputSpec(ProbTrackXBaseInputSpec): usedefault=False, argstr='--simple') fopd = File(exists=True, desc='Other mask for binning tract distribution', argstr='--fopd=%s') - waycond = traits.Enum("OR", "AND", argstr='--waycond=%s', - desc='Waypoint condition. Either "AND" (default) or "OR"') + waycond = traits.Enum('OR', 'AND', argstr='--waycond=%s', + desc='Waypoint condition. Either \'AND\' (default) or \'OR\'') wayorder = traits.Bool(desc='Reject streamlines that do not hit waypoints in given order. ' + 'Only valid if waycond=AND', argstr='--wayorder') onewaycondition = traits.Bool(desc='Apply waypoint conditions to each half tract separately', @@ -905,9 +845,9 @@ class ProbTrackX2InputSpec(ProbTrackXBaseInputSpec): colmask4 = File(exists=True, desc='Mask for columns of matrix4 (default=seed mask)', argstr='--colmask4=%s') target4 = File(exists=True, desc='Brain mask in DTI space', argstr='--target4=%s') - meshspace = traits.Enum("caret", "freesurfer", "first", "vox", argstr='--meshspace=%s', - desc='Mesh reference space - either "caret" (default) or ' + - '"freesurfer" or "first" or "vox"') + meshspace = traits.Enum('caret', 'freesurfer', 'first', 'vox', argstr='--meshspace=%s', + desc='Mesh reference space - either \'caret\' (default) or ' + + '\'freesurfer\' or \'first\' or \'vox\'') class ProbTrackX2OutputSpec(ProbTrackXOutputSpec): @@ -938,11 +878,11 @@ class ProbTrackX2(ProbTrackX): 'probtrackx2 --forcedir -m nodif_brain_mask.nii.gz --nsamples=3 --nsteps=10 --opd --dir=. --samples=merged --seed=seed_source.nii.gz' """ _cmd = 'probtrackx2' - input_spec = ProbTrackX2InputSpec - output_spec = ProbTrackX2OutputSpec + _input_spec = ProbTrackX2InputSpec + _output_spec = ProbTrackX2OutputSpec - def _list_outputs(self): - outputs = super(ProbTrackX2, self)._list_outputs() + def _post_run(self): + outputs = super(ProbTrackX2, self)._post_run() if not isdefined(self.inputs.out_dir): out_dir = os.getcwd() @@ -950,17 +890,16 @@ def _list_outputs(self): out_dir = self.inputs.out_dir if isdefined(self.inputs.omatrix1): - outputs['network_matrix'] = os.path.abspath(os.path.join(out_dir, 'fdt_network_matrix')) - outputs['matrix1_dot'] = os.path.abspath(os.path.join(out_dir, 'fdt_matrix1.dot')) + self.outputs.network_matrix = op.abspath(op.join(out_dir, 'fdt_network_matrix')) + self.outputs.matrix1_dot = op.abspath(op.join(out_dir, 'fdt_matrix1.dot')) if isdefined(self.inputs.omatrix2): - outputs['lookup_tractspace'] = \ - os.path.abspath(os.path.join(out_dir, 'lookup_tractspace_fdt_matrix2.nii.gz')) - outputs['matrix2_dot'] = os.path.abspath(os.path.join(out_dir, 'fdt_matrix2.dot')) + self.outputs.lookup_tractspace = \ + op.abspath(op.join(out_dir, 'lookup_tractspace_fdt_matrix2.nii.gz')) + self.outputs.matrix2_dot = op.abspath(op.join(out_dir, 'fdt_matrix2.dot')) if isdefined(self.inputs.omatrix3): - outputs['matrix3_dot'] = os.path.abspath(os.path.join(out_dir, 'fdt_matrix3.dot')) - return outputs + self.outputs.matrix3_dot = op.abspath(op.join(out_dir, 'fdt_matrix3.dot')) class VecRegInputSpec(FSLCommandInputSpec): @@ -980,7 +919,7 @@ class VecRegInputSpec(FSLCommandInputSpec): rotation_warp = File(exists=True, argstr='--rotwarp=%s', desc='filename for secondary warp field' + 'if set, this will be used for the rotation of the vector/tensor field') - interpolation = traits.Enum("nearestneighbour", "trilinear", "sinc", "spline", + interpolation = traits.Enum('nearestneighbour', 'trilinear', 'sinc', 'spline', argstr='--interp=%s', desc='interpolation method : ' + 'nearestneighbour, trilinear (default), sinc or spline') @@ -1012,29 +951,27 @@ class VecReg(FSLCommand): """ _cmd = 'vecreg' - input_spec = VecRegInputSpec - output_spec = VecRegOutputSpec + _input_spec = VecRegInputSpec + _output_spec = VecRegOutputSpec def _run_interface(self, runtime): if not isdefined(self.inputs.out_file): - pth, base_name = os.path.split(self.inputs.in_file) - self.inputs.out_file = self._gen_fname(base_name, cwd=os.path.abspath(pth), + pth, base_name = op.split(self.inputs.in_file) + self.inputs.out_file = self._gen_fname(base_name, op.abspath(pth), suffix='_vreg') return super(VecReg, self)._run_interface(runtime) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_file - if not isdefined(outputs['out_file']) and isdefined(self.inputs.in_file): - pth, base_name = os.path.split(self.inputs.in_file) - outputs['out_file'] = self._gen_fname(base_name, cwd=os.path.abspath(pth), + def _post_run(self): + self.outputs.out_file = self.inputs.out_file + if not isdefined(self.outputs.out_file) and isdefined(self.inputs.in_file): + pth, base_name = op.split(self.inputs.in_file) + self.outputs.out_file = self._gen_fname(base_name, op.abspath(pth), suffix='_vreg') - outputs['out_file'] = os.path.abspath(outputs['out_file']) - return outputs + self.outputs.out_file = op.abspath(self.outputs.out_file) def _gen_filename(self, name): if name is 'out_file': - return self._list_outputs()[name] + return self._post_run()[name] else: return None @@ -1069,18 +1006,16 @@ class ProjThresh(FSLCommand): """ _cmd = 'proj_thresh' - input_spec = ProjThreshInputSpec - output_spec = ProjThreshOuputSpec + _input_spec = ProjThreshInputSpec + _output_spec = ProjThreshOuputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_files'] = [] + def _post_run(self): + self.outputs.out_files = [] for name in self.inputs.in_files: - cwd, base_name = os.path.split(name) - outputs['out_files'].append(self._gen_fname(base_name, cwd=cwd, + cwd, base_name = op.split(name) + self.outputs.out_files.append(self._gen_fname(base_name, cwd, suffix='_proj_seg_thr_' + repr(self.inputs.threshold))) - return outputs class FindTheBiggestInputSpec(FSLCommandInputSpec): @@ -1113,25 +1048,23 @@ class FindTheBiggest(FSLCommand): """ _cmd = 'find_the_biggest' - input_spec = FindTheBiggestInputSpec - output_spec = FindTheBiggestOutputSpec + _input_spec = FindTheBiggestInputSpec + _output_spec = FindTheBiggestOutputSpec def _run_interface(self, runtime): if not isdefined(self.inputs.out_file): self.inputs.out_file = self._gen_fname('biggestSegmentation', suffix='') return super(FindTheBiggest, self)._run_interface(runtime) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_file - if not isdefined(outputs['out_file']): - outputs['out_file'] = self._gen_fname('biggestSegmentation', suffix='') - outputs['out_file'] = os.path.abspath(outputs['out_file']) - return outputs + def _post_run(self): + self.outputs.out_file = self.inputs.out_file + if not isdefined(self.outputs.out_file): + self.outputs.out_file = self._gen_fname('biggestSegmentation', suffix='') + self.outputs.out_file = op.abspath(self.outputs.out_file) def _gen_filename(self, name): if name is 'out_file': - return self._list_outputs()[name] + return self._post_run()[name] else: return None @@ -1140,15 +1073,15 @@ class TractSkeletonInputSpec(FSLCommandInputSpec): in_file = File(exists=True, mandatory=True, argstr="-i %s", desc="input image (typcially mean FA volume)") - _proj_inputs = ["threshold", "distance_map", "data_file"] + _proj_inputs = ['threshold', 'distance_map', 'data_file'] project_data = traits.Bool(argstr="-p %.3f %s %s %s %s", requires=_proj_inputs, desc="project data onto skeleton") threshold = traits.Float(desc="skeleton threshold value") distance_map = File(exists=True, desc="distance map image") - search_mask_file = File(exists=True, xor=["use_cingulum_mask"], + search_mask_file = File(exists=True, xor=['use_cingulum_mask'], desc="mask in which to use alternate search rule") use_cingulum_mask = traits.Bool(True, usedefault=True, - xor=["search_mask_file"], + xor=['search_mask_file'], desc="perform alternate search using built-in cingulum mask") data_file = File(exists=True, desc="4D data to project onto skeleton (usually FA)") alt_data_file = File(exists=True, argstr="-a %s", desc="4D non-FA data to project onto skeleton") @@ -1179,62 +1112,59 @@ class TractSkeleton(FSLCommand): >>> import nipype.interfaces.fsl as fsl >>> skeletor = fsl.TractSkeleton() - >>> skeletor.inputs.in_file = "all_FA.nii.gz" + >>> skeletor.inputs.in_file = 'all_FA.nii.gz' >>> skeletor.inputs.skeleton_file = True >>> skeletor.run() # doctest: +SKIP """ - _cmd = "tbss_skeleton" - input_spec = TractSkeletonInputSpec - output_spec = TractSkeletonOutputSpec + _cmd = 'tbss_skeleton' + _input_spec = TractSkeletonInputSpec + _output_spec = TractSkeletonOutputSpec def _format_arg(self, name, spec, value): - if name == "project_data": + if name == 'project_data': if isdefined(value) and value: _si = self.inputs if isdefined(_si.use_cingulum_mask) and _si.use_cingulum_mask: - mask_file = Info.standard_image("LowerCingulum_1mm.nii.gz") + mask_file = Info.standard_image('LowerCingulum_1mm.nii.gz') else: mask_file = _si.search_mask_file if not isdefined(_si.projected_data): - proj_file = self._list_outputs()["projected_data"] + proj_file = self.outputs.projected_data else: proj_file = _si.projected_data return spec.argstr % (_si.threshold, _si.distance_map, mask_file, _si.data_file, proj_file) - elif name == "skeleton_file": + elif name == 'skeleton_file': if isinstance(value, bool): - return spec.argstr % self._list_outputs()["skeleton_file"] + return spec.argstr % self.outputs.skeleton_file else: return spec.argstr % value return super(TractSkeleton, self)._format_arg(name, spec, value) - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): _si = self.inputs if isdefined(_si.project_data) and _si.project_data: proj_data = _si.projected_data - outputs["projected_data"] = proj_data + self.outputs.projected_data = proj_data if not isdefined(proj_data): stem = _si.data_file if isdefined(_si.alt_data_file): stem = _si.alt_data_file - outputs["projected_data"] = fname_presuffix(stem, - suffix="_skeletonised", + self.outputs.projected_data = fname_presuffix(stem, + suffix='_skeletonised', newpath=os.getcwd(), use_ext=True) if isdefined(_si.skeleton_file) and _si.skeleton_file: - outputs["skeleton_file"] = _si.skeleton_file + self.outputs.skeleton_file = _si.skeleton_file if isinstance(_si.skeleton_file, bool): - outputs["skeleton_file"] = fname_presuffix(_si.in_file, - suffix="_skeleton", + self.outputs.skeleton_file = fname_presuffix(_si.in_file, + suffix='_skeleton', newpath=os.getcwd(), use_ext=True) - return outputs class DistanceMapInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, mandatory=True, argstr="--in=%s", desc="image to calculate distance values for") mask_file = File(exists=True, argstr="--mask=%s", @@ -1242,7 +1172,15 @@ class DistanceMapInputSpec(FSLCommandInputSpec): invert_input = traits.Bool(argstr="--invert", desc="invert input image") local_max_file = traits.Either(traits.Bool, File, argstr="--localmax=%s", desc="write an image of the local maxima", hash_files=False) - distance_map = File(genfile=True, argstr="--out=%s", desc="distance map to write", hash_files=False) + distance_map = GenFile(template='{in_file}_dstmap{output_type_}', argstr="--out=%s", + hash_files=False, desc="distance map to write") + + + def _format_arg(self, name, spec, value): + if name == 'local_max_file': + if isinstance(value, bool): + return spec.argstr % self.outputs.local_max_file + return super(DistanceMap, self)._format_arg(name, spec, value) class DistanceMapOutputSpec(TraitedSpec): @@ -1259,56 +1197,48 @@ class DistanceMap(FSLCommand): >>> import nipype.interfaces.fsl as fsl >>> mapper = fsl.DistanceMap() - >>> mapper.inputs.in_file = "skeleton_mask.nii.gz" + >>> mapper.inputs.in_file = 'skeleton_mask.nii.gz' >>> mapper.run() # doctest: +SKIP """ - _cmd = "distancemap" - input_spec = DistanceMapInputSpec - output_spec = DistanceMapOutputSpec - - def _format_arg(self, name, spec, value): - if name == "local_max_file": - if isinstance(value, bool): - return spec.argstr % self._list_outputs()["local_max_file"] - return super(DistanceMap, self)._format_arg(name, spec, value) + _cmd = 'distancemap' + _input_spec = DistanceMapInputSpec + _output_spec = DistanceMapOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): _si = self.inputs - outputs["distance_map"] = _si.distance_map + self.outputs.distance_map = _si.distance_map if not isdefined(_si.distance_map): - outputs["distance_map"] = fname_presuffix(_si.in_file, - suffix="_dstmap", + self.outputs.distance_map = fname_presuffix(_si.in_file, + suffix='_dstmap', use_ext=True, newpath=os.getcwd()) - outputs["distance_map"] = os.path.abspath(outputs["distance_map"]) + self.outputs.distance_map = op.abspath(self.outputs.distance_map) if isdefined(_si.local_max_file): - outputs["local_max_file"] = _si.local_max_file + self.outputs.local_max_file = _si.local_max_file if isinstance(_si.local_max_file, bool): - outputs["local_max_file"] = fname_presuffix(_si.in_file, - suffix="_lclmax", + self.outputs.local_max_file = fname_presuffix(_si.in_file, + suffix='_lclmax', use_ext=True, newpath=os.getcwd()) - outputs["local_max_file"] = os.path.abspath(outputs["local_max_file"]) - return outputs + self.outputs.local_max_file = op.abspath(self.outputs.local_max_file) def _gen_filename(self, name): - if name == "distance_map": - return self._list_outputs()["distance_map"] + if name == 'distance_map': + return self.outputs.distance_map return None class MakeDyadicVectorsInputSpec(FSLCommandInputSpec): - theta_vol = File(exists=True, mandatory=True, position=0, argstr="%s") - phi_vol = File(exists=True, mandatory=True, position=1, argstr="%s") - mask = File(exists=True, position=2, argstr="%s") - output = File("dyads", position=3, usedefault=True, argstr="%s", hash_files=False) + theta_vol = File(exists=True, mandatory=True, position=0, argstr='%s') + phi_vol = File(exists=True, mandatory=True, position=1, argstr='%s') + mask = File(exists=True, position=2, argstr='%s') + output = File('dyads', position=3, usedefault=True, argstr='%s', hash_files=False) perc = traits.Float(desc="the {perc}% angle of the output cone of \ uncertainty (output will be in degrees)", position=4, - argstr="%f") + argstr='%f') class MakeDyadicVectorsOutputSpec(TraitedSpec): @@ -1320,14 +1250,12 @@ class MakeDyadicVectors(FSLCommand): """Create vector volume representing mean principal diffusion direction and its uncertainty (dispersion)""" - _cmd = "make_dyadic_vectors" - input_spec = MakeDyadicVectorsInputSpec - output_spec = MakeDyadicVectorsOutputSpec + _cmd = 'make_dyadic_vectors' + _input_spec = MakeDyadicVectorsInputSpec + _output_spec = MakeDyadicVectorsOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs["dyads"] = self._gen_fname(self.inputs.output) - outputs["dispersion"] = self._gen_fname(self.inputs.output, - suffix="_dispersion") + def _post_run(self): + self.outputs.dyads = self._gen_fname(self.inputs.output) + self.outputs.dispersion = self._gen_fname(self.inputs.output, + suffix='_dispersion') - return outputs diff --git a/nipype/interfaces/fsl/epi.py b/nipype/interfaces/fsl/epi.py index 30b1a2c330..96466967a9 100644 --- a/nipype/interfaces/fsl/epi.py +++ b/nipype/interfaces/fsl/epi.py @@ -13,19 +13,18 @@ """ import os -import warnings from glob import glob import numpy as np import nibabel as nib from ..fsl.base import FSLCommand, FSLCommandInputSpec, Info -from ..base import (traits, TraitedSpec, InputMultiPath, File, +from ..base import (traits, TraitedSpec, InputMultiPath, File, GenFile, isdefined, Undefined) from ...utils.filemanip import (load_json, save_json, split_filename, fname_presuffix) - -warn = warnings.warn +from ... import logging +IFLOGGER = logging.getLogger('interface') class PrepareFieldmapInputSpec(FSLCommandInputSpec): @@ -41,12 +40,11 @@ class PrepareFieldmapInputSpec(FSLCommandInputSpec): desc=('echo time difference of the ' 'fieldmap sequence in ms. (usually 2.46ms in' ' Siemens)')) - nocheck = traits.Bool(False, position=-1, argstr='--nocheck', - usedefault=True, + nocheck = traits.Bool(False, position=-1, argstr='--nocheck', usedefault=True, desc=('do not perform sanity checks for image ' 'size/range/dimensions')) - out_fieldmap = File(argstr='%s', position=4, - desc='output name for prepared fieldmap') + out_fieldmap = GenFile(template='{in_phase}_fslprepared{output_type_}', argstr='%s', + position=4, desc='output name for prepared fieldmap') class PrepareFieldmapOutputSpec(TraitedSpec): @@ -72,37 +70,21 @@ class PrepareFieldmap(FSLCommand): >>> prepare.inputs.output_type = "NIFTI_GZ" >>> prepare.cmdline #doctest: +ELLIPSIS 'fsl_prepare_fieldmap SIEMENS phase.nii magnitude.nii \ -.../phase_fslprepared.nii.gz 2.460000' +phase_fslprepared.nii.gz 2.460000' >>> res = prepare.run() # doctest: +SKIP """ _cmd = 'fsl_prepare_fieldmap' - input_spec = PrepareFieldmapInputSpec - output_spec = PrepareFieldmapOutputSpec - - def _parse_inputs(self, skip=None): - if skip is None: - skip = [] - - if not isdefined(self.inputs.out_fieldmap): - self.inputs.out_fieldmap = self._gen_fname( - self.inputs.in_phase, suffix='_fslprepared') - - if not isdefined(self.inputs.nocheck) or not self.inputs.nocheck: - skip += ['nocheck'] - - return super(PrepareFieldmap, self)._parse_inputs(skip=skip) - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_fieldmap'] = self.inputs.out_fieldmap - return outputs + _input_spec = PrepareFieldmapInputSpec + _output_spec = PrepareFieldmapOutputSpec def _run_interface(self, runtime): runtime = super(PrepareFieldmap, self)._run_interface(runtime) if runtime.returncode == 0: + # Add an empty volume to the output, since downstream software + # expects two GRE images to compute the difference out_file = self.inputs.out_fieldmap im = nib.load(out_file) dumb_img = nib.Nifti1Image(np.zeros(im.shape), im.affine, @@ -116,35 +98,19 @@ def _run_interface(self, runtime): class TOPUPInputSpec(FSLCommandInputSpec): in_file = File(exists=True, mandatory=True, desc='name of 4D file with images', argstr='--imain=%s') - encoding_file = File(exists=True, mandatory=True, - xor=['encoding_direction'], - desc='name of text file with PE directions/times', - argstr='--datain=%s') - encoding_direction = traits.List(traits.Enum('y', 'x', 'z', 'x-', 'y-', - 'z-'), mandatory=True, - xor=['encoding_file'], - requires=['readout_times'], - argstr='--datain=%s', - desc=('encoding direction for automatic ' - 'generation of encoding_file')) - readout_times = InputMultiPath(traits.Float, - requires=['encoding_direction'], - xor=['encoding_file'], mandatory=True, - desc=('readout times (dwell times by # ' - 'phase-encode steps minus 1)')) - out_base = File(desc=('base-name of output files (spline ' - 'coefficients (Hz) and movement parameters)'), - name_source=['in_file'], name_template='%s_base', - argstr='--out=%s', hash_files=False) - out_field = File(argstr='--fout=%s', hash_files=False, - name_source=['in_file'], name_template='%s_field', - desc='name of image file with field (Hz)') - out_corrected = File(argstr='--iout=%s', hash_files=False, - name_source=['in_file'], name_template='%s_corrected', - desc='name of 4D image file with unwarped images') - out_logfile = File(argstr='--logout=%s', desc='name of log-file', - name_source=['in_file'], name_template='%s_topup.log', - keep_extension=True, hash_files=False) + encoding_file = File( + template='{in_file}_encfile.txt', hash_files=False, + output_name='out_enc_file', mandatory=True, xor=['encoding_direction'], + argstr='--datain=%s', desc='name of text file with PE directions/times') + + encoding_direction = traits.List(traits.Enum( + 'y', 'x', 'z', 'x-', 'y-', 'z-'), mandatory=True, xor=['encoding_file'], + requires=['readout_times'], desc='encoding direction for automatic ' + 'generation of encoding_file') + readout_times = InputMultiPath( + traits.Float, requires=['encoding_direction'], xor=['encoding_file'], + mandatory=True, desc='readout times (dwell times by # phase-encode ' + 'steps minus 1)') # TODO: the following traits admit values separated by commas, one value # per registration level inside topup. @@ -204,6 +170,26 @@ class TOPUPInputSpec(FSLCommandInputSpec): desc=('If set (=1), the calculations are done in a ' 'different grid')) + # Outputs + out_base = GenFile( + template='{in_file}_base', argstr='--out=%s', hash_files=False, + desc='base-name of output files (spline coefficients (Hz) and movement parameters)') + out_field = GenFile( + template='{in_file}_field{output_type_}', argstr='--fout=%s', hash_files=False, + desc='name of image file with field (Hz)') + out_corrected = GenFile( + template='{in_file}_corrected{output_type_}', argstr='--iout=%s', hash_files=False, + desc='name of 4D image file with unwarped images') + out_logfile = GenFile( + template='{in_file}_topup.log', argstr='--logout=%s', hash_files=False, + desc='name of log-file') + + out_fieldcoef = GenFile( + template='{out_base}_fieldcoef{output_type_}', hash_files=False, + desc='file containing the field coefficients') + out_movpar = GenFile( + template='{out_base}_movpar.txt', hash_files=False, + desc='file containing the field coefficients') class TOPUPOutputSpec(TraitedSpec): out_fieldcoef = File(exists=True, @@ -241,70 +227,16 @@ class TOPUP(FSLCommand): """ _cmd = 'topup' - input_spec = TOPUPInputSpec - output_spec = TOPUPOutputSpec + _input_spec = TOPUPInputSpec + _output_spec = TOPUPOutputSpec - def _format_arg(self, name, trait_spec, value): - if name == 'encoding_direction': - return trait_spec.argstr % self._generate_encfile() - if name == 'out_base': - path, name, ext = split_filename(value) - if path != '': - if not os.path.exists(path): - raise ValueError('out_base path must exist if provided') - return super(TOPUP, self)._format_arg(name, trait_spec, value) - - def _list_outputs(self): - outputs = super(TOPUP, self)._list_outputs() - del outputs['out_base'] - base_path = None - if isdefined(self.inputs.out_base): - base_path, base, _ = split_filename(self.inputs.out_base) - if base_path == '': - base_path = None - else: - base = split_filename(self.inputs.in_file)[1] + '_base' - outputs['out_fieldcoef'] = self._gen_fname(base, suffix='_fieldcoef', - cwd=base_path) - outputs['out_movpar'] = self._gen_fname(base, suffix='_movpar', - ext='.txt', cwd=base_path) - - if isdefined(self.inputs.encoding_direction): - outputs['out_enc_file'] = self._get_encfilename() - return outputs - - def _get_encfilename(self): - out_file = os.path.join(os.getcwd(), - ('%s_encfile.txt' % - split_filename(self.inputs.in_file)[1])) - return out_file - - def _generate_encfile(self): - """Generate a topup compatible encoding file based on given directions - """ - out_file = self._get_encfilename() - durations = self.inputs.readout_times - if len(self.inputs.encoding_direction) != len(durations): - if len(self.inputs.readout_times) != 1: - raise ValueError(('Readout time must be a float or match the' - 'length of encoding directions')) - durations = durations * len(self.inputs.encoding_direction) - - lines = [] - for idx, encdir in enumerate(self.inputs.encoding_direction): - direction = 1.0 - if encdir.endswith('-'): - direction = -1.0 - line = [float(val[0] == encdir[0]) * direction - for val in ['x', 'y', 'z']] + [durations[idx]] - lines.append(line) - np.savetxt(out_file, np.array(lines), fmt='%d %d %d %.8f') - return out_file - - def _overload_extension(self, value, name=None): - if name == 'out_base': - return value - return super(TOPUP, self)._overload_extension(value, name) + def _run_interface(self, runtime): + if not os.path.isfile(self.inputs.encoding_file): + topup_generate_encfile( + self.inputs.readout_times, + self.inputs.encoding_direction, + self.inputs.encoding_file) + return super(TOPUP, self)._run_interface(runtime) class ApplyTOPUPInputSpec(FSLCommandInputSpec): @@ -325,10 +257,9 @@ class ApplyTOPUPInputSpec(FSLCommandInputSpec): 'coefficients')) in_topup_movpar = File(exists=True, requires=['in_topup_fieldcoef'], copyfile=False, desc='topup movpar.txt file') - out_corrected = File(desc='output (warped) image', - name_source=['in_files'], - name_template='%s_corrected', - argstr='--out=%s') + out_corrected = GenFile( + template='{in_files[0]}_corrected{output_type_}', argstr='--out=%s', + desc='output (warped) image') method = traits.Enum('jac', 'lsr', argstr='--method=%s', desc=('use jacobian modulation (jac) or least-squares' ' resampling (lsr)')) @@ -338,6 +269,11 @@ class ApplyTOPUPInputSpec(FSLCommandInputSpec): argstr='-d=%s', desc='force output data type') + def _format_arg(self, name, spec, value): + if name == 'in_topup_fieldcoef': + return spec.argstr % value.split('_fieldcoef')[0] + return super(ApplyTOPUPInputSpec, self)._format_arg(name, spec, value) + class ApplyTOPUPOutputSpec(TraitedSpec): out_corrected = File(exists=True, desc=('name of 4D image file with ' 'unwarped images')) @@ -371,13 +307,8 @@ class ApplyTOPUP(FSLCommand): """ _cmd = 'applytopup' - input_spec = ApplyTOPUPInputSpec - output_spec = ApplyTOPUPOutputSpec - - def _format_arg(self, name, spec, value): - if name == 'in_topup_fieldcoef': - return spec.argstr % value.split('_fieldcoef')[0] - return super(ApplyTOPUP, self)._format_arg(name, spec, value) + _input_spec = ApplyTOPUPInputSpec + _output_spec = ApplyTOPUPOutputSpec class EddyInputSpec(FSLCommandInputSpec): @@ -458,13 +389,13 @@ class Eddy(FSLCommand): >>> eddy.cmdline #doctest: +ELLIPSIS 'eddy --acqp=epi_acqp.txt --bvals=bvals.scheme --bvecs=bvecs.scheme \ --imain=epi.nii --index=epi_index.txt --mask=epi_mask.nii \ ---out=.../eddy_corrected' +--out=eddy_corrected' >>> res = eddy.run() # doctest: +SKIP """ _cmd = 'eddy' - input_spec = EddyInputSpec - output_spec = EddyOutputSpec + _input_spec = EddyInputSpec + _output_spec = EddyOutputSpec _num_threads = 1 @@ -480,10 +411,10 @@ def __init__(self, **inputs): def _num_threads_update(self): self._num_threads = self.inputs.num_threads if not isdefined(self.inputs.num_threads): - if 'OMP_NUM_THREADS' in self.inputs.environ: - del self.inputs.environ['OMP_NUM_THREADS'] + if 'OMP_NUM_THREADS' in self.environ: + del self.environ['OMP_NUM_THREADS'] else: - self.inputs.environ['OMP_NUM_THREADS'] = str(self.inputs.num_threads) + self.environ['OMP_NUM_THREADS'] = str(self.inputs.num_threads) def _format_arg(self, name, spec, value): if name == 'in_topup_fieldcoef': @@ -492,11 +423,10 @@ def _format_arg(self, name, spec, value): return spec.argstr % os.path.abspath(value) return super(Eddy, self)._format_arg(name, spec, value) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_corrected'] = os.path.abspath('%s.nii.gz' % self.inputs.out_base) - outputs['out_parameter'] = os.path.abspath('%s.eddy_parameters' % self.inputs.out_base) - return outputs + def _post_run(self): + + self.outputs.out_corrected = os.path.abspath('%s.nii.gz' % self.inputs.out_base) + self.outputs.out_parameter = os.path.abspath('%s.eddy_parameters' % self.inputs.out_base) class SigLossInputSpec(FSLCommandInputSpec): @@ -504,9 +434,9 @@ class SigLossInputSpec(FSLCommandInputSpec): exists=True, argstr='-i %s', desc='b0 fieldmap file') - out_file = File(argstr='-s %s', - desc='output signal loss estimate file', - genfile=True) + out_file = GenFile( + template='{in_file}_sigloss{output_type_}', argstr='-s %s', + desc='output signal loss estimate file') mask_file = File(exists=True, argstr='-m %s', @@ -536,27 +466,26 @@ class SigLoss(FSLCommand): >>> sigloss.inputs.echo_time = 0.03 >>> sigloss.inputs.output_type = "NIFTI_GZ" >>> sigloss.cmdline #doctest: +ELLIPSIS - 'sigloss --te=0.030000 -i phase.nii -s .../phase_sigloss.nii.gz' + 'sigloss --te=0.030000 -i phase.nii -s phase_sigloss.nii.gz' >>> res = sigloss.run() # doctest: +SKIP """ - input_spec = SigLossInputSpec - output_spec = SigLossOuputSpec + _input_spec = SigLossInputSpec + _output_spec = SigLossOuputSpec _cmd = 'sigloss' - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_file - if ((not isdefined(outputs['out_file'])) and + def _post_run(self): + + self.outputs.out_file = self.inputs.out_file + if ((not isdefined(self.outputs.out_file)) and (isdefined(self.inputs.in_file))): - outputs['out_file'] = self._gen_fname(self.inputs.in_file, + self.outputs.out_file = self._gen_fname(self.inputs.in_file, suffix='_sigloss') - return outputs def _gen_filename(self, name): if name == 'out_file': - return self._list_outputs()['out_file'] + return self.outputs.out_file return None @@ -586,12 +515,38 @@ class EpiRegInputSpec(FSLCommandInputSpec): weight_image = File(exists=True, argstr='--weight=%s', desc='weighting image (in T1 space)') - no_fmapreg = traits.Bool(False, argstr='--nofmapreg', - desc='do not perform registration of fmap to T1 \ - (use if fmap already registered)') + no_fmapreg = traits.Bool(False, usedefault=True, argstr='--nofmapreg', + desc='do not perform registration of fmap to T1 ' + '(use if fmap already registered).') no_clean = traits.Bool(True, argstr='--noclean', usedefault=True, desc='do not clean up intermediate files') + out_file = GenFile(template='{out_base}{output_type_}', keep_extension=False, + desc='output file name') + epi2str_mat = GenFile(template='{out_base}.mat', keep_extension=False, + desc='rigid epi-to-structural transform') + wmedge = GenFile(template='{out_base}_fast_wmedge{output_type_}', keep_extension=False, + desc='output file name') + wmseg = GenFile(template='{out_base}_fast_wmseg{output_type_}', keep_extension=False, + desc='output file name') + # Optional outputs + out_1vol = GenFile(template='{out_base}_1vol{output_type_}', keep_extension=False, + desc='output file name') + fmap2str_mat = GenFile(template='{out_base}_fieldmap2str.mat', keep_extension=False, + desc='output file name') + fmap2epi_mat = GenFile(template='{out_base}_fieldmaprads2epi.mat', keep_extension=False, + desc='output file name') + fmap_epi = GenFile(template='{out_base}_fieldmaprads2epi{output_type_}', keep_extension=False, + desc='output file name') + fmap_str = GenFile(template='{out_base}_fieldmaprads2str{output_type_}', keep_extension=False, + desc='output file name') + shiftmap = GenFile(template='{out_base}_fieldmaprads2epi_shift{output_type_}', + keep_extension=False, desc='output file name') + fullwarp = GenFile(template='{out_base}_warp{output_type_}', keep_extension=False, + desc='output file name') + epi2str_inv = GenFile(template='{out_base}_inv.mat', keep_extension=False, + desc='output file name') + class EpiRegOutputSpec(TraitedSpec): out_file = File(exists=True, @@ -617,6 +572,18 @@ class EpiRegOutputSpec(TraitedSpec): wmseg = File(exists=True, desc='white matter segmentation used in flirt bbr') wmedge = File(exists=True, desc='white matter edges for visualization') + def _post_run(self): + if self.inputs.no_fmapreg or not isdefined(self.inputs.fmap): + self.outputs.out_1vol = Undefined + self.outputs.fmap2str_mat = Undefined + self.outputs.fmap2epi_mat = Undefined + self.outputs.fmap_epi = Undefined + self.outputs.fmap_str = Undefined + self.outputs.fmapmag_str = Undefined + self.outputs.shiftmap = Undefined + self.outputs.fullwarp = Undefined + self.outputs.epi2str_inv = Undefined + class EpiReg(FSLCommand): """ @@ -646,90 +613,35 @@ class EpiReg(FSLCommand): """ _cmd = 'epi_reg' - input_spec = EpiRegInputSpec - output_spec = EpiRegOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = os.path.join(os.getcwd(), - self.inputs.out_base + '.nii.gz') - if not (isdefined(self.inputs.no_fmapreg) and self.inputs.no_fmapreg) and isdefined(self.inputs.fmap): - outputs['out_1vol'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_1vol.nii.gz') - outputs['fmap2str_mat'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_fieldmap2str.mat') - outputs['fmap2epi_mat'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_fieldmaprads2epi.mat') - outputs['fmap_epi'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_fieldmaprads2epi.nii.gz') - outputs['fmap_str'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_fieldmaprads2str.nii.gz') - outputs['fmapmag_str'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_fieldmap2str.nii.gz') - outputs['shiftmap'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_fieldmaprads2epi_shift.nii.gz') - outputs['fullwarp'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_warp.nii.gz') - outputs['epi2str_inv'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_inv.mat') - - outputs['epi2str_mat'] = os.path.join(os.getcwd(), - self.inputs.out_base + '.mat') - outputs['wmedge'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_fast_wmedge.nii.gz') - outputs['wmseg'] = os.path.join(os.getcwd(), - self.inputs.out_base + '_fast_wmseg.nii.gz') - - return outputs + _input_spec = EpiRegInputSpec + _output_spec = EpiRegOutputSpec +# Helper functions ------------------------ +def topup_generate_encfile(durations, encoding_direction, out_file): + """Generate a topup compatible encoding file based on given directions + """ + if len(encoding_direction) != len(durations): + if len(durations) != 1: + raise ValueError('Readout time must be a float or match the ' + 'length of encoding directions') + durations = durations * len(encoding_direction) + + lines = [] + for idx, encdir in enumerate(encoding_direction): + direction = 1.0 + if encdir.endswith('-'): + direction = -1.0 + line = [float(val[0] == encdir[0]) * direction + for val in ['x', 'y', 'z']] + [durations[idx]] + lines.append(line) + np.savetxt(out_file, np.array(lines), fmt='%d %d %d %.8f') + ####################################### # deprecated interfaces ####################################### -class EPIDeWarpInputSpec(FSLCommandInputSpec): - mag_file = File(exists=True, - desc='Magnitude file', - argstr='--mag %s', position=0, mandatory=True) - dph_file = File(exists=True, - desc='Phase file assumed to be scaled from 0 to 4095', - argstr='--dph %s', mandatory=True) - exf_file = File(exists=True, - desc='example func volume (or use epi)', - argstr='--exf %s') - epi_file = File(exists=True, - desc='EPI volume to unwarp', - argstr='--epi %s') - tediff = traits.Float(2.46, usedefault=True, - desc='difference in B0 field map TEs', - argstr='--tediff %s') - esp = traits.Float(0.58, desc='EPI echo spacing', - argstr='--esp %s', usedefault=True) - sigma = traits.Int(2, usedefault=True, argstr='--sigma %s', - desc="2D spatial gaussing smoothing \ - stdev (default = 2mm)") - vsm = traits.String(genfile=True, desc='voxel shift map', - argstr='--vsm %s') - exfdw = traits.String(desc='dewarped example func volume', genfile=True, - argstr='--exfdw %s') - epidw = traits.String(desc='dewarped epi volume', genfile=False, - argstr='--epidw %s') - tmpdir = traits.String(genfile=True, desc='tmpdir', - argstr='--tmpdir %s') - nocleanup = traits.Bool(True, usedefault=True, desc='no cleanup', - argstr='--nocleanup') - cleanup = traits.Bool(desc='cleanup', - argstr='--cleanup') - - -class EPIDeWarpOutputSpec(TraitedSpec): - unwarped_file = File(desc="unwarped epi file") - vsm_file = File(desc="voxel shift map") - exfdw = File(desc="dewarped functional volume example") - exf_mask = File(desc="Mask from example functional volume") - - class EPIDeWarp(FSLCommand): """ Wraps the unwarping script `epidewarp.fsl @@ -738,94 +650,18 @@ class EPIDeWarp(FSLCommand): .. warning:: deprecated in FSL, please use :func:`nipype.workflows.dmri.preprocess.epi.sdc_fmb` instead. - Examples - -------- - - >>> from nipype.interfaces.fsl import EPIDeWarp - >>> dewarp = EPIDeWarp() - >>> dewarp.inputs.epi_file = "functional.nii" - >>> dewarp.inputs.mag_file = "magnitude.nii" - >>> dewarp.inputs.dph_file = "phase.nii" - >>> dewarp.inputs.output_type = "NIFTI_GZ" - >>> dewarp.cmdline #doctest: +ELLIPSIS - 'epidewarp.fsl --mag magnitude.nii --dph phase.nii --epi functional.nii \ ---esp 0.58 --exfdw .../exfdw.nii.gz --nocleanup --sigma 2 --tediff 2.46 \ ---tmpdir .../temp --vsm .../vsm.nii.gz' - >>> res = dewarp.run() # doctest: +SKIP - + >>> from nipype.interfaces import fsl + >>> fsl.EPIDeWarp() + Traceback (most recent call last): + ... + NotImplementedError: deprecated, please use nipype.workflows.dmri.preprocess.epi.sdc_fmb instead """ _cmd = 'epidewarp.fsl' - input_spec = EPIDeWarpInputSpec - output_spec = EPIDeWarpOutputSpec def __init__(self, **inputs): - warnings.warn(("Deprecated: Please use " - "nipype.workflows.dmri.preprocess.epi.sdc_fmb instead"), - DeprecationWarning) - return super(EPIDeWarp, self).__init__(**inputs) - - def _run_interface(self, runtime): - runtime = super(EPIDeWarp, self)._run_interface(runtime) - if runtime.stderr: - self.raise_exception(runtime) - return runtime - - def _gen_filename(self, name): - if name == 'exfdw': - if isdefined(self.inputs.exf_file): - return self._gen_fname(self.inputs.exf_file, - suffix="_exfdw") - else: - return self._gen_fname("exfdw") - if name == 'epidw': - if isdefined(self.inputs.epi_file): - return self._gen_fname(self.inputs.epi_file, - suffix="_epidw") - if name == 'vsm': - return self._gen_fname('vsm') - if name == 'tmpdir': - return os.path.join(os.getcwd(), 'temp') - return None - - def _list_outputs(self): - outputs = self.output_spec().get() - if not isdefined(self.inputs.exfdw): - outputs['exfdw'] = self._gen_filename('exfdw') - else: - outputs['exfdw'] = self.inputs.exfdw - if isdefined(self.inputs.epi_file): - if isdefined(self.inputs.epidw): - outputs['unwarped_file'] = self.inputs.epidw - else: - outputs['unwarped_file'] = self._gen_filename('epidw') - if not isdefined(self.inputs.vsm): - outputs['vsm_file'] = self._gen_filename('vsm') - else: - outputs['vsm_file'] = self._gen_fname(self.inputs.vsm) - if not isdefined(self.inputs.tmpdir): - outputs[ - 'exf_mask'] = self._gen_fname(cwd=self._gen_filename('tmpdir'), - basename='maskexf') - else: - outputs['exf_mask'] = self._gen_fname(cwd=self.inputs.tmpdir, - basename='maskexf') - return outputs - - -class EddyCorrectInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, desc='4D input file', argstr='%s', position=0, - mandatory=True) - out_file = File(desc='4D output file', argstr='%s', position=1, - name_source=['in_file'], name_template='%s_edc', - output_name='eddy_corrected') - ref_num = traits.Int(0, argstr='%d', position=2, desc='reference number', - mandatory=True, usedefault=True) - - -class EddyCorrectOutputSpec(TraitedSpec): - eddy_corrected = File(exists=True, - desc='path/name of 4D eddy corrected output file') + raise NotImplementedError( + 'deprecated, please use nipype.workflows.dmri.preprocess.epi.sdc_fmb instead') class EddyCorrect(FSLCommand): @@ -834,27 +670,16 @@ class EddyCorrect(FSLCommand): .. warning:: Deprecated in FSL. Please use :class:`nipype.interfaces.fsl.epi.Eddy` instead - Example - ------- - - >>> from nipype.interfaces.fsl import EddyCorrect - >>> eddyc = EddyCorrect(in_file='diffusion.nii', - ... out_file="diffusion_edc.nii", ref_num=0) - >>> eddyc.cmdline - 'eddy_correct diffusion.nii diffusion_edc.nii 0' + >>> from nipype.interfaces import fsl + >>> fsl.EddyCorrect() + Traceback (most recent call last): + ... + NotImplementedError: deprecated, please use nipype.interfaces.fsl.epi.Eddy instead """ _cmd = 'eddy_correct' - input_spec = EddyCorrectInputSpec - output_spec = EddyCorrectOutputSpec def __init__(self, **inputs): - warnings.warn(("Deprecated: Please use nipype.interfaces.fsl.epi.Eddy " - "instead"), DeprecationWarning) - return super(EddyCorrect, self).__init__(**inputs) + raise NotImplementedError( + 'deprecated, please use nipype.interfaces.fsl.epi.Eddy instead') - def _run_interface(self, runtime): - runtime = super(EddyCorrect, self)._run_interface(runtime) - if runtime.stderr: - self.raise_exception(runtime) - return runtime diff --git a/nipype/interfaces/fsl/maths.py b/nipype/interfaces/fsl/maths.py index c22874d13f..4c0f442ce2 100644 --- a/nipype/interfaces/fsl/maths.py +++ b/nipype/interfaces/fsl/maths.py @@ -12,56 +12,42 @@ """ from __future__ import division -import os import numpy as np -from ..base import (TraitedSpec, File, traits, InputMultiPath, isdefined) +from ..base import (TraitedSpec, File, GenFile, traits, InputMultiPath, isdefined) from ..fsl.base import FSLCommand, FSLCommandInputSpec class MathsInput(FSLCommandInputSpec): - in_file = File(position=2, argstr="%s", exists=True, mandatory=True, desc="image to operate on") - out_file = File(genfile=True, position=-2, argstr="%s", desc="image to write", hash_files=False) + out_file = GenFile( + template='{in_file}_maths{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") _dtypes = ["float", "char", "int", "short", "double", "input"] internal_datatype = traits.Enum(*_dtypes, position=1, argstr="-dt %s", desc="datatype to use for calculations (default is float)") output_datatype = traits.Enum(*_dtypes, position=-1, argstr="-odt %s", desc="datatype to use for output (default uses input type)") - - nan2zeros = traits.Bool(position=3, argstr='-nan', + nan2zeros = traits.Bool(False, usedefault=True, position=3, argstr='-nan', desc='change NaNs to zeros before doing anything') class MathsOutput(TraitedSpec): - out_file = File(exists=True, desc="image written after calculations") class MathsCommand(FSLCommand): - _cmd = "fslmaths" - input_spec = MathsInput - output_spec = MathsOutput - _suffix = "_maths" - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs["out_file"] = self.inputs.out_file - if not isdefined(self.inputs.out_file): - outputs["out_file"] = self._gen_fname(self.inputs.in_file, suffix=self._suffix) - outputs["out_file"] = os.path.abspath(outputs["out_file"]) - return outputs - - def _gen_filename(self, name): - if name == "out_file": - return self._list_outputs()["out_file"] - return None + _input_spec = MathsInput + _output_spec = MathsOutput class ChangeDataTypeInput(MathsInput): + out_file = GenFile( + template='{in_file}_chdt{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") _dtypes = ["float", "char", "int", "short", "double", "input"] output_datatype = traits.Enum(*_dtypes, @@ -70,15 +56,14 @@ class ChangeDataTypeInput(MathsInput): class ChangeDataType(MathsCommand): - """Use fslmaths to change the datatype of an image. - - """ - input_spec = ChangeDataTypeInput - _suffix = "_chdt" + """Use fslmaths to change the datatype of an image.""" + _input_spec = ChangeDataTypeInput class ThresholdInputSpec(MathsInput): - + out_file = GenFile( + template='{in_file}_thresh{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") thresh = traits.Float(mandatory=True, position=4, argstr="%s", desc="threshold value") direction = traits.Enum("below", "above", usedefault=True, @@ -87,53 +72,50 @@ class ThresholdInputSpec(MathsInput): use_nonzero_voxels = traits.Bool(desc="use nonzero voxels to calculate robust range", requires=["use_robust_range"]) - -class Threshold(MathsCommand): - """Use fslmaths to apply a threshold to an image in a variety of ways. - - """ - input_spec = ThresholdInputSpec - _suffix = "_thresh" - def _format_arg(self, name, spec, value): if name == "thresh": arg = "-" - _si = self.inputs - if self.inputs.direction == "above": + if self.direction == "above": arg += "u" arg += "thr" - if isdefined(_si.use_robust_range) and _si.use_robust_range: - if isdefined(_si.use_nonzero_voxels) and _si.use_nonzero_voxels: + if isdefined(self.use_robust_range) and self.use_robust_range: + if isdefined(self.use_nonzero_voxels) and self.use_nonzero_voxels: arg += "P" else: arg += "p" arg += " %.10f" % value return arg - return super(Threshold, self)._format_arg(name, spec, value) + return super(ThresholdInputSpec, self)._format_arg(name, spec, value) + +class Threshold(MathsCommand): + """Use fslmaths to apply a threshold to an image in a variety of ways.""" + _input_spec = ThresholdInputSpec class MeanImageInput(MathsInput): - + out_file = GenFile( + template='{in_file}_mean{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True, argstr="-%smean", position=4, desc="dimension to mean across") class MeanImage(MathsCommand): - """Use fslmaths to generate a mean image across a given dimension. - - """ - input_spec = MeanImageInput - _suffix = "_mean" + """Use fslmaths to generate a mean image across a given dimension.""" + _input_spec = MeanImageInput class MaxImageInput(MathsInput): - + out_file = GenFile( + template='{in_file}_max{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True, argstr="-%smax", position=4, desc="dimension to max across") class MaxImage(MathsCommand): - """Use fslmaths to generate a max image across a given dimension. + """ + Use fslmaths to generate a max image across a given dimension. Examples -------- @@ -145,48 +127,43 @@ class MaxImage(MathsCommand): 'fslmaths functional.nii -Tmax functional_max.nii' """ - input_spec = MaxImageInput - _suffix = "_max" + _input_spec = MaxImageInput class IsotropicSmoothInput(MathsInput): - + out_file = GenFile( + template='{in_file}_smooth{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") fwhm = traits.Float(mandatory=True, xor=["sigma"], position=4, argstr="-s %.5f", desc="fwhm of smoothing kernel [mm]") sigma = traits.Float(mandatory=True, xor=["fwhm"], position=4, argstr="-s %.5f", desc="sigma of smoothing kernel [mm]") - -class IsotropicSmooth(MathsCommand): - """Use fslmaths to spatially smooth an image with a gaussian kernel. - - """ - input_spec = IsotropicSmoothInput - _suffix = "_smooth" - def _format_arg(self, name, spec, value): if name == "fwhm": sigma = float(value) / np.sqrt(8 * np.log(2)) return spec.argstr % sigma - return super(IsotropicSmooth, self)._format_arg(name, spec, value) + return super(IsotropicSmoothInput, self)._format_arg(name, spec, value) + +class IsotropicSmooth(MathsCommand): + """Use fslmaths to spatially smooth an image with a gaussian kernel.""" + _input_spec = IsotropicSmoothInput class ApplyMaskInput(MathsInput): - + out_file = GenFile( + template='{in_file}_masked{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") mask_file = File(exists=True, mandatory=True, argstr="-mas %s", position=4, desc="binary image defining mask space") class ApplyMask(MathsCommand): - """Use fslmaths to apply a binary mask to another image. - - """ - input_spec = ApplyMaskInput - _suffix = "_masked" + """Use fslmaths to apply a binary mask to another image.""" + _input_spec = ApplyMaskInput class KernelInput(MathsInput): - kernel_shape = traits.Enum("3D", "2D", "box", "boxv", "gauss", "sphere", "file", argstr="-kernel %s", position=4, desc="kernel shape to use") kernel_size = traits.Float(argstr="%.4f", position=5, xor=["kernel_file"], @@ -196,61 +173,59 @@ class KernelInput(MathsInput): class DilateInput(KernelInput): - + out_file = GenFile( + template='{in_file}_dil{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") operation = traits.Enum("mean", "modal", "max", argstr="-dil%s", position=6, mandatory=True, desc="filtering operation to perfoem in dilation") - -class DilateImage(MathsCommand): - """Use fslmaths to perform a spatial dilation of an image. - - """ - input_spec = DilateInput - _suffix = "_dil" - def _format_arg(self, name, spec, value): if name == "operation": return spec.argstr % dict(mean="M", modal="D", max="F")[value] - return super(DilateImage, self)._format_arg(name, spec, value) + return super(DilateInput, self)._format_arg(name, spec, value) -class ErodeInput(KernelInput): - - minimum_filter = traits.Bool(argstr="%s", position=6, usedefault=True, default_value=False, - desc="if true, minimum filter rather than erosion by zeroing-out") +class DilateImage(MathsCommand): + """Use fslmaths to perform a spatial dilation of an image.""" + _input_spec = DilateInput -class ErodeImage(MathsCommand): - """Use fslmaths to perform a spatial erosion of an image. - - """ - input_spec = ErodeInput - _suffix = "_ero" +class ErodeInput(KernelInput): + out_file = GenFile( + template='{in_file}_ero{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") + minimum_filter = traits.Bool( + False, argstr="-eroF", position=6, usedefault=True, + desc="if true, minimum filter rather than erosion by zeroing-out") def _format_arg(self, name, spec, value): if name == "minimum_filter": - if value: - return "-eroF" - return "-ero" - return super(ErodeImage, self)._format_arg(name, spec, value) + if not value: + return "-ero" + return super(ErodeInput, self)._format_arg(name, spec, value) + +class ErodeImage(MathsCommand): + """Use fslmaths to perform a spatial erosion of an image.""" + _input_spec = ErodeInput class SpatialFilterInput(KernelInput): - + out_file = GenFile( + template='{in_file}_{operation}{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") operation = traits.Enum("mean", "median", "meanu", argstr="-f%s", position=6, mandatory=True, desc="operation to filter with") class SpatialFilter(MathsCommand): - """Use fslmaths to spatially filter an image. - - """ - input_spec = SpatialFilterInput - _suffix = "_filt" + """Use fslmaths to spatially filter an image.""" + _input_spec = SpatialFilterInput class UnaryMathsInput(MathsInput): - + out_file = GenFile( + template='{in_file}_{operation}{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") operation = traits.Enum("exp", "log", "sin", "cos", "tan", "asin", "acos", "atan", "sqr", "sqrt", "recip", "abs", "bin", "binv", "fillh", "fillh26", "index", "edge", "nan", "nanm", "rand", "randn", "range", @@ -259,18 +234,11 @@ class UnaryMathsInput(MathsInput): class UnaryMaths(MathsCommand): - """Use fslmaths to perorm a variety of mathematical operations on an image. - - """ - input_spec = UnaryMathsInput - - def _list_outputs(self): - self._suffix = "_" + self.inputs.operation - return super(UnaryMaths, self)._list_outputs() + """Use fslmaths to perorm a variety of mathematical operations on an image.""" + _input_spec = UnaryMathsInput class BinaryMathsInput(MathsInput): - operation = traits.Enum("add", "sub", "mul", "div", "rem", "max", "min", mandatory=True, argstr="-%s", position=4, desc="operation to perform") @@ -281,19 +249,23 @@ class BinaryMathsInput(MathsInput): class BinaryMaths(MathsCommand): - """Use fslmaths to perform mathematical operations using a second image or a numeric value. - """ - input_spec = BinaryMathsInput + Use fslmaths to perform mathematical operations using a second + image or a numeric value. + """ + _input_spec = BinaryMathsInput class MultiImageMathsInput(MathsInput): - op_string = traits.String(position=4, argstr="%s", mandatory=True, desc="python formatted string of operations to perform") operand_files = InputMultiPath(File(exists=True), mandatory=True, desc="list of file names to plug into op string") + def _format_arg(self, name, spec, value): + if name == "op_string": + return value % tuple(self.operand_files) + return super(MultiImageMathsInput, self)._format_arg(name, spec, value) class MultiImageMaths(MathsCommand): """Use fslmaths to perform a sequence of mathematical operations. @@ -305,21 +277,17 @@ class MultiImageMaths(MathsCommand): >>> maths.inputs.in_file = "functional.nii" >>> maths.inputs.op_string = "-add %s -mul -1 -div %s" >>> maths.inputs.operand_files = ["functional2.nii", "functional3.nii"] - >>> maths.inputs.out_file = "functional4.nii" >>> maths.cmdline - 'fslmaths functional.nii -add functional2.nii -mul -1 -div functional3.nii functional4.nii' + 'fslmaths functional.nii -add functional2.nii -mul -1 -div functional3.nii functional_maths.nii.gz' """ - input_spec = MultiImageMathsInput - - def _format_arg(self, name, spec, value): - if name == "op_string": - return value % tuple(self.inputs.operand_files) - return super(MultiImageMaths, self)._format_arg(name, spec, value) + _input_spec = MultiImageMathsInput class TemporalFilterInput(MathsInput): - + out_file = GenFile( + template='{in_file}_filt{output_type_}', position=-2, argstr="%s", hash_files=False, + desc="image to write") lowpass_sigma = traits.Float(-1, argstr="%.6f", position=5, usedefault=True, desc="lowpass filter sigma (in volumes)") highpass_sigma = traits.Float(-1, argstr="-bptf %.6f", position=4, usedefault=True, @@ -327,8 +295,5 @@ class TemporalFilterInput(MathsInput): class TemporalFilter(MathsCommand): - """Use fslmaths to apply a low, high, or bandpass temporal filter to a timeseries. - - """ - input_spec = TemporalFilterInput - _suffix = "_filt" + """Use fslmaths to apply a low, high, or bandpass temporal filter to a timeseries. """ + _input_spec = TemporalFilterInput diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py index 3d07fa21de..5336a7eda6 100644 --- a/nipype/interfaces/fsl/model.py +++ b/nipype/interfaces/fsl/model.py @@ -25,17 +25,18 @@ from ... import LooseVersion from .base import (FSLCommand, FSLCommandInputSpec, Info) -from ..base import (load_template, File, traits, isdefined, +from ..base import (load_template, File, GenFile, traits, isdefined, TraitedSpec, BaseInterface, Directory, InputMultiPath, OutputMultiPath, - BaseInterfaceInputSpec) + BaseInputSpec) from ...utils.filemanip import (list_to_filename, filename_to_list) from ...utils.misc import human_order_sorted -warn = warnings.warn +from ... import logging +IFLOGGER = logging.getLogger('interface') -class Level1DesignInputSpec(BaseInterfaceInputSpec): +class Level1DesignInputSpec(BaseInputSpec): interscan_interval = traits.Float(mandatory=True, desc='Interscan interval (in secs)') session_info = traits.Any(mandatory=True, @@ -111,8 +112,8 @@ class Level1Design(BaseInterface): """ - input_spec = Level1DesignInputSpec - output_spec = Level1DesignOutputSpec + _input_spec = Level1DesignInputSpec + _output_spec = Level1DesignOutputSpec def _create_ev_file(self, evfname, evinfo): f = open(evfname, 'wt') @@ -343,18 +344,18 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + cwd = os.getcwd() - outputs['fsf_files'] = [] - outputs['ev_files'] = [] + self.outputs.fsf_files = [] + self.outputs.ev_files = [] usetd = 0 basis_key = list(self.inputs.bases.keys())[0] if basis_key in ['dgamma', 'gamma']: usetd = int(self.inputs.bases[basis_key]['derivs']) for runno, runinfo in enumerate(self._format_session_info(self.inputs.session_info)): - outputs['fsf_files'].append(os.path.join(cwd, 'run%d.fsf' % runno)) - outputs['ev_files'].insert(runno, []) + self.outputs.fsf_files.append(os.path.join(cwd, 'run%d.fsf' % runno)) + self.outputs.ev_files.insert(runno, []) evname = [] for field in ['cond', 'regress']: for i, cond in enumerate(runinfo[field]): @@ -366,9 +367,8 @@ def _list_outputs(self): if field == 'cond': if usetd: evname.append(name + 'TD') - outputs['ev_files'][runno].append( + self.outputs.ev_files[runno].append( os.path.join(cwd, evfname)) - return outputs class FEATInputSpec(FSLCommandInputSpec): @@ -384,13 +384,12 @@ class FEAT(FSLCommand): """Uses FSL feat to calculate first level stats """ _cmd = 'feat' - input_spec = FEATInputSpec - output_spec = FEATOutputSpec + _input_spec = FEATInputSpec + _output_spec = FEATOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): is_ica = False - outputs['feat_dir'] = None + self.outputs.feat_dir = None with open(self.inputs.fsf_file, 'rt') as fp: text = fp.read() if "set fmri(inmelodic) 1" in text: @@ -400,17 +399,16 @@ def _list_outputs(self): try: outputdir_spec = line.split('"')[-2] if os.path.exists(outputdir_spec): - outputs['feat_dir'] = outputdir_spec + self.outputs.feat_dir = outputdir_spec except: pass - if not outputs['feat_dir']: + if not self.outputs.feat_dir: if is_ica: - outputs['feat_dir'] = glob(os.path.join(os.getcwd(), '*ica'))[0] + self.outputs.feat_dir = glob(os.path.join(os.getcwd(), '*ica'))[0] else: - outputs['feat_dir'] = glob(os.path.join(os.getcwd(), '*feat'))[0] - print('Outputs from FEATmodel:', outputs) - return outputs + self.outputs.feat_dir = glob(os.path.join(os.getcwd(), '*feat'))[0] + IFLOGGER.info('Outputs from FEATmodel: %s', self.outputs) class FEATModelInputSpec(FSLCommandInputSpec): @@ -422,8 +420,17 @@ class FEATModelInputSpec(FSLCommandInputSpec): desc="Event spec files generated by level1design", position=1, copyfile=False) + def _format_arg(self, name, trait_spec, value): + if name == 'fsf_file': + return super(FEATModelInputSpec, self)._format_arg( + name, trait_spec, self._get_design_root(value)) + elif name == 'ev_files': + return '' + else: + return super(FEATModelInputSpec, self)._format_arg(name, trait_spec, value) + -class FEATModelOutpuSpec(TraitedSpec): +class FEATModelOutputSpec(TraitedSpec): design_file = File( exists=True, desc='Mat file containing ascii matrix for design') design_image = File( @@ -439,44 +446,34 @@ class FEATModel(FSLCommand): """Uses FSL feat_model to generate design.mat files """ _cmd = 'feat_model' - input_spec = FEATModelInputSpec - output_spec = FEATModelOutpuSpec - - def _format_arg(self, name, trait_spec, value): - if name == 'fsf_file': - return super(FEATModel, self)._format_arg(name, trait_spec, self._get_design_root(value)) - elif name == 'ev_files': - return '' - else: - return super(FEATModel, self)._format_arg(name, trait_spec, value) + _input_spec = FEATModelInputSpec + _output_spec = FEATModelOutputSpec def _get_design_root(self, infile): _, fname = os.path.split(infile) return fname.split('.')[0] - def _list_outputs(self): + def _post_run(self): # TODO: figure out file names and get rid off the globs - outputs = self._outputs().get() root = self._get_design_root(list_to_filename(self.inputs.fsf_file)) design_file = glob(os.path.join(os.getcwd(), '%s*.mat' % root)) assert len(design_file) == 1, 'No mat file generated by FEAT Model' - outputs['design_file'] = design_file[0] + self.outputs.design_file = design_file[0] design_image = glob(os.path.join(os.getcwd(), '%s.png' % root)) assert len( design_image) == 1, 'No design image generated by FEAT Model' - outputs['design_image'] = design_image[0] + self.outputs.design_image = design_image[0] design_cov = glob(os.path.join(os.getcwd(), '%s_cov.png' % root)) assert len( design_cov) == 1, 'No covariance image generated by FEAT Model' - outputs['design_cov'] = design_cov[0] + self.outputs.design_cov = design_cov[0] con_file = glob(os.path.join(os.getcwd(), '%s*.con' % root)) assert len(con_file) == 1, 'No con file generated by FEAT Model' - outputs['con_file'] = con_file[0] + self.outputs.con_file = con_file[0] fcon_file = glob(os.path.join(os.getcwd(), '%s*.fts' % root)) if fcon_file: assert len(fcon_file) == 1, 'No fts file generated by FEAT Model' - outputs['fcon_file'] = fcon_file[0] - return outputs + self.outputs.fcon_file = fcon_file[0] class FILMGLSInputSpec(FSLCommandInputSpec): @@ -649,15 +646,15 @@ class FILMGLS(FSLCommand): _cmd = 'film_gls' if Info.version() and LooseVersion(Info.version()) > LooseVersion('5.0.6'): - input_spec = FILMGLSInputSpec507 + _input_spec = FILMGLSInputSpec507 elif Info.version() and LooseVersion(Info.version()) > LooseVersion('5.0.4'): - input_spec = FILMGLSInputSpec505 + _input_spec = FILMGLSInputSpec505 else: - input_spec = FILMGLSInputSpec + _input_spec = FILMGLSInputSpec if Info.version() and LooseVersion(Info.version()) > LooseVersion('5.0.6'): - output_spec = FILMGLSOutputSpec507 + _output_spec = FILMGLSOutputSpec507 else: - output_spec = FILMGLSOutputSpec + _output_spec = FILMGLSOutputSpec def _get_pe_files(self, cwd): files = None @@ -693,24 +690,23 @@ def _get_numcons(self): fp.close() return numtcons, numfcons - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): cwd = os.getcwd() results_dir = os.path.join(cwd, self.inputs.results_dir) - outputs['results_dir'] = results_dir + self.outputs.results_dir = results_dir pe_files = self._get_pe_files(results_dir) if pe_files: - outputs['param_estimates'] = pe_files - outputs['residual4d'] = self._gen_fname('res4d.nii', cwd=results_dir) - outputs['dof_file'] = os.path.join(results_dir, 'dof') - outputs['sigmasquareds'] = self._gen_fname('sigmasquareds.nii', + self.outputs.param_estimates = pe_files + self.outputs.residual4d = self._gen_fname('res4d.nii', cwd=results_dir) + self.outputs.dof_file = os.path.join(results_dir, 'dof') + self.outputs.sigmasquareds = self._gen_fname('sigmasquareds.nii', cwd=results_dir) - outputs['thresholdac'] = self._gen_fname('threshac1.nii', + self.outputs.thresholdac = self._gen_fname('threshac1.nii', cwd=results_dir) if Info.version() and LooseVersion(Info.version()) < LooseVersion('5.0.7'): - outputs['corrections'] = self._gen_fname('corrections.nii', + self.outputs.corrections = self._gen_fname('corrections.nii', cwd=results_dir) - outputs['logfile'] = self._gen_fname('logfile', + self.outputs.logfile = self._gen_fname('logfile', change_ext=False, cwd=results_dir) @@ -734,10 +730,10 @@ def _list_outputs(self): tstats.append(self._gen_fname('tstat%d.nii' % (base_contrast + i), cwd=pth)) if copes: - outputs['copes'] = copes - outputs['varcopes'] = varcopes - outputs['zstats'] = zstats - outputs['tstats'] = tstats + self.outputs.copes = copes + self.outputs.varcopes = varcopes + self.outputs.zstats = zstats + self.outputs.tstats = tstats fstats = [] zfstats = [] for i in range(numfcons): @@ -747,12 +743,11 @@ def _list_outputs(self): self._gen_fname('zfstat%d.nii' % (base_contrast + i), cwd=pth)) if fstats: - outputs['fstats'] = fstats - outputs['zfstats'] = zfstats - return outputs + self.outputs.fstats = fstats + self.outputs.zfstats = zfstats -class FEATRegisterInputSpec(BaseInterfaceInputSpec): +class FEATRegisterInputSpec(BaseInputSpec): feat_dirs = InputMultiPath( Directory(exists=True), desc="Lower level feat dirs", mandatory=True) @@ -771,8 +766,8 @@ class FEATRegisterOutputSpec(TraitedSpec): class FEATRegister(BaseInterface): """Register feat directories to a specific standard """ - input_spec = FEATRegisterInputSpec - output_spec = FEATRegisterOutputSpec + _input_spec = FEATRegisterInputSpec + _output_spec = FEATRegisterOutputSpec def _run_interface(self, runtime): fsf_header = load_template('featreg_header.tcl') @@ -793,11 +788,9 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['fsf_file'] = os.path.abspath( + def _post_run(self): + self.outputs.fsf_file = os.path.abspath( os.path.join(os.getcwd(), 'register.fsf')) - return outputs class FLAMEOInputSpec(FSLCommandInputSpec): @@ -894,8 +887,8 @@ class FLAMEO(FSLCommand): """ _cmd = 'flameo' - input_spec = FLAMEOInputSpec - output_spec = FLAMEOOutputSpec + _input_spec = FLAMEOInputSpec + _output_spec = FLAMEOOutputSpec # ohinds: 2010-04-06 def _run_interface(self, runtime): @@ -908,67 +901,65 @@ def _run_interface(self, runtime): # ohinds: 2010-04-06 # made these compatible with flameo - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): pth = os.path.join(os.getcwd(), self.inputs.log_dir) pes = human_order_sorted(glob(os.path.join(pth, 'pe[0-9]*.*'))) assert len(pes) >= 1, 'No pe volumes generated by FSL Estimate' - outputs['pes'] = pes + self.outputs.pes = pes res4d = human_order_sorted(glob(os.path.join(pth, 'res4d.*'))) assert len(res4d) == 1, 'No residual volume generated by FSL Estimate' - outputs['res4d'] = res4d[0] + self.outputs.res4d = res4d[0] copes = human_order_sorted(glob(os.path.join(pth, 'cope[0-9]*.*'))) assert len(copes) >= 1, 'No cope volumes generated by FSL CEstimate' - outputs['copes'] = copes + self.outputs.copes = copes var_copes = human_order_sorted( glob(os.path.join(pth, 'varcope[0-9]*.*'))) assert len( var_copes) >= 1, 'No varcope volumes generated by FSL CEstimate' - outputs['var_copes'] = var_copes + self.outputs.var_copes = var_copes zstats = human_order_sorted(glob(os.path.join(pth, 'zstat[0-9]*.*'))) assert len(zstats) >= 1, 'No zstat volumes generated by FSL CEstimate' - outputs['zstats'] = zstats + self.outputs.zstats = zstats if isdefined(self.inputs.f_con_file): zfstats = human_order_sorted( glob(os.path.join(pth, 'zfstat[0-9]*.*'))) assert len( zfstats) >= 1, 'No zfstat volumes generated by FSL CEstimate' - outputs['zfstats'] = zfstats + self.outputs.zfstats = zfstats fstats = human_order_sorted( glob(os.path.join(pth, 'fstat[0-9]*.*'))) assert len( fstats) >= 1, 'No fstat volumes generated by FSL CEstimate' - outputs['fstats'] = fstats + self.outputs.fstats = fstats tstats = human_order_sorted(glob(os.path.join(pth, 'tstat[0-9]*.*'))) assert len(tstats) >= 1, 'No tstat volumes generated by FSL CEstimate' - outputs['tstats'] = tstats + self.outputs.tstats = tstats mrefs = human_order_sorted( glob(os.path.join(pth, 'mean_random_effects_var[0-9]*.*'))) assert len( mrefs) >= 1, 'No mean random effects volumes generated by FLAMEO' - outputs['mrefvars'] = mrefs + self.outputs.mrefvars = mrefs tdof = human_order_sorted(glob(os.path.join(pth, 'tdof_t[0-9]*.*'))) assert len(tdof) >= 1, 'No T dof volumes generated by FLAMEO' - outputs['tdof'] = tdof + self.outputs.tdof = tdof weights = human_order_sorted( glob(os.path.join(pth, 'weights[0-9]*.*'))) assert len(weights) >= 1, 'No weight volumes generated by FLAMEO' - outputs['weights'] = weights + self.outputs.weights = weights - outputs['stats_dir'] = pth + self.outputs.stats_dir = pth - return outputs class ContrastMgrInputSpec(FSLCommandInputSpec): @@ -1019,8 +1010,8 @@ class ContrastMgr(FSLCommand): """ _cmd = 'contrast_mgr' - input_spec = ContrastMgrInputSpec - output_spec = ContrastMgrOutputSpec + _input_spec = ContrastMgrInputSpec + _output_spec = ContrastMgrOutputSpec def _run_interface(self, runtime): # The returncode is meaningless in ContrastMgr. So check the output @@ -1063,8 +1054,7 @@ def _get_numcons(self): fp.close() return numtcons, numfcons - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): pth, _ = os.path.split(self.inputs.sigmasquareds) numtcons, numfcons = self._get_numcons() base_contrast = 1 @@ -1088,11 +1078,11 @@ def _list_outputs(self): neffs.append(self._gen_fname('neff%d.nii' % (base_contrast + i), cwd=pth)) if copes: - outputs['copes'] = copes - outputs['varcopes'] = varcopes - outputs['zstats'] = zstats - outputs['tstats'] = tstats - outputs['neffs'] = neffs + self.outputs.copes = copes + self.outputs.varcopes = varcopes + self.outputs.zstats = zstats + self.outputs.tstats = tstats + self.outputs.neffs = neffs fstats = [] zfstats = [] for i in range(numfcons): @@ -1102,12 +1092,11 @@ def _list_outputs(self): self._gen_fname('zfstat%d.nii' % (base_contrast + i), cwd=pth)) if fstats: - outputs['fstats'] = fstats - outputs['zfstats'] = zfstats - return outputs + self.outputs.fstats = fstats + self.outputs.zfstats = zfstats -class L2ModelInputSpec(BaseInterfaceInputSpec): +class L2ModelInputSpec(BaseInputSpec): num_copes = traits.Range(low=1, mandatory=True, desc='number of copes to be combined') @@ -1129,8 +1118,8 @@ class L2Model(BaseInterface): """ - input_spec = L2ModelInputSpec - output_spec = L2ModelOutputSpec + _input_spec = L2ModelInputSpec + _output_spec = L2ModelOutputSpec def _run_interface(self, runtime): cwd = os.getcwd() @@ -1174,15 +1163,12 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): for field in list(outputs.keys()): - outputs[field] = os.path.join(os.getcwd(), - field.replace('_', '.')) - return outputs + setattr(self.outputs, field, os.path.join(os.getcwd(), field.replace('_', '.'))) -class MultipleRegressDesignInputSpec(BaseInterfaceInputSpec): +class MultipleRegressDesignInputSpec(BaseInputSpec): contrasts = traits.List( traits.Either(traits.Tuple(traits.Str, traits.Enum('T'), @@ -1237,8 +1223,8 @@ class MultipleRegressDesign(BaseInterface): """ - input_spec = MultipleRegressDesignInputSpec - output_spec = MultipleRegressDesignOutputSpec + _input_spec = MultipleRegressDesignInputSpec + _output_spec = MultipleRegressDesignOutputSpec def _run_interface(self, runtime): cwd = os.getcwd() @@ -1323,36 +1309,45 @@ def _run_interface(self, runtime): 'design.grp': grp_txt} # write design files - for key, val in list(txt.items()): - if ('fts' in key) and (nfcons == 0): - continue - filename = key.replace('_', '.') - f = open(os.path.join(cwd, filename), 'wt') - f.write(val) - f.close() + with open(os.path.join(cwd, filename), 'wt') as out_file: + for key, val in list(txt.items()): + if ('fts' in key) and (nfcons == 0): + continue + filename = key.replace('_', '.') + + out_file.write(val) return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): nfcons = sum([1 for con in self.inputs.contrasts if con[1] == 'F']) - for field in list(outputs.keys()): + for field, _ in list(self.outputs.items()): if ('fts' in field) and (nfcons == 0): continue - outputs[field] = os.path.join(os.getcwd(), - field.replace('_', '.')) - return outputs + setattr(self.outputs, field, os.path.join(os.getcwd(), field.replace('_', '.'))) class SMMInputSpec(FSLCommandInputSpec): + logdir = traits.Directory('logdir', argstr='--ld=%s', usedefault=True, mandatory=True, + position=0, desc='output directory base') spatial_data_file = File( - exists=True, position=0, argstr='--sdf="%s"', mandatory=True, + exists=True, position=1, argstr='--sdf="%s"', mandatory=True, desc="statistics spatial map", copyfile=False) - mask = File(exists=True, position=1, argstr='--mask="%s"', mandatory=True, + mask = File(exists=True, position=2, argstr='--mask="%s"', mandatory=True, desc="mask file", copyfile=False) no_deactivation_class = traits.Bool(position=2, argstr="--zfstatmode", desc="enforces no deactivation class") + null_p_map = GenFile( + template='{logdir}/{spatial_data_file}_w1mean.txt', hash_files=False, + desc='output null p-values map') + activation_p_map = GenFile( + template='{logdir}/{spatial_data_file}_w2mean.txt', hash_files=False, + desc='output activation p-values map') + deactivation_p_map = GenFile( + template='{logdir}/{spatial_data_file}_w3mean.txt', hash_files=False, + desc='output deactivation p-values map') + class SMMOutputSpec(TraitedSpec): null_p_map = File(exists=True) @@ -1361,26 +1356,14 @@ class SMMOutputSpec(TraitedSpec): class SMM(FSLCommand): - ''' + """ Spatial Mixture Modelling. For more detail on the spatial mixture modelling see Mixture Models with Adaptive Spatial Regularisation for Segmentation with an Application to FMRI Data; Woolrich, M., Behrens, T., Beckmann, C., and Smith, S.; IEEE Trans. Medical Imaging, 24(1):1-11, 2005. - ''' - _cmd = 'mm --ld=logdir' - input_spec = SMMInputSpec - output_spec = SMMOutputSpec - - def _list_outputs(self): - outputs = self._outputs().get() - # TODO get the true logdir from the stdout - outputs['null_p_map'] = self._gen_fname(basename="w1_mean", - cwd="logdir") - outputs['activation_p_map'] = self._gen_fname( - basename="w2_mean", cwd="logdir") - if not isdefined(self.inputs.no_deactivation_class) or not self.inputs.no_deactivation_class: - outputs['deactivation_p_map'] = self._gen_fname( - basename="w3_mean", cwd="logdir") - return outputs + """ + _cmd = 'mm' + _input_spec = SMMInputSpec + _output_spec = SMMOutputSpec class MELODICInputSpec(FSLCommandInputSpec): @@ -1496,19 +1479,18 @@ class MELODIC(FSLCommand): """ - input_spec = MELODICInputSpec - output_spec = MELODICOutputSpec + _input_spec = MELODICInputSpec + _output_spec = MELODICOutputSpec _cmd = 'melodic' - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_dir'] = self.inputs.out_dir - if not isdefined(outputs['out_dir']): - outputs['out_dir'] = self._gen_filename("out_dir") + def _post_run(self): + + self.outputs.out_dir = self.inputs.out_dir + if not isdefined(self.outputs.out_dir): + self.outputs.out_dir = self._gen_filename("out_dir") if isdefined(self.inputs.report) and self.inputs.report: - outputs['report_dir'] = os.path.join( + self.outputs.report_dir = os.path.join( self._gen_filename("out_dir"), "report") - return outputs def _gen_filename(self, name): if name == "out_dir": @@ -1550,8 +1532,8 @@ class SmoothEstimate(FSLCommand): """ - input_spec = SmoothEstimateInputSpec - output_spec = SmoothEstimateOutputSpec + _input_spec = SmoothEstimateInputSpec + _output_spec = SmoothEstimateOutputSpec _cmd = 'smoothest' def aggregate_outputs(self, runtime=None, needed_outputs=None): @@ -1560,7 +1542,6 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None): outputs.dlh = float(stdout[0].split()[1]) outputs.volume = int(stdout[1].split()[1]) outputs.resels = float(stdout[2].split()[1]) - return outputs class ClusterInputSpec(FSLCommandInputSpec): @@ -1569,30 +1550,6 @@ class ClusterInputSpec(FSLCommandInputSpec): threshold = traits.Float(argstr='--thresh=%.10f', mandatory=True, desc='threshold for input volume') - out_index_file = traits.Either(traits.Bool, File, - argstr='--oindex=%s', - desc='output of cluster index (in size order)', hash_files=False) - out_threshold_file = traits.Either(traits.Bool, File, - argstr='--othresh=%s', - desc='thresholded image', hash_files=False) - out_localmax_txt_file = traits.Either(traits.Bool, File, - argstr='--olmax=%s', - desc='local maxima text file', hash_files=False) - out_localmax_vol_file = traits.Either(traits.Bool, File, - argstr='--olmaxim=%s', - desc='output of local maxima volume', hash_files=False) - out_size_file = traits.Either(traits.Bool, File, - argstr='--osize=%s', - desc='filename for output of size image', hash_files=False) - out_max_file = traits.Either(traits.Bool, File, - argstr='--omax=%s', - desc='filename for output of max image', hash_files=False) - out_mean_file = traits.Either(traits.Bool, File, - argstr='--omean=%s', - desc='filename for output of mean image', hash_files=False) - out_pval_file = traits.Either(traits.Bool, File, - argstr='--opvals=%s', - desc='filename for image output of log pvals', hash_files=False) pthreshold = traits.Float(argstr='--pthresh=%.10f', requires=['dlh', 'volume'], desc='p-threshold for clusters') @@ -1624,15 +1581,55 @@ class ClusterInputSpec(FSLCommandInputSpec): desc='file contining warpfield') + out_index_file = GenFile( + template='{in_file}_index{output_type_}', argstr='--oindex=%s', hash_files=False, + desc='output of cluster index (in size order)', output_name='index_file') + out_threshold_file = GenFile( + template='{in_file}_threshold{output_type_}', argstr='--othresh=%s', hash_files=False, + desc='thresholded image') + out_localmax_txt_file = GenFile(template='{in_file}_localmax.txt', argstr='--olmax=%s', + hash_files=False, desc='local maxima text file') + out_localmax_vol_file = GenFile( + template='{in_file}_localmax{output_type_}', argstr='--olmaxim=%s', hash_files=False, + desc='output of local maxima volume') + out_size_file = GenFile(template='{in_file}_size{output_type_}', argstr='--osize=%s', + hash_files=False, desc='filename for output of size image') + out_max_file = GenFile(template='{in_file}_max{output_type_}', argstr='--omax=%s', + hash_files=False, desc='filename for output of max image') + out_mean_file = GenFile(template='{in_file}_mean{output_type_}', argstr='--omean=%s', + hash_files=False, desc='filename for output of mean image') + out_pval_file = GenFile(template='{in_file}_pval{output_type_}', argstr='--opvals=%s', + hash_files=False, desc='filename for image output of log pvals') + + save_index_file = traits.Bool(False, usedefault=True, desc='enable this output') + save_threshold_file = traits.Bool(False, usedefault=True, desc='enable this output') + save_localmax_txt_file = traits.Bool(False, usedefault=True, desc='enable this output') + save_localmax_vol_file = traits.Bool(False, usedefault=True, desc='enable this output') + save_size_file = traits.Bool(False, usedefault=True, desc='enable this output') + save_max_file = traits.Bool(False, usedefault=True, desc='enable this output') + save_mean_file = traits.Bool(False, usedefault=True, desc='enable this output') + save_pval_file = traits.Bool(False, usedefault=True, desc='enable this output') + + def parse_args(self, skip=None): + if skip is None: + skip = [] + + for name, _ in list(self.items()): + if not name.startswith('save_'): + continue + if not getattr(self, name): + skip += ['out_' + name[5:]] + return super(ClusterInputSpec, self).parse_args(skip) + class ClusterOutputSpec(TraitedSpec): index_file = File(desc='output of cluster index (in size order)') - threshold_file = File(desc='thresholded image') - localmax_txt_file = File(desc='local maxima text file') - localmax_vol_file = File(desc='output of local maxima volume') - size_file = File(desc='filename for output of size image') - max_file = File(desc='filename for output of max image') - mean_file = File(desc='filename for output of mean image') - pval_file = File(desc='filename for image output of log pvals') + out_threshold_file = File(desc='thresholded image') + out_localmax_txt_file = File(desc='local maxima text file') + out_localmax_vol_file = File(desc='output of local maxima volume') + out_size_file = File(desc='filename for output of size image') + out_max_file = File(desc='filename for output of max image') + out_mean_file = File(desc='filename for output of mean image') + out_pval_file = File(desc='filename for image output of log pvals') class Cluster(FSLCommand): @@ -1649,43 +1646,10 @@ class Cluster(FSLCommand): 'cluster --in=zstat1.nii.gz --olmax=stats.txt --thresh=2.3000000000' """ - input_spec = ClusterInputSpec - output_spec = ClusterOutputSpec + _input_spec = ClusterInputSpec + _output_spec = ClusterOutputSpec _cmd = 'cluster' - filemap = {'out_index_file': 'index', 'out_threshold_file': 'threshold', - 'out_localmax_txt_file': 'localmax.txt', - 'out_localmax_vol_file': 'localmax', - 'out_size_file': 'size', 'out_max_file': 'max', - 'out_mean_file': 'mean', 'out_pval_file': 'pval'} - - def _list_outputs(self): - outputs = self.output_spec().get() - for key, suffix in list(self.filemap.items()): - outkey = key[4:] - inval = getattr(self.inputs, key) - if isdefined(inval): - if isinstance(inval, bool): - if inval: - change_ext = True - if suffix.endswith('.txt'): - change_ext = False - outputs[outkey] = self._gen_fname(self.inputs.in_file, - suffix='_' + suffix, - change_ext=change_ext) - else: - outputs[outkey] = os.path.abspath(inval) - return outputs - - def _format_arg(self, name, spec, value): - if name in list(self.filemap.keys()): - if isinstance(value, bool): - fname = self._list_outputs()[name[4:]] - else: - fname = value - return spec.argstr % fname - return super(Cluster, self)._format_arg(name, spec, value) - class RandomiseInputSpec(FSLCommandInputSpec): in_file = File(exists=True, desc='4D input file', argstr='-i %s', @@ -1786,14 +1750,14 @@ class Randomise(FSLCommand): """ _cmd = 'randomise' - input_spec = RandomiseInputSpec - output_spec = RandomiseOutputSpec + _input_spec = RandomiseInputSpec + _output_spec = RandomiseOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['tstat_files'] = glob(self._gen_fname( + self.outputs.tstat_files = glob(self._gen_fname( '%s_tstat*.nii' % self.inputs.base_name)) - outputs['fstat_files'] = glob(self._gen_fname( + self.outputs.fstat_files = glob(self._gen_fname( '%s_fstat*.nii' % self.inputs.base_name)) prefix = False if self.inputs.tfce or self.inputs.tfce2D: @@ -1805,16 +1769,15 @@ def _list_outputs(self): elif self.inputs.cm_thresh or self.inputs.f_cm_thresh: prefix = 'clusterm' if prefix: - outputs['t_p_files'] = glob(self._gen_fname( + self.outputs.t_p_files = glob(self._gen_fname( '%s_%s_p_tstat*' % (self.inputs.base_name, prefix))) - outputs['t_corrected_p_files'] = glob(self._gen_fname( + self.outputs.t_corrected_p_files = glob(self._gen_fname( '%s_%s_corrp_tstat*.nii' % (self.inputs.base_name, prefix))) - outputs['f_p_files'] = glob(self._gen_fname( + self.outputs.f_p_files = glob(self._gen_fname( '%s_%s_p_fstat*.nii' % (self.inputs.base_name, prefix))) - outputs['f_corrected_p_files'] = glob(self._gen_fname( + self.outputs.f_corrected_p_files = glob(self._gen_fname( '%s_%s_corrp_fstat*.nii' % (self.inputs.base_name, prefix))) - return outputs class GLMInputSpec(FSLCommandInputSpec): @@ -1922,44 +1885,44 @@ class GLM(FSLCommand): """ _cmd = 'fsl_glm' - input_spec = GLMInputSpec - output_spec = GLMOutputSpec + _input_spec = GLMInputSpec + _output_spec = GLMOutputSpec - def _list_outputs(self): + def _post_run(self): outputs = super(GLM, self)._list_outputs() if isdefined(self.inputs.out_cope): - outputs['out_cope'] = os.path.abspath(self.inputs.out_cope) + self.outputs.out_cope = os.path.abspath(self.inputs.out_cope) if isdefined(self.inputs.out_z_name): - outputs['out_z'] = os.path.abspath(self.inputs.out_z_name) + self.outputs.out_z = os.path.abspath(self.inputs.out_z_name) if isdefined(self.inputs.out_t_name): - outputs['out_t'] = os.path.abspath(self.inputs.out_t_name) + self.outputs.out_t = os.path.abspath(self.inputs.out_t_name) if isdefined(self.inputs.out_p_name): - outputs['out_p'] = os.path.abspath(self.inputs.out_p_name) + self.outputs.out_p = os.path.abspath(self.inputs.out_p_name) if isdefined(self.inputs.out_f_name): - outputs['out_f'] = os.path.abspath(self.inputs.out_f_name) + self.outputs.out_f = os.path.abspath(self.inputs.out_f_name) if isdefined(self.inputs.out_pf_name): - outputs['out_pf'] = os.path.abspath(self.inputs.out_pf_name) + self.outputs.out_pf = os.path.abspath(self.inputs.out_pf_name) if isdefined(self.inputs.out_res_name): - outputs['out_res'] = os.path.abspath(self.inputs.out_res_name) + self.outputs.out_res = os.path.abspath(self.inputs.out_res_name) if isdefined(self.inputs.out_varcb_name): - outputs['out_varcb'] = os.path.abspath(self.inputs.out_varcb_name) + self.outputs.out_varcb = os.path.abspath(self.inputs.out_varcb_name) if isdefined(self.inputs.out_sigsq_name): - outputs['out_sigsq'] = os.path.abspath(self.inputs.out_sigsq_name) + self.outputs.out_sigsq = os.path.abspath(self.inputs.out_sigsq_name) if isdefined(self.inputs.out_data_name): - outputs['out_data'] = os.path.abspath(self.inputs.out_data_name) + self.outputs.out_data = os.path.abspath(self.inputs.out_data_name) if isdefined(self.inputs.out_vnscales_name): - outputs['out_vnscales'] = os.path.abspath( + self.outputs.out_vnscales = os.path.abspath( self.inputs.out_vnscales_name) - return outputs + diff --git a/nipype/interfaces/fsl/preprocess.py b/nipype/interfaces/fsl/preprocess.py index 1f3137085e..a4519af713 100644 --- a/nipype/interfaces/fsl/preprocess.py +++ b/nipype/interfaces/fsl/preprocess.py @@ -13,53 +13,46 @@ from __future__ import print_function from __future__ import division -from builtins import range import os import os.path as op -import warnings - import numpy as np from nibabel import load +from builtins import range + +from ..base import (TraitedSpec, File, GenFile, GenMultiFile, + InputMultiPath, OutputMultiPath, traits, isdefined) from ..fsl.base import FSLCommand, FSLCommandInputSpec -from ..base import (TraitedSpec, File, InputMultiPath, - OutputMultiPath, Undefined, traits, - isdefined, OutputMultiPath) from ...utils.filemanip import split_filename -warn = warnings.warn +from ... import logging +IFLOGGER = logging.getLogger('interface') class BETInputSpec(FSLCommandInputSpec): # We use position args here as list indices - so a negative number # will put something on the end - in_file = File(exists=True, - desc='input file to skull strip', - argstr='%s', position=0, mandatory=True) - out_file = File(desc='name of output skull stripped image', - argstr='%s', position=1, genfile=True, hash_files=False) - outline = traits.Bool(desc='create surface outline image', - argstr='-o') - mask = traits.Bool(desc='create binary mask image', - argstr='-m') - skull = traits.Bool(desc='create skull image', - argstr='-s') - no_output = traits.Bool(argstr='-n', + in_file = File(exists=True, argstr='%s', position=0, mandatory=True, + desc='input file to skull strip') + outline = traits.Bool(False, usedefault=True, argstr='-o', + desc='create surface outline image') + mask = traits.Bool(False, usedefault=True, argstr='-m', + desc='create binary mask image') + skull = traits.Bool(False, usedefault=True, argstr='-s', + desc='create skull image') + no_output = traits.Bool(False, usedefault=True, argstr='-n', desc="Don't generate segmented output") - frac = traits.Float(desc='fractional intensity threshold', - argstr='-f %.2f') - vertical_gradient = traits.Float(argstr='-g %.2f', - desc='vertical gradient in fractional intensity ' - 'threshold (-1, 1)') - radius = traits.Int(argstr='-r %d', units='mm', - desc="head radius") - center = traits.List(traits.Int, desc='center of gravity in voxels', - argstr='-c %s', minlen=0, maxlen=3, - units='voxels') - threshold = traits.Bool(argstr='-t', + frac = traits.Float(desc='fractional intensity threshold', argstr='-f %.2f') + vertical_gradient = traits.Float( + argstr='-g %.2f', desc='vertical gradient in fractional intensity ' + 'threshold (-1, 1)') + radius = traits.Int(argstr='-r %d', units='mm', desc="head radius") + center = traits.List(traits.Int, argstr='-c %s', minlen=0, maxlen=3, units='voxels', + desc='center of gravity in voxels') + threshold = traits.Bool(False, usedefault=True, argstr='-t', desc="apply thresholding to segmented brain image and mask") - mesh = traits.Bool(argstr='-e', + mesh = traits.Bool(False, usedefault=True, argstr='-e', desc="generate a vtk mesh brain surface") # the remaining 'options' are more like modes (mutually exclusive) that # FSL actually implements in a shell script wrapper around the bet binary. @@ -68,9 +61,9 @@ class BETInputSpec(FSLCommandInputSpec): # supported _xor_inputs = ('functional', 'reduce_bias', 'robust', 'padding', 'remove_eyes', 'surfaces', 't2_guided') - robust = traits.Bool(desc='robust brain centre estimation ' - '(iterates BET several times)', - argstr='-R', xor=_xor_inputs) + robust = traits.Bool(False, usedefault=True, argstr='-R', xor=_xor_inputs, + desc='robust brain centre estimation ' + '(iterates BET several times)') padding = traits.Bool(desc='improve BET if FOV is very small in Z ' '(by temporarily padding end slices)', argstr='-Z', xor=_xor_inputs) @@ -89,30 +82,47 @@ class BETInputSpec(FSLCommandInputSpec): reduce_bias = traits.Bool(argstr='-B', xor=_xor_inputs, desc="bias field and neck cleanup") + # Automatically generated input names + out_file = GenFile(argstr='%s', position=1, template='{in_file}_brain{output_type_}', + hash_files=False, desc='name of output skull stripped image') + mask_file = GenFile(template='{in_file}_mask{output_type_}', + desc="path/name of binary brain mask") + meshfile = GenFile( + template='{in_file}_mesh.vtk', keep_extension=False, + desc="path/name of vtk mesh file") + outline_file = GenFile(template='{in_file}_overlay{output_type_}', + desc="path/name of outline file") + inskull_mask_file = GenFile(template='{in_file}_inskull_mask{output_type_}', + desc="path/name of inskull mask") + inskull_mesh_file = GenFile( + template='{in_file}_inskull_mesh.vtk', keep_extension=False, + desc="path/name of inskull mesh outline") + outskull_mask_file = GenFile(template='{in_file}_outskull_mask{output_type_}', + desc="path/name of outskull mask") + outskull_mesh_file = GenFile( + template='{in_file}_outskull_mesh.vtk', keep_extension=False, + desc="path/name of outskull mesh outline") + outskin_mask_file = GenFile(template='{in_file}_outskin_mask{output_type_}', + desc="path/name of outskin mask") + outskin_mesh_file = GenFile( + template='{in_file}_outskin_mesh.vtk', keep_extension=False, + desc="path/name of outskin mesh outline") + skull_mask_file = GenFile(template='{in_file}_skull_mask{output_type_}', + desc="path/name of skull mask") + class BETOutputSpec(TraitedSpec): - out_file = File( - desc="path/name of skullstripped file (if generated)") - mask_file = File( - desc="path/name of binary brain mask (if generated)") - outline_file = File( - desc="path/name of outline file (if generated)") - meshfile = File( - desc="path/name of vtk mesh file (if generated)") - inskull_mask_file = File( - desc="path/name of inskull mask (if generated)") - inskull_mesh_file = File( - desc="path/name of inskull mesh outline (if generated)") - outskull_mask_file = File( - desc="path/name of outskull mask (if generated)") - outskull_mesh_file = File( - desc="path/name of outskull mesh outline (if generated)") - outskin_mask_file = File( - desc="path/name of outskin mask (if generated)") - outskin_mesh_file = File( - desc="path/name of outskin mesh outline (if generated)") - skull_mask_file = File( - desc="path/name of skull mask (if generated)") + out_file = File(desc="path/name of skullstripped file") + mask_file = File(desc="path/name of binary brain mask") + meshfile = File(desc="path/name of vtk mesh file") + outline_file = File(desc="path/name of outline file") + inskull_mask_file = File(desc="path/name of inskull mask") + inskull_mesh_file = File(desc="path/name of inskull mesh outline") + outskull_mask_file = File(desc="path/name of outskull mask") + outskull_mesh_file = File(desc="path/name of outskull mesh outline") + outskin_mask_file = File(desc="path/name of outskin mask") + outskin_mesh_file = File(desc="path/name of outskin mesh outline") + skull_mask_file = File(desc="path/name of skull mask") class BET(FSLCommand): @@ -133,8 +143,8 @@ class BET(FSLCommand): """ _cmd = 'bet' - input_spec = BETInputSpec - output_spec = BETOutputSpec + _input_spec = BETInputSpec + _output_spec = BETOutputSpec def _run_interface(self, runtime): # The returncode is meaningless in BET. So check the output @@ -145,65 +155,13 @@ def _run_interface(self, runtime): self.raise_exception(runtime) return runtime - def _gen_outfilename(self): - out_file = self.inputs.out_file - if not isdefined(out_file) and isdefined(self.inputs.in_file): - out_file = self._gen_fname(self.inputs.in_file, - suffix='_brain') - return os.path.abspath(out_file) - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self._gen_outfilename() - if ((isdefined(self.inputs.mesh) and self.inputs.mesh) or - (isdefined(self.inputs.surfaces) and self.inputs.surfaces)): - outputs['meshfile'] = self._gen_fname(outputs['out_file'], - suffix='_mesh.vtk', - change_ext=False) - if (isdefined(self.inputs.mask) and self.inputs.mask) or \ - (isdefined(self.inputs.reduce_bias) and - self.inputs.reduce_bias): - outputs['mask_file'] = self._gen_fname(outputs['out_file'], - suffix='_mask') - if isdefined(self.inputs.outline) and self.inputs.outline: - outputs['outline_file'] = self._gen_fname(outputs['out_file'], - suffix='_overlay') - if isdefined(self.inputs.surfaces) and self.inputs.surfaces: - outputs['inskull_mask_file'] = self._gen_fname(outputs['out_file'], - suffix='_inskull_mask') - outputs['inskull_mesh_file'] = self._gen_fname(outputs['out_file'], - suffix='_inskull_mesh') - outputs[ - 'outskull_mask_file'] = self._gen_fname(outputs['out_file'], - suffix='_outskull_mask') - outputs[ - 'outskull_mesh_file'] = self._gen_fname(outputs['out_file'], - suffix='_outskull_mesh') - outputs['outskin_mask_file'] = self._gen_fname(outputs['out_file'], - suffix='_outskin_mask') - outputs['outskin_mesh_file'] = self._gen_fname(outputs['out_file'], - suffix='_outskin_mesh') - outputs['skull_mask_file'] = self._gen_fname(outputs['out_file'], - suffix='_skull_mask') - if isdefined(self.inputs.no_output) and self.inputs.no_output: - outputs['out_file'] = Undefined - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._gen_outfilename() - return None - class FASTInputSpec(FSLCommandInputSpec): """ Defines inputs (trait classes) for FAST """ - in_files = InputMultiPath(File(exists=True), copyfile=False, - desc='image, or multi-channel set of images, ' - 'to be segmented', - argstr='%s', position=-1, mandatory=True) - out_basename = File(desc='base name of output files', - argstr='-o %s') # uses in_file name as basename if none given - number_classes = traits.Range(low=1, high=10, argstr='-n %d', + in_files = InputMultiPath( + File(exists=True), copyfile=False, argstr='%s', position=-1, mandatory=True, + desc='image, or multi-channel set of images, to be segmented') + number_classes = traits.Range(low=1, high=10, argstr='-n %d', usedefault=True, default=3, desc='number of tissue-type classes') output_biasfield = traits.Bool(desc='output estimated bias field', argstr='-b') @@ -266,24 +224,61 @@ class FASTInputSpec(FSLCommandInputSpec): probability_maps = traits.Bool(desc='outputs individual probability maps', argstr='-p') + # Automatically generated names + out_basename = GenFile(template='{in_files[0]}', argstr='-o %s', keep_extension=False, + desc='base name of output files') + tissue_class_map = GenFile(template='{out_basename}_seg{output_type_}', + desc='binary segmented volume file one val for each class') + partial_volume_map = GenFile(template='{out_basename}_pveseg{output_type_}', + desc="segmentation corresponding to the partial volume files") + mixeltype = GenFile(template='{out_basename}_mixeltype{output_type_}', + desc="path/name of mixeltype volume file ") + + # Automatically generated lists of names, one element per in_files + restored_image = GenMultiFile( + template='{in_files}_restore{output_type_}', + desc='restored images (one for each input image) named according to the input images') + bias_field = GenMultiFile( + template='{in_files}_bias{output_type_}', desc='Estimated bias field') + + # Automatically generated lists of names, using range + tissue_class_files = GenMultiFile( + template='{out_basename}_seg_{number_classes:d}{output_type_}', range_source='number_classes', + desc='path/name of binary segmented volumes one file for each class _seg_x') + partial_volume_files = GenMultiFile( + template='{out_basename}_pve_{number_classes:d}{output_type_}', range_source='number_classes', + desc='path/name of partial volumes files one for each class, _pve_x') + probability_maps_files = GenMultiFile( + template='{out_basename}_prob_{number_classes:d}{output_type_}', range_source='number_classes', + desc='filenames, one for each class, for each input, prob_x', output_name='probability_maps') + + + def _format_arg(self, name, spec, value): + # first do what should be done in general + formatted = super(FASTInputSpec, self)._format_arg(name, spec, value) + if name == 'in_files': + # FAST needs the -S parameter value to correspond to the number + # of input images, otherwise it will ignore all but the first + formatted = "-S %d %s" % (len(value), formatted) + return formatted + class FASTOutputSpec(TraitedSpec): """Specify possible outputs from FAST""" - tissue_class_map = File(exists=True, - desc='path/name of binary segmented volume file' - ' one val for each class _seg') - tissue_class_files = OutputMultiPath(File(desc='path/name of binary segmented volumes ' - 'one file for each class _seg_x')) + tissue_class_map = File( + desc='path/name of binary segmented volume file one val for each class _seg') + partial_volume_map = File(desc="path/name of partial volume file _pveseg") + mixeltype = File(desc="path/name of mixeltype volume file _mixeltype") + restored_image = OutputMultiPath(File(desc='restored images (one for each input image) ' 'named according to the input images _restore')) + bias_field = OutputMultiPath(File(desc='Estimated bias field _bias')) - mixeltype = File(desc="path/name of mixeltype volume file _mixeltype") - partial_volume_map = File(desc="path/name of partial volume file _pveseg") + tissue_class_files = OutputMultiPath(File(desc='path/name of binary segmented volumes ' + 'one file for each class _seg_x')) partial_volume_files = OutputMultiPath(File(desc='path/name of partial volumes files ' 'one for each class, _pve_x')) - - bias_field = OutputMultiPath(File(desc='Estimated bias field _bias')) probability_maps = OutputMultiPath(File(desc='filenames, one for each class, for each ' 'input, prob_x')) @@ -307,20 +302,12 @@ class FAST(FSLCommand): """ _cmd = 'fast' - input_spec = FASTInputSpec - output_spec = FASTOutputSpec + _input_spec = FASTInputSpec + _output_spec = FASTOutputSpec + + def _post_run(self): - def _format_arg(self, name, spec, value): - # first do what should be done in general - formated = super(FAST, self)._format_arg(name, spec, value) - if name == 'in_files': - # FAST needs the -S parameter value to correspond to the number - # of input images, otherwise it will ignore all but the first - formated = "-S %d %s" % (len(value), formated) - return formated - def _list_outputs(self): - outputs = self.output_spec().get() if not isdefined(self.inputs.number_classes): nclasses = 3 else: @@ -332,56 +319,52 @@ def _list_outputs(self): else: basefile = self.inputs.in_files[-1] - outputs['tissue_class_map'] = self._gen_fname(basefile, - suffix='_seg') if self.inputs.segments: - outputs['tissue_class_files'] = [] + self.outputs.tissue_class_files = [] for i in range(nclasses): - outputs['tissue_class_files'].append( + self.outputs.tissue_class_files.append( self._gen_fname(basefile, suffix='_seg_%d' % i)) if isdefined(self.inputs.output_biascorrected): - outputs['restored_image'] = [] + self.outputs.restored_image = [] if len(self.inputs.in_files) > 1: # for multi-image segmentation there is one corrected image # per input for val, f in enumerate(self.inputs.in_files): # image numbering is 1-based - outputs['restored_image'].append( + self.outputs.restored_image.append( self._gen_fname(basefile, suffix='_restore_%d' % (val + 1))) else: # single image segmentation has unnumbered output image - outputs['restored_image'].append( + self.outputs.restored_image.append( self._gen_fname(basefile, suffix='_restore')) - outputs['mixeltype'] = self._gen_fname(basefile, suffix='_mixeltype') if not self.inputs.no_pve: - outputs['partial_volume_map'] = self._gen_fname( + self.outputs.partial_volume_map = self._gen_fname( basefile, suffix='_pveseg') - outputs['partial_volume_files'] = [] + self.outputs.partial_volume_files = [] for i in range(nclasses): outputs[ 'partial_volume_files'].append(self._gen_fname(basefile, suffix='_pve_%d' % i)) if self.inputs.output_biasfield: - outputs['bias_field'] = [] + self.outputs.bias_field = [] if len(self.inputs.in_files) > 1: # for multi-image segmentation there is one bias field image # per input for val, f in enumerate(self.inputs.in_files): # image numbering is 1-based - outputs['bias_field'].append( + self.outputs.bias_field.append( self._gen_fname(basefile, suffix='_bias_%d' % (val + 1))) else: # single image segmentation has unnumbered output image - outputs['bias_field'].append( + self.outputs.bias_field.append( self._gen_fname(basefile, suffix='_bias')) if self.inputs.probability_maps: - outputs['probability_maps'] = [] + self.outputs.probability_maps = [] for i in range(nclasses): - outputs['probability_maps'].append( + self.outputs.probability_maps.append( self._gen_fname(basefile, suffix='_prob_%d' % i)) - return outputs class FLIRTInputSpec(FSLCommandInputSpec): @@ -509,6 +492,14 @@ class FLIRTInputSpec(FSLCommandInputSpec): argstr='-bbrslope %f', min_ver='5.0.0', desc='value of bbr slope') + def parse_args(self, skip=None): + skip = [] + if isdefined(self.save_log) and self.save_log: + if not isdefined(self.verbose) or self.verbose == 0: + self.verbose = 1 + skip.append('save_log') + return super(FLIRTInputSpec, self).parse_args(skip=skip) + class FLIRTOutputSpec(TraitedSpec): out_file = File(exists=True, @@ -542,24 +533,18 @@ class FLIRT(FSLCommand): """ _cmd = 'flirt' - input_spec = FLIRTInputSpec - output_spec = FLIRTOutputSpec + _input_spec = FLIRTInputSpec + _output_spec = FLIRTOutputSpec + + def _run_interface(self, runtime, **kwargs): + runtime = super(FLIRT, self)._run_interface(runtime, **kwargs) - def aggregate_outputs(self, runtime=None, needed_outputs=None): - outputs = super(FLIRT, self).aggregate_outputs( - runtime=runtime, needed_outputs=needed_outputs) if isdefined(self.inputs.save_log) and self.inputs.save_log: - with open(outputs.out_log, "a") as text_file: + with open(self.inputs.out_log, "a") as text_file: text_file.write(runtime.stdout + '\n') - return outputs - def _parse_inputs(self, skip=None): - skip = [] - if isdefined(self.inputs.save_log) and self.inputs.save_log: - if not isdefined(self.inputs.verbose) or self.inputs.verbose == 0: - self.inputs.verbose = 1 - skip.append('save_log') - return super(FLIRT, self)._parse_inputs(skip=skip) + return runtime + class ApplyXfmInputSpec(FLIRTInputSpec): @@ -589,14 +574,14 @@ class ApplyXfm(FLIRT): >>> result = applyxfm.run() # doctest: +SKIP """ - input_spec = ApplyXfmInputSpec + _input_spec = ApplyXfmInputSpec class MCFLIRTInputSpec(FSLCommandInputSpec): in_file = File(exists=True, position=0, argstr="-in %s", mandatory=True, desc="timeseries to motion-correct") - out_file = File(argstr='-out %s', genfile=True, - desc="file to write", hash_files=False) + out_file = GenFile(template='{in_file}_mcf{output_type_}', argstr='-out %s', + hash_files=False, desc="file to write") cost = traits.Enum( 'mutualinfo', 'woods', 'corratio', 'normcorr', 'normmi', 'leastsquares', argstr='-cost %s', desc="cost function to optimize") @@ -632,6 +617,13 @@ class MCFLIRTInputSpec(FSLCommandInputSpec): ref_file = File(exists=True, argstr='-reffile %s', desc="target image for motion correction") + def _format_arg(self, name, spec, value): + if name == "interpolation": + if value == "trilinear": + return "" + else: + return spec.argstr % value + return super(MCFLIRTInputSpec, self)._format_arg(name, spec, value) class MCFLIRTOutputSpec(TraitedSpec): out_file = File(exists=True, desc="motion-corrected timeseries") @@ -660,27 +652,18 @@ class MCFLIRT(FSLCommand): """ _cmd = 'mcflirt' - input_spec = MCFLIRTInputSpec - output_spec = MCFLIRTOutputSpec + _input_spec = MCFLIRTInputSpec + _output_spec = MCFLIRTOutputSpec - def _format_arg(self, name, spec, value): - if name == "interpolation": - if value == "trilinear": - return "" - else: - return spec.argstr % value - return super(MCFLIRT, self)._format_arg(name, spec, value) + def _post_run(self): - def _list_outputs(self): cwd = os.getcwd() - outputs = self._outputs().get() - - outputs['out_file'] = self._gen_outfilename() + self.outputs.out_file = self._gen_outfilename() if isdefined(self.inputs.stats_imgs) and self.inputs.stats_imgs: - outputs['variance_img'] = self._gen_fname(outputs['out_file'] + + self.outputs.variance_img = self._gen_fname(self.outputs.out_file + '_variance.ext', cwd=cwd) - outputs['std_img'] = self._gen_fname(outputs['out_file'] + + self.outputs.std_img = self._gen_fname(self.outputs.out_file + '_sigma.ext', cwd=cwd) # The mean image created if -stats option is specified ('meanvol') @@ -690,39 +673,24 @@ def _list_outputs(self): # Note that the same problem holds for the std and variance image. if isdefined(self.inputs.mean_vol) and self.inputs.mean_vol: - outputs['mean_img'] = self._gen_fname(outputs['out_file'] + + self.outputs.mean_img = self._gen_fname(self.outputs.out_file + '_mean_reg.ext', cwd=cwd) if isdefined(self.inputs.save_mats) and self.inputs.save_mats: - _, filename = os.path.split(outputs['out_file']) + _, filename = os.path.split(self.outputs.out_file) matpathname = os.path.join(cwd, filename + '.mat') _, _, _, timepoints = load(self.inputs.in_file).shape - outputs['mat_file'] = [] + self.outputs.mat_file = [] for t in range(timepoints): - outputs['mat_file'].append(os.path.join(matpathname, + self.outputs.mat_file.append(os.path.join(matpathname, 'MAT_%04d' % t)) if isdefined(self.inputs.save_plots) and self.inputs.save_plots: # Note - if e.g. out_file has .nii.gz, you get .nii.gz.par, # which is what mcflirt does! - outputs['par_file'] = outputs['out_file'] + '.par' + self.outputs.par_file = self.outputs.out_file + '.par' if isdefined(self.inputs.save_rms) and self.inputs.save_rms: - outfile = outputs['out_file'] - outputs['rms_files'] = [outfile + '_abs.rms', outfile + '_rel.rms'] - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._gen_outfilename() - return None - - def _gen_outfilename(self): - out_file = self.inputs.out_file - if isdefined(out_file): - out_file = os.path.realpath(out_file) - if not isdefined(out_file) and isdefined(self.inputs.in_file): - out_file = self._gen_fname(self.inputs.in_file, - suffix='_mcf') - return os.path.abspath(out_file) + outfile = self.outputs.out_file + self.outputs.rms_files = [outfile + '_abs.rms', outfile + '_rel.rms'] class FNIRTInputSpec(FSLCommandInputSpec): @@ -838,6 +806,12 @@ class FNIRTInputSpec(FSLCommandInputSpec): desc='Precision for representing Hessian, double or float. Default double') + def _format_arg(self, name, spec, value): + if name in list(self.filemap.keys()): + return spec.argstr % getattr(self.outputs, name) + return super(FSLCommandInputSpec, self)._format_arg(name, spec, value) + + class FNIRTOutputSpec(TraitedSpec): fieldcoeff_file = File(exists=True, desc='file with field coefficients') warped_file = File(exists=True, desc='warped image') @@ -879,8 +853,8 @@ class FNIRT(FSLCommand): """ _cmd = 'fnirt' - input_spec = FNIRTInputSpec - output_spec = FNIRTOutputSpec + _input_spec = FNIRTInputSpec + _output_spec = FNIRTOutputSpec filemap = {'warped_file': 'warped', 'field_file': 'field', @@ -890,8 +864,7 @@ class FNIRT(FSLCommand): 'log_file': 'log.txt', 'fieldcoeff_file': 'fieldwarp'} - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): for key, suffix in list(self.filemap.items()): inval = getattr(self.inputs, key) change_ext = True @@ -899,29 +872,23 @@ def _list_outputs(self): if suffix.endswith('.txt'): change_ext = False if isdefined(inval): - outputs[key] = inval + setattr(self.outputs, key, inval) else: - outputs[key] = self._gen_fname(self.inputs.in_file, + setattr(self.outputs, key, self._gen_fname(self.inputs.in_file, suffix='_' + suffix, - change_ext=change_ext) + change_ext=change_ext)) elif isdefined(inval): if isinstance(inval, bool): if inval: - outputs[key] = self._gen_fname(self.inputs.in_file, + setattr(self.outputs, key, self._gen_fname(self.inputs.in_file, suffix='_' + suffix, - change_ext=change_ext) + change_ext=change_ext)) else: - outputs[key] = os.path.abspath(inval) - return outputs - - def _format_arg(self, name, spec, value): - if name in list(self.filemap.keys()): - return spec.argstr % self._list_outputs()[name] - return super(FNIRT, self)._format_arg(name, spec, value) + setattr(self.outputs, key, os.path.abspath(inval)) def _gen_filename(self, name): if name in ['warped_file', 'log_file']: - return self._list_outputs()[name] + return getattr(self.outputs, name) return None def write_config(self, configfile): @@ -977,6 +944,12 @@ class ApplyWarpInputSpec(FSLCommandInputSpec): desc='interpolation method') + def _format_arg(self, name, spec, value): + if name == 'superlevel': + return spec.argstr % str(value) + return super(ApplyWarpInputSpec, self)._format_arg(name, spec, value) + + class ApplyWarpOutputSpec(TraitedSpec): out_file = File(exists=True, desc='Warped output file') @@ -998,26 +971,20 @@ class ApplyWarp(FSLCommand): """ _cmd = 'applywarp' - input_spec = ApplyWarpInputSpec - output_spec = ApplyWarpOutputSpec + _input_spec = ApplyWarpInputSpec + _output_spec = ApplyWarpOutputSpec - def _format_arg(self, name, spec, value): - if name == 'superlevel': - return spec.argstr % str(value) - return super(ApplyWarp, self)._format_arg(name, spec, value) + def _post_run(self): - def _list_outputs(self): - outputs = self._outputs().get() if not isdefined(self.inputs.out_file): - outputs['out_file'] = self._gen_fname(self.inputs.in_file, + self.outputs.out_file = self._gen_fname(self.inputs.in_file, suffix='_warp') else: - outputs['out_file'] = os.path.abspath(self.inputs.out_file) - return outputs + self.outputs.out_file = os.path.abspath(self.inputs.out_file) def _gen_filename(self, name): if name == 'out_file': - return self._list_outputs()[name] + return getattr(self.outputs, name) return None @@ -1063,21 +1030,19 @@ class SliceTimer(FSLCommand): """ _cmd = 'slicetimer' - input_spec = SliceTimerInputSpec - output_spec = SliceTimerOutputSpec + _input_spec = SliceTimerInputSpec + _output_spec = SliceTimerOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): out_file = self.inputs.out_file if not isdefined(out_file): out_file = self._gen_fname(self.inputs.in_file, suffix='_st') - outputs['slice_time_corrected_file'] = os.path.abspath(out_file) - return outputs + self.outputs.slice_time_corrected_file = os.path.abspath(out_file) def _gen_filename(self, name): if name == 'out_file': - return self._list_outputs()['slice_time_corrected_file'] + return self.outputs.slice_time_corrected_file return None @@ -1108,6 +1073,19 @@ class SUSANInputSpec(FSLCommandInputSpec): desc='output file name', hash_files=False) + def _format_arg(self, name, spec, value): + if name == 'fwhm': + return spec.argstr % (float(value) / np.sqrt(8 * np.log(2))) + if name == 'usans': + if not value: + return '0' + arglist = [str(len(value))] + for filename, thresh in value: + arglist.extend([filename, '%.10f' % thresh]) + return ' '.join(arglist) + return super(SUSANInputSpec, self)._format_arg(name, spec, value) + + class SUSANOutputSpec(TraitedSpec): smoothed_file = File(exists=True, desc='smoothed output file') @@ -1130,33 +1108,20 @@ class SUSAN(FSLCommand): """ _cmd = 'susan' - input_spec = SUSANInputSpec - output_spec = SUSANOutputSpec + _input_spec = SUSANInputSpec + _output_spec = SUSANOutputSpec - def _format_arg(self, name, spec, value): - if name == 'fwhm': - return spec.argstr % (float(value) / np.sqrt(8 * np.log(2))) - if name == 'usans': - if not value: - return '0' - arglist = [str(len(value))] - for filename, thresh in value: - arglist.extend([filename, '%.10f' % thresh]) - return ' '.join(arglist) - return super(SUSAN, self)._format_arg(name, spec, value) + def _post_run(self): - def _list_outputs(self): - outputs = self._outputs().get() out_file = self.inputs.out_file if not isdefined(out_file): out_file = self._gen_fname(self.inputs.in_file, suffix='_smooth') - outputs['smoothed_file'] = os.path.abspath(out_file) - return outputs + self.outputs.smoothed_file = os.path.abspath(out_file) def _gen_filename(self, name): if name == 'out_file': - return self._list_outputs()['smoothed_file'] + return self.outputs.smoothed_file return None @@ -1169,10 +1134,12 @@ class FUGUEInputSpec(FSLCommandInputSpec): desc='filename for input phase image') fmap_in_file = File(exists=True, argstr='--loadfmap=%s', desc='filename for loading fieldmap (rad/s)') - unwarped_file = File(argstr='--unwarp=%s', desc='apply unwarping and save as filename', - xor=['warped_file'], requires=['in_file']) - warped_file = File(argstr='--warp=%s', desc='apply forward warping and save as filename', - xor=['unwarped_file'], requires=['in_file']) + unwarped_file = GenFile( + template='{in_file}_unwarped{output_type_}', argstr='--unwarp=%s', xor=['warped_file'], + requires=['in_file'], desc='apply unwarping and save as filename') + warped_file = GenFile( + template='{in_file}_warped{output_type_}', argstr='--warp=%s', xor=['unwarped_file'], + requires=['in_file'], desc='apply forward warping and save as filename') forward_warping = traits.Bool(False, usedefault=True, desc='apply forward warping instead of unwarping') @@ -1217,18 +1184,50 @@ class FUGUEInputSpec(FSLCommandInputSpec): nokspace = traits.Bool(False, argstr='--nokspace', desc='do not use k-space forward warping') # Special outputs: shift (voxel shift map, vsm) - save_shift = traits.Bool(False, xor=['save_unmasked_shift'], + save_shift = traits.Bool(False, xor=['save_unmasked_shift'], usedefault=True, desc='write pixel shift volume') - shift_out_file = File(argstr='--saveshift=%s', desc='filename for saving pixel shift volume') save_unmasked_shift = traits.Bool(argstr='--unmaskshift', xor=['save_shift'], desc='saves the unmasked shiftmap when using --saveshift') + shift_out_file = GenFile( + template='{fmap_in_file|phasemap_in_file|shift_in_file}_vsm{output_type_}', + argstr='--saveshift=%s', desc='filename for saving pixel shift volume') # Special outputs: fieldmap (fmap) - save_fmap = traits.Bool(False, xor=['save_unmasked_fmap'], + save_fmap = traits.Bool(False, xor=['save_unmasked_fmap'], usedefault=True, desc='write field map volume') - fmap_out_file = File(argstr='--savefmap=%s', desc='filename for saving fieldmap (rad/s)') save_unmasked_fmap = traits.Bool(False, argstr='--unmaskfmap', xor=['save_fmap'], desc='saves the unmasked fieldmap when using --savefmap') + fmap_out_file = GenFile( + template='{shift_in_file|phasemap_in_file|fmap_in_file}_fieldmap{output_type_}', + argstr='--savefmap=%s', desc='filename for saving fieldmap (rad/s)') + + def parse_args(self, skip=None): + if skip is None: + skip = [] + + input_phase = isdefined(self.phasemap_in_file) + input_vsm = isdefined(self.shift_in_file) + input_fmap = isdefined(self.fmap_in_file) + + if not input_phase and not input_vsm and not input_fmap: + raise RuntimeError('Either phasemap_in_file, shift_in_file or fmap_in_file must be set.') + + if not isdefined(self.in_file): + skip += ['unwarped_file', 'warped_file'] + else: + if self.forward_warping: + skip += ['unwarped_file'] + else: + skip += ['warped_file'] + + # Handle shift output + if not self.save_shift and not self.save_unmasked_shift: + skip += ['save_shift', 'save_unmasked_shift', 'shift_out_file'] + + if not self.save_fmap and not self.save_unmasked_fmap: + skip += ['save_fmap', 'save_unmasked_fmap', 'fmap_out_file'] + + return super(FUGUEInputSpec, self).parse_args(skip=skip) class FUGUEOutputSpec(TraitedSpec): @@ -1299,93 +1298,9 @@ class FUGUE(FSLCommand): """ - _cmd = 'fugue' - input_spec = FUGUEInputSpec - output_spec = FUGUEOutputSpec - - def _parse_inputs(self, skip=None): - if skip is None: - skip = [] - - input_phase = isdefined(self.inputs.phasemap_in_file) - input_vsm = isdefined(self.inputs.shift_in_file) - input_fmap = isdefined(self.inputs.fmap_in_file) - - if not input_phase and not input_vsm and not input_fmap: - raise RuntimeError('Either phasemap_in_file, shift_in_file or fmap_in_file must be set.') - - if not isdefined(self.inputs.in_file): - skip += ['unwarped_file', 'warped_file'] - else: - if self.inputs.forward_warping: - skip += ['unwarped_file'] - trait_spec = self.inputs.trait('warped_file') - trait_spec.name_template = "%s_warped" - trait_spec.name_source = 'in_file' - trait_spec.output_name = 'warped_file' - else: - skip += ['warped_file'] - trait_spec = self.inputs.trait('unwarped_file') - trait_spec.name_template = "%s_unwarped" - trait_spec.name_source = 'in_file' - trait_spec.output_name = 'unwarped_file' - - # Handle shift output - if not isdefined(self.inputs.shift_out_file): - vsm_save_masked = (isdefined(self.inputs.save_shift) and self.inputs.save_shift) - vsm_save_unmasked = (isdefined(self.inputs.save_unmasked_shift) and - self.inputs.save_unmasked_shift) - - if (vsm_save_masked or vsm_save_unmasked): - trait_spec = self.inputs.trait('shift_out_file') - trait_spec.output_name = 'shift_out_file' - - if input_fmap: - trait_spec.name_source = 'fmap_in_file' - elif input_phase: - trait_spec.name_source = 'phasemap_in_file' - elif input_vsm: - trait_spec.name_source = 'shift_in_file' - else: - raise RuntimeError(('Either phasemap_in_file, shift_in_file or ' - 'fmap_in_file must be set.')) - - if vsm_save_unmasked: - trait_spec.name_template = '%s_vsm_unmasked' - else: - trait_spec.name_template = '%s_vsm' - else: - skip += ['save_shift', 'save_unmasked_shift', 'shift_out_file'] - - # Handle fieldmap output - if not isdefined(self.inputs.fmap_out_file): - fmap_save_masked = (isdefined(self.inputs.save_fmap) and self.inputs.save_fmap) - fmap_save_unmasked = (isdefined(self.inputs.save_unmasked_fmap) and - self.inputs.save_unmasked_fmap) - - if (fmap_save_masked or fmap_save_unmasked): - trait_spec = self.inputs.trait('fmap_out_file') - trait_spec.output_name = 'fmap_out_file' - - if input_vsm: - trait_spec.name_source = 'shift_in_file' - elif input_phase: - trait_spec.name_source = 'phasemap_in_file' - elif input_fmap: - trait_spec.name_source = 'fmap_in_file' - else: - raise RuntimeError(('Either phasemap_in_file, shift_in_file or ' - 'fmap_in_file must be set.')) - - if fmap_save_unmasked: - trait_spec.name_template = '%s_fieldmap_unmasked' - else: - trait_spec.name_template = '%s_fieldmap' - else: - skip += ['save_fmap', 'save_unmasked_fmap', 'fmap_out_file'] - - return super(FUGUE, self)._parse_inputs(skip=skip) + _input_spec = FUGUEInputSpec + _output_spec = FUGUEOutputSpec class PRELUDEInputSpec(FSLCommandInputSpec): @@ -1446,16 +1361,16 @@ class PRELUDE(FSLCommand): Please insert examples for use of this command """ - input_spec = PRELUDEInputSpec - output_spec = PRELUDEOutputSpec + _input_spec = PRELUDEInputSpec + _output_spec = PRELUDEOutputSpec _cmd = 'prelude' def __init__(self, **kwargs): super(PRELUDE, self).__init__(**kwargs) - warn('This has not been fully tested. Please report any failures.') + IFLOGGER.warn('This has not been fully tested. Please report any failures.') + + def _post_run(self): - def _list_outputs(self): - outputs = self._outputs().get() out_file = self.inputs.unwrapped_phase_file if not isdefined(out_file): if isdefined(self.inputs.phase_file): @@ -1464,12 +1379,11 @@ def _list_outputs(self): elif isdefined(self.inputs.complex_phase_file): out_file = self._gen_fname(self.inputs.complex_phase_file, suffix='_phase_unwrapped') - outputs['unwrapped_phase_file'] = os.path.abspath(out_file) - return outputs + self.outputs.unwrapped_phase_file = os.path.abspath(out_file) def _gen_filename(self, name): if name == 'unwrapped_phase_file': - return self._list_outputs()['unwrapped_phase_file'] + return self.outputs.unwrapped_phase_file return None @@ -1542,11 +1456,12 @@ class FIRST(FSLCommand): """ _cmd = 'run_first_all' - input_spec = FIRSTInputSpec - output_spec = FIRSTOutputSpec + _input_spec = FIRSTInputSpec + _output_spec = FIRSTOutputSpec + + def _post_run(self): + - def _list_outputs(self): - outputs = self.output_spec().get() if isdefined(self.inputs.list_of_specific_structures): structures = self.inputs.list_of_specific_structures @@ -1559,13 +1474,12 @@ def _list_outputs(self): 'L_Puta', 'R_Puta', 'L_Thal', 'R_Thal', 'BrStem'] - outputs['original_segmentations'] = \ + self.outputs.original_segmentations = \ self._gen_fname('original_segmentations') - outputs['segmentation_file'] = self._gen_fname('segmentation_file') - outputs['vtk_surfaces'] = self._gen_mesh_names('vtk_surfaces', + self.outputs.segmentation_file = self._gen_fname('segmentation_file') + self.outputs.vtk_surfaces = self._gen_mesh_names('vtk_surfaces', structures) - outputs['bvars'] = self._gen_mesh_names('bvars', structures) - return outputs + self.outputs.bvars = self._gen_mesh_names('bvars', structures) def _gen_fname(self, name): path, outname, ext = split_filename(self.inputs.out_file) diff --git a/nipype/interfaces/fsl/tests/test_auto_ApplyMask.py b/nipype/interfaces/fsl/tests/test_auto_ApplyMask.py index d374567662..098ca5b12b 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ApplyMask.py +++ b/nipype/interfaces/fsl/tests/test_auto_ApplyMask.py @@ -6,12 +6,6 @@ def test_ApplyMask_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -25,20 +19,19 @@ def test_ApplyMask_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = ApplyMask.input_spec() + inputs = ApplyMask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -48,7 +41,7 @@ def test_ApplyMask_inputs(): def test_ApplyMask_outputs(): output_map = dict(out_file=dict(), ) - outputs = ApplyMask.output_spec() + outputs = ApplyMask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ApplyTOPUP.py b/nipype/interfaces/fsl/tests/test_auto_ApplyTOPUP.py index 77a11e3232..d95f50dcf6 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ApplyTOPUP.py +++ b/nipype/interfaces/fsl/tests/test_auto_ApplyTOPUP.py @@ -11,12 +11,6 @@ def test_ApplyTOPUP_inputs(): encoding_file=dict(argstr='--datain=%s', mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='--imain=%s', mandatory=True, sep=',', @@ -37,14 +31,11 @@ def test_ApplyTOPUP_inputs(): method=dict(argstr='--method=%s', ), out_corrected=dict(argstr='--out=%s', - name_source=['in_files'], - name_template='%s_corrected', ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = ApplyTOPUP.input_spec() + inputs = ApplyTOPUP._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -54,7 +45,7 @@ def test_ApplyTOPUP_inputs(): def test_ApplyTOPUP_outputs(): output_map = dict(out_corrected=dict(), ) - outputs = ApplyTOPUP.output_spec() + outputs = ApplyTOPUP._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ApplyWarp.py b/nipype/interfaces/fsl/tests/test_auto_ApplyWarp.py index 47e2703cb6..61d933bb66 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ApplyWarp.py +++ b/nipype/interfaces/fsl/tests/test_auto_ApplyWarp.py @@ -11,14 +11,8 @@ def test_ApplyWarp_inputs(): ), datatype=dict(argstr='--datatype=%s', ), - environ=dict(nohash=True, - usedefault=True, - ), field_file=dict(argstr='--warp=%s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--in=%s', mandatory=True, position=0, @@ -33,7 +27,8 @@ def test_ApplyWarp_inputs(): hash_files=False, position=2, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), postmat=dict(argstr='--postmat=%s', ), premat=dict(argstr='--premat=%s', @@ -50,10 +45,8 @@ def test_ApplyWarp_inputs(): ), supersample=dict(argstr='--super', ), - terminal_output=dict(nohash=True, - ), ) - inputs = ApplyWarp.input_spec() + inputs = ApplyWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -63,7 +56,7 @@ def test_ApplyWarp_inputs(): def test_ApplyWarp_outputs(): output_map = dict(out_file=dict(), ) - outputs = ApplyWarp.output_spec() + outputs = ApplyWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ApplyXfm.py b/nipype/interfaces/fsl/tests/test_auto_ApplyXfm.py index 897d6478ed..a464f0d194 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ApplyXfm.py +++ b/nipype/interfaces/fsl/tests/test_auto_ApplyXfm.py @@ -41,9 +41,6 @@ def test_ApplyXfm_inputs(): echospacing=dict(argstr='-echospacing %f', min_ver='5.0.0', ), - environ=dict(nohash=True, - usedefault=True, - ), fieldmap=dict(argstr='-fieldmap %s', min_ver='5.0.0', ), @@ -55,9 +52,6 @@ def test_ApplyXfm_inputs(): ), force_scaling=dict(argstr='-forcescaling', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-in %s', mandatory=True, position=0, @@ -97,7 +91,8 @@ def test_ApplyXfm_inputs(): name_template='%s_flirt.mat', position=3, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), padding_size=dict(argstr='-paddingsize %d', units='voxels', ), @@ -129,8 +124,6 @@ def test_ApplyXfm_inputs(): ), sinc_window=dict(argstr='-sincwindow %s', ), - terminal_output=dict(nohash=True, - ), uses_qform=dict(argstr='-usesqform', ), verbose=dict(argstr='-verbose %d', @@ -145,7 +138,7 @@ def test_ApplyXfm_inputs(): min_ver='5.0.0', ), ) - inputs = ApplyXfm.input_spec() + inputs = ApplyXfm._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -157,7 +150,7 @@ def test_ApplyXfm_outputs(): out_log=dict(), out_matrix_file=dict(), ) - outputs = ApplyXfm.output_spec() + outputs = ApplyXfm._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_AvScale.py b/nipype/interfaces/fsl/tests/test_auto_AvScale.py index 0d750ddbc0..96ba24c1fc 100644 --- a/nipype/interfaces/fsl/tests/test_auto_AvScale.py +++ b/nipype/interfaces/fsl/tests/test_auto_AvScale.py @@ -6,20 +6,13 @@ def test_AvScale_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), mat_file=dict(argstr='%s', position=0, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = AvScale.input_spec() + inputs = AvScale._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +29,7 @@ def test_AvScale_outputs(): scales=dict(), skews=dict(), ) - outputs = AvScale.output_spec() + outputs = AvScale._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_BEDPOSTX4.py b/nipype/interfaces/fsl/tests/test_auto_BEDPOSTX4.py index ca71395c20..0dc8e15583 100644 --- a/nipype/interfaces/fsl/tests/test_auto_BEDPOSTX4.py +++ b/nipype/interfaces/fsl/tests/test_auto_BEDPOSTX4.py @@ -24,9 +24,6 @@ def test_BEDPOSTX4_inputs(): ), dwi=dict(mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), fibres=dict(argstr='-n %d', ), force_dir=dict(argstr='--forcedir', @@ -36,9 +33,6 @@ def test_BEDPOSTX4_inputs(): ), gradnonlin=dict(argstr='--gradnonlin=%s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), jumps=dict(argstr='-j %d', ), logdir=dict(argstr='--logdir=%s', @@ -65,21 +59,20 @@ def test_BEDPOSTX4_inputs(): non_linear=dict(argstr='--nonlinear', xor=('no_spat', 'non_linear'), ), - output_type=dict(), + output_type=dict(usedefault=True, + ), sample_every=dict(argstr='--sampleevery=%d', ), sampling=dict(argstr='-s %d', ), seed=dict(argstr='--seed=%d', ), - terminal_output=dict(nohash=True, - ), update_proposal_every=dict(argstr='--updateproposalevery=%d', ), weight=dict(argstr='-w %.2f', ), ) - inputs = BEDPOSTX4.input_spec() + inputs = BEDPOSTX4._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -97,7 +90,7 @@ def test_BEDPOSTX4_outputs(): merged_thsamples=dict(), xfms_directory=dict(), ) - outputs = BEDPOSTX4.output_spec() + outputs = BEDPOSTX4._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_BEDPOSTX5.py b/nipype/interfaces/fsl/tests/test_auto_BEDPOSTX5.py index 48f229eabd..ffaeba4426 100644 --- a/nipype/interfaces/fsl/tests/test_auto_BEDPOSTX5.py +++ b/nipype/interfaces/fsl/tests/test_auto_BEDPOSTX5.py @@ -22,9 +22,8 @@ def test_BEDPOSTX5_inputs(): ), dwi=dict(mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), + dyads=dict(), + dyads_dispersion=dict(), f0_ard=dict(argstr='--f0 --ardf0', xor=['f0_noard', 'f0_ard', 'all_ard'], ), @@ -34,17 +33,22 @@ def test_BEDPOSTX5_inputs(): force_dir=dict(argstr='--forcedir', usedefault=True, ), + fsamples=dict(), fudge=dict(argstr='-w %d', ), gradnonlin=dict(argstr='-g', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), logdir=dict(argstr='--logdir=%s', ), mask=dict(mandatory=True, ), + mean_S0samples=dict(keep_extension=False, + ), + mean_dsamples=dict(keep_extension=False, + ), + mean_fsamples=dict(), + mean_tausamples=dict(keep_extension=False, + ), model=dict(argstr='-model %d', ), n_fibres=dict(argstr='-n %d', @@ -67,20 +71,22 @@ def test_BEDPOSTX5_inputs(): position=1, usedefault=True, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), + phsamples=dict(), rician=dict(argstr='--rician', + usedefault=True, ), sample_every=dict(argstr='-s %d', ), seed=dict(argstr='--seed=%d', ), - terminal_output=dict(nohash=True, - ), + thsamples=dict(), update_proposal_every=dict(argstr='--updateproposalevery=%d', ), use_gpu=dict(), ) - inputs = BEDPOSTX5.input_spec() + inputs = BEDPOSTX5._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -90,16 +96,15 @@ def test_BEDPOSTX5_inputs(): def test_BEDPOSTX5_outputs(): output_map = dict(dyads=dict(), dyads_dispersion=dict(), + fsamples=dict(), mean_S0samples=dict(), mean_dsamples=dict(), mean_fsamples=dict(), - mean_phsamples=dict(), - mean_thsamples=dict(), - merged_fsamples=dict(), - merged_phsamples=dict(), - merged_thsamples=dict(), + mean_tausamples=dict(), + phsamples=dict(), + thsamples=dict(), ) - outputs = BEDPOSTX5.output_spec() + outputs = BEDPOSTX5._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_BET.py b/nipype/interfaces/fsl/tests/test_auto_BET.py index 9f91d76d2f..31d60f6a7f 100644 --- a/nipype/interfaces/fsl/tests/test_auto_BET.py +++ b/nipype/interfaces/fsl/tests/test_auto_BET.py @@ -9,35 +9,46 @@ def test_BET_inputs(): center=dict(argstr='-c %s', units='voxels', ), - environ=dict(nohash=True, - usedefault=True, - ), frac=dict(argstr='-f %.2f', ), functional=dict(argstr='-F', xor=('functional', 'reduce_bias', 'robust', 'padding', 'remove_eyes', 'surfaces', 't2_guided'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=0, ), + inskull_mask_file=dict(), + inskull_mesh_file=dict(keep_extension=False, + ), mask=dict(argstr='-m', + usedefault=True, ), + mask_file=dict(), mesh=dict(argstr='-e', + usedefault=True, + ), + meshfile=dict(keep_extension=False, ), no_output=dict(argstr='-n', + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=1, ), outline=dict(argstr='-o', + usedefault=True, + ), + outline_file=dict(), + output_type=dict(usedefault=True, + ), + outskin_mask_file=dict(), + outskin_mesh_file=dict(keep_extension=False, + ), + outskull_mask_file=dict(), + outskull_mesh_file=dict(keep_extension=False, ), - output_type=dict(), padding=dict(argstr='-Z', xor=('functional', 'reduce_bias', 'robust', 'padding', 'remove_eyes', 'surfaces', 't2_guided'), ), @@ -51,24 +62,26 @@ def test_BET_inputs(): xor=('functional', 'reduce_bias', 'robust', 'padding', 'remove_eyes', 'surfaces', 't2_guided'), ), robust=dict(argstr='-R', + usedefault=True, xor=('functional', 'reduce_bias', 'robust', 'padding', 'remove_eyes', 'surfaces', 't2_guided'), ), skull=dict(argstr='-s', + usedefault=True, ), + skull_mask_file=dict(), surfaces=dict(argstr='-A', xor=('functional', 'reduce_bias', 'robust', 'padding', 'remove_eyes', 'surfaces', 't2_guided'), ), t2_guided=dict(argstr='-A2 %s', xor=('functional', 'reduce_bias', 'robust', 'padding', 'remove_eyes', 'surfaces', 't2_guided'), ), - terminal_output=dict(nohash=True, - ), threshold=dict(argstr='-t', + usedefault=True, ), vertical_gradient=dict(argstr='-g %.2f', ), ) - inputs = BET.input_spec() + inputs = BET._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -88,7 +101,7 @@ def test_BET_outputs(): outskull_mesh_file=dict(), skull_mask_file=dict(), ) - outputs = BET.output_spec() + outputs = BET._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_BinaryMaths.py b/nipype/interfaces/fsl/tests/test_auto_BinaryMaths.py index dfc8dcec09..a6d5916e32 100644 --- a/nipype/interfaces/fsl/tests/test_auto_BinaryMaths.py +++ b/nipype/interfaces/fsl/tests/test_auto_BinaryMaths.py @@ -6,12 +6,6 @@ def test_BinaryMaths_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -21,6 +15,7 @@ def test_BinaryMaths_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), operand_file=dict(argstr='%s', mandatory=True, @@ -37,18 +32,16 @@ def test_BinaryMaths_inputs(): position=4, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = BinaryMaths.input_spec() + inputs = BinaryMaths._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +51,7 @@ def test_BinaryMaths_inputs(): def test_BinaryMaths_outputs(): output_map = dict(out_file=dict(), ) - outputs = BinaryMaths.output_spec() + outputs = BinaryMaths._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ChangeDataType.py b/nipype/interfaces/fsl/tests/test_auto_ChangeDataType.py index 4de7103895..f6bddc3a8d 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ChangeDataType.py +++ b/nipype/interfaces/fsl/tests/test_auto_ChangeDataType.py @@ -6,12 +6,6 @@ def test_ChangeDataType_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -21,9 +15,9 @@ def test_ChangeDataType_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), @@ -31,11 +25,10 @@ def test_ChangeDataType_inputs(): mandatory=True, position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = ChangeDataType.input_spec() + inputs = ChangeDataType._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +38,7 @@ def test_ChangeDataType_inputs(): def test_ChangeDataType_outputs(): output_map = dict(out_file=dict(), ) - outputs = ChangeDataType.output_spec() + outputs = ChangeDataType._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Cluster.py b/nipype/interfaces/fsl/tests/test_auto_Cluster.py index 7b460a5fd6..92b4a02bde 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Cluster.py +++ b/nipype/interfaces/fsl/tests/test_auto_Cluster.py @@ -12,14 +12,8 @@ def test_Cluster_inputs(): ), dlh=dict(argstr='--dlh=%.10f', ), - environ=dict(nohash=True, - usedefault=True, - ), find_min=dict(), fractional=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--in=%s', mandatory=True, ), @@ -30,6 +24,7 @@ def test_Cluster_inputs(): ), out_index_file=dict(argstr='--oindex=%s', hash_files=False, + output_name='index_file', ), out_localmax_txt_file=dict(argstr='--olmax=%s', hash_files=False, @@ -52,15 +47,30 @@ def test_Cluster_inputs(): out_threshold_file=dict(argstr='--othresh=%s', hash_files=False, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), peak_distance=dict(argstr='--peakdist=%.10f', ), pthreshold=dict(argstr='--pthresh=%.10f', requires=['dlh', 'volume'], ), - std_space_file=dict(argstr='--stdvol=%s', + save_index_file=dict(usedefault=True, + ), + save_localmax_txt_file=dict(usedefault=True, + ), + save_localmax_vol_file=dict(usedefault=True, ), - terminal_output=dict(nohash=True, + save_max_file=dict(usedefault=True, + ), + save_mean_file=dict(usedefault=True, + ), + save_pval_file=dict(usedefault=True, + ), + save_size_file=dict(usedefault=True, + ), + save_threshold_file=dict(usedefault=True, + ), + std_space_file=dict(argstr='--stdvol=%s', ), threshold=dict(argstr='--thresh=%.10f', mandatory=True, @@ -73,7 +83,7 @@ def test_Cluster_inputs(): xfm_file=dict(argstr='--xfm=%s', ), ) - inputs = Cluster.input_spec() + inputs = Cluster._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -82,15 +92,15 @@ def test_Cluster_inputs(): def test_Cluster_outputs(): output_map = dict(index_file=dict(), - localmax_txt_file=dict(), - localmax_vol_file=dict(), - max_file=dict(), - mean_file=dict(), - pval_file=dict(), - size_file=dict(), - threshold_file=dict(), + out_localmax_txt_file=dict(), + out_localmax_vol_file=dict(), + out_max_file=dict(), + out_mean_file=dict(), + out_pval_file=dict(), + out_size_file=dict(), + out_threshold_file=dict(), ) - outputs = Cluster.output_spec() + outputs = Cluster._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Complex.py b/nipype/interfaces/fsl/tests/test_auto_Complex.py index eae95be846..4e82423f23 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Complex.py +++ b/nipype/interfaces/fsl/tests/test_auto_Complex.py @@ -21,9 +21,7 @@ def test_Complex_inputs(): xor=['real_polar', 'real_cartesian', 'complex_cartesian', 'complex_polar', 'complex_split', 'complex_merge', 'start_vol', 'end_vol'], ), complex_out_file=dict(argstr='%s', - genfile=True, position=-3, - xor=['complex_out_file', 'magnitude_out_file', 'phase_out_file', 'real_out_file', 'imaginary_out_file', 'real_polar', 'real_cartesian'], ), complex_polar=dict(argstr='-complexpolar', position=1, @@ -36,36 +34,25 @@ def test_Complex_inputs(): end_vol=dict(argstr='%d', position=-1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), imaginary_in_file=dict(argstr='%s', position=3, ), imaginary_out_file=dict(argstr='%s', - genfile=True, position=-3, - xor=['complex_out_file', 'magnitude_out_file', 'phase_out_file', 'real_polar', 'complex_cartesian', 'complex_polar', 'complex_split', 'complex_merge'], ), magnitude_in_file=dict(argstr='%s', position=2, ), magnitude_out_file=dict(argstr='%s', - genfile=True, position=-4, - xor=['complex_out_file', 'real_out_file', 'imaginary_out_file', 'real_cartesian', 'complex_cartesian', 'complex_polar', 'complex_split', 'complex_merge'], ), - output_type=dict(), + output_type=dict(usedefault=True, + ), phase_in_file=dict(argstr='%s', position=3, ), phase_out_file=dict(argstr='%s', - genfile=True, position=-3, - xor=['complex_out_file', 'real_out_file', 'imaginary_out_file', 'real_cartesian', 'complex_cartesian', 'complex_polar', 'complex_split', 'complex_merge'], ), real_cartesian=dict(argstr='-realcartesian', position=1, @@ -75,9 +62,7 @@ def test_Complex_inputs(): position=2, ), real_out_file=dict(argstr='%s', - genfile=True, position=-4, - xor=['complex_out_file', 'magnitude_out_file', 'phase_out_file', 'real_polar', 'complex_cartesian', 'complex_polar', 'complex_split', 'complex_merge'], ), real_polar=dict(argstr='-realpolar', position=1, @@ -86,10 +71,8 @@ def test_Complex_inputs(): start_vol=dict(argstr='%d', position=-2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Complex.input_spec() + inputs = Complex._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -103,7 +86,7 @@ def test_Complex_outputs(): phase_out_file=dict(), real_out_file=dict(), ) - outputs = Complex.output_spec() + outputs = Complex._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ContrastMgr.py b/nipype/interfaces/fsl/tests/test_auto_ContrastMgr.py index 361f9cd086..3a65975e6e 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ContrastMgr.py +++ b/nipype/interfaces/fsl/tests/test_auto_ContrastMgr.py @@ -15,15 +15,10 @@ def test_ContrastMgr_inputs(): copyfile=False, mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), fcon_file=dict(argstr='-f %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, + output_type=dict(usedefault=True, ), - output_type=dict(), param_estimates=dict(argstr='', copyfile=False, mandatory=True, @@ -39,10 +34,8 @@ def test_ContrastMgr_inputs(): mandatory=True, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ContrastMgr.input_spec() + inputs = ContrastMgr._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +51,7 @@ def test_ContrastMgr_outputs(): zfstats=dict(), zstats=dict(), ) - outputs = ContrastMgr.output_spec() + outputs = ContrastMgr._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ConvertWarp.py b/nipype/interfaces/fsl/tests/test_auto_ConvertWarp.py index d140396548..dfe4246853 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ConvertWarp.py +++ b/nipype/interfaces/fsl/tests/test_auto_ConvertWarp.py @@ -11,12 +11,6 @@ def test_ConvertWarp_inputs(): ), cons_jacobian=dict(argstr='--constrainj', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), jacobian_max=dict(argstr='--jmax=%f', ), jacobian_min=dict(argstr='--jmin=%f', @@ -27,15 +21,13 @@ def test_ConvertWarp_inputs(): xor=['out_relwarp'], ), out_file=dict(argstr='--out=%s', - name_source=['reference'], - name_template='%s_concatwarp', - output_name='out_file', position=-1, ), out_relwarp=dict(argstr='--relout', xor=['out_abswarp'], ), - output_type=dict(), + output_type=dict(usedefault=True, + ), postmat=dict(argstr='--postmat=%s', ), premat=dict(argstr='--premat=%s', @@ -52,14 +44,12 @@ def test_ConvertWarp_inputs(): ), shift_in_file=dict(argstr='--shiftmap=%s', ), - terminal_output=dict(nohash=True, - ), warp1=dict(argstr='--warp1=%s', ), warp2=dict(argstr='--warp2=%s', ), ) - inputs = ConvertWarp.input_spec() + inputs = ConvertWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -69,7 +59,7 @@ def test_ConvertWarp_inputs(): def test_ConvertWarp_outputs(): output_map = dict(out_file=dict(), ) - outputs = ConvertWarp.output_spec() + outputs = ConvertWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ConvertXFM.py b/nipype/interfaces/fsl/tests/test_auto_ConvertXFM.py index 21bfe5ff1c..e904325b9a 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ConvertXFM.py +++ b/nipype/interfaces/fsl/tests/test_auto_ConvertXFM.py @@ -11,17 +11,11 @@ def test_ConvertXFM_inputs(): requires=['in_file2'], xor=['invert_xfm', 'concat_xfm', 'fix_scale_skew'], ), - environ=dict(nohash=True, - usedefault=True, - ), fix_scale_skew=dict(argstr='-fixscaleskew', position=-3, requires=['in_file2'], xor=['invert_xfm', 'concat_xfm', 'fix_scale_skew'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-1, @@ -33,16 +27,19 @@ def test_ConvertXFM_inputs(): position=-3, xor=['invert_xfm', 'concat_xfm', 'fix_scale_skew'], ), + operation=dict(argstr='-%s', + mandatory=True, + position=-3, + usedefault=True, + ), out_file=dict(argstr='-omat %s', - genfile=True, hash_files=False, position=1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = ConvertXFM.input_spec() + inputs = ConvertXFM._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +49,7 @@ def test_ConvertXFM_inputs(): def test_ConvertXFM_outputs(): output_map = dict(out_file=dict(), ) - outputs = ConvertXFM.output_spec() + outputs = ConvertXFM._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_CopyGeom.py b/nipype/interfaces/fsl/tests/test_auto_CopyGeom.py index 75e58ee331..54303cdc20 100644 --- a/nipype/interfaces/fsl/tests/test_auto_CopyGeom.py +++ b/nipype/interfaces/fsl/tests/test_auto_CopyGeom.py @@ -9,29 +9,21 @@ def test_CopyGeom_inputs(): dest_file=dict(argstr='%s', copyfile=True, mandatory=True, - name_source='dest_file', - name_template='%s', output_name='out_file', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), ignore_dims=dict(argstr='-d', - position='-1', - ), - ignore_exception=dict(nohash=True, + position=-1, usedefault=True, ), in_file=dict(argstr='%s', mandatory=True, position=0, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = CopyGeom.input_spec() + inputs = CopyGeom._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +33,7 @@ def test_CopyGeom_inputs(): def test_CopyGeom_outputs(): output_map = dict(out_file=dict(), ) - outputs = CopyGeom.output_spec() + outputs = CopyGeom._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_DTIFit.py b/nipype/interfaces/fsl/tests/test_auto_DTIFit.py index 803a78b930..6978ddbf26 100644 --- a/nipype/interfaces/fsl/tests/test_auto_DTIFit.py +++ b/nipype/interfaces/fsl/tests/test_auto_DTIFit.py @@ -24,14 +24,8 @@ def test_DTIFit_inputs(): mandatory=True, position=0, ), - environ=dict(nohash=True, - usedefault=True, - ), gradnonlin=dict(argstr='--gradnonlin=%s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), little_bit=dict(argstr='--littlebit', ), mask=dict(argstr='-m %s', @@ -50,15 +44,37 @@ def test_DTIFit_inputs(): ), min_z=dict(argstr='-z %d', ), - output_type=dict(), + out_fa=dict(keep_extension=False, + ), + out_l1=dict(keep_extension=False, + ), + out_l2=dict(keep_extension=False, + ), + out_l3=dict(keep_extension=False, + ), + out_md=dict(keep_extension=False, + ), + out_mo=dict(keep_extension=False, + ), + out_s0=dict(keep_extension=False, + ), + out_v1=dict(keep_extension=False, + ), + out_v2=dict(keep_extension=False, + ), + out_v3=dict(keep_extension=False, + ), + output_type=dict(usedefault=True, + ), save_tensor=dict(argstr='--save_tensor', + usedefault=True, ), sse=dict(argstr='--sse', ), - terminal_output=dict(nohash=True, + tensor=dict(keep_extension=False, ), ) - inputs = DTIFit.input_spec() + inputs = DTIFit._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -66,19 +82,19 @@ def test_DTIFit_inputs(): def test_DTIFit_outputs(): - output_map = dict(FA=dict(), - L1=dict(), - L2=dict(), - L3=dict(), - MD=dict(), - MO=dict(), - S0=dict(), - V1=dict(), - V2=dict(), - V3=dict(), + output_map = dict(out_fa=dict(), + out_l1=dict(), + out_l2=dict(), + out_l3=dict(), + out_md=dict(), + out_mo=dict(), + out_s0=dict(), + out_v1=dict(), + out_v2=dict(), + out_v3=dict(), tensor=dict(), ) - outputs = DTIFit.output_spec() + outputs = DTIFit._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_DilateImage.py b/nipype/interfaces/fsl/tests/test_auto_DilateImage.py index 7c0f3e9823..26c2a5f3d3 100644 --- a/nipype/interfaces/fsl/tests/test_auto_DilateImage.py +++ b/nipype/interfaces/fsl/tests/test_auto_DilateImage.py @@ -6,12 +6,6 @@ def test_DilateImage_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -32,24 +26,23 @@ def test_DilateImage_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), operation=dict(argstr='-dil%s', mandatory=True, position=6, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = DilateImage.input_spec() + inputs = DilateImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -59,7 +52,7 @@ def test_DilateImage_inputs(): def test_DilateImage_outputs(): output_map = dict(out_file=dict(), ) - outputs = DilateImage.output_spec() + outputs = DilateImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_DistanceMap.py b/nipype/interfaces/fsl/tests/test_auto_DistanceMap.py index 083590ed5d..07e0fc83ee 100644 --- a/nipype/interfaces/fsl/tests/test_auto_DistanceMap.py +++ b/nipype/interfaces/fsl/tests/test_auto_DistanceMap.py @@ -7,15 +7,8 @@ def test_DistanceMap_inputs(): input_map = dict(args=dict(argstr='%s', ), distance_map=dict(argstr='--out=%s', - genfile=True, hash_files=False, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--in=%s', mandatory=True, ), @@ -26,11 +19,10 @@ def test_DistanceMap_inputs(): ), mask_file=dict(argstr='--mask=%s', ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = DistanceMap.input_spec() + inputs = DistanceMap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +33,7 @@ def test_DistanceMap_outputs(): output_map = dict(distance_map=dict(), local_max_file=dict(), ) - outputs = DistanceMap.output_spec() + outputs = DistanceMap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_EPIDeWarp.py b/nipype/interfaces/fsl/tests/test_auto_EPIDeWarp.py index 2f1eaf2522..c523272816 100644 --- a/nipype/interfaces/fsl/tests/test_auto_EPIDeWarp.py +++ b/nipype/interfaces/fsl/tests/test_auto_EPIDeWarp.py @@ -6,54 +6,10 @@ def test_EPIDeWarp_inputs(): input_map = dict(args=dict(argstr='%s', ), - cleanup=dict(argstr='--cleanup', - ), - dph_file=dict(argstr='--dph %s', - mandatory=True, - ), - environ=dict(nohash=True, - usedefault=True, - ), - epi_file=dict(argstr='--epi %s', - ), - epidw=dict(argstr='--epidw %s', - genfile=False, - ), - esp=dict(argstr='--esp %s', - usedefault=True, - ), - exf_file=dict(argstr='--exf %s', - ), - exfdw=dict(argstr='--exfdw %s', - genfile=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - mag_file=dict(argstr='--mag %s', - mandatory=True, - position=0, - ), - nocleanup=dict(argstr='--nocleanup', - usedefault=True, - ), - output_type=dict(), - sigma=dict(argstr='--sigma %s', - usedefault=True, - ), - tediff=dict(argstr='--tediff %s', - usedefault=True, - ), - terminal_output=dict(nohash=True, - ), - tmpdir=dict(argstr='--tmpdir %s', - genfile=True, - ), - vsm=dict(argstr='--vsm %s', - genfile=True, + output_type=dict(usedefault=True, ), ) - inputs = EPIDeWarp.input_spec() + inputs = EPIDeWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -61,12 +17,8 @@ def test_EPIDeWarp_inputs(): def test_EPIDeWarp_outputs(): - output_map = dict(exf_mask=dict(), - exfdw=dict(), - unwarped_file=dict(), - vsm_file=dict(), - ) - outputs = EPIDeWarp.output_spec() + output_map = dict() + outputs = EPIDeWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Eddy.py b/nipype/interfaces/fsl/tests/test_auto_Eddy.py index 07b17244c9..2268c751c2 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Eddy.py +++ b/nipype/interfaces/fsl/tests/test_auto_Eddy.py @@ -6,16 +6,10 @@ def test_Eddy_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), flm=dict(argstr='--flm=%s', ), fwhm=dict(argstr='--fwhm=%s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_acqp=dict(argstr='--acqp=%s', mandatory=True, ), @@ -49,15 +43,14 @@ def test_Eddy_inputs(): out_base=dict(argstr='--out=%s', usedefault=True, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), repol=dict(argstr='--repol', ), session=dict(argstr='--session=%s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = Eddy.input_spec() + inputs = Eddy._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -68,7 +61,7 @@ def test_Eddy_outputs(): output_map = dict(out_corrected=dict(), out_parameter=dict(), ) - outputs = Eddy.output_spec() + outputs = Eddy._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_EddyCorrect.py b/nipype/interfaces/fsl/tests/test_auto_EddyCorrect.py index b7f93f0b52..c4f9763257 100644 --- a/nipype/interfaces/fsl/tests/test_auto_EddyCorrect.py +++ b/nipype/interfaces/fsl/tests/test_auto_EddyCorrect.py @@ -6,32 +6,10 @@ def test_EddyCorrect_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - in_file=dict(argstr='%s', - mandatory=True, - position=0, - ), - out_file=dict(argstr='%s', - name_source=['in_file'], - name_template='%s_edc', - output_name='eddy_corrected', - position=1, - ), - output_type=dict(), - ref_num=dict(argstr='%d', - mandatory=True, - position=2, - usedefault=True, - ), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = EddyCorrect.input_spec() + inputs = EddyCorrect._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,9 +17,8 @@ def test_EddyCorrect_inputs(): def test_EddyCorrect_outputs(): - output_map = dict(eddy_corrected=dict(), - ) - outputs = EddyCorrect.output_spec() + output_map = dict() + outputs = EddyCorrect._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_EpiReg.py b/nipype/interfaces/fsl/tests/test_auto_EpiReg.py index 10014e521a..4135b6354d 100644 --- a/nipype/interfaces/fsl/tests/test_auto_EpiReg.py +++ b/nipype/interfaces/fsl/tests/test_auto_EpiReg.py @@ -8,34 +8,50 @@ def test_EpiReg_inputs(): ), echospacing=dict(argstr='--echospacing=%f', ), - environ=dict(nohash=True, - usedefault=True, - ), epi=dict(argstr='--epi=%s', mandatory=True, position=-4, ), + epi2str_inv=dict(keep_extension=False, + ), + epi2str_mat=dict(keep_extension=False, + ), fmap=dict(argstr='--fmap=%s', ), + fmap2epi_mat=dict(keep_extension=False, + ), + fmap2str_mat=dict(keep_extension=False, + ), + fmap_epi=dict(keep_extension=False, + ), + fmap_str=dict(keep_extension=False, + ), fmapmag=dict(argstr='--fmapmag=%s', ), fmapmagbrain=dict(argstr='--fmapmagbrain=%s', ), - ignore_exception=dict(nohash=True, - usedefault=True, + fullwarp=dict(keep_extension=False, ), no_clean=dict(argstr='--noclean', usedefault=True, ), no_fmapreg=dict(argstr='--nofmapreg', + usedefault=True, + ), + out_1vol=dict(keep_extension=False, ), out_base=dict(argstr='--out=%s', position=-1, usedefault=True, ), - output_type=dict(), + out_file=dict(keep_extension=False, + ), + output_type=dict(usedefault=True, + ), pedir=dict(argstr='--pedir=%s', ), + shiftmap=dict(keep_extension=False, + ), t1_brain=dict(argstr='--t1brain=%s', mandatory=True, position=-2, @@ -44,14 +60,14 @@ def test_EpiReg_inputs(): mandatory=True, position=-3, ), - terminal_output=dict(nohash=True, - ), weight_image=dict(argstr='--weight=%s', ), - wmseg=dict(argstr='--wmseg=%s', + wmedge=dict(keep_extension=False, + ), + wmseg=dict(keep_extension=False, ), ) - inputs = EpiReg.input_spec() + inputs = EpiReg._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -73,7 +89,7 @@ def test_EpiReg_outputs(): wmedge=dict(), wmseg=dict(), ) - outputs = EpiReg.output_spec() + outputs = EpiReg._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ErodeImage.py b/nipype/interfaces/fsl/tests/test_auto_ErodeImage.py index 3981afc1a5..9aae2d081d 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ErodeImage.py +++ b/nipype/interfaces/fsl/tests/test_auto_ErodeImage.py @@ -6,12 +6,6 @@ def test_ErodeImage_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -30,26 +24,25 @@ def test_ErodeImage_inputs(): position=5, xor=['kernel_file'], ), - minimum_filter=dict(argstr='%s', + minimum_filter=dict(argstr='-eroF', position=6, usedefault=True, ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = ErodeImage.input_spec() + inputs = ErodeImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -59,7 +52,7 @@ def test_ErodeImage_inputs(): def test_ErodeImage_outputs(): output_map = dict(out_file=dict(), ) - outputs = ErodeImage.output_spec() + outputs = ErodeImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ExtractROI.py b/nipype/interfaces/fsl/tests/test_auto_ExtractROI.py index 4368a41256..5c1e20f345 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ExtractROI.py +++ b/nipype/interfaces/fsl/tests/test_auto_ExtractROI.py @@ -10,19 +10,13 @@ def test_ExtractROI_inputs(): position=2, xor=['x_min', 'x_size', 'y_min', 'y_size', 'z_min', 'z_size', 't_min', 't_size'], ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=0, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), roi_file=dict(argstr='%s', - genfile=True, hash_files=False, position=1, ), @@ -32,8 +26,6 @@ def test_ExtractROI_inputs(): t_size=dict(argstr='%d', position=9, ), - terminal_output=dict(nohash=True, - ), x_min=dict(argstr='%d', position=2, ), @@ -53,7 +45,7 @@ def test_ExtractROI_inputs(): position=7, ), ) - inputs = ExtractROI.input_spec() + inputs = ExtractROI._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -63,7 +55,7 @@ def test_ExtractROI_inputs(): def test_ExtractROI_outputs(): output_map = dict(roi_file=dict(), ) - outputs = ExtractROI.output_spec() + outputs = ExtractROI._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FAST.py b/nipype/interfaces/fsl/tests/test_auto_FAST.py index 3dc8ca73f2..4f58452280 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FAST.py +++ b/nipype/interfaces/fsl/tests/test_auto_FAST.py @@ -6,19 +6,14 @@ def test_FAST_inputs(): input_map = dict(args=dict(argstr='%s', ), + bias_field=dict(), bias_iters=dict(argstr='-I %d', ), bias_lowpass=dict(argstr='-l %d', units='mm', ), - environ=dict(nohash=True, - usedefault=True, - ), hyper=dict(argstr='-H %.2f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), img_type=dict(argstr='-t %d', ), in_files=dict(argstr='%s', @@ -36,35 +31,44 @@ def test_FAST_inputs(): ), mixel_smooth=dict(argstr='-R %.2f', ), + mixeltype=dict(), no_bias=dict(argstr='-N', ), no_pve=dict(argstr='--nopve', ), number_classes=dict(argstr='-n %d', + usedefault=True, ), other_priors=dict(argstr='-A %s', ), out_basename=dict(argstr='-o %s', + keep_extension=False, ), output_biascorrected=dict(argstr='-B', ), output_biasfield=dict(argstr='-b', ), - output_type=dict(), + output_type=dict(usedefault=True, + ), + partial_volume_files=dict(), + partial_volume_map=dict(), probability_maps=dict(argstr='-p', ), + probability_maps_files=dict(output_name='probability_maps', + ), + restored_image=dict(), segment_iters=dict(argstr='-W %d', ), segments=dict(argstr='-g', ), - terminal_output=dict(nohash=True, - ), + tissue_class_files=dict(), + tissue_class_map=dict(), use_priors=dict(argstr='-P', ), verbose=dict(argstr='-v', ), ) - inputs = FAST.input_spec() + inputs = FAST._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -81,7 +85,7 @@ def test_FAST_outputs(): tissue_class_files=dict(), tissue_class_map=dict(), ) - outputs = FAST.output_spec() + outputs = FAST._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FEAT.py b/nipype/interfaces/fsl/tests/test_auto_FEAT.py index 8500302502..3f3068f6cb 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FEAT.py +++ b/nipype/interfaces/fsl/tests/test_auto_FEAT.py @@ -6,21 +6,14 @@ def test_FEAT_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fsf_file=dict(argstr='%s', mandatory=True, position=0, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = FEAT.input_spec() + inputs = FEAT._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -30,7 +23,7 @@ def test_FEAT_inputs(): def test_FEAT_outputs(): output_map = dict(feat_dir=dict(), ) - outputs = FEAT.output_spec() + outputs = FEAT._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FEATModel.py b/nipype/interfaces/fsl/tests/test_auto_FEATModel.py index 06cbe57d84..e34ce1d73c 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FEATModel.py +++ b/nipype/interfaces/fsl/tests/test_auto_FEATModel.py @@ -6,9 +6,6 @@ def test_FEATModel_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), ev_files=dict(argstr='%s', copyfile=False, mandatory=True, @@ -19,14 +16,10 @@ def test_FEATModel_inputs(): mandatory=True, position=0, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = FEATModel.input_spec() + inputs = FEATModel._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +33,7 @@ def test_FEATModel_outputs(): design_image=dict(), fcon_file=dict(), ) - outputs = FEATModel.output_spec() + outputs = FEATModel._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FEATRegister.py b/nipype/interfaces/fsl/tests/test_auto_FEATRegister.py index 3af3b4695d..a13ad971cc 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FEATRegister.py +++ b/nipype/interfaces/fsl/tests/test_auto_FEATRegister.py @@ -6,15 +6,12 @@ def test_FEATRegister_inputs(): input_map = dict(feat_dirs=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), reg_dof=dict(usedefault=True, ), reg_image=dict(mandatory=True, ), ) - inputs = FEATRegister.input_spec() + inputs = FEATRegister._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -24,7 +21,7 @@ def test_FEATRegister_inputs(): def test_FEATRegister_outputs(): output_map = dict(fsf_file=dict(), ) - outputs = FEATRegister.output_spec() + outputs = FEATRegister._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FIRST.py b/nipype/interfaces/fsl/tests/test_auto_FIRST.py index 876f89f5b6..8fee38f29f 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FIRST.py +++ b/nipype/interfaces/fsl/tests/test_auto_FIRST.py @@ -12,12 +12,6 @@ def test_FIRST_inputs(): brain_extracted=dict(argstr='-b', position=2, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', copyfile=False, mandatory=True, @@ -44,14 +38,13 @@ def test_FIRST_inputs(): position=-1, usedefault=True, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), verbose=dict(argstr='-v', position=1, ), ) - inputs = FIRST.input_spec() + inputs = FIRST._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -64,7 +57,7 @@ def test_FIRST_outputs(): segmentation_file=dict(), vtk_surfaces=dict(), ) - outputs = FIRST.output_spec() + outputs = FIRST._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FLAMEO.py b/nipype/interfaces/fsl/tests/test_auto_FLAMEO.py index bd4d938ffb..bfae762622 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FLAMEO.py +++ b/nipype/interfaces/fsl/tests/test_auto_FLAMEO.py @@ -19,16 +19,10 @@ def test_FLAMEO_inputs(): ), dof_var_cope_file=dict(argstr='--dofvarcopefile=%s', ), - environ=dict(nohash=True, - usedefault=True, - ), f_con_file=dict(argstr='--fcontrastsfile=%s', ), fix_mean=dict(argstr='--fixmean', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), infer_outliers=dict(argstr='--inferoutliers', ), log_dir=dict(argstr='--ld=%s', @@ -43,7 +37,8 @@ def test_FLAMEO_inputs(): ), outlier_iter=dict(argstr='--ioni=%d', ), - output_type=dict(), + output_type=dict(usedefault=True, + ), run_mode=dict(argstr='--runmode=%s', mandatory=True, ), @@ -54,12 +49,10 @@ def test_FLAMEO_inputs(): t_con_file=dict(argstr='--tcontrastsfile=%s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), var_cope_file=dict(argstr='--varcopefile=%s', ), ) - inputs = FLAMEO.input_spec() + inputs = FLAMEO._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -80,7 +73,7 @@ def test_FLAMEO_outputs(): zfstats=dict(), zstats=dict(), ) - outputs = FLAMEO.output_spec() + outputs = FLAMEO._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FLIRT.py b/nipype/interfaces/fsl/tests/test_auto_FLIRT.py index 8bba532da8..9324c15c88 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FLIRT.py +++ b/nipype/interfaces/fsl/tests/test_auto_FLIRT.py @@ -40,9 +40,6 @@ def test_FLIRT_inputs(): echospacing=dict(argstr='-echospacing %f', min_ver='5.0.0', ), - environ=dict(nohash=True, - usedefault=True, - ), fieldmap=dict(argstr='-fieldmap %s', min_ver='5.0.0', ), @@ -54,9 +51,6 @@ def test_FLIRT_inputs(): ), force_scaling=dict(argstr='-forcescaling', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-in %s', mandatory=True, position=0, @@ -96,7 +90,8 @@ def test_FLIRT_inputs(): name_template='%s_flirt.mat', position=3, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), padding_size=dict(argstr='-paddingsize %d', units='voxels', ), @@ -128,8 +123,6 @@ def test_FLIRT_inputs(): ), sinc_window=dict(argstr='-sincwindow %s', ), - terminal_output=dict(nohash=True, - ), uses_qform=dict(argstr='-usesqform', ), verbose=dict(argstr='-verbose %d', @@ -144,7 +137,7 @@ def test_FLIRT_inputs(): min_ver='5.0.0', ), ) - inputs = FLIRT.input_spec() + inputs = FLIRT._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -156,7 +149,7 @@ def test_FLIRT_outputs(): out_log=dict(), out_matrix_file=dict(), ) - outputs = FLIRT.output_spec() + outputs = FLIRT._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FNIRT.py b/nipype/interfaces/fsl/tests/test_auto_FNIRT.py index f37e3b7eb2..cb0901b185 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FNIRT.py +++ b/nipype/interfaces/fsl/tests/test_auto_FNIRT.py @@ -28,9 +28,6 @@ def test_FNIRT_inputs(): ), derive_from_ref=dict(argstr='--refderiv', ), - environ=dict(nohash=True, - usedefault=True, - ), field_file=dict(argstr='--fout=%s', hash_files=False, ), @@ -38,9 +35,6 @@ def test_FNIRT_inputs(): ), hessian_precision=dict(argstr='--numprec=%s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--in=%s', mandatory=True, ), @@ -77,7 +71,8 @@ def test_FNIRT_inputs(): out_intensitymap_file=dict(argstr='--intout=%s', hash_files=False, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), ref_file=dict(argstr='--ref=%s', mandatory=True, ), @@ -113,8 +108,6 @@ def test_FNIRT_inputs(): subsampling_scheme=dict(argstr='--subsamp=%s', sep=',', ), - terminal_output=dict(nohash=True, - ), warp_resolution=dict(argstr='--warpres=%d,%d,%d', ), warped_file=dict(argstr='--iout=%s', @@ -122,7 +115,7 @@ def test_FNIRT_inputs(): hash_files=False, ), ) - inputs = FNIRT.input_spec() + inputs = FNIRT._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -138,7 +131,7 @@ def test_FNIRT_outputs(): out_intensitymap_file=dict(), warped_file=dict(), ) - outputs = FNIRT.output_spec() + outputs = FNIRT._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FSLCommand.py b/nipype/interfaces/fsl/tests/test_auto_FSLCommand.py index c5b0bb63a2..f3105a49e4 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FSLCommand.py +++ b/nipype/interfaces/fsl/tests/test_auto_FSLCommand.py @@ -6,19 +6,20 @@ def test_FSLCommand_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = FSLCommand.input_spec() + inputs = FSLCommand._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_FSLCommand_outputs(): + output_map = dict() + outputs = FSLCommand._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/fsl/tests/test_auto_FSLXCommand.py b/nipype/interfaces/fsl/tests/test_auto_FSLXCommand.py index 57b06760d5..45a2fac163 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FSLXCommand.py +++ b/nipype/interfaces/fsl/tests/test_auto_FSLXCommand.py @@ -25,9 +25,7 @@ def test_FSLXCommand_inputs(): dwi=dict(argstr='--data=%s', mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), + dyads=dict(), f0_ard=dict(argstr='--f0 --ardf0', xor=['f0_noard', 'f0_ard', 'all_ard'], ), @@ -37,17 +35,22 @@ def test_FSLXCommand_inputs(): force_dir=dict(argstr='--forcedir', usedefault=True, ), + fsamples=dict(), fudge=dict(argstr='--fudge=%d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), logdir=dict(argstr='--logdir=%s', usedefault=True, ), mask=dict(argstr='--mask=%s', mandatory=True, ), + mean_S0samples=dict(keep_extension=False, + ), + mean_dsamples=dict(keep_extension=False, + ), + mean_fsamples=dict(), + mean_tausamples=dict(keep_extension=False, + ), model=dict(argstr='--model=%d', ), n_fibres=dict(argstr='--nfibres=%d', @@ -65,19 +68,21 @@ def test_FSLXCommand_inputs(): non_linear=dict(argstr='--nonlinear', xor=('no_spat', 'non_linear', 'cnlinear'), ), - output_type=dict(), + output_type=dict(usedefault=True, + ), + phsamples=dict(), rician=dict(argstr='--rician', + usedefault=True, ), sample_every=dict(argstr='--sampleevery=%d', ), seed=dict(argstr='--seed=%d', ), - terminal_output=dict(nohash=True, - ), + thsamples=dict(), update_proposal_every=dict(argstr='--updateproposalevery=%d', ), ) - inputs = FSLXCommand.input_spec() + inputs = FSLXCommand._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -94,7 +99,7 @@ def test_FSLXCommand_outputs(): phsamples=dict(), thsamples=dict(), ) - outputs = FSLXCommand.output_spec() + outputs = FSLXCommand._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FUGUE.py b/nipype/interfaces/fsl/tests/test_auto_FUGUE.py index 84de7126df..651fedf580 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FUGUE.py +++ b/nipype/interfaces/fsl/tests/test_auto_FUGUE.py @@ -16,9 +16,6 @@ def test_FUGUE_inputs(): ), dwell_to_asym_ratio=dict(argstr='--dwelltoasym=%.10f', ), - environ=dict(nohash=True, - usedefault=True, - ), fmap_in_file=dict(argstr='--loadfmap=%s', ), fmap_out_file=dict(argstr='--savefmap=%s', @@ -33,9 +30,6 @@ def test_FUGUE_inputs(): icorr_only=dict(argstr='--icorronly', requires=['unwarped_file'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--in=%s', ), mask_file=dict(argstr='--mask=%s', @@ -48,7 +42,8 @@ def test_FUGUE_inputs(): ), nokspace=dict(argstr='--nokspace', ), - output_type=dict(), + output_type=dict(usedefault=True, + ), pava=dict(argstr='--pava', ), phase_conjugate=dict(argstr='--phaseconj', @@ -57,9 +52,11 @@ def test_FUGUE_inputs(): ), poly_order=dict(argstr='--poly=%d', ), - save_fmap=dict(xor=['save_unmasked_fmap'], + save_fmap=dict(usedefault=True, + xor=['save_unmasked_fmap'], ), - save_shift=dict(xor=['save_unmasked_shift'], + save_shift=dict(usedefault=True, + xor=['save_unmasked_shift'], ), save_unmasked_fmap=dict(argstr='--unmaskfmap', xor=['save_fmap'], @@ -75,8 +72,6 @@ def test_FUGUE_inputs(): ), smooth3d=dict(argstr='--smooth3=%.2f', ), - terminal_output=dict(nohash=True, - ), unwarp_direction=dict(argstr='--unwarpdir=%s', ), unwarped_file=dict(argstr='--unwarp=%s', @@ -88,7 +83,7 @@ def test_FUGUE_inputs(): xor=['unwarped_file'], ), ) - inputs = FUGUE.input_spec() + inputs = FUGUE._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -101,7 +96,7 @@ def test_FUGUE_outputs(): unwarped_file=dict(), warped_file=dict(), ) - outputs = FUGUE.output_spec() + outputs = FUGUE._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FilterRegressor.py b/nipype/interfaces/fsl/tests/test_auto_FilterRegressor.py index 2904b70798..5970c5c347 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FilterRegressor.py +++ b/nipype/interfaces/fsl/tests/test_auto_FilterRegressor.py @@ -10,9 +10,6 @@ def test_FilterRegressor_inputs(): mandatory=True, position=3, ), - environ=dict(nohash=True, - usedefault=True, - ), filter_all=dict(argstr="-f '%s'", mandatory=True, position=4, @@ -23,9 +20,6 @@ def test_FilterRegressor_inputs(): position=4, xor=['filter_all'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, position=1, @@ -33,19 +27,18 @@ def test_FilterRegressor_inputs(): mask=dict(argstr='-m %s', ), out_file=dict(argstr='-o %s', - genfile=True, hash_files=False, position=2, + template='{in_file}_regfilt{output_type_}', ), out_vnscales=dict(argstr='--out_vnscales', ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), var_norm=dict(argstr='--vn', ), ) - inputs = FilterRegressor.input_spec() + inputs = FilterRegressor._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +48,7 @@ def test_FilterRegressor_inputs(): def test_FilterRegressor_outputs(): output_map = dict(out_file=dict(), ) - outputs = FilterRegressor.output_spec() + outputs = FilterRegressor._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_FindTheBiggest.py b/nipype/interfaces/fsl/tests/test_auto_FindTheBiggest.py index 0fd902dbf0..8f7da940b5 100644 --- a/nipype/interfaces/fsl/tests/test_auto_FindTheBiggest.py +++ b/nipype/interfaces/fsl/tests/test_auto_FindTheBiggest.py @@ -6,12 +6,6 @@ def test_FindTheBiggest_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='%s', mandatory=True, position=0, @@ -21,11 +15,10 @@ def test_FindTheBiggest_inputs(): hash_files=False, position=2, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = FindTheBiggest.input_spec() + inputs = FindTheBiggest._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +29,7 @@ def test_FindTheBiggest_outputs(): output_map = dict(out_file=dict(argstr='%s', ), ) - outputs = FindTheBiggest.output_spec() + outputs = FindTheBiggest._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_GLM.py b/nipype/interfaces/fsl/tests/test_auto_GLM.py index 3aeef972c0..9ae8cda12e 100644 --- a/nipype/interfaces/fsl/tests/test_auto_GLM.py +++ b/nipype/interfaces/fsl/tests/test_auto_GLM.py @@ -20,12 +20,6 @@ def test_GLM_inputs(): ), dof=dict(argstr='--dof=%d', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, position=1, @@ -60,13 +54,12 @@ def test_GLM_inputs(): ), out_z_name=dict(argstr='--out_z=%s', ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), var_norm=dict(argstr='--vn', ), ) - inputs = GLM.input_spec() + inputs = GLM._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -87,7 +80,7 @@ def test_GLM_outputs(): out_vnscales=dict(), out_z=dict(), ) - outputs = GLM.output_spec() + outputs = GLM._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ImageMaths.py b/nipype/interfaces/fsl/tests/test_auto_ImageMaths.py index 008516f571..5f95a5ae0d 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ImageMaths.py +++ b/nipype/interfaces/fsl/tests/test_auto_ImageMaths.py @@ -6,12 +6,6 @@ def test_ImageMaths_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=1, @@ -26,16 +20,15 @@ def test_ImageMaths_inputs(): position=5, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=4, ), - output_type=dict(), - suffix=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, + ), + suffix=dict(deprecated=True, ), ) - inputs = ImageMaths.input_spec() + inputs = ImageMaths._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +38,7 @@ def test_ImageMaths_inputs(): def test_ImageMaths_outputs(): output_map = dict(out_file=dict(), ) - outputs = ImageMaths.output_spec() + outputs = ImageMaths._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ImageMeants.py b/nipype/interfaces/fsl/tests/test_auto_ImageMeants.py index 2a07ee64f0..7b7b620cde 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ImageMeants.py +++ b/nipype/interfaces/fsl/tests/test_auto_ImageMeants.py @@ -8,12 +8,6 @@ def test_ImageMeants_inputs(): ), eig=dict(argstr='--eig', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, position=0, @@ -26,22 +20,20 @@ def test_ImageMeants_inputs(): usedefault=True, ), out_file=dict(argstr='-o %s', - genfile=True, hash_files=False, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), show_all=dict(argstr='--showall', ), spatial_coord=dict(argstr='-c %s', ), - terminal_output=dict(nohash=True, - ), transpose=dict(argstr='--transpose', ), use_mm=dict(argstr='--usemm', ), ) - inputs = ImageMeants.input_spec() + inputs = ImageMeants._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -51,7 +43,7 @@ def test_ImageMeants_inputs(): def test_ImageMeants_outputs(): output_map = dict(out_file=dict(), ) - outputs = ImageMeants.output_spec() + outputs = ImageMeants._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ImageStats.py b/nipype/interfaces/fsl/tests/test_auto_ImageStats.py index 86be9772c4..9a0cfb4df3 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ImageStats.py +++ b/nipype/interfaces/fsl/tests/test_auto_ImageStats.py @@ -6,30 +6,23 @@ def test_ImageStats_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, ), - mask_file=dict(argstr='', + mask_file=dict(argstr='-k %s', ), op_string=dict(argstr='%s', mandatory=True, position=3, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), split_4d=dict(argstr='-t', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ImageStats.input_spec() + inputs = ImageStats._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +32,7 @@ def test_ImageStats_inputs(): def test_ImageStats_outputs(): output_map = dict(out_stat=dict(), ) - outputs = ImageStats.output_spec() + outputs = ImageStats._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_InvWarp.py b/nipype/interfaces/fsl/tests/test_auto_InvWarp.py index ad367bf904..a9bda879a4 100644 --- a/nipype/interfaces/fsl/tests/test_auto_InvWarp.py +++ b/nipype/interfaces/fsl/tests/test_auto_InvWarp.py @@ -9,16 +9,8 @@ def test_InvWarp_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inverse_warp=dict(argstr='--out=%s', hash_files=False, - name_source=['warp'], - name_template='%s_inverse', ), jacobian_max=dict(argstr='--jmax=%f', ), @@ -28,7 +20,8 @@ def test_InvWarp_inputs(): ), noconstraint=dict(argstr='--noconstraint', ), - output_type=dict(), + output_type=dict(usedefault=True, + ), reference=dict(argstr='--ref=%s', mandatory=True, ), @@ -37,13 +30,11 @@ def test_InvWarp_inputs(): relative=dict(argstr='--rel', xor=['absolute'], ), - terminal_output=dict(nohash=True, - ), warp=dict(argstr='--warp=%s', mandatory=True, ), ) - inputs = InvWarp.input_spec() + inputs = InvWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +44,7 @@ def test_InvWarp_inputs(): def test_InvWarp_outputs(): output_map = dict(inverse_warp=dict(), ) - outputs = InvWarp.output_spec() + outputs = InvWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_IsotropicSmooth.py b/nipype/interfaces/fsl/tests/test_auto_IsotropicSmooth.py index 2d1023d674..0cb3758a0a 100644 --- a/nipype/interfaces/fsl/tests/test_auto_IsotropicSmooth.py +++ b/nipype/interfaces/fsl/tests/test_auto_IsotropicSmooth.py @@ -6,17 +6,11 @@ def test_IsotropicSmooth_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fwhm=dict(argstr='-s %.5f', mandatory=True, position=4, xor=['sigma'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -26,25 +20,24 @@ def test_IsotropicSmooth_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), sigma=dict(argstr='-s %.5f', mandatory=True, position=4, xor=['fwhm'], ), - terminal_output=dict(nohash=True, - ), ) - inputs = IsotropicSmooth.input_spec() + inputs = IsotropicSmooth._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -54,7 +47,7 @@ def test_IsotropicSmooth_inputs(): def test_IsotropicSmooth_outputs(): output_map = dict(out_file=dict(), ) - outputs = IsotropicSmooth.output_spec() + outputs = IsotropicSmooth._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_L2Model.py b/nipype/interfaces/fsl/tests/test_auto_L2Model.py index bcf3737fdd..1c9573e588 100644 --- a/nipype/interfaces/fsl/tests/test_auto_L2Model.py +++ b/nipype/interfaces/fsl/tests/test_auto_L2Model.py @@ -4,13 +4,10 @@ def test_L2Model_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - num_copes=dict(mandatory=True, + input_map = dict(num_copes=dict(mandatory=True, ), ) - inputs = L2Model.input_spec() + inputs = L2Model._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -22,7 +19,7 @@ def test_L2Model_outputs(): design_grp=dict(), design_mat=dict(), ) - outputs = L2Model.output_spec() + outputs = L2Model._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Level1Design.py b/nipype/interfaces/fsl/tests/test_auto_Level1Design.py index f1500d42be..c1a2702ffb 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Level1Design.py +++ b/nipype/interfaces/fsl/tests/test_auto_Level1Design.py @@ -7,9 +7,6 @@ def test_Level1Design_inputs(): input_map = dict(bases=dict(mandatory=True, ), contrasts=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), interscan_interval=dict(mandatory=True, ), model_serial_correlations=dict(mandatory=True, @@ -17,7 +14,7 @@ def test_Level1Design_inputs(): session_info=dict(mandatory=True, ), ) - inputs = Level1Design.input_spec() + inputs = Level1Design._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +25,7 @@ def test_Level1Design_outputs(): output_map = dict(ev_files=dict(), fsf_files=dict(), ) - outputs = Level1Design.output_spec() + outputs = Level1Design._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_MCFLIRT.py b/nipype/interfaces/fsl/tests/test_auto_MCFLIRT.py index 355c9ab527..bd312fafef 100644 --- a/nipype/interfaces/fsl/tests/test_auto_MCFLIRT.py +++ b/nipype/interfaces/fsl/tests/test_auto_MCFLIRT.py @@ -12,12 +12,6 @@ def test_MCFLIRT_inputs(): ), dof=dict(argstr='-dof %d', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-in %s', mandatory=True, position=0, @@ -29,10 +23,10 @@ def test_MCFLIRT_inputs(): mean_vol=dict(argstr='-meanvol', ), out_file=dict(argstr='-out %s', - genfile=True, hash_files=False, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), ref_file=dict(argstr='-reffile %s', ), ref_vol=dict(argstr='-refvol %d', @@ -53,14 +47,12 @@ def test_MCFLIRT_inputs(): ), stats_imgs=dict(argstr='-stats', ), - terminal_output=dict(nohash=True, - ), use_contour=dict(argstr='-edge', ), use_gradient=dict(argstr='-gdt', ), ) - inputs = MCFLIRT.input_spec() + inputs = MCFLIRT._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -76,7 +68,7 @@ def test_MCFLIRT_outputs(): std_img=dict(), variance_img=dict(), ) - outputs = MCFLIRT.output_spec() + outputs = MCFLIRT._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_MELODIC.py b/nipype/interfaces/fsl/tests/test_auto_MELODIC.py index 3f4c0047ca..5c63c94bac 100644 --- a/nipype/interfaces/fsl/tests/test_auto_MELODIC.py +++ b/nipype/interfaces/fsl/tests/test_auto_MELODIC.py @@ -20,16 +20,10 @@ def test_MELODIC_inputs(): ), dim_est=dict(argstr='--dimest=%s', ), - environ=dict(nohash=True, - usedefault=True, - ), epsilon=dict(argstr='--eps=%f', ), epsilonS=dict(argstr='--epsS=%f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='-i %s', mandatory=True, position=0, @@ -74,7 +68,8 @@ def test_MELODIC_inputs(): ), out_white=dict(argstr='--Owhite', ), - output_type=dict(), + output_type=dict(usedefault=True, + ), pbsc=dict(argstr='--pbsc', ), rem_cmp=dict(argstr='-f %d', @@ -99,8 +94,6 @@ def test_MELODIC_inputs(): ), t_des=dict(argstr='--Tdes=%s', ), - terminal_output=dict(nohash=True, - ), tr_sec=dict(argstr='--tr=%f', ), update_mask=dict(argstr='--update_mask', @@ -108,7 +101,7 @@ def test_MELODIC_inputs(): var_norm=dict(argstr='--vn', ), ) - inputs = MELODIC.input_spec() + inputs = MELODIC._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -119,7 +112,7 @@ def test_MELODIC_outputs(): output_map = dict(out_dir=dict(), report_dir=dict(), ) - outputs = MELODIC.output_spec() + outputs = MELODIC._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_MakeDyadicVectors.py b/nipype/interfaces/fsl/tests/test_auto_MakeDyadicVectors.py index cbc35e34c9..4f2576e0e5 100644 --- a/nipype/interfaces/fsl/tests/test_auto_MakeDyadicVectors.py +++ b/nipype/interfaces/fsl/tests/test_auto_MakeDyadicVectors.py @@ -6,12 +6,6 @@ def test_MakeDyadicVectors_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), mask=dict(argstr='%s', position=2, ), @@ -20,7 +14,8 @@ def test_MakeDyadicVectors_inputs(): position=3, usedefault=True, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), perc=dict(argstr='%f', position=4, ), @@ -28,14 +23,12 @@ def test_MakeDyadicVectors_inputs(): mandatory=True, position=1, ), - terminal_output=dict(nohash=True, - ), theta_vol=dict(argstr='%s', mandatory=True, position=0, ), ) - inputs = MakeDyadicVectors.input_spec() + inputs = MakeDyadicVectors._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +39,7 @@ def test_MakeDyadicVectors_outputs(): output_map = dict(dispersion=dict(), dyads=dict(), ) - outputs = MakeDyadicVectors.output_spec() + outputs = MakeDyadicVectors._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_MathsCommand.py b/nipype/interfaces/fsl/tests/test_auto_MathsCommand.py index 3c3eee3d14..c5d4ab27b9 100644 --- a/nipype/interfaces/fsl/tests/test_auto_MathsCommand.py +++ b/nipype/interfaces/fsl/tests/test_auto_MathsCommand.py @@ -6,12 +6,6 @@ def test_MathsCommand_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -21,20 +15,19 @@ def test_MathsCommand_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = MathsCommand.input_spec() + inputs = MathsCommand._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +37,7 @@ def test_MathsCommand_inputs(): def test_MathsCommand_outputs(): output_map = dict(out_file=dict(), ) - outputs = MathsCommand.output_spec() + outputs = MathsCommand._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_MaxImage.py b/nipype/interfaces/fsl/tests/test_auto_MaxImage.py index 4edd2cfb13..b9a5b968f2 100644 --- a/nipype/interfaces/fsl/tests/test_auto_MaxImage.py +++ b/nipype/interfaces/fsl/tests/test_auto_MaxImage.py @@ -10,12 +10,6 @@ def test_MaxImage_inputs(): position=4, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -25,20 +19,19 @@ def test_MaxImage_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = MaxImage.input_spec() + inputs = MaxImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -48,7 +41,7 @@ def test_MaxImage_inputs(): def test_MaxImage_outputs(): output_map = dict(out_file=dict(), ) - outputs = MaxImage.output_spec() + outputs = MaxImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_MeanImage.py b/nipype/interfaces/fsl/tests/test_auto_MeanImage.py index f6792d368d..112fa13819 100644 --- a/nipype/interfaces/fsl/tests/test_auto_MeanImage.py +++ b/nipype/interfaces/fsl/tests/test_auto_MeanImage.py @@ -10,12 +10,6 @@ def test_MeanImage_inputs(): position=4, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -25,20 +19,19 @@ def test_MeanImage_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = MeanImage.input_spec() + inputs = MeanImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -48,7 +41,7 @@ def test_MeanImage_inputs(): def test_MeanImage_outputs(): output_map = dict(out_file=dict(), ) - outputs = MeanImage.output_spec() + outputs = MeanImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Merge.py b/nipype/interfaces/fsl/tests/test_auto_Merge.py index 621d43dd65..62420a593e 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Merge.py +++ b/nipype/interfaces/fsl/tests/test_auto_Merge.py @@ -10,30 +10,21 @@ def test_Merge_inputs(): mandatory=True, position=0, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='%s', mandatory=True, position=2, ), merged_file=dict(argstr='%s', hash_files=False, - name_source='in_files', - name_template='%s_merged', position=1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), tr=dict(argstr='%.2f', position=-1, ), ) - inputs = Merge.input_spec() + inputs = Merge._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +34,7 @@ def test_Merge_inputs(): def test_Merge_outputs(): output_map = dict(merged_file=dict(), ) - outputs = Merge.output_spec() + outputs = Merge._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_MotionOutliers.py b/nipype/interfaces/fsl/tests/test_auto_MotionOutliers.py index d8d88d809e..f579333cc7 100644 --- a/nipype/interfaces/fsl/tests/test_auto_MotionOutliers.py +++ b/nipype/interfaces/fsl/tests/test_auto_MotionOutliers.py @@ -8,12 +8,6 @@ def test_MotionOutliers_inputs(): ), dummy=dict(argstr='--dummy=%d', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, ), @@ -25,29 +19,19 @@ def test_MotionOutliers_inputs(): ), out_file=dict(argstr='-o %s', hash_files=False, - keep_extension=True, - name_source='in_file', - name_template='%s_outliers.txt', ), out_metric_plot=dict(argstr='-p %s', hash_files=False, - keep_extension=True, - name_source='in_file', - name_template='%s_metrics.png', ), out_metric_values=dict(argstr='-s %s', hash_files=False, - keep_extension=True, - name_source='in_file', - name_template='%s_metrics.txt', ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), threshold=dict(argstr='--thresh=%g', ), ) - inputs = MotionOutliers.input_spec() + inputs = MotionOutliers._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -59,7 +43,7 @@ def test_MotionOutliers_outputs(): out_metric_plot=dict(), out_metric_values=dict(), ) - outputs = MotionOutliers.output_spec() + outputs = MotionOutliers._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_MultiImageMaths.py b/nipype/interfaces/fsl/tests/test_auto_MultiImageMaths.py index 91b5f03657..08dc8ed355 100644 --- a/nipype/interfaces/fsl/tests/test_auto_MultiImageMaths.py +++ b/nipype/interfaces/fsl/tests/test_auto_MultiImageMaths.py @@ -6,12 +6,6 @@ def test_MultiImageMaths_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -21,6 +15,7 @@ def test_MultiImageMaths_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), op_string=dict(argstr='%s', mandatory=True, @@ -29,18 +24,16 @@ def test_MultiImageMaths_inputs(): operand_files=dict(mandatory=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = MultiImageMaths.input_spec() + inputs = MultiImageMaths._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +43,7 @@ def test_MultiImageMaths_inputs(): def test_MultiImageMaths_outputs(): output_map = dict(out_file=dict(), ) - outputs = MultiImageMaths.output_spec() + outputs = MultiImageMaths._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_MultipleRegressDesign.py b/nipype/interfaces/fsl/tests/test_auto_MultipleRegressDesign.py index 5e4a88cf79..030f9ce78c 100644 --- a/nipype/interfaces/fsl/tests/test_auto_MultipleRegressDesign.py +++ b/nipype/interfaces/fsl/tests/test_auto_MultipleRegressDesign.py @@ -7,13 +7,10 @@ def test_MultipleRegressDesign_inputs(): input_map = dict(contrasts=dict(mandatory=True, ), groups=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), regressors=dict(mandatory=True, ), ) - inputs = MultipleRegressDesign.input_spec() + inputs = MultipleRegressDesign._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -26,7 +23,7 @@ def test_MultipleRegressDesign_outputs(): design_grp=dict(), design_mat=dict(), ) - outputs = MultipleRegressDesign.output_spec() + outputs = MultipleRegressDesign._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Overlay.py b/nipype/interfaces/fsl/tests/test_auto_Overlay.py index 14257803be..f4a0a85d82 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Overlay.py +++ b/nipype/interfaces/fsl/tests/test_auto_Overlay.py @@ -20,19 +20,12 @@ def test_Overlay_inputs(): position=5, xor=('auto_thresh_bg', 'full_bg_range', 'bg_thresh'), ), - environ=dict(nohash=True, - usedefault=True, - ), full_bg_range=dict(argstr='-A', mandatory=True, position=5, xor=('auto_thresh_bg', 'full_bg_range', 'bg_thresh'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-1, ), @@ -40,7 +33,8 @@ def test_Overlay_inputs(): position=2, usedefault=True, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), show_negative_stats=dict(argstr='%s', position=8, xor=['stat_image2'], @@ -60,8 +54,6 @@ def test_Overlay_inputs(): stat_thresh2=dict(argstr='%.2f %.2f', position=10, ), - terminal_output=dict(nohash=True, - ), transparency=dict(argstr='%s', position=1, usedefault=True, @@ -70,7 +62,7 @@ def test_Overlay_inputs(): position=3, ), ) - inputs = Overlay.input_spec() + inputs = Overlay._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -80,7 +72,7 @@ def test_Overlay_inputs(): def test_Overlay_outputs(): output_map = dict(out_file=dict(), ) - outputs = Overlay.output_spec() + outputs = Overlay._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_PRELUDE.py b/nipype/interfaces/fsl/tests/test_auto_PRELUDE.py index 434322da60..947ca52fbd 100644 --- a/nipype/interfaces/fsl/tests/test_auto_PRELUDE.py +++ b/nipype/interfaces/fsl/tests/test_auto_PRELUDE.py @@ -12,12 +12,6 @@ def test_PRELUDE_inputs(): ), end=dict(argstr='--end=%d', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), label_file=dict(argstr='--labels=%s', hash_files=False, ), @@ -31,7 +25,8 @@ def test_PRELUDE_inputs(): ), num_partitions=dict(argstr='--numphasesplit=%d', ), - output_type=dict(), + output_type=dict(usedefault=True, + ), phase_file=dict(argstr='--phase=%s', mandatory=True, xor=['complex_phase_file'], @@ -52,8 +47,6 @@ def test_PRELUDE_inputs(): ), start=dict(argstr='--start=%d', ), - terminal_output=dict(nohash=True, - ), threshold=dict(argstr='--thresh=%.10f', ), unwrapped_phase_file=dict(argstr='--unwrap=%s', @@ -61,7 +54,7 @@ def test_PRELUDE_inputs(): hash_files=False, ), ) - inputs = PRELUDE.input_spec() + inputs = PRELUDE._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -71,7 +64,7 @@ def test_PRELUDE_inputs(): def test_PRELUDE_outputs(): output_map = dict(unwrapped_phase_file=dict(), ) - outputs = PRELUDE.output_spec() + outputs = PRELUDE._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_PlotMotionParams.py b/nipype/interfaces/fsl/tests/test_auto_PlotMotionParams.py index 75d376e32e..25acaab775 100644 --- a/nipype/interfaces/fsl/tests/test_auto_PlotMotionParams.py +++ b/nipype/interfaces/fsl/tests/test_auto_PlotMotionParams.py @@ -6,32 +6,26 @@ def test_PlotMotionParams_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - in_file=dict(argstr='%s', + in_file=dict(argstr='-i %s', mandatory=True, position=1, + sep=',', ), in_source=dict(mandatory=True, ), out_file=dict(argstr='-o %s', - genfile=True, hash_files=False, + template='{in_file}_{plot_type[:5]}.png', ), - output_type=dict(), - plot_size=dict(argstr='%s', + output_type=dict(usedefault=True, + ), + plot_size=dict(argstr='-h %d -w %d', ), plot_type=dict(argstr='%s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = PlotMotionParams.input_spec() + inputs = PlotMotionParams._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +35,7 @@ def test_PlotMotionParams_inputs(): def test_PlotMotionParams_outputs(): output_map = dict(out_file=dict(), ) - outputs = PlotMotionParams.output_spec() + outputs = PlotMotionParams._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_PlotTimeSeries.py b/nipype/interfaces/fsl/tests/test_auto_PlotTimeSeries.py index e8c28c68de..cc3b7193a8 100644 --- a/nipype/interfaces/fsl/tests/test_auto_PlotTimeSeries.py +++ b/nipype/interfaces/fsl/tests/test_auto_PlotTimeSeries.py @@ -6,41 +6,36 @@ def test_PlotTimeSeries_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=1, + sep=',', ), - labels=dict(argstr='%s', + labels=dict(argstr='-a %s', + sep=',', ), legend_file=dict(argstr='--legend=%s', ), out_file=dict(argstr='-o %s', - genfile=True, hash_files=False, + template='{in_file}.png', + ), + output_type=dict(usedefault=True, ), - output_type=dict(), plot_finish=dict(argstr='--finish=%d', - xor=('plot_range',), + xor=['plot_range'], ), - plot_range=dict(argstr='%s', - xor=('plot_start', 'plot_finish'), + plot_range=dict(argstr='--start=%d --finish=%d', + xor=['plot_start', 'plot_finish'], ), - plot_size=dict(argstr='%s', + plot_size=dict(argstr='-h %d -w %d', ), plot_start=dict(argstr='--start=%d', - xor=('plot_range',), + xor=['plot_range'], ), sci_notation=dict(argstr='--sci', ), - terminal_output=dict(nohash=True, - ), - title=dict(argstr='%s', + title=dict(argstr="-t '%s'", ), x_precision=dict(argstr='--precision=%d', ), @@ -48,16 +43,16 @@ def test_PlotTimeSeries_inputs(): usedefault=True, ), y_max=dict(argstr='--ymax=%.2f', - xor=('y_range',), + xor=['y_range'], ), y_min=dict(argstr='--ymin=%.2f', - xor=('y_range',), + xor=['y_range'], ), - y_range=dict(argstr='%s', - xor=('y_min', 'y_max'), + y_range=dict(argstr='--ymin=%.2f --ymax=%.2f', + xor=['y_min', 'y_max'], ), ) - inputs = PlotTimeSeries.input_spec() + inputs = PlotTimeSeries._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -67,7 +62,7 @@ def test_PlotTimeSeries_inputs(): def test_PlotTimeSeries_outputs(): output_map = dict(out_file=dict(), ) - outputs = PlotTimeSeries.output_spec() + outputs = PlotTimeSeries._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_PowerSpectrum.py b/nipype/interfaces/fsl/tests/test_auto_PowerSpectrum.py index bacda34c21..f57c42bedf 100644 --- a/nipype/interfaces/fsl/tests/test_auto_PowerSpectrum.py +++ b/nipype/interfaces/fsl/tests/test_auto_PowerSpectrum.py @@ -6,26 +6,18 @@ def test_PowerSpectrum_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=0, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = PowerSpectrum.input_spec() + inputs = PowerSpectrum._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +27,7 @@ def test_PowerSpectrum_inputs(): def test_PowerSpectrum_outputs(): output_map = dict(out_file=dict(), ) - outputs = PowerSpectrum.output_spec() + outputs = PowerSpectrum._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_PrepareFieldmap.py b/nipype/interfaces/fsl/tests/test_auto_PrepareFieldmap.py index 01aea929dc..040fe4fdff 100644 --- a/nipype/interfaces/fsl/tests/test_auto_PrepareFieldmap.py +++ b/nipype/interfaces/fsl/tests/test_auto_PrepareFieldmap.py @@ -11,12 +11,6 @@ def test_PrepareFieldmap_inputs(): position=-2, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_magnitude=dict(argstr='%s', mandatory=True, position=3, @@ -32,15 +26,14 @@ def test_PrepareFieldmap_inputs(): out_fieldmap=dict(argstr='%s', position=4, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), scanner=dict(argstr='%s', position=1, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = PrepareFieldmap.input_spec() + inputs = PrepareFieldmap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +43,7 @@ def test_PrepareFieldmap_inputs(): def test_PrepareFieldmap_outputs(): output_map = dict(out_fieldmap=dict(), ) - outputs = PrepareFieldmap.output_spec() + outputs = PrepareFieldmap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ProbTrackX.py b/nipype/interfaces/fsl/tests/test_auto_ProbTrackX.py index a4b60ff6f6..5fde7eddc4 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ProbTrackX.py +++ b/nipype/interfaces/fsl/tests/test_auto_ProbTrackX.py @@ -14,9 +14,6 @@ def test_ProbTrackX_inputs(): ), dist_thresh=dict(argstr='--distthresh=%.3f', ), - environ=dict(nohash=True, - usedefault=True, - ), fibst=dict(argstr='--fibst=%d', ), force_dir=dict(argstr='--forcedir', @@ -24,9 +21,6 @@ def test_ProbTrackX_inputs(): ), fsamples=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inv_xfm=dict(argstr='--invxfm=%s', ), loop_check=dict(argstr='--loopcheck', @@ -58,7 +52,8 @@ def test_ProbTrackX_inputs(): out_dir=dict(argstr='--dir=%s', genfile=True, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), phsamples=dict(mandatory=True, ), rand_fib=dict(argstr='--randfib=%d', @@ -83,8 +78,6 @@ def test_ProbTrackX_inputs(): ), target_masks=dict(argstr='--targetmasks=%s', ), - terminal_output=dict(nohash=True, - ), thsamples=dict(mandatory=True, ), use_anisotropy=dict(argstr='--usef', @@ -96,7 +89,7 @@ def test_ProbTrackX_inputs(): xfm=dict(argstr='--xfm=%s', ), ) - inputs = ProbTrackX.input_spec() + inputs = ProbTrackX._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -110,7 +103,7 @@ def test_ProbTrackX_outputs(): targets=dict(), way_total=dict(), ) - outputs = ProbTrackX.output_spec() + outputs = ProbTrackX._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ProbTrackX2.py b/nipype/interfaces/fsl/tests/test_auto_ProbTrackX2.py index df69f76670..e34d3070bb 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ProbTrackX2.py +++ b/nipype/interfaces/fsl/tests/test_auto_ProbTrackX2.py @@ -20,9 +20,6 @@ def test_ProbTrackX2_inputs(): ), distthresh3=dict(argstr='--distthresh3=%.3f', ), - environ=dict(nohash=True, - usedefault=True, - ), fibst=dict(argstr='--fibst=%d', ), fopd=dict(argstr='--fopd=%s', @@ -32,9 +29,6 @@ def test_ProbTrackX2_inputs(): ), fsamples=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inv_xfm=dict(argstr='--invxfm=%s', ), loop_check=dict(argstr='--loopcheck', @@ -75,7 +69,8 @@ def test_ProbTrackX2_inputs(): out_dir=dict(argstr='--dir=%s', genfile=True, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), phsamples=dict(mandatory=True, ), rand_fib=dict(argstr='--randfib=%d', @@ -109,8 +104,6 @@ def test_ProbTrackX2_inputs(): ), target_masks=dict(argstr='--targetmasks=%s', ), - terminal_output=dict(nohash=True, - ), thsamples=dict(mandatory=True, ), use_anisotropy=dict(argstr='--usef', @@ -126,7 +119,7 @@ def test_ProbTrackX2_inputs(): xfm=dict(argstr='--xfm=%s', ), ) - inputs = ProbTrackX2.input_spec() + inputs = ProbTrackX2._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -145,7 +138,7 @@ def test_ProbTrackX2_outputs(): targets=dict(), way_total=dict(), ) - outputs = ProbTrackX2.output_spec() + outputs = ProbTrackX2._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_ProjThresh.py b/nipype/interfaces/fsl/tests/test_auto_ProjThresh.py index a8fbd352a9..8641dcc76c 100644 --- a/nipype/interfaces/fsl/tests/test_auto_ProjThresh.py +++ b/nipype/interfaces/fsl/tests/test_auto_ProjThresh.py @@ -6,25 +6,18 @@ def test_ProjThresh_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='%s', mandatory=True, position=0, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), threshold=dict(argstr='%d', mandatory=True, position=1, ), ) - inputs = ProjThresh.input_spec() + inputs = ProjThresh._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +27,7 @@ def test_ProjThresh_inputs(): def test_ProjThresh_outputs(): output_map = dict(out_files=dict(), ) - outputs = ProjThresh.output_spec() + outputs = ProjThresh._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Randomise.py b/nipype/interfaces/fsl/tests/test_auto_Randomise.py index 72a38393fd..54df4630d2 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Randomise.py +++ b/nipype/interfaces/fsl/tests/test_auto_Randomise.py @@ -19,9 +19,6 @@ def test_Randomise_inputs(): design_mat=dict(argstr='-d %s', position=2, ), - environ=dict(nohash=True, - usedefault=True, - ), f_c_thresh=dict(argstr='-F %.2f', ), f_cm_thresh=dict(argstr='-S %.2f', @@ -30,9 +27,6 @@ def test_Randomise_inputs(): ), fcon=dict(argstr='-f %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, position=0, @@ -43,7 +37,8 @@ def test_Randomise_inputs(): ), one_sample_group_mean=dict(argstr='-1', ), - output_type=dict(), + output_type=dict(usedefault=True, + ), p_vec_n_dist_files=dict(argstr='-P', ), raw_stats_imgs=dict(argstr='-R', @@ -57,8 +52,6 @@ def test_Randomise_inputs(): tcon=dict(argstr='-t %s', position=3, ), - terminal_output=dict(nohash=True, - ), tfce=dict(argstr='-T', ), tfce2D=dict(argstr='--T2', @@ -76,7 +69,7 @@ def test_Randomise_inputs(): x_block_labels=dict(argstr='-e %s', ), ) - inputs = Randomise.input_spec() + inputs = Randomise._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -91,7 +84,7 @@ def test_Randomise_outputs(): t_p_files=dict(), tstat_files=dict(), ) - outputs = Randomise.output_spec() + outputs = Randomise._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Reorient2Std.py b/nipype/interfaces/fsl/tests/test_auto_Reorient2Std.py index 0f252d5d61..21b374c4dd 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Reorient2Std.py +++ b/nipype/interfaces/fsl/tests/test_auto_Reorient2Std.py @@ -6,24 +6,16 @@ def test_Reorient2Std_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = Reorient2Std.input_spec() + inputs = Reorient2Std._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -33,7 +25,7 @@ def test_Reorient2Std_inputs(): def test_Reorient2Std_outputs(): output_map = dict(out_file=dict(), ) - outputs = Reorient2Std.output_spec() + outputs = Reorient2Std._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_RobustFOV.py b/nipype/interfaces/fsl/tests/test_auto_RobustFOV.py index d28c8845dd..53365b47e4 100644 --- a/nipype/interfaces/fsl/tests/test_auto_RobustFOV.py +++ b/nipype/interfaces/fsl/tests/test_auto_RobustFOV.py @@ -6,26 +6,17 @@ def test_RobustFOV_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, position=0, ), out_roi=dict(argstr='-r %s', hash_files=False, - name_source=['in_file'], - name_template='%s_ROI', ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = RobustFOV.input_spec() + inputs = RobustFOV._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +26,7 @@ def test_RobustFOV_inputs(): def test_RobustFOV_outputs(): output_map = dict(out_roi=dict(), ) - outputs = RobustFOV.output_spec() + outputs = RobustFOV._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_SMM.py b/nipype/interfaces/fsl/tests/test_auto_SMM.py index b2440eaa7e..bc117b0ccb 100644 --- a/nipype/interfaces/fsl/tests/test_auto_SMM.py +++ b/nipype/interfaces/fsl/tests/test_auto_SMM.py @@ -4,32 +4,36 @@ def test_SMM_inputs(): - input_map = dict(args=dict(argstr='%s', + input_map = dict(activation_p_map=dict(hash_files=False, ), - environ=dict(nohash=True, - usedefault=True, + args=dict(argstr='%s', + ), + deactivation_p_map=dict(hash_files=False, ), - ignore_exception=dict(nohash=True, + logdir=dict(argstr='--ld=%s', + mandatory=True, + position=0, usedefault=True, ), mask=dict(argstr='--mask="%s"', copyfile=False, mandatory=True, - position=1, + position=2, ), no_deactivation_class=dict(argstr='--zfstatmode', position=2, ), - output_type=dict(), + null_p_map=dict(hash_files=False, + ), + output_type=dict(usedefault=True, + ), spatial_data_file=dict(argstr='--sdf="%s"', copyfile=False, mandatory=True, - position=0, - ), - terminal_output=dict(nohash=True, + position=1, ), ) - inputs = SMM.input_spec() + inputs = SMM._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +45,7 @@ def test_SMM_outputs(): deactivation_p_map=dict(), null_p_map=dict(), ) - outputs = SMM.output_spec() + outputs = SMM._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_SUSAN.py b/nipype/interfaces/fsl/tests/test_auto_SUSAN.py index 0b813fc31e..33599c7e64 100644 --- a/nipype/interfaces/fsl/tests/test_auto_SUSAN.py +++ b/nipype/interfaces/fsl/tests/test_auto_SUSAN.py @@ -14,16 +14,10 @@ def test_SUSAN_inputs(): position=4, usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), fwhm=dict(argstr='%.10f', mandatory=True, position=3, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=1, @@ -33,8 +27,7 @@ def test_SUSAN_inputs(): hash_files=False, position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), usans=dict(argstr='', position=6, @@ -45,7 +38,7 @@ def test_SUSAN_inputs(): usedefault=True, ), ) - inputs = SUSAN.input_spec() + inputs = SUSAN._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +48,7 @@ def test_SUSAN_inputs(): def test_SUSAN_outputs(): output_map = dict(smoothed_file=dict(), ) - outputs = SUSAN.output_spec() + outputs = SUSAN._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_SigLoss.py b/nipype/interfaces/fsl/tests/test_auto_SigLoss.py index e42dc4ba88..f0ba131de2 100644 --- a/nipype/interfaces/fsl/tests/test_auto_SigLoss.py +++ b/nipype/interfaces/fsl/tests/test_auto_SigLoss.py @@ -8,27 +8,20 @@ def test_SigLoss_inputs(): ), echo_time=dict(argstr='--te=%f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, ), mask_file=dict(argstr='-m %s', ), out_file=dict(argstr='-s %s', - genfile=True, + hash_files=False, ), - output_type=dict(), - slice_direction=dict(argstr='-d %s', + output_type=dict(usedefault=True, ), - terminal_output=dict(nohash=True, + slice_direction=dict(argstr='-d %s', ), ) - inputs = SigLoss.input_spec() + inputs = SigLoss._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +31,7 @@ def test_SigLoss_inputs(): def test_SigLoss_outputs(): output_map = dict(out_file=dict(), ) - outputs = SigLoss.output_spec() + outputs = SigLoss._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_SliceTimer.py b/nipype/interfaces/fsl/tests/test_auto_SliceTimer.py index c02b80cf3b..80af4a62d6 100644 --- a/nipype/interfaces/fsl/tests/test_auto_SliceTimer.py +++ b/nipype/interfaces/fsl/tests/test_auto_SliceTimer.py @@ -10,14 +10,8 @@ def test_SliceTimer_inputs(): ), custom_timings=dict(argstr='--tcustom=%s', ), - environ=dict(nohash=True, - usedefault=True, - ), global_shift=dict(argstr='--tglobal', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--in=%s', mandatory=True, position=0, @@ -30,15 +24,14 @@ def test_SliceTimer_inputs(): genfile=True, hash_files=False, ), - output_type=dict(), - slice_direction=dict(argstr='--direction=%d', + output_type=dict(usedefault=True, ), - terminal_output=dict(nohash=True, + slice_direction=dict(argstr='--direction=%d', ), time_repetition=dict(argstr='--repeat=%f', ), ) - inputs = SliceTimer.input_spec() + inputs = SliceTimer._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -48,7 +41,7 @@ def test_SliceTimer_inputs(): def test_SliceTimer_outputs(): output_map = dict(slice_time_corrected_file=dict(), ) - outputs = SliceTimer.output_spec() + outputs = SliceTimer._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Slicer.py b/nipype/interfaces/fsl/tests/test_auto_Slicer.py index edcaafaa30..ee9067f54d 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Slicer.py +++ b/nipype/interfaces/fsl/tests/test_auto_Slicer.py @@ -17,10 +17,8 @@ def test_Slicer_inputs(): dither_edges=dict(argstr='-t', position=7, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, + hide_orientation=dict(argstr='-u', + position=9, usedefault=True, ), image_edges=dict(argstr='%s', @@ -37,6 +35,7 @@ def test_Slicer_inputs(): position=5, ), label_slices=dict(argstr='-L', + mandatory=True, position=3, usedefault=True, ), @@ -48,11 +47,11 @@ def test_Slicer_inputs(): position=8, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-1, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), sample_axial=dict(argstr='-S %d', position=10, requires=['image_width'], @@ -61,9 +60,9 @@ def test_Slicer_inputs(): scaling=dict(argstr='-s %f', position=0, ), - show_orientation=dict(argstr='%s', + show_orientation=dict(deprecated=True, + new_name='hide_orientation', position=9, - usedefault=True, ), single_slice=dict(argstr='-%s', position=10, @@ -73,13 +72,11 @@ def test_Slicer_inputs(): slice_number=dict(argstr='-%d', position=11, ), - terminal_output=dict(nohash=True, - ), threshold_edges=dict(argstr='-e %.3f', position=6, ), ) - inputs = Slicer.input_spec() + inputs = Slicer._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -89,7 +86,7 @@ def test_Slicer_inputs(): def test_Slicer_outputs(): output_map = dict(out_file=dict(), ) - outputs = Slicer.output_spec() + outputs = Slicer._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Smooth.py b/nipype/interfaces/fsl/tests/test_auto_Smooth.py index f1cebc39d7..45361f392b 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Smooth.py +++ b/nipype/interfaces/fsl/tests/test_auto_Smooth.py @@ -6,22 +6,17 @@ def test_Smooth_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fwhm=dict(argstr='-kernel gauss %.03f -fmean', mandatory=True, position=1, xor=['sigma'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=0, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), sigma=dict(argstr='-kernel gauss %.03f -fmean', mandatory=True, position=1, @@ -29,14 +24,10 @@ def test_Smooth_inputs(): ), smoothed_file=dict(argstr='%s', hash_files=False, - name_source=['in_file'], - name_template='%s_smooth', position=2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Smooth.input_spec() + inputs = Smooth._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +37,7 @@ def test_Smooth_inputs(): def test_Smooth_outputs(): output_map = dict(smoothed_file=dict(), ) - outputs = Smooth.output_spec() + outputs = Smooth._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_SmoothEstimate.py b/nipype/interfaces/fsl/tests/test_auto_SmoothEstimate.py index 5c3f8c46b0..15c142e58d 100644 --- a/nipype/interfaces/fsl/tests/test_auto_SmoothEstimate.py +++ b/nipype/interfaces/fsl/tests/test_auto_SmoothEstimate.py @@ -10,26 +10,19 @@ def test_SmoothEstimate_inputs(): mandatory=True, xor=['zstat_file'], ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), mask_file=dict(argstr='--mask=%s', mandatory=True, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), residual_fit_file=dict(argstr='--res=%s', requires=['dof'], ), - terminal_output=dict(nohash=True, - ), zstat_file=dict(argstr='--zstat=%s', xor=['dof'], ), ) - inputs = SmoothEstimate.input_spec() + inputs = SmoothEstimate._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +34,7 @@ def test_SmoothEstimate_outputs(): resels=dict(), volume=dict(), ) - outputs = SmoothEstimate.output_spec() + outputs = SmoothEstimate._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_SpatialFilter.py b/nipype/interfaces/fsl/tests/test_auto_SpatialFilter.py index ab605fed0b..bd8dddb3b5 100644 --- a/nipype/interfaces/fsl/tests/test_auto_SpatialFilter.py +++ b/nipype/interfaces/fsl/tests/test_auto_SpatialFilter.py @@ -6,12 +6,6 @@ def test_SpatialFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -32,24 +26,23 @@ def test_SpatialFilter_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), operation=dict(argstr='-f%s', mandatory=True, position=6, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = SpatialFilter.input_spec() + inputs = SpatialFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -59,7 +52,7 @@ def test_SpatialFilter_inputs(): def test_SpatialFilter_outputs(): output_map = dict(out_file=dict(), ) - outputs = SpatialFilter.output_spec() + outputs = SpatialFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Split.py b/nipype/interfaces/fsl/tests/test_auto_Split.py index a7469eca48..e227147319 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Split.py +++ b/nipype/interfaces/fsl/tests/test_auto_Split.py @@ -10,12 +10,6 @@ def test_Split_inputs(): mandatory=True, position=2, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=0, @@ -23,11 +17,10 @@ def test_Split_inputs(): out_base_name=dict(argstr='%s', position=1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = Split.input_spec() + inputs = Split._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +30,7 @@ def test_Split_inputs(): def test_Split_outputs(): output_map = dict(out_files=dict(), ) - outputs = Split.output_spec() + outputs = Split._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_SwapDimensions.py b/nipype/interfaces/fsl/tests/test_auto_SwapDimensions.py index 60dd31a304..6849741f16 100644 --- a/nipype/interfaces/fsl/tests/test_auto_SwapDimensions.py +++ b/nipype/interfaces/fsl/tests/test_auto_SwapDimensions.py @@ -6,28 +6,20 @@ def test_SwapDimensions_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, - position='1', + position=1, ), new_dims=dict(argstr='%s %s %s', mandatory=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = SwapDimensions.input_spec() + inputs = SwapDimensions._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +29,7 @@ def test_SwapDimensions_inputs(): def test_SwapDimensions_outputs(): output_map = dict(out_file=dict(), ) - outputs = SwapDimensions.output_spec() + outputs = SwapDimensions._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_TOPUP.py b/nipype/interfaces/fsl/tests/test_auto_TOPUP.py index 3e097b26ab..08ebe51c3a 100644 --- a/nipype/interfaces/fsl/tests/test_auto_TOPUP.py +++ b/nipype/interfaces/fsl/tests/test_auto_TOPUP.py @@ -9,25 +9,21 @@ def test_TOPUP_inputs(): config=dict(argstr='--config=%s', usedefault=True, ), - encoding_direction=dict(argstr='--datain=%s', - mandatory=True, + encoding_direction=dict(mandatory=True, requires=['readout_times'], xor=['encoding_file'], ), encoding_file=dict(argstr='--datain=%s', + hash_files=False, mandatory=True, + output_name='out_enc_file', + template='{in_file}_encfile.txt', xor=['encoding_direction'], ), - environ=dict(nohash=True, - usedefault=True, - ), estmov=dict(argstr='--estmov=%d', ), fwhm=dict(argstr='--fwhm=%f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--imain=%s', mandatory=True, ), @@ -41,26 +37,22 @@ def test_TOPUP_inputs(): ), out_base=dict(argstr='--out=%s', hash_files=False, - name_source=['in_file'], - name_template='%s_base', ), out_corrected=dict(argstr='--iout=%s', hash_files=False, - name_source=['in_file'], - name_template='%s_corrected', ), out_field=dict(argstr='--fout=%s', hash_files=False, - name_source=['in_file'], - name_template='%s_field', + ), + out_fieldcoef=dict(hash_files=False, ), out_logfile=dict(argstr='--logout=%s', hash_files=False, - keep_extension=True, - name_source=['in_file'], - name_template='%s_topup.log', ), - output_type=dict(), + out_movpar=dict(hash_files=False, + ), + output_type=dict(usedefault=True, + ), readout_times=dict(mandatory=True, requires=['encoding_direction'], xor=['encoding_file'], @@ -79,12 +71,10 @@ def test_TOPUP_inputs(): ), subsamp=dict(argstr='--subsamp=%d', ), - terminal_output=dict(nohash=True, - ), warp_res=dict(argstr='--warpres=%f', ), ) - inputs = TOPUP.input_spec() + inputs = TOPUP._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -99,7 +89,7 @@ def test_TOPUP_outputs(): out_logfile=dict(), out_movpar=dict(), ) - outputs = TOPUP.output_spec() + outputs = TOPUP._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_TemporalFilter.py b/nipype/interfaces/fsl/tests/test_auto_TemporalFilter.py index 049af8bd52..7e8ef612fb 100644 --- a/nipype/interfaces/fsl/tests/test_auto_TemporalFilter.py +++ b/nipype/interfaces/fsl/tests/test_auto_TemporalFilter.py @@ -6,16 +6,10 @@ def test_TemporalFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), highpass_sigma=dict(argstr='-bptf %.6f', position=4, usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -29,20 +23,19 @@ def test_TemporalFilter_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = TemporalFilter.input_spec() + inputs = TemporalFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +45,7 @@ def test_TemporalFilter_inputs(): def test_TemporalFilter_outputs(): output_map = dict(out_file=dict(), ) - outputs = TemporalFilter.output_spec() + outputs = TemporalFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_Threshold.py b/nipype/interfaces/fsl/tests/test_auto_Threshold.py index dfaa3594bb..79c340aaa4 100644 --- a/nipype/interfaces/fsl/tests/test_auto_Threshold.py +++ b/nipype/interfaces/fsl/tests/test_auto_Threshold.py @@ -8,12 +8,6 @@ def test_Threshold_inputs(): ), direction=dict(usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -23,17 +17,16 @@ def test_Threshold_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), thresh=dict(argstr='%s', mandatory=True, @@ -43,7 +36,7 @@ def test_Threshold_inputs(): ), use_robust_range=dict(), ) - inputs = Threshold.input_spec() + inputs = Threshold._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +46,7 @@ def test_Threshold_inputs(): def test_Threshold_outputs(): output_map = dict(out_file=dict(), ) - outputs = Threshold.output_spec() + outputs = Threshold._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_TractSkeleton.py b/nipype/interfaces/fsl/tests/test_auto_TractSkeleton.py index 3808504b9d..1619e77951 100644 --- a/nipype/interfaces/fsl/tests/test_auto_TractSkeleton.py +++ b/nipype/interfaces/fsl/tests/test_auto_TractSkeleton.py @@ -12,16 +12,11 @@ def test_TractSkeleton_inputs(): ), data_file=dict(), distance_map=dict(), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), project_data=dict(argstr='-p %.3f %s %s %s %s', requires=['threshold', 'distance_map', 'data_file'], ), @@ -30,14 +25,12 @@ def test_TractSkeleton_inputs(): ), skeleton_file=dict(argstr='-o %s', ), - terminal_output=dict(nohash=True, - ), threshold=dict(), use_cingulum_mask=dict(usedefault=True, xor=['search_mask_file'], ), ) - inputs = TractSkeleton.input_spec() + inputs = TractSkeleton._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -48,7 +41,7 @@ def test_TractSkeleton_outputs(): output_map = dict(projected_data=dict(), skeleton_file=dict(), ) - outputs = TractSkeleton.output_spec() + outputs = TractSkeleton._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_UnaryMaths.py b/nipype/interfaces/fsl/tests/test_auto_UnaryMaths.py index 9bc209e532..64725d5b86 100644 --- a/nipype/interfaces/fsl/tests/test_auto_UnaryMaths.py +++ b/nipype/interfaces/fsl/tests/test_auto_UnaryMaths.py @@ -6,12 +6,6 @@ def test_UnaryMaths_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=2, @@ -21,24 +15,23 @@ def test_UnaryMaths_inputs(): ), nan2zeros=dict(argstr='-nan', position=3, + usedefault=True, ), operation=dict(argstr='-%s', mandatory=True, position=4, ), out_file=dict(argstr='%s', - genfile=True, hash_files=False, position=-2, ), output_datatype=dict(argstr='-odt %s', position=-1, ), - output_type=dict(), - terminal_output=dict(nohash=True, + output_type=dict(usedefault=True, ), ) - inputs = UnaryMaths.input_spec() + inputs = UnaryMaths._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -48,7 +41,7 @@ def test_UnaryMaths_inputs(): def test_UnaryMaths_outputs(): output_map = dict(out_file=dict(), ) - outputs = UnaryMaths.output_spec() + outputs = UnaryMaths._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_VecReg.py b/nipype/interfaces/fsl/tests/test_auto_VecReg.py index 55c84c1164..04c313e829 100644 --- a/nipype/interfaces/fsl/tests/test_auto_VecReg.py +++ b/nipype/interfaces/fsl/tests/test_auto_VecReg.py @@ -8,12 +8,6 @@ def test_VecReg_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, ), @@ -25,7 +19,8 @@ def test_VecReg_inputs(): genfile=True, hash_files=False, ), - output_type=dict(), + output_type=dict(usedefault=True, + ), ref_mask=dict(argstr='--refmask=%s', ), ref_vol=dict(argstr='-r %s', @@ -35,12 +30,10 @@ def test_VecReg_inputs(): ), rotation_warp=dict(argstr='--rotwarp=%s', ), - terminal_output=dict(nohash=True, - ), warp_field=dict(argstr='-w %s', ), ) - inputs = VecReg.input_spec() + inputs = VecReg._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +43,7 @@ def test_VecReg_inputs(): def test_VecReg_outputs(): output_map = dict(out_file=dict(), ) - outputs = VecReg.output_spec() + outputs = VecReg._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_WarpPoints.py b/nipype/interfaces/fsl/tests/test_auto_WarpPoints.py index 984b3f77a1..eecae5c374 100644 --- a/nipype/interfaces/fsl/tests/test_auto_WarpPoints.py +++ b/nipype/interfaces/fsl/tests/test_auto_WarpPoints.py @@ -15,12 +15,6 @@ def test_WarpPoints_inputs(): dest_file=dict(argstr='-dest %s', mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_coords=dict(argstr='%s', mandatory=True, position=-1, @@ -32,8 +26,6 @@ def test_WarpPoints_inputs(): src_file=dict(argstr='-src %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), warp_file=dict(argstr='-warp %s', xor=['xfm_file'], ), @@ -41,7 +33,7 @@ def test_WarpPoints_inputs(): xor=['warp_file'], ), ) - inputs = WarpPoints.input_spec() + inputs = WarpPoints._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -51,7 +43,7 @@ def test_WarpPoints_inputs(): def test_WarpPoints_outputs(): output_map = dict(out_file=dict(), ) - outputs = WarpPoints.output_spec() + outputs = WarpPoints._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_WarpPointsToStd.py b/nipype/interfaces/fsl/tests/test_auto_WarpPointsToStd.py index f6ecd09f2e..7434772911 100644 --- a/nipype/interfaces/fsl/tests/test_auto_WarpPointsToStd.py +++ b/nipype/interfaces/fsl/tests/test_auto_WarpPointsToStd.py @@ -12,12 +12,6 @@ def test_WarpPointsToStd_inputs(): coord_vox=dict(argstr='-vox', xor=['coord_mm'], ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), img_file=dict(argstr='-img %s', mandatory=True, ), @@ -34,8 +28,6 @@ def test_WarpPointsToStd_inputs(): std_file=dict(argstr='-std %s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), warp_file=dict(argstr='-warp %s', xor=['xfm_file'], ), @@ -43,7 +35,7 @@ def test_WarpPointsToStd_inputs(): xor=['warp_file'], ), ) - inputs = WarpPointsToStd.input_spec() + inputs = WarpPointsToStd._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +45,7 @@ def test_WarpPointsToStd_inputs(): def test_WarpPointsToStd_outputs(): output_map = dict(out_file=dict(), ) - outputs = WarpPointsToStd.output_spec() + outputs = WarpPointsToStd._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_WarpUtils.py b/nipype/interfaces/fsl/tests/test_auto_WarpUtils.py index 065e2b455b..147d3f17b7 100644 --- a/nipype/interfaces/fsl/tests/test_auto_WarpUtils.py +++ b/nipype/interfaces/fsl/tests/test_auto_WarpUtils.py @@ -6,32 +6,23 @@ def test_WarpUtils_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='--in=%s', mandatory=True, ), knot_space=dict(argstr='--knotspace=%d,%d,%d', ), out_file=dict(argstr='--out=%s', - name_source=['in_file'], - output_name='out_file', position=-1, ), out_format=dict(argstr='--outformat=%s', ), out_jacobian=dict(argstr='--jac=%s', ), - output_type=dict(), + output_type=dict(usedefault=True, + ), reference=dict(argstr='--ref=%s', mandatory=True, ), - terminal_output=dict(nohash=True, - ), warp_resolution=dict(argstr='--warpres=%0.4f,%0.4f,%0.4f', ), with_affine=dict(argstr='--withaff', @@ -40,7 +31,7 @@ def test_WarpUtils_inputs(): usedefault=True, ), ) - inputs = WarpUtils.input_spec() + inputs = WarpUtils._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -51,7 +42,7 @@ def test_WarpUtils_outputs(): output_map = dict(out_file=dict(), out_jacobian=dict(), ) - outputs = WarpUtils.output_spec() + outputs = WarpUtils._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_XFibres4.py b/nipype/interfaces/fsl/tests/test_auto_XFibres4.py index 5fa46bb954..cf67e5300a 100644 --- a/nipype/interfaces/fsl/tests/test_auto_XFibres4.py +++ b/nipype/interfaces/fsl/tests/test_auto_XFibres4.py @@ -22,9 +22,6 @@ def test_XFibres4_inputs(): dwi=dict(argstr='--data=%s', mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), force_dir=dict(argstr='--forcedir', usedefault=True, ), @@ -32,9 +29,6 @@ def test_XFibres4_inputs(): ), gradnonlin=dict(argstr='--gradnonlin=%s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), logdir=dict(argstr='--logdir=%s', usedefault=True, ), @@ -56,17 +50,16 @@ def test_XFibres4_inputs(): non_linear=dict(argstr='--nonlinear', xor=('no_spat', 'non_linear'), ), - output_type=dict(), + output_type=dict(usedefault=True, + ), sample_every=dict(argstr='--sampleevery=%d', ), seed=dict(argstr='--seed=%d', ), - terminal_output=dict(nohash=True, - ), update_proposal_every=dict(argstr='--updateproposalevery=%d', ), ) - inputs = XFibres4.input_spec() + inputs = XFibres4._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -82,7 +75,7 @@ def test_XFibres4_outputs(): phsamples=dict(), thsamples=dict(), ) - outputs = XFibres4.output_spec() + outputs = XFibres4._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_auto_XFibres5.py b/nipype/interfaces/fsl/tests/test_auto_XFibres5.py index f877d894e5..3b4a55285b 100644 --- a/nipype/interfaces/fsl/tests/test_auto_XFibres5.py +++ b/nipype/interfaces/fsl/tests/test_auto_XFibres5.py @@ -25,9 +25,7 @@ def test_XFibres5_inputs(): dwi=dict(argstr='--data=%s', mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), + dyads=dict(), f0_ard=dict(argstr='--f0 --ardf0', xor=['f0_noard', 'f0_ard', 'all_ard'], ), @@ -37,19 +35,24 @@ def test_XFibres5_inputs(): force_dir=dict(argstr='--forcedir', usedefault=True, ), + fsamples=dict(), fudge=dict(argstr='--fudge=%d', ), gradnonlin=dict(argstr='--gradnonlin=%s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), logdir=dict(argstr='--logdir=%s', usedefault=True, ), mask=dict(argstr='--mask=%s', mandatory=True, ), + mean_S0samples=dict(keep_extension=False, + ), + mean_dsamples=dict(keep_extension=False, + ), + mean_fsamples=dict(), + mean_tausamples=dict(keep_extension=False, + ), model=dict(argstr='--model=%d', ), n_fibres=dict(argstr='--nfibres=%d', @@ -67,19 +70,21 @@ def test_XFibres5_inputs(): non_linear=dict(argstr='--nonlinear', xor=('no_spat', 'non_linear', 'cnlinear'), ), - output_type=dict(), + output_type=dict(usedefault=True, + ), + phsamples=dict(), rician=dict(argstr='--rician', + usedefault=True, ), sample_every=dict(argstr='--sampleevery=%d', ), seed=dict(argstr='--seed=%d', ), - terminal_output=dict(nohash=True, - ), + thsamples=dict(), update_proposal_every=dict(argstr='--updateproposalevery=%d', ), ) - inputs = XFibres5.input_spec() + inputs = XFibres5._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -96,7 +101,7 @@ def test_XFibres5_outputs(): phsamples=dict(), thsamples=dict(), ) - outputs = XFibres5.output_spec() + outputs = XFibres5._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/fsl/tests/test_base.py b/nipype/interfaces/fsl/tests/test_base.py index a8ec012905..06366a6139 100644 --- a/nipype/interfaces/fsl/tests/test_base.py +++ b/nipype/interfaces/fsl/tests/test_base.py @@ -4,36 +4,22 @@ from nipype.testing import (assert_equal, assert_true, assert_raises, assert_not_equal, skipif) -import nipype.interfaces.fsl as fsl +from ... import fsl +from ..base import FSLCommandInputSpec from nipype.interfaces.base import InterfaceResult from nipype.interfaces.fsl import check_fsl, no_fsl -@skipif(no_fsl) # skip if fsl not installed) def test_fslversion(): ver = fsl.Info.version() - if ver: + if check_fsl(): # If ver is None, fsl is not installed ver = ver.split('.') yield assert_true, ver[0] in ['4', '5'] + else: + yield assert_equal, None, ver -@skipif(no_fsl) # skip if fsl not installed) -def test_fsloutputtype(): - types = list(fsl.Info.ftypes.keys()) - orig_out_type = fsl.Info.output_type() - yield assert_true, orig_out_type in types - - -def test_outputtype_to_ext(): - for ftype, ext in fsl.Info.ftypes.items(): - res = fsl.Info.output_type_to_ext(ftype) - yield assert_equal, res, ext - - yield assert_raises, KeyError, fsl.Info.output_type_to_ext, 'JUNK' - - -@skipif(no_fsl) # skip if fsl not installed) def test_FSLCommand(): # Most methods in FSLCommand are tested in the subclasses. Only # testing the one item that is not. @@ -42,43 +28,14 @@ def test_FSLCommand(): yield assert_equal, type(res), InterfaceResult -@skipif(no_fsl) # skip if fsl not installed) -def test_FSLCommand2(): +def test_FSLCommandInputSpec(): # Check default output type and environ - cmd = fsl.FSLCommand(command='junk') - yield assert_equal, cmd._output_type, fsl.Info.output_type() - yield assert_equal, cmd.inputs.environ['FSLOUTPUTTYPE'], cmd._output_type - yield assert_true, cmd._output_type in fsl.Info.ftypes + fslspec = FSLCommandInputSpec() + yield assert_equal, fslspec.output_type, lambda: os.getenv('FSLOUTPUTTYPE', 'NIFTI') - cmd = fsl.FSLCommand - cmdinst = fsl.FSLCommand(command='junk') +def test_FSLCommand2(): + cmd = fsl.FSLCommand(command='junk') + yield assert_equal, cmd.inputs.environ.get('FSLOUTPUTTYPE'), cmd.inputs.output_type for out_type in fsl.Info.ftypes: - cmd.set_default_output_type(out_type) - yield assert_equal, cmd._output_type, out_type - if out_type != fsl.Info.output_type(): - # Setting class outputtype should not effect existing instances - yield assert_not_equal, cmdinst.inputs.output_type, out_type - - -@skipif(no_fsl) # skip if fsl not installed) -def test_gen_fname(): - # Test _gen_fname method of FSLCommand - cmd = fsl.FSLCommand(command='junk', output_type='NIFTI_GZ') - pth = os.getcwd() - # just the filename - fname = cmd._gen_fname('foo.nii.gz', suffix='_fsl') - desired = os.path.join(pth, 'foo_fsl.nii.gz') - yield assert_equal, fname, desired - # filename with suffix - fname = cmd._gen_fname('foo.nii.gz', suffix='_brain') - desired = os.path.join(pth, 'foo_brain.nii.gz') - yield assert_equal, fname, desired - # filename with suffix and working directory - fname = cmd._gen_fname('foo.nii.gz', suffix='_brain', cwd='/data') - desired = os.path.join('/data', 'foo_brain.nii.gz') - yield assert_equal, fname, desired - # filename with suffix and no file extension change - fname = cmd._gen_fname('foo.nii.gz', suffix='_brain.mat', - change_ext=False) - desired = os.path.join(pth, 'foo_brain.mat') - yield assert_equal, fname, desired + cmd.inputs.output_type = out_type + yield assert_equal, cmd.inputs.output_type_, fsl.Info.ftypes[out_type] diff --git a/nipype/interfaces/fsl/tests/test_dti.py b/nipype/interfaces/fsl/tests/test_dti.py index 43a3e4becf..99db9470ba 100644 --- a/nipype/interfaces/fsl/tests/test_dti.py +++ b/nipype/interfaces/fsl/tests/test_dti.py @@ -476,7 +476,7 @@ def test_distancemap(): mapper.inputs.in_file = "a.nii" # It should - yield assert_equal, mapper.cmdline, "distancemap --out=%s --in=a.nii" % os.path.join(newdir, "a_dstmap.nii") + yield assert_equal, mapper.cmdline, "distancemap --in=a.nii --out=a_dstmap.nii" # And we should be able to write out a maxima map mapper.inputs.local_max_file = True diff --git a/nipype/interfaces/fsl/tests/test_epi.py b/nipype/interfaces/fsl/tests/test_epi.py deleted file mode 100644 index 4f2b0ed2c3..0000000000 --- a/nipype/interfaces/fsl/tests/test_epi.py +++ /dev/null @@ -1,63 +0,0 @@ -# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- -# vi: set ft=python sts=4 ts=4 sw=4 et: -import os - -from tempfile import mkdtemp -from shutil import rmtree - -import numpy as np - -import nibabel as nb - -from nipype.testing import (assert_equal, assert_not_equal, - assert_raises, skipif) -import nipype.interfaces.fsl.epi as fsl -from nipype.interfaces.fsl import no_fsl - - -def create_files_in_directory(): - outdir = os.path.realpath(mkdtemp()) - cwd = os.getcwd() - os.chdir(outdir) - filelist = ['a.nii', 'b.nii'] - for f in filelist: - hdr = nb.Nifti1Header() - shape = (3, 3, 3, 4) - hdr.set_data_shape(shape) - img = np.random.random(shape) - nb.save(nb.Nifti1Image(img, np.eye(4), hdr), - os.path.join(outdir, f)) - return filelist, outdir, cwd - - -def clean_directory(outdir, old_wd): - if os.path.exists(outdir): - rmtree(outdir) - os.chdir(old_wd) - - -# test eddy_correct -@skipif(no_fsl) -def test_eddy_correct2(): - filelist, outdir, cwd = create_files_in_directory() - eddy = fsl.EddyCorrect() - - # make sure command gets called - yield assert_equal, eddy.cmd, 'eddy_correct' - - # test raising error with mandatory args absent - yield assert_raises, ValueError, eddy.run - - # .inputs based parameters setting - eddy.inputs.in_file = filelist[0] - eddy.inputs.out_file = 'foo_eddc.nii' - eddy.inputs.ref_num = 100 - yield assert_equal, eddy.cmdline, 'eddy_correct %s foo_eddc.nii 100' % filelist[0] - - # .run based parameter setting - eddy2 = fsl.EddyCorrect(in_file=filelist[0], out_file='foo_ec.nii', ref_num=20) - yield assert_equal, eddy2.cmdline, 'eddy_correct %s foo_ec.nii 20' % filelist[0] - - # test arguments for opt_map - # eddy_correct class doesn't have opt_map{} - clean_directory(outdir, cwd) diff --git a/nipype/interfaces/fsl/tests/test_maths.py b/nipype/interfaces/fsl/tests/test_maths.py index d4003e8d74..e9a245e56b 100644 --- a/nipype/interfaces/fsl/tests/test_maths.py +++ b/nipype/interfaces/fsl/tests/test_maths.py @@ -16,19 +16,6 @@ from nipype.interfaces.fsl.base import FSLCommand -def set_output_type(fsl_output_type): - prev_output_type = os.environ.get('FSLOUTPUTTYPE', None) - - if fsl_output_type is not None: - os.environ['FSLOUTPUTTYPE'] = fsl_output_type - elif 'FSLOUTPUTTYPE' in os.environ: - del os.environ['FSLOUTPUTTYPE'] - - FSLCommand.set_default_output_type(Info.output_type()) - - return prev_output_type - - def create_files_in_directory(): testdir = os.path.realpath(mkdtemp()) origdir = os.getcwd() @@ -43,7 +30,7 @@ def create_files_in_directory(): nb.save(nb.Nifti1Image(img, np.eye(4), hdr), os.path.join(testdir, f)) - out_ext = Info.output_type_to_ext(Info.output_type()) + out_ext = Info.ftypes[Info.output_type()] return filelist, testdir, origdir, out_ext @@ -54,12 +41,11 @@ def clean_directory(testdir, origdir): @skipif(no_fsl) -def test_maths_base(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) +def test_maths_base(fsl_output_type='NIFTI'): files, testdir, origdir, out_ext = create_files_in_directory() # Get some fslmaths - maths = fsl.MathsCommand() + maths = fsl.MathsCommand(output_type=fsl_output_type) # Test that we got what we wanted yield assert_equal, maths.cmd, "fslmaths" @@ -80,11 +66,11 @@ def test_maths_base(fsl_output_type=None): out_cmdline = "fslmaths a.nii " + os.path.join(testdir, out_file) + " -odt %s" duo_cmdline = "fslmaths -dt %s a.nii " + os.path.join(testdir, out_file) + " -odt %s" for dtype in dtypes: - foo = fsl.MathsCommand(in_file="a.nii", internal_datatype=dtype) + foo = fsl.MathsCommand(in_file="a.nii", internal_datatype=dtype, output_type=fsl_output_type) yield assert_equal, foo.cmdline, int_cmdline % dtype - bar = fsl.MathsCommand(in_file="a.nii", output_datatype=dtype) + bar = fsl.MathsCommand(in_file="a.nii", output_datatype=dtype, output_type=fsl_output_type) yield assert_equal, bar.cmdline, out_cmdline % dtype - foobar = fsl.MathsCommand(in_file="a.nii", internal_datatype=dtype, output_datatype=dtype) + foobar = fsl.MathsCommand(in_file="a.nii", internal_datatype=dtype, output_datatype=dtype, output_type=fsl_output_type) yield assert_equal, foobar.cmdline, duo_cmdline % (dtype, dtype) # Test that we can ask for an outfile name @@ -93,16 +79,14 @@ def test_maths_base(fsl_output_type=None): # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) -def test_changedt(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) +def test_changedt(fsl_output_type='NIFTI'): files, testdir, origdir, out_ext = create_files_in_directory() # Get some fslmaths - cdt = fsl.ChangeDataType() + cdt = fsl.ChangeDataType(output_type=fsl_output_type) # Test that we got what we wanted yield assert_equal, cdt.cmd, "fslmaths" @@ -121,21 +105,19 @@ def test_changedt(fsl_output_type=None): dtypes = ["float", "char", "int", "short", "double", "input"] cmdline = "fslmaths a.nii b.nii -odt %s" for dtype in dtypes: - foo = fsl.MathsCommand(in_file="a.nii", out_file="b.nii", output_datatype=dtype) + foo = fsl.MathsCommand(in_file="a.nii", out_file="b.nii", output_datatype=dtype, output_type=fsl_output_type) yield assert_equal, foo.cmdline, cmdline % dtype # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) -def test_threshold(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) +def test_threshold(fsl_output_type='NIFTI'): files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - thresh = fsl.Threshold(in_file="a.nii", out_file="b.nii") + thresh = fsl.Threshold(in_file="a.nii", out_file="b.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, thresh.cmd, "fslmaths" @@ -150,11 +132,11 @@ def test_threshold(fsl_output_type=None): yield assert_equal, thresh.cmdline, cmdline % "-thr %.10f" % val val = "%.10f" % 42 - thresh = fsl.Threshold(in_file="a.nii", out_file="b.nii", thresh=42, use_robust_range=True) + thresh = fsl.Threshold(in_file="a.nii", out_file="b.nii", thresh=42, use_robust_range=True, output_type=fsl_output_type) yield assert_equal, thresh.cmdline, cmdline % ("-thrp " + val) thresh.inputs.use_nonzero_voxels = True yield assert_equal, thresh.cmdline, cmdline % ("-thrP " + val) - thresh = fsl.Threshold(in_file="a.nii", out_file="b.nii", thresh=42, direction="above") + thresh = fsl.Threshold(in_file="a.nii", out_file="b.nii", thresh=42, direction="above", output_type=fsl_output_type) yield assert_equal, thresh.cmdline, cmdline % ("-uthr " + val) thresh.inputs.use_robust_range = True yield assert_equal, thresh.cmdline, cmdline % ("-uthrp " + val) @@ -163,16 +145,14 @@ def test_threshold(fsl_output_type=None): # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) -def test_meanimage(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) +def test_meanimage(fsl_output_type='NIFTI'): files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - meaner = fsl.MeanImage(in_file="a.nii", out_file="b.nii") + meaner = fsl.MeanImage(in_file="a.nii", out_file="b.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, meaner.cmd, "fslmaths" @@ -187,21 +167,19 @@ def test_meanimage(fsl_output_type=None): yield assert_equal, meaner.cmdline, cmdline % dim # Test the auto naming - meaner = fsl.MeanImage(in_file="a.nii") + meaner = fsl.MeanImage(in_file="a.nii", output_type=fsl_output_type) yield assert_equal, meaner.cmdline, "fslmaths a.nii -Tmean %s" % os.path.join(testdir, "a_mean%s" % out_ext) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) -def test_maximage(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) +def test_maximage(fsl_output_type='NIFTI'): files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - maxer = fsl.MaxImage(in_file="a.nii", out_file="b.nii") + maxer = fsl.MaxImage(in_file="a.nii", out_file="b.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, maxer.cmd, "fslmaths" @@ -216,21 +194,19 @@ def test_maximage(fsl_output_type=None): yield assert_equal, maxer.cmdline, cmdline % dim # Test the auto naming - maxer = fsl.MaxImage(in_file="a.nii") + maxer = fsl.MaxImage(in_file="a.nii", output_type=fsl_output_type) yield assert_equal, maxer.cmdline, "fslmaths a.nii -Tmax %s" % os.path.join(testdir, "a_max%s" % out_ext) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) -def test_smooth(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) +def test_smooth(fsl_output_type='NIFTI'): files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - smoother = fsl.IsotropicSmooth(in_file="a.nii", out_file="b.nii") + smoother = fsl.IsotropicSmooth(in_file="a.nii", out_file="b.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, smoother.cmd, "fslmaths" @@ -248,21 +224,19 @@ def test_smooth(fsl_output_type=None): yield assert_equal, smoother.cmdline, cmdline % val # Test automatic naming - smoother = fsl.IsotropicSmooth(in_file="a.nii", sigma=5) + smoother = fsl.IsotropicSmooth(in_file="a.nii", sigma=5, output_type=fsl_output_type) yield assert_equal, smoother.cmdline, "fslmaths a.nii -s %.5f %s" % (5, os.path.join(testdir, "a_smooth%s" % out_ext)) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) -def test_mask(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) +def test_mask(fsl_output_type='NIFTI'): files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - masker = fsl.ApplyMask(in_file="a.nii", out_file="c.nii") + masker = fsl.ApplyMask(in_file="a.nii", out_file="c.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, masker.cmd, "fslmaths" @@ -275,21 +249,19 @@ def test_mask(fsl_output_type=None): yield assert_equal, masker.cmdline, "fslmaths a.nii -mas b.nii c.nii" # Test auto name generation - masker = fsl.ApplyMask(in_file="a.nii", mask_file="b.nii") + masker = fsl.ApplyMask(in_file="a.nii", mask_file="b.nii", output_type=fsl_output_type) yield assert_equal, masker.cmdline, "fslmaths a.nii -mas b.nii " + os.path.join(testdir, "a_masked%s" % out_ext) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) def test_dilation(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - diller = fsl.DilateImage(in_file="a.nii", out_file="b.nii") + diller = fsl.DilateImage(in_file="a.nii", out_file="b.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, diller.cmd, "fslmaths" @@ -319,21 +291,19 @@ def test_dilation(fsl_output_type=None): yield assert_equal, diller.cmdline, "fslmaths a.nii -kernel file kernel.txt -dilF b.nii" # Test that we don't need to request an out name - dil = fsl.DilateImage(in_file="a.nii", operation="max") + dil = fsl.DilateImage(in_file="a.nii", operation="max", output_type=fsl_output_type) yield assert_equal, dil.cmdline, "fslmaths a.nii -dilF %s" % os.path.join(testdir, "a_dil%s" % out_ext) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) def test_erosion(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - erode = fsl.ErodeImage(in_file="a.nii", out_file="b.nii") + erode = fsl.ErodeImage(in_file="a.nii", out_file="b.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, erode.cmd, "fslmaths" @@ -346,49 +316,45 @@ def test_erosion(fsl_output_type=None): yield assert_equal, erode.cmdline, "fslmaths a.nii -eroF b.nii" # Test that we don't need to request an out name - erode = fsl.ErodeImage(in_file="a.nii") + erode = fsl.ErodeImage(in_file="a.nii", output_type=fsl_output_type) yield assert_equal, erode.cmdline, "fslmaths a.nii -ero %s" % os.path.join(testdir, "a_ero%s" % out_ext) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) def test_spatial_filter(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - filter = fsl.SpatialFilter(in_file="a.nii", out_file="b.nii") + spfilt = fsl.SpatialFilter(in_file="a.nii", out_file="b.nii", output_type=fsl_output_type) # Test the underlying command - yield assert_equal, filter.cmd, "fslmaths" + yield assert_equal, spfilt.cmd, "fslmaths" # Test that it fails without an operation - yield assert_raises, ValueError, filter.run + yield assert_raises, ValueError, spfilt.run # Test the different operations for op in ["mean", "meanu", "median"]: - filter.inputs.operation = op - yield assert_equal, filter.cmdline, "fslmaths a.nii -f%s b.nii" % op + spfilt.inputs.operation = op + yield assert_equal, spfilt.cmdline, "fslmaths a.nii -f%s b.nii" % op # Test that we don't need to ask for an out name - filter = fsl.SpatialFilter(in_file="a.nii", operation="mean") - yield assert_equal, filter.cmdline, "fslmaths a.nii -fmean %s" % os.path.join(testdir, "a_filt%s" % out_ext) + spfilt = fsl.SpatialFilter(in_file="a.nii", operation="mean", output_type=fsl_output_type) + yield assert_equal, spfilt.cmdline, "fslmaths a.nii -fmean %s" % os.path.join(testdir, "a_filt%s" % out_ext) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) def test_unarymaths(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - maths = fsl.UnaryMaths(in_file="a.nii", out_file="b.nii") + maths = fsl.UnaryMaths(in_file="a.nii", out_file="b.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, maths.cmd, "fslmaths" @@ -404,21 +370,19 @@ def test_unarymaths(fsl_output_type=None): # Test that we don't need to ask for an out file for op in ops: - maths = fsl.UnaryMaths(in_file="a.nii", operation=op) + maths = fsl.UnaryMaths(in_file="a.nii", operation=op, output_type=fsl_output_type) yield assert_equal, maths.cmdline, "fslmaths a.nii -%s %s" % (op, os.path.join(testdir, "a_%s%s" % (op, out_ext))) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) def test_binarymaths(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - maths = fsl.BinaryMaths(in_file="a.nii", out_file="c.nii") + maths = fsl.BinaryMaths(in_file="a.nii", out_file="c.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, maths.cmd, "fslmaths" @@ -431,7 +395,7 @@ def test_binarymaths(fsl_output_type=None): operands = ["b.nii", -2, -0.5, 0, .123456, np.pi, 500] for op in ops: for ent in operands: - maths = fsl.BinaryMaths(in_file="a.nii", out_file="c.nii", operation=op) + maths = fsl.BinaryMaths(in_file="a.nii", out_file="c.nii", operation=op, output_type=fsl_output_type) if ent == "b.nii": maths.inputs.operand_file = ent yield assert_equal, maths.cmdline, "fslmaths a.nii -%s b.nii c.nii" % op @@ -441,21 +405,19 @@ def test_binarymaths(fsl_output_type=None): # Test that we don't need to ask for an out file for op in ops: - maths = fsl.BinaryMaths(in_file="a.nii", operation=op, operand_file="b.nii") + maths = fsl.BinaryMaths(in_file="a.nii", operation=op, operand_file="b.nii", output_type=fsl_output_type) yield assert_equal, maths.cmdline, "fslmaths a.nii -%s b.nii %s" % (op, os.path.join(testdir, "a_maths%s" % out_ext)) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) def test_multimaths(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - maths = fsl.MultiImageMaths(in_file="a.nii", out_file="c.nii") + maths = fsl.MultiImageMaths(in_file="a.nii", out_file="c.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, maths.cmd, "fslmaths" @@ -473,22 +435,20 @@ def test_multimaths(fsl_output_type=None): yield assert_equal, maths.cmdline, "fslmaths a.nii %s c.nii" % ostr % ("a.nii", "b.nii") # Test that we don't need to ask for an out file - maths = fsl.MultiImageMaths(in_file="a.nii", op_string="-add %s -mul 5", operand_files=["b.nii"]) + maths = fsl.MultiImageMaths(in_file="a.nii", op_string="-add %s -mul 5", operand_files=["b.nii"], output_type=fsl_output_type) yield assert_equal, maths.cmdline, \ "fslmaths a.nii -add b.nii -mul 5 %s" % os.path.join(testdir, "a_maths%s" % out_ext) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) def test_tempfilt(fsl_output_type=None): - prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory() # Get the command - filt = fsl.TemporalFilter(in_file="a.nii", out_file="b.nii") + filt = fsl.TemporalFilter(in_file="a.nii", out_file="b.nii", output_type=fsl_output_type) # Test the underlying command yield assert_equal, filt.cmd, "fslmaths" @@ -504,13 +464,12 @@ def test_tempfilt(fsl_output_type=None): yield assert_equal, filt.cmdline, "fslmaths a.nii -bptf %.6f %.6f b.nii" % win # Test that we don't need to ask for an out file - filt = fsl.TemporalFilter(in_file="a.nii", highpass_sigma=64) + filt = fsl.TemporalFilter(in_file="a.nii", highpass_sigma=64, output_type=fsl_output_type) yield assert_equal, filt.cmdline, \ "fslmaths a.nii -bptf 64.000000 -1.000000 %s" % os.path.join(testdir, "a_filt%s" % out_ext) # Clean up our mess clean_directory(testdir, origdir) - set_output_type(prev_type) @skipif(no_fsl) diff --git a/nipype/interfaces/fsl/tests/test_preprocess.py b/nipype/interfaces/fsl/tests/test_preprocess.py index 1065fad6a5..90e3d33bb0 100644 --- a/nipype/interfaces/fsl/tests/test_preprocess.py +++ b/nipype/interfaces/fsl/tests/test_preprocess.py @@ -224,7 +224,7 @@ def test_flirt(): _, tmpfile = tempfile.mkstemp(suffix='.nii', dir=tmpdir) # Loop over all inputs, set a reasonable value and make sure the # cmdline is updated correctly. - for key, trait_spec in sorted(fsl.FLIRT.input_spec().traits().items()): + for key, trait_spec in sorted(fsl.FLIRT._input_spec().traits().items()): # Skip mandatory inputs and the trait methods if key in ('trait_added', 'trait_modified', 'in_file', 'reference', 'environ', 'output_type', 'out_file', 'out_matrix_file', diff --git a/nipype/interfaces/fsl/utils.py b/nipype/interfaces/fsl/utils.py index 8e58b0d8cf..eec12db6cf 100644 --- a/nipype/interfaces/fsl/utils.py +++ b/nipype/interfaces/fsl/utils.py @@ -29,26 +29,27 @@ import numpy as np from .base import FSLCommand, FSLCommandInputSpec, Info -from ..base import (traits, TraitedSpec, OutputMultiPath, File, - CommandLine, CommandLineInputSpec, isdefined) +from ..base import (traits, TraitedSpec, InputMultiPath, OutputMultiPath, + File, GenFile, CommandLine, CommandLineInputSpec, + isdefined, Undefined) from ...utils.filemanip import (load_json, save_json, split_filename, fname_presuffix, copyfile) - -warn = warnings.warn +from ... import logging +IFLOGGER = logging.getLogger('interface') class CopyGeomInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, mandatory=True, argstr="%s", position=0, - desc="source image") - dest_file = File(exists=True, mandatory=True, argstr="%s", position=1, - desc="destination image", copyfile=True, output_name='out_file', - name_source='dest_file', name_template='%s') - ignore_dims = traits.Bool(desc='Do not copy image dimensions', - argstr='-d', position="-1") + in_file = File(exists=True, mandatory=True, argstr='%s', position=0, + desc='source image') + dest_file = File(exists=True, mandatory=True, argstr='%s', position=1, + desc='destination image', copyfile=True, + output_name='out_file') + ignore_dims = traits.Bool(False, usedefault=True, argstr='-d', position=-1, + desc='Do not copy image dimensions') class CopyGeomOutputSpec(TraitedSpec): - out_file = File(exists=True, desc="image with new geometry header") + out_file = File(exists=True, desc='image with new geometry header') class CopyGeom(FSLCommand): @@ -59,53 +60,49 @@ class CopyGeom(FSLCommand): or Nifti to Nifti will work properly. Copying from different files will result in loss of information or potentially incorrect settings. """ - _cmd = "fslcpgeom" - input_spec = CopyGeomInputSpec - output_spec = CopyGeomOutputSpec + _cmd = 'fslcpgeom' + _input_spec = CopyGeomInputSpec + _output_spec = CopyGeomOutputSpec class RobustFOVInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, - desc='input filename', - argstr='-i %s', position=0, mandatory=True) - out_roi = File(desc="ROI volume output name", argstr="-r %s", - name_source=['in_file'], hash_files=False, - name_template='%s_ROI') + in_file = File(exists=True, argstr='-i %s', position=0, mandatory=True, + desc='input filename') + out_roi = GenFile(template='{in_file}_ROI{output_type_}', argstr='-r %s', + hash_files=False, desc='ROI volume output name') class RobustFOVOutputSpec(TraitedSpec): - out_roi = File(exists=True, desc="ROI volume output name") + out_roi = File(exists=True, desc='ROI volume output name') class RobustFOV(FSLCommand): _cmd = 'robustfov' - input_spec = RobustFOVInputSpec - output_spec = RobustFOVOutputSpec + _input_spec = RobustFOVInputSpec + _output_spec = RobustFOVOutputSpec class ImageMeantsInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, - desc='input file for computing the average timeseries', - argstr='-i %s', position=0, mandatory=True) - out_file = File(desc='name of output text matrix', - argstr='-o %s', genfile=True, hash_files=False) + in_file = File(exists=True, argstr='-i %s', position=0, mandatory=True, + desc='input file for computing the average timeseries') + out_file = GenFile(template='{in_file}_ts.txt', argstr='-o %s', + hash_files=False, desc='name of output text matrix') mask = File(exists=True, desc='input 3D mask', argstr='-m %s') - spatial_coord = traits.List(traits.Int, - desc=(' requested spatial coordinate ' - '(instead of mask)'), - argstr='-c %s') - use_mm = traits.Bool(desc=('use mm instead of voxel coordinates (for -c ' - 'option)'), argstr='--usemm') - show_all = traits.Bool(desc=('show all voxel time series (within mask) ' - 'instead of averaging'), argstr='--showall') - eig = traits.Bool(desc=('calculate Eigenvariate(s) instead of mean (output ' - 'will have 0 mean)'), argstr='--eig') + spatial_coord = traits.List(traits.Int, argstr='-c %s', + desc=' requested spatial coordinate ' + '(instead of mask)') + use_mm = traits.Bool(desc='use mm instead of voxel coordinates (for -c ' + 'option)', argstr='--usemm') + show_all = traits.Bool(desc='show all voxel time series (within mask) ' + 'instead of averaging', argstr='--showall') + eig = traits.Bool(desc='calculate Eigenvariate(s) instead of mean (output ' + 'will have 0 mean)', argstr='--eig') order = traits.Int(1, desc='select number of Eigenvariates', argstr='--order=%d', usedefault=True) - nobin = traits.Bool(desc=('do not binarise the mask for calculation of ' - 'Eigenvariates'), argstr='--no_bin') - transpose = traits.Bool(desc=('output results in transpose format (one row ' - 'per voxel/mean)'), argstr='--transpose') + nobin = traits.Bool(desc='do not binarise the mask for calculation of ' + 'Eigenvariates', argstr='--no_bin') + transpose = traits.Bool(desc='output results in transpose format (one row ' + 'per voxel/mean)', argstr='--transpose') class ImageMeantsOutputSpec(TraitedSpec): @@ -119,37 +116,25 @@ class ImageMeants(FSLCommand): """ _cmd = 'fslmeants' - input_spec = ImageMeantsInputSpec - output_spec = ImageMeantsOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_file - if not isdefined(outputs['out_file']): - outputs['out_file'] = self._gen_fname(self.inputs.in_file, - suffix='_ts', - ext='.txt', - change_ext=True) - outputs['out_file'] = os.path.abspath(outputs['out_file']) - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._list_outputs()[name] - return None + _input_spec = ImageMeantsInputSpec + _output_spec = ImageMeantsOutputSpec class SmoothInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, argstr="%s", position=0, mandatory=True) + in_file = File(exists=True, argstr='%s', position=0, mandatory=True) + smoothed_file = GenFile(template='{in_file}_smooth{output_type_}', argstr='%s', + position=2, hash_files=False, desc='smoothed, output file') sigma = traits.Float( - argstr="-kernel gauss %.03f -fmean", position=1, xor=['fwhm'], mandatory=True, + argstr='-kernel gauss %.03f -fmean', position=1, xor=['fwhm'], mandatory=True, desc='gaussian kernel sigma in mm (not voxels)') fwhm = traits.Float( - argstr="-kernel gauss %.03f -fmean", position=1, xor=['sigma'], mandatory=True, + argstr='-kernel gauss %.03f -fmean', position=1, xor=['sigma'], mandatory=True, desc='gaussian kernel fwhm, will be converted to sigma in mm (not voxels)') - smoothed_file = File( - argstr="%s", position=2, name_source=['in_file'], name_template='%s_smooth', hash_files=False) + def _format_arg(self, name, trait_spec, value): + if name == 'fwhm': + value = float(value) / np.sqrt(8 * np.log(2)) + return super(SmoothInputSpec, self)._format_arg(name, trait_spec, value) class SmoothOutputSpec(TraitedSpec): smoothed_file = File(exists=True) @@ -164,6 +149,7 @@ class Smooth(FSLCommand): Setting the kernel width using sigma: + >>> from nipype.interfaces.fsl import Smooth >>> sm = Smooth() >>> sm.inputs.in_file = 'functional2.nii' >>> sm.inputs.sigma = 8.0 @@ -180,43 +166,47 @@ class Smooth(FSLCommand): One of sigma or fwhm must be set: - >>> from nipype.interfaces.fsl import Smooth >>> sm = Smooth() >>> sm.inputs.in_file = 'functional2.nii' >>> sm.cmdline #doctest: +ELLIPSIS Traceback (most recent call last): ... - ValueError: Smooth requires a value for one of the inputs ... + ValueError: ... """ - input_spec = SmoothInputSpec - output_spec = SmoothOutputSpec + _input_spec = SmoothInputSpec + _output_spec = SmoothOutputSpec _cmd = 'fslmaths' - def _format_arg(self, name, trait_spec, value): - if name == 'fwhm': - sigma = float(value) / np.sqrt(8 * np.log(2)) - return super(Smooth, self)._format_arg(name, trait_spec, sigma) - return super(Smooth, self)._format_arg(name, trait_spec, value) - class MergeInputSpec(FSLCommandInputSpec): - in_files = traits.List(File(exists=True), argstr="%s", position=2, - mandatory=True) - dimension = traits.Enum('t', 'x', 'y', 'z', 'a', argstr="-%s", position=0, - desc=("dimension along which to merge, optionally " - "set tr input when dimension is t"), - mandatory=True) + in_files = InputMultiPath(File(exists=True), argstr='%s', position=2, + mandatory=True) + dimension = traits.Enum( + 't', 'x', 'y', 'z', 'a', argstr='-%s', position=0, mandatory=True, + desc='dimension along which to merge, optionally set tr input when' + ' dimension is t') tr = traits.Float(position=-1, argstr='%.2f', - desc=('use to specify TR in seconds (default is 1.00 ' - 'sec), overrides dimension and sets it to tr')) - merged_file = File(argstr="%s", position=1, name_source='in_files', - name_template='%s_merged', hash_files=False) + desc='use to specify TR in seconds (default is 1.00 sec), ' + 'overrides dimension and sets it to tr') + merged_file = GenFile( + template='{in_files[0]}_merged{output_type_}', argstr='%s', position=1, + hash_files=False, desc='output, merged file') + def _format_arg(self, name, spec, value): + if name == 'tr': + if self.dimension != 't': + raise ValueError('When TR is specified, dimension must be t') + return spec.argstr % value + if name == 'dimension': + if isdefined(self.tr): + return '-tr' + return spec.argstr % value + return super(MergeInputSpec, self)._format_arg(name, spec, value) class MergeOutputSpec(TraitedSpec): - merged_file = File(exists=True) + merged_file = File(exists=True, desc='output, merged file') class Merge(FSLCommand): @@ -247,43 +237,36 @@ class Merge(FSLCommand): """ _cmd = 'fslmerge' - input_spec = MergeInputSpec - output_spec = MergeOutputSpec - - def _format_arg(self, name, spec, value): - if name == 'tr': - if self.inputs.dimension != 't': - raise ValueError('When TR is specified, dimension must be t') - return spec.argstr % value - if name == 'dimension': - if isdefined(self.inputs.tr): - return '-tr' - return spec.argstr % value - return super(Merge, self)._format_arg(name, spec, value) + _input_spec = MergeInputSpec + _output_spec = MergeOutputSpec class ExtractROIInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, argstr="%s", - position=0, desc="input file", mandatory=True) - roi_file = File(argstr="%s", position=1, - desc="output file", genfile=True, hash_files=False) - x_min = traits.Int(argstr="%d", position=2) - x_size = traits.Int(argstr="%d", position=3) - y_min = traits.Int(argstr="%d", position=4) - y_size = traits.Int(argstr="%d", position=5) - z_min = traits.Int(argstr="%d", position=6) - z_size = traits.Int(argstr="%d", position=7) - t_min = traits.Int(argstr="%d", position=8) - t_size = traits.Int(argstr="%d", position=9) + in_file = File(exists=True, argstr='%s', + position=0, desc='input file', mandatory=True) + roi_file = GenFile(template='{in_file}_roi{output_type_}', argstr='%s', position=1, + hash_files=False, desc='output file') + x_min = traits.Int(argstr='%d', position=2) + x_size = traits.Int(argstr='%d', position=3) + y_min = traits.Int(argstr='%d', position=4) + y_size = traits.Int(argstr='%d', position=5) + z_min = traits.Int(argstr='%d', position=6) + z_size = traits.Int(argstr='%d', position=7) + t_min = traits.Int(argstr='%d', position=8) + t_size = traits.Int(argstr='%d', position=9) _crop_xor = ['x_min', 'x_size', 'y_min', 'y_size', 'z_min', 'z_size', 't_min', 't_size'] crop_list = traits.List(traits.Tuple(traits.Int, traits.Int), - argstr="%s", position=2, xor=_crop_xor, - desc="list of two tuples specifying crop options") + argstr='%s', position=2, xor=_crop_xor, + desc='list of two tuples specifying crop options') + def _format_arg(self, name, spec, value): + if name == 'crop_list': + return ' '.join(map(str, sum(list(map(list, value)), []))) + return super(ExtractROIInputSpec, self)._format_arg(name, spec, value) class ExtractROIOutputSpec(TraitedSpec): - roi_file = File(exists=True) + roi_file = File(exists=True, desc='output file') class ExtractROI(FSLCommand): @@ -303,63 +286,28 @@ class ExtractROI(FSLCommand): -------- >>> from nipype.interfaces.fsl import ExtractROI - >>> from nipype.testing import anatfile - >>> fslroi = ExtractROI(in_file=anatfile, roi_file='bar.nii', t_min=0, - ... t_size=1) - >>> fslroi.cmdline == 'fslroi %s bar.nii 0 1' % anatfile - True + >>> fslroi = ExtractROI() + >>> fslroi.inputs.in_file = 'functional.nii' + >>> fslroi.inputs.t_min = 0 + >>> fslroi.inputs.t_size = 1 + >>> fslroi.cmdline + 'fslroi functional.nii functional_roi.nii.gz 0 1' """ _cmd = 'fslroi' - input_spec = ExtractROIInputSpec - output_spec = ExtractROIOutputSpec - - def _format_arg(self, name, spec, value): - - if name == "crop_list": - return " ".join(map(str, sum(list(map(list, value)), []))) - return super(ExtractROI, self)._format_arg(name, spec, value) - - def _list_outputs(self): - """Create a Bunch which contains all possible files generated - by running the interface. Some files are always generated, others - depending on which ``inputs`` options are set. - - - Returns - ------- - - outputs : Bunch object - Bunch object containing all possible files generated by - interface object. - - If None, file was not generated - Else, contains path, filename of generated outputfile - - """ - outputs = self._outputs().get() - outputs['roi_file'] = self.inputs.roi_file - if not isdefined(outputs['roi_file']): - outputs['roi_file'] = self._gen_fname(self.inputs.in_file, - suffix='_roi') - outputs['roi_file'] = os.path.abspath(outputs['roi_file']) - return outputs - - def _gen_filename(self, name): - if name == 'roi_file': - return self._list_outputs()[name] - return None + _input_spec = ExtractROIInputSpec + _output_spec = ExtractROIOutputSpec class SplitInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, argstr="%s", position=0, mandatory=True, - desc="input filename") - out_base_name = traits.Str(argstr="%s", position=1, desc="outputs prefix") - dimension = traits.Enum('t', 'x', 'y', 'z', argstr="-%s", position=2, + in_file = File(exists=True, argstr='%s', position=0, mandatory=True, + desc='input filename') + out_base_name = traits.Str(argstr='%s', position=1, desc='outputs prefix') + dimension = traits.Enum('t', 'x', 'y', 'z', argstr='-%s', position=2, mandatory=True, - desc="dimension along which the file will be split") + desc='dimension along which the file will be split') class SplitOutputSpec(TraitedSpec): @@ -371,46 +319,31 @@ class Split(FSLCommand): time, x, y or z dimension. """ _cmd = 'fslsplit' - input_spec = SplitInputSpec - output_spec = SplitOutputSpec - - def _list_outputs(self): - """Create a Bunch which contains all possible files generated - by running the interface. Some files are always generated, others - depending on which ``inputs`` options are set. + _input_spec = SplitInputSpec + _output_spec = SplitOutputSpec - Returns - ------- - - outputs : Bunch object - Bunch object containing all possible files generated by - interface object. - - If None, file was not generated - Else, contains path, filename of generated outputfile - - """ - outputs = self._outputs().get() - ext = Info.output_type_to_ext(self.inputs.output_type) + def _post_run(self): + ext = self.inputs.output_type_ outbase = 'vol*' if isdefined(self.inputs.out_base_name): outbase = '%s*' % self.inputs.out_base_name - outputs['out_files'] = sorted(glob(os.path.join(os.getcwd(), - outbase + ext))) - return outputs + self.outputs.out_files = sorted(glob(os.path.join(os.getcwd(), + outbase + ext))) class ImageMathsInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, argstr="%s", mandatory=True, position=1) - in_file2 = File(exists=True, argstr="%s", position=3) - out_file = File(argstr="%s", position=4, genfile=True, hash_files=False) - op_string = traits.Str(argstr="%s", position=2, - desc="string defining the operation, i. e. -add") - suffix = traits.Str(desc="out_file suffix") - out_data_type = traits.Enum('char', 'short', 'int', 'float', 'double', - 'input', argstr="-odt %s", position=5, - desc=("output datatype, one of (char, short, " - "int, float, double, input)")) + in_file = File(exists=True, argstr='%s', mandatory=True, position=1) + in_file2 = File(exists=True, argstr='%s', position=3) + out_file = GenFile( + template='{in_file}_maths{output_type_}', argstr='%s', position=4, + hash_files=False) + op_string = traits.Str(argstr='%s', position=2, + desc='string defining the operation, i. e. -add') + suffix = traits.Str(desc='out_file suffix', deprecated=True) + out_data_type = traits.Enum('char', 'short', 'int', 'float', 'double', 'input', + argstr='-odt %s', position=5, + desc='output datatype, one of (char, short, ' + 'int, float, double, input)') class ImageMathsOutputSpec(TraitedSpec): @@ -427,68 +360,60 @@ class ImageMaths(FSLCommand): >>> from nipype.interfaces import fsl >>> from nipype.testing import anatfile - >>> maths = fsl.ImageMaths(in_file=anatfile, op_string= '-add 5', - ... out_file='foo_maths.nii') - >>> maths.cmdline == 'fslmaths %s -add 5 foo_maths.nii' % anatfile - True + >>> maths = fsl.ImageMaths() + >>> maths.inputs.in_file = 'anatomical.nii' + >>> maths.inputs.op_string= '-add 5' + >>> maths.cmdline + 'fslmaths anatomical.nii -add 5 anatomical_maths.nii.gz' """ - input_spec = ImageMathsInputSpec - output_spec = ImageMathsOutputSpec - + _input_spec = ImageMathsInputSpec + _output_spec = ImageMathsOutputSpec _cmd = 'fslmaths' - def _gen_filename(self, name): - if name == 'out_file': - return self._list_outputs()[name] - return None - - def _parse_inputs(self, skip=None): - return super(ImageMaths, self)._parse_inputs(skip=['suffix']) - - def _list_outputs(self): - suffix = '_maths' # ohinds: build suffix - if isdefined(self.inputs.suffix): - suffix = self.inputs.suffix - outputs = self._outputs().get() - outputs['out_file'] = self.inputs.out_file - if not isdefined(outputs['out_file']): - outputs['out_file'] = self._gen_fname(self.inputs.in_file, - suffix=suffix) - outputs['out_file'] = os.path.abspath(outputs['out_file']) - return outputs - class FilterRegressorInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, argstr="-i %s", - desc="input file name (4D image)", mandatory=True, + in_file = File(exists=True, argstr='-i %s', + desc='input file name (4D image)', mandatory=True, position=1) - out_file = File(argstr="-o %s", - desc="output file name for the filtered data", - genfile=True, position=2, hash_files=False) - design_file = File(exists=True, argstr="-d %s", position=3, mandatory=True, - desc=("name of the matrix with time courses (e.g. GLM " - "design or MELODIC mixing matrix)")) - filter_columns = traits.List(traits.Int, argstr="-f '%s'", - xor=["filter_all"], mandatory=True, + out_file = File(template='{in_file}_regfilt{output_type_}', + argstr='-o %s', position=2, hash_files=False, + desc='output file name for the filtered data') + design_file = File(exists=True, argstr='-d %s', position=3, mandatory=True, + desc='name of the matrix with time courses (e.g. GLM ' + 'design or MELODIC mixing matrix)') + filter_columns = traits.List(traits.Int, argstr='-f \'%s\'', + xor=['filter_all'], mandatory=True, position=4, - desc=("(1-based) column indices to filter out " - "of the data")) - filter_all = traits.Bool(mandatory=True, argstr="-f '%s'", - xor=["filter_columns"], position=4, - desc=("use all columns in the design file in " - "denoising")) - mask = File(exists=True, argstr="-m %s", desc="mask image file name") - var_norm = traits.Bool(argstr="--vn", - desc="perform variance-normalization on data") - out_vnscales = traits.Bool(argstr="--out_vnscales", - desc=("output scaling factors for variance " - "normalization")) + desc='(1-based) column indices to filter out ' + 'of the data') + filter_all = traits.Bool(mandatory=True, argstr='-f \'%s\'', + xor=['filter_columns'], position=4, + desc='use all columns in the design file in ' + 'denoising') + mask = File(exists=True, argstr='-m %s', desc='mask image file name') + var_norm = traits.Bool(argstr='--vn', + desc='perform variance-normalization on data') + out_vnscales = traits.Bool(argstr='--out_vnscales', + desc='output scaling factors for variance ' + 'normalization') + + def _format_arg(self, name, trait_spec, value): + if name == 'filter_columns': + return trait_spec.argstr % ','.join(map(str, value)) + elif name == 'filter_all': + design = np.loadtxt(self.design_file) + try: + n_cols = design.shape[1] + except IndexError: + n_cols = 1 + return trait_spec.argstr % ','.join(map(str, list(range(1, n_cols + 1)))) + return super(FilterRegressorInputSpec, self)._format_arg(name, trait_spec, value) class FilterRegressorOutputSpec(TraitedSpec): - out_file = File(exists=True, desc="output file name for the filtered data") + out_file = File(exists=True, desc='output file name for the filtered data') class FilterRegressor(FSLCommand): @@ -496,51 +421,37 @@ class FilterRegressor(FSLCommand): Uses simple OLS regression on 4D images """ - input_spec = FilterRegressorInputSpec - output_spec = FilterRegressorOutputSpec + _input_spec = FilterRegressorInputSpec + _output_spec = FilterRegressorOutputSpec _cmd = 'fsl_regfilt' - def _format_arg(self, name, trait_spec, value): - if name == 'filter_columns': - return trait_spec.argstr % ",".join(map(str, value)) - elif name == "filter_all": - design = np.loadtxt(self.inputs.design_file) - try: - n_cols = design.shape[1] - except IndexError: - n_cols = 1 - return trait_spec.argstr % ",".join(map(str, list(range(1, n_cols + 1)))) - return super(FilterRegressor, self)._format_arg(name, trait_spec, value) - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_file - if not isdefined(outputs['out_file']): - outputs['out_file'] = self._gen_fname( - self.inputs.in_file, suffix='_regfilt') - outputs['out_file'] = os.path.abspath(outputs['out_file']) - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._list_outputs()[name] - return None - class ImageStatsInputSpec(FSLCommandInputSpec): split_4d = traits.Bool(argstr='-t', position=1, - desc=('give a separate output line for each 3D ' - 'volume of a 4D timeseries')) - in_file = File(exists=True, argstr="%s", mandatory=True, position=2, + desc='give a separate output line for each 3D ' + 'volume of a 4D timeseries') + in_file = File(exists=True, argstr='%s', mandatory=True, position=2, desc='input file to generate stats of') - op_string = traits.Str(argstr="%s", mandatory=True, position=3, - desc=("string defining the operation, options are " - "applied in order, e.g. -M -l 10 -M will " - "report the non-zero mean, apply a threshold " - "and then report the new nonzero mean")) - mask_file = File(exists=True, argstr="", + op_string = traits.Str(argstr='%s', mandatory=True, position=3, + desc='string defining the operation, options are ' + 'applied in order, e.g. -M -l 10 -M will ' + 'report the non-zero mean, apply a threshold ' + 'and then report the new nonzero mean') + mask_file = File(exists=True, argstr='-k %s', desc='mask file used for option -k %s') + def _format_arg(self, name, trait_spec, value): + if name == 'mask_file': + return '' + if name == 'op_string': + if '-k %s' in value: + if isdefined(self.mask_file): + return self.op_string % self.mask_file + else: + raise ValueError( + '-k %s option in op_string requires mask_file') + return super(ImageStatsInputSpec, self)._format_arg(name, trait_spec, value) + class ImageStatsOutputSpec(TraitedSpec): out_stat = traits.Any(desc='stats output') @@ -563,22 +474,12 @@ class ImageStats(FSLCommand): """ - input_spec = ImageStatsInputSpec - output_spec = ImageStatsOutputSpec + _input_spec = ImageStatsInputSpec + _output_spec = ImageStatsOutputSpec _cmd = 'fslstats' - def _format_arg(self, name, trait_spec, value): - if name == 'mask_file': - return '' - if name == 'op_string': - if '-k %s' in self.inputs.op_string: - if isdefined(self.inputs.mask_file): - return self.inputs.op_string % self.inputs.mask_file - else: - raise ValueError( - '-k %s option in op_string requires mask_file') - return super(ImageStats, self)._format_arg(name, trait_spec, value) + def aggregate_outputs(self, runtime=None, needed_outputs=None): outputs = self._outputs() @@ -602,11 +503,10 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None): out_stat = out_stat[0] save_json(outfile, dict(stat=out_stat)) outputs.out_stat = out_stat - return outputs class AvScaleInputSpec(FSLCommandInputSpec): - mat_file = File(exists=True, argstr="%s", + mat_file = File(exists=True, argstr='%s', desc='mat file to read', position=0) @@ -635,8 +535,8 @@ class AvScale(FSLCommand): """ - input_spec = AvScaleInputSpec - output_spec = AvScaleOutputSpec + _input_spec = AvScaleInputSpec + _output_spec = AvScaleOutputSpec _cmd = 'avscale' @@ -656,18 +556,17 @@ def lines_to_float(lines): out = runtime.stdout.split('\n') outputs.rotation_translation_matrix = lines_to_float(out[1:5]) - outputs.scales = lines_to_float([out[6].split(" = ")[1]]) - outputs.skews = lines_to_float([out[8].split(" = ")[1]]) - outputs.average_scaling = lines_to_float([out[10].split(" = ")[1]]) - outputs.determinant = lines_to_float([out[12].split(" = ")[1]]) - if out[13].split(": ")[1] == 'preserved': + outputs.scales = lines_to_float([out[6].split(' = ')[1]]) + outputs.skews = lines_to_float([out[8].split(' = ')[1]]) + outputs.average_scaling = lines_to_float([out[10].split(' = ')[1]]) + outputs.determinant = lines_to_float([out[12].split(' = ')[1]]) + if out[13].split(': ')[1] == 'preserved': outputs.left_right_orientation_preserved = True else: outputs.left_right_orientation_preserved = False outputs.forward_half_transform = lines_to_float(out[16:20]) outputs.backward_half_transform = lines_to_float(out[22:-1]) - return outputs class OverlayInputSpec(FSLCommandInputSpec): @@ -682,8 +581,8 @@ class OverlayInputSpec(FSLCommandInputSpec): background_image = File(exists=True, position=4, mandatory=True, argstr='%s', desc='image to use as background') _xor_inputs = ('auto_thresh_bg', 'full_bg_range', 'bg_thresh') - auto_thresh_bg = traits.Bool(desc=('automatically threshold the background ' - 'image'), + auto_thresh_bg = traits.Bool(desc='automatically threshold the background ' + 'image', argstr='-a', position=5, xor=_xor_inputs, mandatory=True) full_bg_range = traits.Bool(desc='use full range of background image', @@ -697,20 +596,38 @@ class OverlayInputSpec(FSLCommandInputSpec): desc='statistical image to overlay in color') stat_thresh = traits.Tuple(traits.Float, traits.Float, position=7, mandatory=True, argstr='%.2f %.2f', - desc=('min and max values for the statistical ' - 'overlay')) - show_negative_stats = traits.Bool(desc=('display negative statistics in ' - 'overlay'), xor=['stat_image2'], + desc='min and max values for the statistical ' + 'overlay') + show_negative_stats = traits.Bool(desc='display negative statistics in ' + 'overlay', xor=['stat_image2'], argstr='%s', position=8) stat_image2 = File(exists=True, position=9, xor=['show_negative_stats'], argstr='%s', desc='second statistical image to overlay in color') stat_thresh2 = traits.Tuple(traits.Float, traits.Float, position=10, - desc=('min and max values for second ' - 'statistical overlay'), + desc='min and max values for second ' + 'statistical overlay', argstr='%.2f %.2f') - out_file = File(desc='combined image volume', - position=-1, argstr='%s', genfile=True, hash_files=False) + out_file = GenFile(template='overlay{output_type_}', position=-1, argstr='%s', + hash_files=False, desc='combined image volume') + + + def _format_arg(self, name, spec, value): + if name == 'transparency': + if value: + return '1' + else: + return '0' + if name == 'out_type': + if value == 'float': + return '0' + else: + return '1' + if name == 'show_negative_stats': + return '%s %.2f %.2f' % (self.stat_image, + self.stat_thresh[0] * -1, + self.stat_thresh[1] * -1) + return super(OverlayInputSpec, self)._format_arg(name, spec, value) class OverlayOutputSpec(TraitedSpec): @@ -732,102 +649,75 @@ class Overlay(FSLCommand): >>> combine.inputs.stat_image = 'zstat1.nii.gz' >>> combine.inputs.stat_thresh = (3.5, 10) >>> combine.inputs.show_negative_stats = True + >>> combine.cmdline + 'overlay 1 0 mean_func.nii.gz -a zstat1.nii.gz 3.50 10.00 zstat1.nii.gz -3.50 -10.00 overlay.nii.gz' >>> res = combine.run() #doctest: +SKIP """ _cmd = 'overlay' - input_spec = OverlayInputSpec - output_spec = OverlayOutputSpec - - def _format_arg(self, name, spec, value): - if name == 'transparency': - if value: - return '1' - else: - return '0' - if name == 'out_type': - if value == 'float': - return '0' - else: - return '1' - if name == 'show_negative_stats': - return '%s %.2f %.2f' % (self.inputs.stat_image, - self.inputs.stat_thresh[0] * -1, - self.inputs.stat_thresh[1] * -1) - return super(Overlay, self)._format_arg(name, spec, value) - - def _list_outputs(self): - outputs = self._outputs().get() - out_file = self.inputs.out_file - if not isdefined(out_file): - if isdefined(self.inputs.stat_image2) and ( - not isdefined(self.inputs.show_negative_stats) or not - self.inputs.show_negative_stats): - stem = "%s_and_%s" % (split_filename(self.inputs.stat_image)[1], - split_filename(self.inputs.stat_image2)[1]) - else: - stem = split_filename(self.inputs.stat_image)[1] - out_file = self._gen_fname(stem, suffix='_overlay') - outputs['out_file'] = os.path.abspath(out_file) - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._list_outputs()['out_file'] - return None + _input_spec = OverlayInputSpec + _output_spec = OverlayOutputSpec class SlicerInputSpec(FSLCommandInputSpec): in_file = File(exists=True, position=1, argstr='%s', mandatory=True, desc='input volume') image_edges = File(exists=True, position=2, argstr='%s', - desc=('volume to display edge overlay for (useful for ' - 'checking registration')) + desc='volume to display edge overlay for (useful for ' + 'checking registration') label_slices = traits.Bool( - position=3, argstr='-L', desc='display slice number', - usedefault=True, default_value=True) + True, position=3, argstr='-L', desc='display slice number', + usedefault=True, mandatory=True) colour_map = File(exists=True, position=4, argstr='-l %s', - desc=('use different colour map from that stored in ' - 'nifti header')) + desc='use different colour map from that stored in ' + 'nifti header') intensity_range = traits.Tuple(traits.Float, traits.Float, position=5, argstr='-i %.3f %.3f', desc='min and max intensities to display') threshold_edges = traits.Float(position=6, argstr='-e %.3f', desc='use threshold for edges') dither_edges = traits.Bool(position=7, argstr='-t', - desc=('produce semi-transparent (dithered) ' - 'edges')) + desc='produce semi-transparent (dithered) ' + 'edges') nearest_neighbour = traits.Bool(position=8, argstr='-n', - desc=('use nearest neighbor interpolation ' - 'for output')) - show_orientation = traits.Bool(position=9, argstr='%s', usedefault=True, - default_value=True, + desc='use nearest neighbor interpolation ' + 'for output') + hide_orientation = traits.Bool(False, position=9, argstr='-u', usedefault=True, desc='label left-right orientation') + show_orientation = traits.Bool(True, position=9, deprecated=True, + new_name='hide_orientation') + _xor_options = ('single_slice', 'middle_slices', 'all_axial', 'sample_axial') single_slice = traits.Enum('x', 'y', 'z', position=10, argstr='-%s', xor=_xor_options, requires=['slice_number'], - desc=('output picture of single slice in the x, ' - 'y, or z plane')) + desc='output picture of single slice in the x, ' + 'y, or z plane') slice_number = traits.Int(position=11, argstr='-%d', desc='slice number to save in picture') middle_slices = traits.Bool(position=10, argstr='-a', xor=_xor_options, - desc=('output picture of mid-sagittal, axial, ' - 'and coronal slices')) + desc='output picture of mid-sagittal, axial, ' + 'and coronal slices') all_axial = traits.Bool(position=10, argstr='-A', xor=_xor_options, requires=['image_width'], desc='output all axial slices into one picture') sample_axial = traits.Int(position=10, argstr='-S %d', xor=_xor_options, requires=['image_width'], - desc=('output every n axial slices into one ' - 'picture')) - image_width = traits.Int( - position=-2, argstr='%d', desc='max picture width') - out_file = File(position=-1, genfile=True, argstr='%s', - desc='picture to write', hash_files=False) + desc='output every n axial slices into one ' + 'picture') + image_width = traits.Int(position=-2, argstr='%d', desc='max picture width') scaling = traits.Float(position=0, argstr='-s %f', desc='image scale') + out_file = GenFile(template='{in_file}.png', position=-1, argstr='%s', + desc='picture to write', hash_files=False) + + + def _format_arg(self, name, spec, value): + if name == 'show_orientation': + return None if value else '-u' + return super(SlicerInputSpec, self)._format_arg(name, spec, value) + class SlicerOutputSpec(TraitedSpec): out_file = File(exists=True, desc='picture to write') @@ -841,86 +731,60 @@ class Slicer(FSLCommand): -------- >>> from nipype.interfaces import fsl - >>> from nipype.testing import example_data >>> slice = fsl.Slicer() - >>> slice.inputs.in_file = example_data('functional.nii') + >>> slice.inputs.in_file = 'functional.nii' >>> slice.inputs.all_axial = True >>> slice.inputs.image_width = 750 + >>> slice.cmdline + 'slicer functional.nii -L -A 750 functional.png' >>> res = slice.run() #doctest: +SKIP """ _cmd = 'slicer' - input_spec = SlicerInputSpec - output_spec = SlicerOutputSpec - - def _format_arg(self, name, spec, value): - if name == 'show_orientation': - if value: - return '' - else: - return '-u' - elif name == "label_slices": - if value: - return '-L' - else: - return '' - return super(Slicer, self)._format_arg(name, spec, value) - - def _list_outputs(self): - outputs = self._outputs().get() - out_file = self.inputs.out_file - if not isdefined(out_file): - out_file = self._gen_fname(self.inputs.in_file, ext='.png') - outputs['out_file'] = os.path.abspath(out_file) - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._list_outputs()['out_file'] - return None + _input_spec = SlicerInputSpec + _output_spec = SlicerOutputSpec class PlotTimeSeriesInputSpec(FSLCommandInputSpec): - in_file = traits.Either(File(exists=True), traits.List(File(exists=True)), - mandatory=True, argstr="%s", position=1, - desc=("file or list of files with columns of " - "timecourse information")) - plot_start = traits.Int(argstr="--start=%d", xor=("plot_range",), - desc="first column from in-file to plot") - plot_finish = traits.Int(argstr="--finish=%d", xor=("plot_range",), - desc="final column from in-file to plot") - plot_range = traits.Tuple(traits.Int, traits.Int, argstr="%s", - xor=("plot_start", "plot_finish"), - desc=("first and last columns from the in-file " - "to plot")) - title = traits.Str(argstr="%s", desc="plot title") - legend_file = File(exists=True, argstr="--legend=%s", desc="legend file") - labels = traits.Either(traits.Str, traits.List(traits.Str), - argstr="%s", desc="label or list of labels") - y_min = traits.Float(argstr="--ymin=%.2f", desc="minumum y value", - xor=("y_range",)) - y_max = traits.Float(argstr="--ymax=%.2f", desc="maximum y value", - xor=("y_range",)) - y_range = traits.Tuple(traits.Float, traits.Float, argstr="%s", - xor=("y_min", "y_max"), - desc="min and max y axis values") - x_units = traits.Int(argstr="-u %d", usedefault=True, default_value=1, - desc=("scaling units for x-axis (between 1 and length " - "of in file)")) - plot_size = traits.Tuple(traits.Int, traits.Int, argstr="%s", - desc="plot image height and width") - x_precision = traits.Int(argstr="--precision=%d", - desc="precision of x-axis labels") - sci_notation = traits.Bool(argstr="--sci", - desc="switch on scientific notation") - out_file = File(argstr="-o %s", genfile=True, - desc="image to write", hash_files=False) + in_file = InputMultiPath( + File(exists=True), sep=',', mandatory=True, argstr='%s', position=1, + desc='file or list of files with columns of timecourse information') + plot_start = traits.Int(argstr='--start=%d', xor=['plot_range'], + desc='first column from in-file to plot') + plot_finish = traits.Int(argstr='--finish=%d', xor=['plot_range',], + desc='final column from in-file to plot') + plot_range = traits.Tuple( + traits.Int, traits.Int, argstr='--start=%d --finish=%d', + xor=['plot_start', 'plot_finish'], + desc='first and last columns from the in-file to plot') + title = traits.Str(argstr='-t \'%s\'', desc='plot title') + legend_file = File(exists=True, argstr='--legend=%s', desc='legend file') + labels = traits.Either(traits.Str, traits.List(traits.Str), sep=',', + argstr='-a %s', desc='label or list of labels') + y_min = traits.Float(argstr="--ymin=%.2f", desc='minumum y value', + xor=['y_range']) + y_max = traits.Float(argstr="--ymax=%.2f", desc='maximum y value', + xor=['y_range']) + y_range = traits.Tuple( + traits.Float, traits.Float, argstr='--ymin=%.2f --ymax=%.2f', + xor=['y_min', 'y_max'], desc='min and max y axis values') + x_units = traits.Int(argstr='-u %d', usedefault=True, default_value=1, + desc='scaling units for x-axis (between 1 and length ' + 'of in file)') + plot_size = traits.Tuple( + traits.Int, traits.Int, argstr='-h %d -w %d', + desc='plot image height and width') + x_precision = traits.Int(argstr='--precision=%d', + desc='precision of x-axis labels') + sci_notation = traits.Bool(argstr='--sci', + desc='switch on scientific notation') + out_file = File(template='{in_file}.png', argstr='-o %s', + desc='image to write', hash_files=False) class PlotTimeSeriesOutputSpec(TraitedSpec): - out_file = File(exists=True, desc='image to write') @@ -932,78 +796,66 @@ class PlotTimeSeries(FSLCommand): >>> import nipype.interfaces.fsl as fsl >>> plotter = fsl.PlotTimeSeries() - >>> plotter.inputs.in_file = 'functional.par' + >>> plotter.inputs.in_file = ['functional.par', 'functional.par'] >>> plotter.inputs.title = 'Functional timeseries' >>> plotter.inputs.labels = ['run1', 'run2'] + >>> plotter.cmdline + "fsl_tsplot functional.par,functional.par -a run1,run2 -t 'Functional timeseries' -u 1" >>> plotter.run() #doctest: +SKIP """ - _cmd = "fsl_tsplot" - input_spec = PlotTimeSeriesInputSpec - output_spec = PlotTimeSeriesOutputSpec + _cmd = 'fsl_tsplot' + _input_spec = PlotTimeSeriesInputSpec + _output_spec = PlotTimeSeriesOutputSpec + + +class PlotMotionParamsInputSpec(FSLCommandInputSpec): + in_file = InputMultiPath( + File(exists=True), mandatory=True, argstr='-i %s', sep=',', position=1, + desc='file with motion parameters') + in_source = traits.Enum('spm', 'fsl', mandatory=True, + desc='which program generated the motion ' + 'parameter file - fsl, spm') + plot_type = traits.Enum('rotations', 'translations', 'displacement', + argstr='%s', mandatory=True, + desc='which motion type to plot - rotations, ' + 'translations, displacement') + plot_size = traits.Tuple(traits.Int, traits.Int, argstr='-h %d -w %d', + desc='plot image height and width') + out_file = File(template='{in_file}_{plot_type[:5]}.png', argstr='-o %s', + desc='image to write', hash_files=False) + def _format_arg(self, name, spec, value): - if name == "in_file": - if isinstance(value, list): - args = ",".join(value) - return "-i %s" % args - else: - return "-i %s" % value - elif name == "labels": - if isinstance(value, list): - args = ",".join(value) - return "-a %s" % args - else: - return "-a %s" % value - elif name == "title": - return "-t \'%s\'" % value - elif name == "plot_range": - return "--start=%d --finish=%d" % value - elif name == "y_range": - return "--ymin=%d --ymax=%d" % value - elif name == "plot_size": - return "-h %d -w %d" % value - return super(PlotTimeSeries, self)._format_arg(name, spec, value) - - def _list_outputs(self): - outputs = self._outputs().get() - out_file = self.inputs.out_file - if not isdefined(out_file): - if isinstance(self.inputs.in_file, list): - infile = self.inputs.in_file[0] - else: - infile = self.inputs.in_file - out_file = self._gen_fname(infile, ext='.png') - outputs['out_file'] = os.path.abspath(out_file) - return outputs - def _gen_filename(self, name): - if name == 'out_file': - return self._list_outputs()['out_file'] - return None + if name == 'plot_type': + source = self.in_source + if self.plot_type == 'displacement': + title = '-t \'MCFLIRT estimated mean displacement (mm)\'' + labels = '-a abs,rel' + return '%s %s' % (title, labels) -class PlotMotionParamsInputSpec(FSLCommandInputSpec): + # Get the right starting and ending position depending on source + # package + sfdict = dict(fsl_rot=(1, 3), fsl_tra=( + 4, 6), spm_rot=(4, 6), spm_tra=(1, 3)) + + # Format the title properly + sfstr = "--start=%d --finish=%d" % sfdict[ + '%s_%s' % (source, value[:3])] + titledict = dict(fsl='MCFLIRT', spm='Realign') + unitdict = dict(rot='radians', tra='mm') - in_file = traits.Either(File(exists=True), traits.List(File(exists=True)), - mandatory=True, argstr="%s", position=1, - desc="file with motion parameters") - in_source = traits.Enum("spm", "fsl", mandatory=True, - desc=("which program generated the motion " - "parameter file - fsl, spm")) - plot_type = traits.Enum("rotations", "translations", "displacement", - argstr="%s", mandatory=True, - desc=("which motion type to plot - rotations, " - "translations, displacement")) - plot_size = traits.Tuple(traits.Int, traits.Int, argstr="%s", - desc="plot image height and width") - out_file = File(argstr="-o %s", genfile=True, - desc="image to write", hash_files=False) + title = "\'%s estimated %s (%s)\'" % ( + titledict[source], value, unitdict[value[:3]]) + return '-t %s %s -a x,y,z' % (title, sfstr) + return super(PlotMotionParamsInputSpec, self)._format_arg(name, spec, value) -class PlotMotionParamsOutputSpec(TraitedSpec): +class PlotMotionParamsOutputSpec(TraitedSpec): out_file = File(exists=True, desc='image to write') @@ -1020,6 +872,8 @@ class PlotMotionParams(FSLCommand): >>> plotter.inputs.in_file = 'functional.par' >>> plotter.inputs.in_source = 'fsl' >>> plotter.inputs.plot_type = 'rotations' + >>> plotter.cmdline + "fsl_tsplot -i functional.par -t 'MCFLIRT estimated rotations (radians)' --start=1 --finish=3 -a x,y,z" >>> res = plotter.run() #doctest: +SKIP @@ -1035,89 +889,54 @@ class PlotMotionParams(FSLCommand): """ _cmd = 'fsl_tsplot' - input_spec = PlotMotionParamsInputSpec - output_spec = PlotMotionParamsOutputSpec - - def _format_arg(self, name, spec, value): - - if name == "plot_type": - source = self.inputs.in_source - - if self.inputs.plot_type == 'displacement': - title = '-t \'MCFLIRT estimated mean displacement (mm)\'' - labels = '-a abs,rel' - return '%s %s' % (title, labels) - - # Get the right starting and ending position depending on source - # package - sfdict = dict(fsl_rot=(1, 3), fsl_tra=( - 4, 6), spm_rot=(4, 6), spm_tra=(1, 3)) - - # Format the title properly - sfstr = "--start=%d --finish=%d" % sfdict[ - "%s_%s" % (source, value[:3])] - titledict = dict(fsl="MCFLIRT", spm="Realign") - unitdict = dict(rot="radians", tra="mm") - - title = "\'%s estimated %s (%s)\'" % ( - titledict[source], value, unitdict[value[:3]]) + _input_spec = PlotMotionParamsInputSpec + _output_spec = PlotMotionParamsOutputSpec - return "-t %s %s -a x,y,z" % (title, sfstr) - elif name == "plot_size": - return "-h %d -w %d" % value - elif name == "in_file": - if isinstance(value, list): - args = ",".join(value) - return "-i %s" % args - else: - return "-i %s" % value - - return super(PlotMotionParams, self)._format_arg(name, spec, value) - def _list_outputs(self): - outputs = self._outputs().get() - out_file = self.inputs.out_file - if not isdefined(out_file): - if isinstance(self.inputs.in_file, list): - infile = self.inputs.in_file[0] - else: - infile = self.inputs.in_file - plttype = dict(rot="rot", tra="trans", dis="disp")[ - self.inputs.plot_type[:3]] - out_file = fname_presuffix( - infile, suffix="_%s.png" % plttype, use_ext=False) - outputs['out_file'] = os.path.abspath(out_file) - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._list_outputs()['out_file'] - return None +class ConvertXFMInputSpec(FSLCommandInputSpec): + in_file = File(exists=True, mandatory=True, argstr='%s', position=-1, + desc='input transformation matrix') + in_file2 = File(exists=True, argstr='%s', position=-2, + desc='second input matrix (for use with fix_scale_skew or ' + 'concat_xfm') + operation = traits.Enum( + 'inverse', 'concat', 'fixscaleskew', usedefault=True, mandatory=True, + argstr='-%s', position=-3, desc='operation mode') + + _options = ['invert_xfm', 'concat_xfm', 'fix_scale_skew'] + invert_xfm = traits.Bool(argstr='-inverse', position=-3, xor=_options, + desc='invert input transformation') + concat_xfm = traits.Bool(argstr='-concat', position=-3, xor=_options, + requires=['in_file2'], + desc='write joint transformation of two input ' + 'matrices') + fix_scale_skew = traits.Bool(argstr='-fixscaleskew', position=-3, + xor=_options, requires=['in_file2'], + desc='use secondary matrix to fix scale and ' + 'skew') + out_file = GenFile(template='{in_file}_{operation[:3]}.mat', argstr='-omat %s', position=1, + desc='final transformation matrix', hash_files=False) + + def parse_args(self, skip=None): + if skip is None: + skip = [] + if isdefined(self.invert_xfm) and self.invert_xfm: + self.invert_xfm = Undefined + self.operation = 'inverse' + if isdefined(self.concat_xfm) and self.concat_xfm: + self.concat_xfm = Undefined + self.operation = 'concat' + if isdefined(self.fix_scale_skew) and self.fix_scale_skew: + self.fix_scale_skew = Undefined + self.operation = 'fixscaleskew' -class ConvertXFMInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, mandatory=True, argstr="%s", position=-1, - desc="input transformation matrix") - in_file2 = File(exists=True, argstr="%s", position=-2, - desc=("second input matrix (for use with fix_scale_skew or " - "concat_xfm")) - _options = ["invert_xfm", "concat_xfm", "fix_scale_skew"] - invert_xfm = traits.Bool(argstr="-inverse", position=-3, xor=_options, - desc="invert input transformation") - concat_xfm = traits.Bool(argstr="-concat", position=-3, xor=_options, - requires=["in_file2"], - desc=("write joint transformation of two input " - "matrices")) - fix_scale_skew = traits.Bool(argstr="-fixscaleskew", position=-3, - xor=_options, requires=["in_file2"], - desc=("use secondary matrix to fix scale and " - "skew")) - out_file = File(genfile=True, argstr="-omat %s", position=1, - desc="final transformation matrix", hash_files=False) + skip += ['invert_xfm', 'concat_xfm', 'fix_scale_skew'] + return super(ConvertXFMInputSpec, self).parse_args(skip) class ConvertXFMOutputSpec(TraitedSpec): - out_file = File(exists=True, desc="output transformation matrix") + out_file = File(exists=True, desc='output transformation matrix') class ConvertXFM(FSLCommand): @@ -1128,67 +947,42 @@ class ConvertXFM(FSLCommand): >>> import nipype.interfaces.fsl as fsl >>> invt = fsl.ConvertXFM() - >>> invt.inputs.in_file = "flirt.mat" + >>> invt.inputs.in_file = 'flirt.mat' >>> invt.inputs.invert_xfm = True - >>> invt.inputs.out_file = 'flirt_inv.mat' >>> invt.cmdline 'convert_xfm -omat flirt_inv.mat -inverse flirt.mat' + >>> invt.inputs.in_file2 = 'flirt.mat' + >>> invt.inputs.invert_xfm = False + >>> invt.inputs.operation = 'concat' + >>> invt.cmdline + 'convert_xfm -omat flirt_con.mat -concat flirt.mat flirt.mat' - """ - _cmd = "convert_xfm" - input_spec = ConvertXFMInputSpec - output_spec = ConvertXFMOutputSpec - - def _list_outputs(self): - outputs = self._outputs().get() - outfile = self.inputs.out_file - if not isdefined(outfile): - _, infile1, _ = split_filename(self.inputs.in_file) - if self.inputs.invert_xfm: - outfile = fname_presuffix(infile1, - suffix="_inv.mat", - newpath=os.getcwd(), - use_ext=False) - else: - if self.inputs.concat_xfm: - _, infile2, _ = split_filename(self.inputs.in_file2) - outfile = fname_presuffix("%s_%s" % (infile1, infile2), - suffix=".mat", - newpath=os.getcwd(), - use_ext=False) - else: - outfile = fname_presuffix(infile1, - suffix="_fix.mat", - newpath=os.getcwd(), - use_ext=False) - outputs["out_file"] = os.path.abspath(outfile) - return outputs + """ - def _gen_filename(self, name): - if name == "out_file": - return self._list_outputs()["out_file"] - return None + _cmd = 'convert_xfm' + _input_spec = ConvertXFMInputSpec + _output_spec = ConvertXFMOutputSpec class SwapDimensionsInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, mandatory=True, argstr="%s", position="1", - desc="input image") - _dims = ["x", "-x", "y", "-y", "z", - "-z", "RL", "LR", "AP", "PA", "IS", "SI"] + in_file = File(exists=True, mandatory=True, argstr='%s', position=1, + desc='input image') + _dims = ['x', '-x', 'y', '-y', 'z', + '-z', 'RL', 'LR', 'AP', 'PA', 'IS', 'SI'] new_dims = traits.Tuple(traits.Enum(_dims), traits.Enum(_dims), - traits.Enum(_dims), argstr="%s %s %s", + traits.Enum(_dims), argstr='%s %s %s', mandatory=True, - desc="3-tuple of new dimension order") - out_file = File(genfile=True, argstr="%s", - desc="image to write", hash_files=False) + desc='3-tuple of new dimension order') + out_file = GenFile( + template='{in_file}_newdims{output_type_}', argstr='%s', + desc='image to write', hash_files=False) class SwapDimensionsOutputSpec(TraitedSpec): - - out_file = File(exists=True, desc="image with new dimensions") + out_file = File(exists=True, desc='image with new dimensions') class SwapDimensions(FSLCommand): @@ -1199,33 +993,20 @@ class SwapDimensions(FSLCommand): (-)x, (-)y, or (-z), or nifti-syle dimension codes (RL, LR, AP, PA, IS, SI). """ - _cmd = "fslswapdim" - input_spec = SwapDimensionsInputSpec - output_spec = SwapDimensionsOutputSpec - - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_file"] = self.inputs.out_file - if not isdefined(self.inputs.out_file): - outputs["out_file"] = self._gen_fname(self.inputs.in_file, - suffix='_newdims') - outputs["out_file"] = os.path.abspath(outputs["out_file"]) - return outputs - - def _gen_filename(self, name): - if name == "out_file": - return self._list_outputs()["out_file"] - return None + _cmd = 'fslswapdim' + _input_spec = SwapDimensionsInputSpec + _output_spec = SwapDimensionsOutputSpec class PowerSpectrumInputSpec(FSLCommandInputSpec): # We use position args here as list indices - so a negative number # will put something on the end in_file = File(exists=True, - desc="input 4D file to estimate the power spectrum", + desc='input 4D file to estimate the power spectrum', argstr='%s', position=0, mandatory=True) - out_file = File(desc='name of output 4D file for power spectrum', - argstr='%s', position=1, genfile=True, hash_files=False) + out_file = GenFile( + template='{in_file}_ps{output_type_}', argstr='%s', position=1, hash_files=False, + desc='name of output 4D file for power spectrum') class PowerSpectrumOutputSpec(TraitedSpec): @@ -1248,25 +1029,8 @@ class PowerSpectrum(FSLCommand): """ _cmd = 'fslpspec' - input_spec = PowerSpectrumInputSpec - output_spec = PowerSpectrumOutputSpec - - def _gen_outfilename(self): - out_file = self.inputs.out_file - if not isdefined(out_file) and isdefined(self.inputs.in_file): - out_file = self._gen_fname(self.inputs.in_file, - suffix='_ps') - return out_file - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = os.path.abspath(self._gen_outfilename()) - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._gen_outfilename() - return None + _input_spec = PowerSpectrumInputSpec + _output_spec = PowerSpectrumOutputSpec class SigLossInputSpec(FSLCommandInputSpec): @@ -1274,9 +1038,9 @@ class SigLossInputSpec(FSLCommandInputSpec): exists=True, argstr='-i %s', desc='b0 fieldmap file') - out_file = File(argstr='-s %s', - desc='output signal loss estimate file', - genfile=True) + out_file = GenFile( + template='{in_file}_sigloss{output_type_}', argstr='-s %s', hash_files=False, + desc='output signal loss estimate file') mask_file = File(exists=True, argstr='-m %s', @@ -1300,34 +1064,21 @@ class SigLoss(FSLCommand): -------- >>> sigloss = SigLoss() - >>> sigloss.inputs.in_file = "phase.nii" + >>> sigloss.inputs.in_file = 'phase.nii' >>> sigloss.inputs.echo_time = 0.03 >>> res = sigloss.run() # doctest: +SKIP """ - input_spec = SigLossInputSpec - output_spec = SigLossOuputSpec + _input_spec = SigLossInputSpec + _output_spec = SigLossOuputSpec _cmd = 'sigloss' - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_file - if not isdefined(outputs['out_file']) and \ - isdefined(self.inputs.in_file): - outputs['out_file'] = self._gen_fname(self.inputs.in_file, - suffix='_sigloss') - return outputs - - def _gen_filename(self, name): - if name == 'out_file': - return self._list_outputs()['out_file'] - return None - class Reorient2StdInputSpec(FSLCommandInputSpec): - in_file = File(exists=True, mandatory=True, argstr="%s") - out_file = File(genfile=True, hash_files=False, argstr="%s") + in_file = File(exists=True, mandatory=True, argstr='%s') + out_file = GenFile(template='{in_file}_reoriented{output_type_}', + hash_files=False, argstr='%s') class Reorient2StdOutputSpec(TraitedSpec): @@ -1343,83 +1094,66 @@ class Reorient2Std(FSLCommand): -------- >>> reorient = Reorient2Std() - >>> reorient.inputs.in_file = "functional.nii" + >>> reorient.inputs.in_file = 'functional.nii' >>> res = reorient.run() # doctest: +SKIP """ _cmd = 'fslreorient2std' - input_spec = Reorient2StdInputSpec - output_spec = Reorient2StdOutputSpec - - def _gen_filename(self, name): - if name == 'out_file': - return self._gen_fname(self.inputs.in_file, - suffix="_reoriented") - return None - - def _list_outputs(self): - outputs = self.output_spec().get() - if not isdefined(self.inputs.out_file): - outputs['out_file'] = self._gen_filename('out_file') - else: - outputs['out_file'] = os.path.abspath(self.inputs.out_file) - return outputs + _input_spec = Reorient2StdInputSpec + _output_spec = Reorient2StdOutputSpec class InvWarpInputSpec(FSLCommandInputSpec): warp = File(exists=True, argstr='--warp=%s', mandatory=True, - desc=('Name of file containing warp-coefficients/fields. This ' + desc='Name of file containing warp-coefficients/fields. This ' 'would typically be the output from the --cout switch of ' 'fnirt (but can also use fields, like the output from ' - '--fout).')) + '--fout).') reference = File(exists=True, argstr='--ref=%s', mandatory=True, - desc=('Name of a file in target space. Note that the ' + desc='Name of a file in target space. Note that the ' 'target space is now different from the target ' 'space that was used to create the --warp file. It ' 'would typically be the file that was specified ' - 'with the --in argument when running fnirt.')) - inverse_warp = File(argstr='--out=%s', name_source=['warp'], - hash_files=False, name_template='%s_inverse', - desc=('Name of output file, containing warps that are ' - 'the "reverse" of those in --warp. This will be ' - 'a field-file (rather than a file of spline ' - 'coefficients), and it will have any affine ' - 'component included as part of the ' - 'displacements.')) + 'with the --in argument when running fnirt.') absolute = traits.Bool(argstr='--abs', xor=['relative'], - desc=('If set it indicates that the warps in --warp ' + desc='If set it indicates that the warps in --warp ' 'should be interpreted as absolute, provided ' 'that it is not created by fnirt (which ' 'always uses relative warps). If set it also ' 'indicates that the output --out should be ' - 'absolute.')) + 'absolute.') relative = traits.Bool(argstr='--rel', xor=['absolute'], - desc=('If set it indicates that the warps in --warp ' + desc='If set it indicates that the warps in --warp ' 'should be interpreted as relative. I.e. the ' 'values in --warp are displacements from the ' 'coordinates in the --ref space. If set it ' 'also indicates that the output --out should ' - 'be relative.')) + 'be relative.') niter = traits.Int(argstr='--niter=%d', - desc=('Determines how many iterations of the ' - 'gradient-descent search that should be run.')) + desc='Determines how many iterations of the ' + 'gradient-descent search that should be run.') regularise = traits.Float(argstr='--regularise=%f', desc='Regularization strength (deafult=1.0).') noconstraint = traits.Bool(argstr='--noconstraint', desc='Do not apply Jacobian constraint') jacobian_min = traits.Float(argstr='--jmin=%f', - desc=('Minimum acceptable Jacobian value for ' - 'constraint (default 0.01)')) + desc='Minimum acceptable Jacobian value for ' + 'constraint (default 0.01)') jacobian_max = traits.Float(argstr='--jmax=%f', - desc=('Maximum acceptable Jacobian value for ' - 'constraint (default 100.0)')) + desc='Maximum acceptable Jacobian value for ' + 'constraint (default 100.0)') + inverse_warp = GenFile( + template='{warp}_inverse{output_type_}', argstr='--out=%s', hash_files=False, + desc='Name of output file, containing warps that are the \'reverse\' of those in' + ' --warp. This will be a field-file (rather than a file of spline coefficients),' + ' and it will have any affine component included as part of the displacements.') class InvWarpOutputSpec(TraitedSpec): inverse_warp = File(exists=True, - desc=('Name of output file, containing warps that are ' - 'the "reverse" of those in --warp.')) + desc='Name of output file, containing warps that are ' + 'the \'reverse\' of those in --warp.') class InvWarp(FSLCommand): @@ -1432,9 +1166,9 @@ class InvWarp(FSLCommand): >>> from nipype.interfaces.fsl import InvWarp >>> invwarp = InvWarp() - >>> invwarp.inputs.warp = "struct2mni.nii" - >>> invwarp.inputs.reference = "anatomical.nii" - >>> invwarp.inputs.output_type = "NIFTI_GZ" + >>> invwarp.inputs.warp = 'struct2mni.nii' + >>> invwarp.inputs.reference = 'anatomical.nii' + >>> invwarp.inputs.output_type = 'NIFTI_GZ' >>> invwarp.cmdline 'invwarp --out=struct2mni_inverse.nii.gz --ref=anatomical.nii --warp=struct2mni.nii' >>> res = invwarp.run() # doctest: +SKIP @@ -1442,19 +1176,19 @@ class InvWarp(FSLCommand): """ - input_spec = InvWarpInputSpec - output_spec = InvWarpOutputSpec + _input_spec = InvWarpInputSpec + _output_spec = InvWarpOutputSpec _cmd = 'invwarp' class ComplexInputSpec(FSLCommandInputSpec): - complex_in_file = File(exists=True, argstr="%s", position=2) - complex_in_file2 = File(exists=True, argstr="%s", position=3) + complex_in_file = File(exists=True, argstr='%s', position=2) + complex_in_file2 = File(exists=True, argstr='%s', position=3) - real_in_file = File(exists=True, argstr="%s", position=2) - imaginary_in_file = File(exists=True, argstr="%s", position=3) - magnitude_in_file = File(exists=True, argstr="%s", position=2) + real_in_file = File(exists=True, argstr='%s', position=2) + imaginary_in_file = File(exists=True, argstr='%s', position=3) + magnitude_in_file = File(exists=True, argstr='%s', position=2) phase_in_file = File(exists=True, argstr='%s', position=3) _ofs = ['complex_out_file', @@ -1464,16 +1198,6 @@ class ComplexInputSpec(FSLCommandInputSpec): 'complex_cartesian', 'complex_polar', 'complex_split', 'complex_merge', ] - complex_out_file = File(genfile=True, argstr="%s", position=-3, - xor=_ofs + _conversion[:2]) - magnitude_out_file = File(genfile=True, argstr="%s", position=-4, - xor=_ofs[:1] + _ofs[3:] + _conversion[1:]) - phase_out_file = File(genfile=True, argstr="%s", position=-3, - xor=_ofs[:1] + _ofs[3:] + _conversion[1:]) - real_out_file = File(genfile=True, argstr="%s", position=-4, - xor=_ofs[:3] + _conversion[:1] + _conversion[2:]) - imaginary_out_file = File(genfile=True, argstr="%s", position=-3, - xor=_ofs[:3] + _conversion[:1] + _conversion[2:]) start_vol = traits.Int(position=-2, argstr='%d') end_vol = traits.Int(position=-1, argstr='%d') @@ -1499,6 +1223,29 @@ class ComplexInputSpec(FSLCommandInputSpec): position=1,) # requires=['complex_in_file','complex_in_file2','complex_out_file']) + # Auto-generate output file names + complex_out_file = GenFile( + template='generated_cplx{output_type_}', argstr='%s', position=-3) + magnitude_out_file = GenFile( + template='{complex_in_file}_mag{output_type_}', argstr='%s', position=-4) + phase_out_file = GenFile( + template='{complex_in_file}_phase{output_type_}', argstr='%s', position=-3) + real_out_file = GenFile( + template='{complex_in_file}_real{output_type_}', argstr='%s', position=-4) + imaginary_out_file = GenFile( + template='{complex_in_file}_imag{output_type_}', argstr='%s', position=-3) + + + def parse_args(self, skip=None): + if skip is None: + skip = [] + if self.real_cartesian: + skip += self._ofs[:3] + elif self.real_polar: + skip += self._ofs[:1] + self._ofs[3:] + else: + skip += self._ofs[1:] + return super(ComplexInputSpec, self).parse_args(skip) class ComplexOuputSpec(TraitedSpec): magnitude_out_file = File() @@ -1515,91 +1262,38 @@ class Complex(FSLCommand): -------- >>> cplx = Complex() - >>> cplx.inputs.complex_in_file = "complex.nii" + >>> cplx.inputs.complex_in_file = 'complex.nii' >>> cplx.real_polar = True >>> res = cplx.run() # doctest: +SKIP """ _cmd = 'fslcomplex' - input_spec = ComplexInputSpec - output_spec = ComplexOuputSpec - - def _parse_inputs(self, skip=None): - if skip is None: - skip = [] - if self.inputs.real_cartesian: - skip += self.inputs._ofs[:3] - elif self.inputs.real_polar: - skip += self.inputs._ofs[:1] + self.inputs._ofs[3:] - else: - skip += self.inputs._ofs[1:] - return super(Complex, self)._parse_inputs(skip) - - def _gen_filename(self, name): - if name == 'complex_out_file': - if self.inputs.complex_cartesian: - in_file = self.inputs.real_in_file - elif self.inputs.complex_polar: - in_file = self.inputs.magnitude_in_file - elif self.inputs.complex_split or self.inputs.complex_merge: - in_file = self.inputs.complex_in_file - else: - return None - return self._gen_fname(in_file, suffix="_cplx") - elif name == 'magnitude_out_file': - return self._gen_fname(self.inputs.complex_in_file, suffix="_mag") - elif name == 'phase_out_file': - return self._gen_fname(self.inputs.complex_in_file, suffix="_phase") - elif name == 'real_out_file': - return self._gen_fname(self.inputs.complex_in_file, suffix="_real") - elif name == 'imaginary_out_file': - return self._gen_fname(self.inputs.complex_in_file, suffix="_imag") - return None - - def _get_output(self, name): - output = getattr(self.inputs, name) - if not isdefined(output): - output = self._gen_filename(name) - return os.path.abspath(output) - - def _list_outputs(self): - outputs = self.output_spec().get() - if self.inputs.complex_cartesian or self.inputs.complex_polar or \ - self.inputs.complex_split or self.inputs.complex_merge: - outputs['complex_out_file'] = self._get_output('complex_out_file') - elif self.inputs.real_cartesian: - outputs['real_out_file'] = self._get_output('real_out_file') - outputs['imaginary_out_file'] = self._get_output( - 'imaginary_out_file') - elif self.inputs.real_polar: - outputs['magnitude_out_file'] = self._get_output( - 'magnitude_out_file') - outputs['phase_out_file'] = self._get_output('phase_out_file') - return outputs + _input_spec = ComplexInputSpec + _output_spec = ComplexOuputSpec class WarpUtilsInputSpec(FSLCommandInputSpec): in_file = File(exists=True, argstr='--in=%s', mandatory=True, - desc=('Name of file containing warp-coefficients/fields. This ' + desc='Name of file containing warp-coefficients/fields. This ' 'would typically be the output from the --cout switch of ' 'fnirt (but can also use fields, like the output from ' - '--fout).')) + '--fout).') reference = File(exists=True, argstr='--ref=%s', mandatory=True, - desc=('Name of a file in target space. Note that the ' + desc='Name of a file in target space. Note that the ' 'target space is now different from the target ' 'space that was used to create the --warp file. It ' 'would typically be the file that was specified ' - 'with the --in argument when running fnirt.')) + 'with the --in argument when running fnirt.') out_format = traits.Enum('spline', 'field', argstr='--outformat=%s', - desc=('Specifies the output format. If set to field (default) ' + desc='Specifies the output format. If set to field (default) ' 'the output will be a (4D) field-file. If set to spline ' - 'the format will be a (4D) file of spline coefficients.')) + 'the format will be a (4D) file of spline coefficients.') warp_resolution = traits.Tuple(traits.Float, traits.Float, traits.Float, argstr='--warpres=%0.4f,%0.4f,%0.4f', - desc=('Specifies the resolution/knot-spacing of the splines pertaining ' + desc='Specifies the resolution/knot-spacing of the splines pertaining ' 'to the coefficients in the --out file. This parameter is only ' 'relevant if --outformat is set to spline. It should be noted ' 'that if the --in file has a higher resolution, the resulting ' @@ -1607,40 +1301,46 @@ class WarpUtilsInputSpec(FSLCommandInputSpec): ' sense) file in the space of fields with the --warpres' ' resolution. It should also be noted that the resolution ' 'will always be an integer multiple of the voxel ' - 'size.')) + 'size.') knot_space = traits.Tuple(traits.Int, traits.Int, traits.Int, argstr='--knotspace=%d,%d,%d', - desc=('Alternative (to --warpres) specification of the resolution of ' - 'the output spline-field.')) + desc='Alternative (to --warpres) specification of the resolution of ' + 'the output spline-field.') - out_file = File(argstr='--out=%s', position=-1, name_source=['in_file'], output_name='out_file', - desc=('Name of output file. The format of the output depends on what other ' - 'parameters are set. The default format is a (4D) field-file. If the ' - '--outformat is set to spline the format will be a (4D) file of spline ' - 'coefficients.')) + out_file = GenFile( + template='{in_file}_{out_format}{output_type_}', argstr='--out=%s', position=-1, + desc='Name of output file. The format of the output depends on what other ' + 'parameters are set. The default format is a (4D) field-file. If the ' + '--outformat is set to spline the format will be a (4D) file of spline ' + 'coefficients.') write_jacobian = traits.Bool(False, mandatory=True, usedefault=True, desc='Switch on --jac flag with automatically generated filename') - out_jacobian = File(argstr='--jac=%s', - desc=('Specifies that a (3D) file of Jacobian determinants corresponding ' - 'to --in should be produced and written to filename.')) + out_jacobian = GenFile(template='{in_file}_jac{output_type_}', argstr='--jac=%s', + desc='Specifies that a (3D) file of Jacobian determinants corresponding ' + 'to --in should be produced and written to filename.') with_affine = traits.Bool(False, argstr='--withaff', - desc=('Specifies that the affine transform (i.e. that which was ' + desc='Specifies that the affine transform (i.e. that which was ' 'specified for the --aff parameter in fnirt) should be ' 'included as displacements in the --out file. That can be ' 'useful for interfacing with software that cannot decode ' 'FSL/fnirt coefficient-files (where the affine transform is ' - 'stored separately from the displacements).')) + 'stored separately from the displacements).') + def parse_args(self, skip=None): + if skip is None: + skip = [] + if not self.write_jacobian: + skip += ['out_jacobian'] + return super(WarpUtilsInputSpec, self).parse_args(skip) class WarpUtilsOutputSpec(TraitedSpec): - out_file = File( - desc=('Name of output file, containing the warp as field or coefficients.')) - out_jacobian = File(desc=('Name of output file, containing the map of the determinant of ' - 'the Jacobian')) + out_file = File(desc='Name of output file, containing the warp as field or coefficients.') + out_jacobian = File(desc='Name of output file, containing the map of the determinant of ' + 'the Jacobian') class WarpUtils(FSLCommand): @@ -1653,67 +1353,48 @@ class WarpUtils(FSLCommand): >>> from nipype.interfaces.fsl import WarpUtils >>> warputils = WarpUtils() - >>> warputils.inputs.in_file = "warpfield.nii" - >>> warputils.inputs.reference = "T1.nii" + >>> warputils.inputs.in_file = 'warpfield.nii' + >>> warputils.inputs.reference = 'T1.nii' >>> warputils.inputs.out_format = 'spline' >>> warputils.inputs.warp_resolution = (10,10,10) - >>> warputils.inputs.output_type = "NIFTI_GZ" + >>> warputils.inputs.output_type = 'NIFTI_GZ' >>> warputils.cmdline # doctest: +ELLIPSIS - 'fnirtfileutils --in=warpfield.nii --outformat=spline --ref=T1.nii --warpres=10.0000,10.0000,10.0000 --out=warpfield_coeffs.nii.gz' + 'fnirtfileutils --in=warpfield.nii --outformat=spline --ref=T1.nii --warpres=10.0000,10.0000,10.0000 --out=warpfield_spline.nii.gz' >>> res = invwarp.run() # doctest: +SKIP """ - input_spec = WarpUtilsInputSpec - output_spec = WarpUtilsOutputSpec + _input_spec = WarpUtilsInputSpec + _output_spec = WarpUtilsOutputSpec _cmd = 'fnirtfileutils' - def _parse_inputs(self, skip=None): - if skip is None: - skip = [] - - suffix = 'field' - if isdefined(self.inputs.out_format) and self.inputs.out_format == 'spline': - suffix = 'coeffs' - - trait_spec = self.inputs.trait('out_file') - trait_spec.name_template = "%s_" + suffix - - if self.inputs.write_jacobian: - if not isdefined(self.inputs.out_jacobian): - jac_spec = self.inputs.trait('out_jacobian') - jac_spec.name_source = ['in_file'] - jac_spec.name_template = '%s_jac' - jac_spec.output_name = 'out_jacobian' - else: - skip += ['out_jacobian'] - - skip += ['write_jacobian'] - return super(WarpUtils, self)._parse_inputs(skip=skip) + def post_run(self): + if not self.inputs.write_jacobian: + self.outputs.out_jacobian = Undefined class ConvertWarpInputSpec(FSLCommandInputSpec): reference = File(exists=True, argstr='--ref=%s', mandatory=True, position=1, desc='Name of a file in target space of the full transform.') - out_file = File(argstr='--out=%s', position=-1, name_source=['reference'], - name_template='%s_concatwarp', output_name='out_file', - desc=('Name of output file, containing warps that are the combination of all ' - 'those given as arguments. The format of this will be a field-file (rather ' - 'than spline coefficients) with any affine components included.')) + out_file = GenFile( + template='{reference}_concatwarp{output_type_}', argstr='--out=%s', position=-1, + desc='Name of output file, containing warps that are the combination of all ' + 'those given as arguments. The format of this will be a field-file (rather ' + 'than spline coefficients) with any affine components included.') premat = File(exists=True, argstr='--premat=%s', desc='filename for pre-transform (affine matrix)') warp1 = File(exists=True, argstr='--warp1=%s', desc='Name of file containing initial warp-fields/coefficients (follows premat). This could e.g. be a ' - 'fnirt-transform from a subjects structural scan to an average of a group ' - 'of subjects.') + 'fnirt-transform from a subjects structural scan to an average of a group ' + 'of subjects.') - midmat = File(exists=True, argstr="--midmat=%s", - desc="Name of file containing mid-warp-affine transform") + midmat = File(exists=True, argstr='--midmat=%s', + desc='Name of file containing mid-warp-affine transform') warp2 = File(exists=True, argstr='--warp2=%s', desc='Name of file containing secondary warp-fields/coefficients (after warp1/midmat but before postmat). This could e.g. be a ' @@ -1726,48 +1407,48 @@ class ConvertWarpInputSpec(FSLCommandInputSpec): 'Talairach-space (if indeed there is one).') shift_in_file = File(exists=True, argstr='--shiftmap=%s', - desc='Name of file containing a "shiftmap", a non-linear transform with ' + desc='Name of file containing a \'shiftmap\', a non-linear transform with ' 'displacements only in one direction (applied first, before premat). This would typically be a ' 'fieldmap that has been pre-processed using fugue that maps a ' 'subjects functional (EPI) data onto an undistorted space (i.e. a space ' 'that corresponds to his/her true anatomy).') shift_direction = traits.Enum('y-', 'y', 'x', 'x-', 'z', 'z-', - argstr="--shiftdir=%s", requires=['shift_in_file'], + argstr='--shiftdir=%s', requires=['shift_in_file'], desc='Indicates the direction that the distortions from ' - '--shiftmap goes. It depends on the direction and ' - 'polarity of the phase-encoding in the EPI sequence.') + '--shiftmap goes. It depends on the direction and ' + 'polarity of the phase-encoding in the EPI sequence.') cons_jacobian = traits.Bool(False, argstr='--constrainj', desc='Constrain the Jacobian of the warpfield to lie within specified ' - 'min/max limits.') + 'min/max limits.') jacobian_min = traits.Float(argstr='--jmin=%f', desc='Minimum acceptable Jacobian value for ' - 'constraint (default 0.01)') + 'constraint (default 0.01)') jacobian_max = traits.Float(argstr='--jmax=%f', desc='Maximum acceptable Jacobian value for ' - 'constraint (default 100.0)') + 'constraint (default 100.0)') abswarp = traits.Bool(argstr='--abs', xor=['relwarp'], desc='If set it indicates that the warps in --warp1 and --warp2 should be ' - 'interpreted as absolute. I.e. the values in --warp1/2 are the ' - 'coordinates in the next space, rather than displacements. This flag ' - 'is ignored if --warp1/2 was created by fnirt, which always creates ' - 'relative displacements.') + 'interpreted as absolute. I.e. the values in --warp1/2 are the ' + 'coordinates in the next space, rather than displacements. This flag ' + 'is ignored if --warp1/2 was created by fnirt, which always creates ' + 'relative displacements.') relwarp = traits.Bool(argstr='--rel', xor=['abswarp'], desc='If set it indicates that the warps in --warp1/2 should be interpreted ' - 'as relative. I.e. the values in --warp1/2 are displacements from the ' - 'coordinates in the next space.') + 'as relative. I.e. the values in --warp1/2 are displacements from the ' + 'coordinates in the next space.') out_abswarp = traits.Bool(argstr='--absout', xor=['out_relwarp'], desc='If set it indicates that the warps in --out should be absolute, i.e. ' - 'the values in --out are displacements from the coordinates in --ref.') + 'the values in --out are displacements from the coordinates in --ref.') out_relwarp = traits.Bool(argstr='--relout', xor=['out_abswarp'], desc='If set it indicates that the warps in --out should be relative, i.e. ' - 'the values in --out are displacements from the coordinates in --ref.') + 'the values in --out are displacements from the coordinates in --ref.') class ConvertWarpOutputSpec(TraitedSpec): @@ -1785,10 +1466,10 @@ class ConvertWarp(FSLCommand): >>> from nipype.interfaces.fsl import ConvertWarp >>> warputils = ConvertWarp() - >>> warputils.inputs.warp1 = "warpfield.nii" - >>> warputils.inputs.reference = "T1.nii" + >>> warputils.inputs.warp1 = 'warpfield.nii' + >>> warputils.inputs.reference = 'T1.nii' >>> warputils.inputs.relwarp = True - >>> warputils.inputs.output_type = "NIFTI_GZ" + >>> warputils.inputs.output_type = 'NIFTI_GZ' >>> warputils.cmdline # doctest: +ELLIPSIS 'convertwarp --ref=T1.nii --rel --warp1=warpfield.nii --out=T1_concatwarp.nii.gz' >>> res = warputils.run() # doctest: +SKIP @@ -1796,8 +1477,8 @@ class ConvertWarp(FSLCommand): """ - input_spec = ConvertWarpInputSpec - output_spec = ConvertWarpOutputSpec + _input_spec = ConvertWarpInputSpec + _output_spec = ConvertWarpOutputSpec _cmd = 'convertwarp' @@ -1808,7 +1489,7 @@ class WarpPointsBaseInputSpec(CommandLineInputSpec): desc='filename of affine transform (e.g. source2dest.mat)') warp_file = File(exists=True, argstr='-warp %s', xor=['xfm_file'], desc='filename of warpfield (e.g. ' - 'intermediate2dest_warp.nii.gz)') + 'intermediate2dest_warp.nii.gz)') coord_vox = traits.Bool(True, argstr='-vox', xor=['coord_mm'], desc='all coordinates in voxels - default') coord_mm = traits.Bool(False, argstr='-mm', xor=['coord_vox'], @@ -1817,6 +1498,23 @@ class WarpPointsBaseInputSpec(CommandLineInputSpec): name_template='%s_warped', output_name='out_file', desc='output file name') + def parse_args(self, skip=None): + import os.path as op + + fname, ext = op.splitext(self.in_coords) + setattr(self, '_in_file', fname) + setattr(self, '_outformat', ext[1:]) + first_args = super(WarpPoints, self).parse_args(skip=['in_coords', 'out_file']) + second_args = fname + '.txt' + + if ext in ['.vtk', '.trk']: + if self._tmpfile is None: + self._tmpfile = tempfile.NamedTemporaryFile(suffix='.txt', dir=os.getcwd(), + delete=False).name + second_args = self._tmpfile + + return first_args + [second_args] + class WarpPointsInputSpec(WarpPointsBaseInputSpec): src_file = File(exists=True, argstr='-src %s', mandatory=True, @@ -1854,10 +1552,10 @@ class WarpPoints(CommandLine): """ - input_spec = WarpPointsInputSpec - output_spec = WarpPointsOutputSpec + _input_spec = WarpPointsInputSpec + _output_spec = WarpPointsOutputSpec _cmd = 'img2imgcoord' - _terminal_output = 'stream' + terminal_output = 'stream' def __init__(self, command=None, **inputs): self._tmpfile = None @@ -1866,29 +1564,6 @@ def __init__(self, command=None, **inputs): super(WarpPoints, self).__init__(command=command, **inputs) - def _format_arg(self, name, trait_spec, value): - if name == 'out_file': - return '' - - return super(WarpPoints, self)._format_arg(name, trait_spec, value) - - def _parse_inputs(self, skip=None): - fname, ext = op.splitext(self.inputs.in_coords) - setattr(self, '_in_file', fname) - setattr(self, '_outformat', ext[1:]) - first_args = super(WarpPoints, self)._parse_inputs( - skip=['in_coords', 'out_file']) - - second_args = fname + '.txt' - - if ext in ['.vtk', '.trk']: - if self._tmpfile is None: - self._tmpfile = tempfile.NamedTemporaryFile(suffix='.txt', dir=os.getcwd(), - delete=False).name - second_args = self._tmpfile - - return first_args + [second_args] - def _vtk_to_coords(self, in_file, out_file=None): from ..vtkbase import tvtk from ...interfaces import vtkbase as VTKInfo @@ -1978,12 +1653,12 @@ def _run_interface(self, runtime): class WarpPointsToStdInputSpec(WarpPointsBaseInputSpec): img_file = File(exists=True, argstr='-img %s', mandatory=True, - desc=('filename of input image')) + desc='filename of input image') std_file = File(exists=True, argstr='-std %s', mandatory=True, - desc=('filename of destination image')) + desc='filename of destination image') premat_file = File(exists=True, argstr='-premat %s', - desc=('filename of pre-warp affine transform ' - '(e.g. example_func2highres.mat)')) + desc='filename of pre-warp affine transform ' + '(e.g. example_func2highres.mat)') class WarpPointsToStd(WarpPoints): @@ -2012,33 +1687,29 @@ class WarpPointsToStd(WarpPoints): """ - input_spec = WarpPointsToStdInputSpec - output_spec = WarpPointsOutputSpec + _input_spec = WarpPointsToStdInputSpec + _output_spec = WarpPointsOutputSpec _cmd = 'img2stdcoord' class MotionOutliersInputSpec(FSLCommandInputSpec): - in_file = File( - exists=True, mandatory=True, desc="unfiltered 4D image", argstr="-i %s") - out_file = File(argstr="-o %s", name_source='in_file', name_template='%s_outliers.txt', - keep_extension=True, desc='output outlier file name', hash_files=False) - mask = File( - exists=True, argstr="-m %s", desc="mask image for calculating metric") - metric = traits.Enum( - 'refrms', ['refrms', 'dvars', 'refmse', 'fd', 'fdrms'], argstr="--%s", - desc='metrics: refrms - RMS intensity difference to reference volume as metric [default metric], ' - 'refmse - Mean Square Error version of refrms (used in original version of fsl_motion_outliers), ' - 'dvars - DVARS, fd - frame displacement, fdrms - FD with RMS matrix calculation') - threshold = traits.Float(argstr="--thresh=%g", - desc="specify absolute threshold value (otherwise use box-plot cutoff = P75 + 1.5*IQR)") - no_motion_correction = traits.Bool( - argstr="--nomoco", desc="do not run motion correction (assumed already done)") - dummy = traits.Int(argstr="--dummy=%d", - desc='number of dummy scans to delete (before running anything and creating EVs)') - out_metric_values = File(argstr="-s %s", name_source='in_file', name_template='%s_metrics.txt', - keep_extension=True, desc='output metric values (DVARS etc.) file name', hash_files=False) - out_metric_plot = File(argstr="-p %s", name_source='in_file', name_template='%s_metrics.png', hash_files=False, - keep_extension=True, desc='output metric values plot (DVARS etc.) file name') + in_file = File(exists=True, mandatory=True, desc='unfiltered 4D image', argstr='-i %s') + mask = File(exists=True, argstr='-m %s', desc='mask image for calculating metric') + metric = traits.Enum('refrms', ['refrms', 'dvars', 'refmse', 'fd', 'fdrms'], argstr='--%s', desc="metrics: refrms - RMS intensity difference to reference volume as metric [default metric],\ +refmse - Mean Square Error version of refrms (used in original version of fsl_motion_outliers) \ +dvars - DVARS \ +fd - frame displacement \ +fdrms - FD with RMS matrix calculation") + threshold = traits.Float(argstr='--thresh=%g', desc="specify absolute threshold value (otherwise use box-plot cutoff = P75 + 1.5*IQR)") + no_motion_correction = traits.Bool(argstr='--nomoco', desc='do not run motion correction (assumed already done)') + dummy = traits.Int(argstr='--dummy=%d', desc='number of dummy scans to delete (before running anything and creating EVs)') + + out_file = GenFile(template='{in_file}_outliers.txt', argstr='-o %s', hash_files=False, + desc='output outlier file name') + out_metric_values = GenFile(template='{in_file}_metrics.txt', argstr='-s %s', hash_files=False, + desc='output metric values (DVARS etc.) file name') + out_metric_plot = GenFile(template='{in_file}_metrics.png', argstr='-p %s', hash_files=False, + desc='output metric values plot (DVARS etc.) file name') class MotionOutliersOutputSpec(TraitedSpec): @@ -2054,12 +1725,12 @@ class MotionOutliers(FSLCommand): -------- >>> from nipype.interfaces.fsl import MotionOutliers >>> mo = MotionOutliers() - >>> mo.inputs.in_file = "epi.nii" + >>> mo.inputs.in_file = 'epi.nii' >>> mo.cmdline # doctest: +ELLIPSIS 'fsl_motion_outliers -i epi.nii -o epi_outliers.txt -p epi_metrics.png -s epi_metrics.txt' >>> res = mo.run() # doctest: +SKIP """ - input_spec = MotionOutliersInputSpec - output_spec = MotionOutliersOutputSpec + _input_spec = MotionOutliersInputSpec + _output_spec = MotionOutliersOutputSpec _cmd = 'fsl_motion_outliers' diff --git a/nipype/interfaces/io.py b/nipype/interfaces/io.py index 6f0ad3bc32..551c483f9d 100644 --- a/nipype/interfaces/io.py +++ b/nipype/interfaces/io.py @@ -34,11 +34,9 @@ from warnings import warn import sqlite3 - -from .base import (TraitedSpec, traits, File, Directory, - BaseInterface, InputMultiPath, isdefined, - OutputMultiPath, DynamicTraitedSpec, - Undefined, BaseInterfaceInputSpec) +from .base import (traits, Undefined, File, Directory, isdefined, InputMultiPath, + OutputMultiPath, TraitedSpec, DynamicTraitedSpec, + BaseInputSpec, BaseInterface) from .. import config from ..external.six import string_types from ..utils.filemanip import (copyfile, list_to_filename, @@ -89,7 +87,7 @@ def copytree(src, dst, use_hardlink=False): if os.path.isdir(srcname): copytree(srcname, dstname, use_hardlink) else: - copyfile(srcname, dstname, True, hashmethod='content', + copyfile(srcname, dstname, True, hash_method='content', use_hardlink=use_hardlink) except (IOError, os.error) as why: errors.append((srcname, dstname, str(why))) @@ -124,7 +122,7 @@ class IOBase(BaseInterface): def _run_interface(self, runtime): return runtime - def _list_outputs(self): + def _post_run(self): raise NotImplementedError def _outputs(self): @@ -136,14 +134,14 @@ def _add_output_traits(self, base): # Class to track percentage of S3 file upload class ProgressPercentage(object): - ''' + """ Callable class instsance (via __call__ method) that displays upload percentage of a file to S3 - ''' + """ def __init__(self, filename): - ''' - ''' + """ + """ # Import packages import threading @@ -155,8 +153,8 @@ def __init__(self, filename): self._lock = threading.Lock() def __call__(self, bytes_amount): - ''' - ''' + """ + """ # Import packages import sys @@ -177,9 +175,9 @@ def __call__(self, bytes_amount): # DataSink inputs -class DataSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): - ''' - ''' +class DataSinkInputSpec(DynamicTraitedSpec, BaseInputSpec): + """ + """ # Init inputspec data attributes base_directory = Directory( @@ -300,8 +298,8 @@ class DataSink(IOBase): """ # Give obj .inputs and .outputs - input_spec = DataSinkInputSpec - output_spec = DataSinkOutputSpec + _input_spec = DataSinkInputSpec + _output_spec = DataSinkOutputSpec # Initialization method to set up datasink def __init__(self, infields=None, force_run=True, **kwargs): @@ -372,7 +370,7 @@ def _substitute(self, pathstr): # Check for s3 in base directory def _check_s3_base_dir(self): - ''' + """ Method to see if the datasink's base directory specifies an S3 bucket path; if it does, it parses the path for the bucket name in the form 's3://bucket_name/...' and returns it @@ -388,7 +386,7 @@ def _check_s3_base_dir(self): bucket_name : string name of the S3 bucket to connect to; if the base directory is not a valid S3 path, defaults to '' - ''' + """ # Init variables s3_str = 's3://' @@ -419,7 +417,7 @@ def _check_s3_base_dir(self): # Function to return AWS secure environment variables def _return_aws_keys(self): - ''' + """ Method to return AWS access key id and secret access key using credentials found in a local file. @@ -434,7 +432,7 @@ def _return_aws_keys(self): string of the AWS access key ID aws_secret_access_key : string string of the AWS secret access key - ''' + """ # Import packages import os @@ -474,7 +472,7 @@ def _return_aws_keys(self): # Fetch bucket object def _fetch_bucket(self, bucket_name): - ''' + """ Method to return a bucket object which can be used to interact with an AWS S3 bucket using credentials found in a local file. @@ -490,7 +488,7 @@ def _fetch_bucket(self, bucket_name): bucket : boto3.resources.factory.s3.Bucket boto3 s3 Bucket object which is used to interact with files in an S3 bucket on AWS - ''' + """ # Import packages import logging @@ -567,9 +565,9 @@ def _fetch_bucket(self, bucket_name): # Send up to S3 method def _upload_to_s3(self, bucket, src, dst): - ''' + """ Method to upload outputs to S3 bucket instead of on local disk - ''' + """ # Import packages import hashlib @@ -636,13 +634,13 @@ def _upload_to_s3(self, bucket, src, dst): Callback=ProgressPercentage(src_f)) # List outputs, main run routine - def _list_outputs(self): + def _post_run(self): """Execute this module. """ # Init variables iflogger = logging.getLogger('interface') - outputs = self.output_spec().get() + out_files = [] # Use hardlink use_hardlink = str2bool(config.get('execution', 'try_hard_link_datasink')) @@ -752,7 +750,7 @@ def _list_outputs(self): # If src is a file, copy it to dst if os.path.isfile(src): iflogger.debug('copyfile: %s %s' % (src, dst)) - copyfile(src, dst, copy=True, hashmethod='content', + copyfile(src, dst, copy=True, hash_method='content', use_hardlink=use_hardlink) out_files.append(dst) # If src is a directory, copy entire contents to dst dir @@ -765,12 +763,10 @@ def _list_outputs(self): out_files.append(dst) # Return outputs dictionary - outputs['out_file'] = out_files - - return outputs + self.outputs.out_file = out_files -class S3DataGrabberInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class S3DataGrabberInputSpec(DynamicTraitedSpec, BaseInputSpec): anon = traits.Bool(False, usedefault=True, desc='Use anonymous connection to s3. If this is set to True, boto may print' + ' a urlopen error, but this does not prevent data from being downloaded.') @@ -808,8 +804,8 @@ class S3DataGrabber(IOBase): glob-style found in the original DataGrabber. """ - input_spec = S3DataGrabberInputSpec - output_spec = DynamicTraitedSpec + _input_spec = S3DataGrabberInputSpec + _output_spec = DynamicTraitedSpec _always_run = True def __init__(self, infields=None, outfields=None, **kwargs): @@ -861,7 +857,7 @@ def _add_output_traits(self, base): """ return add_traits(base, self.inputs.template_args.keys()) - def _list_outputs(self): + def _post_run(self): # infields are mandatory, however I could not figure out how to set 'mandatory' flag dynamically # hence manual check if self._infields: @@ -880,7 +876,7 @@ def _list_outputs(self): # keys are outfields, args are template args for the outfield for key, args in self.inputs.template_args.items(): - outputs[key] = [] + setattr(self.outputs, key, []) template = self.inputs.template if hasattr(self.inputs, 'field_template') and \ isdefined(self.inputs.field_template) and \ @@ -903,7 +899,7 @@ def _list_outputs(self): else: if self.inputs.sort_filelist: filelist = human_order_sorted(filelist) - outputs[key] = list_to_filename(filelist) + setattr(self.outputs, key, list_to_filename(filelist)) for argnum, arglist in enumerate(args): maxlen = 1 for arg in arglist: @@ -940,17 +936,17 @@ def _list_outputs(self): raise IOError(msg) else: warn(msg) - outputs[key].append(None) + getattr(self.outputs, key).append(None) else: if self.inputs.sort_filelist: outfiles = human_order_sorted(outfiles) - outputs[key].append(list_to_filename(outfiles)) - if any([val is None for val in outputs[key]]): - outputs[key] = [] - if len(outputs[key]) == 0: - outputs[key] = None - elif len(outputs[key]) == 1: - outputs[key] = outputs[key][0] + getattr(self.outputs, key).append(list_to_filename(outfiles)) + if any([val is None for val in getattr(self.outputs, key)]): + setattr(self.outputs, key, []) + if len(getattr(self.outputs, key)) == 0: + setattr(self.outputs, key, None) + elif len(getattr(self.outputs, key)) == 1: + setattr(self.outputs, key, getattr(self.outputs, key)[0]) # Outputs are currently stored as locations on S3. # We must convert to the local location specified # and download the files. @@ -960,13 +956,15 @@ def _list_outputs(self): #tuple, numpy array) and we iterate through each of its #values. If it doesn't, it's string-like (string, #unicode), and we convert that value directly. + + cur_value = getattr(self.outputs, key) if hasattr(val,'__iter__'): for i,path in enumerate(val): - outputs[key][i] = self.s3tolocal(path, bkt) + cur_value[i] = self.s3tolocal(path, bkt) else: - outputs[key] = self.s3tolocal(val, bkt) + cur_value[i] = self.s3tolocal(val, bkt) + setattr(self.outputs, key, cur_value) - return outputs # Takes an s3 address and downloads the file to a local # directory, returning the local path. @@ -989,7 +987,7 @@ def s3tolocal(self, s3path, bkt): return localpath -class DataGrabberInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class DataGrabberInputSpec(DynamicTraitedSpec, BaseInputSpec): base_directory = Directory(exists=True, desc='Path to the base directory consisting of subject data.') raise_on_empty = traits.Bool(True, usedefault=True, @@ -1054,8 +1052,8 @@ class DataGrabber(IOBase): >>> dg.inputs.template_args['struct'] = [['sid']] """ - input_spec = DataGrabberInputSpec - output_spec = DynamicTraitedSpec + _input_spec = DataGrabberInputSpec + _output_spec = DynamicTraitedSpec _always_run = True def __init__(self, infields=None, outfields=None, **kwargs): @@ -1106,7 +1104,7 @@ def _add_output_traits(self, base): """ return add_traits(base, list(self.inputs.template_args.keys())) - def _list_outputs(self): + def _post_run(self): # infields are mandatory, however I could not figure out how to set 'mandatory' flag dynamically # hence manual check if self._infields: @@ -1119,7 +1117,7 @@ def _list_outputs(self): outputs = {} for key, args in list(self.inputs.template_args.items()): - outputs[key] = [] + setattr(self.outputs, key, []) template = self.inputs.template if hasattr(self.inputs, 'field_template') and \ isdefined(self.inputs.field_template) and \ @@ -1142,7 +1140,7 @@ def _list_outputs(self): else: if self.inputs.sort_filelist: filelist = human_order_sorted(filelist) - outputs[key] = list_to_filename(filelist) + setattr(self.outputs, key, list_to_filename(filelist)) for argnum, arglist in enumerate(args): maxlen = 1 for arg in arglist: @@ -1176,21 +1174,20 @@ def _list_outputs(self): raise IOError(msg) else: warn(msg) - outputs[key].append(None) + getattr(self.outputs, key).append(None) else: if self.inputs.sort_filelist: outfiles = human_order_sorted(outfiles) - outputs[key].append(list_to_filename(outfiles)) - if any([val is None for val in outputs[key]]): - outputs[key] = [] - if len(outputs[key]) == 0: - outputs[key] = None - elif len(outputs[key]) == 1: - outputs[key] = outputs[key][0] - return outputs + getattr(self.outputs, key).append(list_to_filename(outfiles)) + if any([val is None for val in getattr(self.outputs, key)]): + setattr(self.outputs, key, []) + if len(getattr(self.outputs, key)) == 0: + setattr(self.outputs, key, None) + elif len(getattr(self.outputs, key)) == 1: + setattr(self.outputs, key, getattr(self.outputs, key)[0]) -class SelectFilesInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class SelectFilesInputSpec(DynamicTraitedSpec, BaseInputSpec): base_directory = Directory(exists=True, desc="Root path common to templates.") @@ -1237,8 +1234,8 @@ class SelectFiles(IOBase): >>> dg.inputs.run = [2, 4] """ - input_spec = SelectFilesInputSpec - output_spec = DynamicTraitedSpec + _input_spec = SelectFilesInputSpec + _output_spec = DynamicTraitedSpec _always_run = True def __init__(self, templates, **kwargs): @@ -1281,7 +1278,7 @@ def _add_output_traits(self, base): """Add the dynamic output fields""" return add_traits(base, list(self._templates.keys())) - def _list_outputs(self): + def _post_run(self): """Find the files and expose them as interface outputs.""" outputs = {} info = dict([(k, v) for k, v in list(self.inputs.__dict__.items()) @@ -1329,12 +1326,10 @@ def _list_outputs(self): if field not in force_lists: filelist = list_to_filename(filelist) - outputs[field] = filelist - - return outputs + setattr(self.outputs, field, filelist) -class DataFinderInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class DataFinderInputSpec(DynamicTraitedSpec, BaseInputSpec): root_paths = traits.Either(traits.List(), traits.Str(), mandatory=True,) @@ -1390,8 +1385,8 @@ class DataFinder(IOBase): """ - input_spec = DataFinderInputSpec - output_spec = DynamicTraitedSpec + _input_spec = DataFinderInputSpec + _output_spec = DynamicTraitedSpec _always_run = True def _match_path(self, target_path): @@ -1473,15 +1468,11 @@ def _run_interface(self, runtime): if not self.result: raise RuntimeError("Regular expression did not match any files!") + self.outputs.update(self.result) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs.update(self.result) - return outputs - -class FSSourceInputSpec(BaseInterfaceInputSpec): +class FSSourceInputSpec(BaseInputSpec): subjects_dir = Directory(mandatory=True, desc='Freesurfer subjects directory.') subject_id = traits.Str(mandatory=True, @@ -1585,8 +1576,8 @@ class FreeSurferSource(IOBase): >>> res = fs.run() # doctest: +SKIP """ - input_spec = FSSourceInputSpec - output_spec = FSSourceOutputSpec + _input_spec = FSSourceInputSpec + _output_spec = FSSourceOutputSpec _always_run = True _additional_metadata = ['loc', 'altkey'] @@ -1611,7 +1602,7 @@ def _get_files(self, path, key, dirval, altkey=None): keydir, ''.join((globprefix, key, globsuffix))) return [os.path.abspath(f) for f in glob.glob(globpattern)] - def _list_outputs(self): + def _post_run(self): subjects_dir = self.inputs.subjects_dir subject_path = os.path.join(subjects_dir, self.inputs.subject_id) output_traits = self._outputs() @@ -1621,11 +1612,10 @@ def _list_outputs(self): output_traits.traits()[k].loc, output_traits.traits()[k].altkey) if val: - outputs[k] = list_to_filename(val) - return outputs + setattr(self.outputs, k, list_to_filename(val)) -class XNATSourceInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class XNATSourceInputSpec(DynamicTraitedSpec, BaseInputSpec): query_template = traits.Str( mandatory=True, @@ -1686,8 +1676,8 @@ class XNATSource(IOBase): """ - input_spec = XNATSourceInputSpec - output_spec = DynamicTraitedSpec + _input_spec = XNATSourceInputSpec + _output_spec = DynamicTraitedSpec def __init__(self, infields=None, outfields=None, **kwargs): """ @@ -1734,7 +1724,7 @@ def _add_output_traits(self, base): """ return add_traits(base, list(self.inputs.query_template_args.keys())) - def _list_outputs(self): + def _post_run(self): # infields are mandatory, however I could not figure out # how to set 'mandatory' flag dynamically, hence manual check @@ -1761,7 +1751,7 @@ def _list_outputs(self): outputs = {} for key, args in list(self.inputs.query_template_args.items()): - outputs[key] = [] + setattr(self.outputs, key, []) template = self.inputs.query_template if hasattr(self.inputs, 'field_template') and \ isdefined(self.inputs.field_template) and \ @@ -1773,11 +1763,11 @@ def _list_outputs(self): raise IOError('Template %s returned no files' % template ) - outputs[key] = list_to_filename( + setattr(self.outputs, key, list_to_filename( [str(file_object.get()) for file_object in file_objects if file_object.exists() - ]) + ])) for argnum, arglist in enumerate(args): maxlen = 1 for arg in arglist: @@ -1831,15 +1821,14 @@ def _list_outputs(self): ] ) - outputs[key].insert(i, outfiles) - if len(outputs[key]) == 0: - outputs[key] = None - elif len(outputs[key]) == 1: - outputs[key] = outputs[key][0] - return outputs + getattr(self.outputs, key).insert(i, outfiles) + if len(getattr(self.outputs, key)) == 0: + setattr(self.outputs, key, None) + elif len(getattr(self.outputs, key)) == 1: + setattr(self.outputs, key, getattr(self.outputs, key)[0]) -class XNATSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class XNATSinkInputSpec(DynamicTraitedSpec, BaseInputSpec): _outputs = traits.Dict(traits.Str, value={}, usedefault=True) @@ -1893,9 +1882,9 @@ class XNATSink(IOBase): list of nifti files and provides a set of structured output fields. """ - input_spec = XNATSinkInputSpec + _input_spec = XNATSinkInputSpec - def _list_outputs(self): + def _post_run(self): """Execute this module. """ @@ -2066,7 +2055,7 @@ def push_provenance(): pass -class SQLiteSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class SQLiteSinkInputSpec(DynamicTraitedSpec, BaseInputSpec): database_file = File(exists=True, mandatory=True) table_name = traits.Str(mandatory=True) @@ -2090,7 +2079,7 @@ class SQLiteSink(IOBase): >>> sql.run() # doctest: +SKIP """ - input_spec = SQLiteSinkInputSpec + _input_spec = SQLiteSinkInputSpec def __init__(self, input_names, **inputs): @@ -2099,7 +2088,7 @@ def __init__(self, input_names, **inputs): self._input_names = filename_to_list(input_names) add_traits(self.inputs, [name for name in self._input_names]) - def _list_outputs(self): + def _post_run(self): """Execute this module. """ conn = sqlite3.connect(self.inputs.database_file, @@ -2114,7 +2103,7 @@ def _list_outputs(self): return None -class MySQLSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class MySQLSinkInputSpec(DynamicTraitedSpec, BaseInputSpec): host = traits.Str('localhost', mandatory=True, requires=['username', 'password'], xor=['config'], usedefault=True) @@ -2143,7 +2132,7 @@ class MySQLSink(IOBase): >>> sql.run() # doctest: +SKIP """ - input_spec = MySQLSinkInputSpec + _input_spec = MySQLSinkInputSpec def __init__(self, input_names, **inputs): @@ -2152,7 +2141,7 @@ def __init__(self, input_names, **inputs): self._input_names = filename_to_list(input_names) add_traits(self.inputs, [name for name in self._input_names]) - def _list_outputs(self): + def _post_run(self): """Execute this module. """ import MySQLdb @@ -2249,8 +2238,8 @@ class SSHDataGrabber(DataGrabber): >>> dg.inputs.template_args['struct'] = [['sid']] """ - input_spec = SSHDataGrabberInputSpec - output_spec = DynamicTraitedSpec + _input_spec = SSHDataGrabberInputSpec + _output_spec = DynamicTraitedSpec _always_run = False def __init__(self, infields=None, outfields=None, **kwargs): @@ -2293,7 +2282,7 @@ def __init__(self, infields=None, outfields=None, **kwargs): ): self.inputs.template += '$' - def _list_outputs(self): + def _post_run(self): try: paramiko except NameError: @@ -2316,7 +2305,7 @@ def _list_outputs(self): outputs = {} for key, args in list(self.inputs.template_args.items()): - outputs[key] = [] + setattr(self.outputs, key, []) template = self.inputs.template if hasattr(self.inputs, 'field_template') and \ isdefined(self.inputs.field_template) and \ @@ -2344,7 +2333,7 @@ def _list_outputs(self): else: if self.inputs.sort_filelist: filelist = human_order_sorted(filelist) - outputs[key] = list_to_filename(filelist) + setattr(self.outputs, key, list_to_filename(filelist)) if self.inputs.download_files: for f in filelist: sftp.get(f, f) @@ -2393,28 +2382,26 @@ def _list_outputs(self): raise IOError(msg) else: warn(msg) - outputs[key].append(None) + getattr(self.outputs, key).append(None) else: if self.inputs.sort_filelist: outfiles = human_order_sorted(outfiles) - outputs[key].append(list_to_filename(outfiles)) + getattr(self.outputs, key).append(list_to_filename(outfiles)) if self.inputs.download_files: for f in outfiles: try: sftp.get(os.path.join(filledtemplate_dir, f), f) except IOError: iflogger.info('remote file %s not found' % f) - if any([val is None for val in outputs[key]]): - outputs[key] = [] - if len(outputs[key]) == 0: - outputs[key] = None - elif len(outputs[key]) == 1: - outputs[key] = outputs[key][0] + if any([val is None for val in getattr(self.outputs, key)]): + setattr(self.outputs, key, []) + if len(getattr(self.outputs, key)) == 0: + setattr(self.outputs, key, None) + elif len(getattr(self.outputs, key)) == 1: + setattr(self.outputs, key, getattr(self.outputs, key)[0]) for k, v in list(outputs.items()): - outputs[k] = os.path.join(os.getcwd(), v) - - return outputs + setattr(self.outputs, k, os.path.join(os.getcwd(), v)) def _get_ssh_client(self): config = paramiko.SSHConfig() @@ -2435,7 +2422,7 @@ def _get_ssh_client(self): return client -class JSONFileGrabberInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class JSONFileGrabberInputSpec(DynamicTraitedSpec, BaseInputSpec): in_file = File(exists=True, desc='JSON source file') defaults = traits.Dict(desc=('JSON dictionary that sets default output' 'values, overridden by values found in in_file')) @@ -2464,11 +2451,11 @@ class JSONFileGrabber(IOBase): """ - input_spec = JSONFileGrabberInputSpec - output_spec = DynamicTraitedSpec + _input_spec = JSONFileGrabberInputSpec + _output_spec = DynamicTraitedSpec _always_run = True - def _list_outputs(self): + def _post_run(self): import simplejson outputs = {} @@ -2480,18 +2467,16 @@ def _list_outputs(self): raise RuntimeError('JSON input has no dictionary structure') for key, value in data.items(): - outputs[key] = value + setattr(self.outputs, key, value) if isdefined(self.inputs.defaults): defaults = self.inputs.defaults for key, value in defaults.items(): if key not in list(outputs.keys()): - outputs[key] = value - - return outputs + setattr(self.outputs, key, value) -class JSONFileSinkInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class JSONFileSinkInputSpec(DynamicTraitedSpec, BaseInputSpec): out_file = File(desc='JSON sink file') in_dict = traits.Dict(value={}, usedefault=True, desc='input JSON dictionary') @@ -2541,8 +2526,8 @@ class JSONFileSink(IOBase): >>> dictsink.run() # doctest: +SKIP """ - input_spec = JSONFileSinkInputSpec - output_spec = JSONFileSinkOutputSpec + _input_spec = JSONFileSinkInputSpec + _output_spec = JSONFileSinkOutputSpec def __init__(self, infields=[], force_run=True, **inputs): super(JSONFileSink, self).__init__(**inputs) @@ -2570,7 +2555,7 @@ def _process_name(self, name, val): return name, val - def _list_outputs(self): + def _post_run(self): import simplejson import os.path as op @@ -2590,6 +2575,5 @@ def _list_outputs(self): with open(out_file, 'w') as f: simplejson.dump(out_dict, f) - outputs = self.output_spec().get() - outputs['out_file'] = out_file - return outputs + + self.outputs.out_file = out_file diff --git a/nipype/interfaces/matlab.py b/nipype/interfaces/matlab.py index a81076b31f..da7b91424c 100644 --- a/nipype/interfaces/matlab.py +++ b/nipype/interfaces/matlab.py @@ -77,7 +77,7 @@ class MatlabCommand(CommandLine): _default_matlab_cmd = None _default_mfile = None _default_paths = None - input_spec = MatlabInputSpec + _input_spec = MatlabInputSpec def __init__(self, matlab_cmd=None, **inputs): """initializes interface to matlab diff --git a/nipype/interfaces/meshfix.py b/nipype/interfaces/meshfix.py index f5a891465e..dcbd521234 100644 --- a/nipype/interfaces/meshfix.py +++ b/nipype/interfaces/meshfix.py @@ -108,24 +108,23 @@ class MeshFix(CommandLine): 'meshfix lh-pial.stl rh-pial.stl -o lh-pial_fixed.off' """ _cmd = 'meshfix' - input_spec = MeshFixInputSpec - output_spec = MeshFixOutputSpec + _input_spec = MeshFixInputSpec + _output_spec = MeshFixOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + if isdefined(self.inputs.out_filename): path, name, ext = split_filename(self.inputs.out_filename) ext = ext.replace('.', '') out_types = ['stl', 'msh', 'wrl', 'vrml', 'fs', 'off'] # Make sure that the output filename uses one of the possible file types if any(ext == out_type.lower() for out_type in out_types): - outputs['mesh_file'] = op.abspath(self.inputs.out_filename) + self.outputs.mesh_file = op.abspath(self.inputs.out_filename) else: - outputs['mesh_file'] = op.abspath(name + '.' + self.inputs.output_type) + self.outputs.mesh_file = op.abspath(name + '.' + self.inputs.output_type) else: - outputs['mesh_file'] = op.abspath(self._gen_outfilename()) - return outputs - + self.outputs.mesh_file = op.abspath(self._gen_outfilename()) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() diff --git a/nipype/interfaces/minc/minc.py b/nipype/interfaces/minc/minc.py index c54e855125..e9ac90d6c6 100644 --- a/nipype/interfaces/minc/minc.py +++ b/nipype/interfaces/minc/minc.py @@ -239,8 +239,8 @@ class Extract(StdOutCommandLine): >>> extract.run() # doctest: +SKIP """ - input_spec = ExtractInputSpec - output_spec = ExtractOutputSpec + _input_spec = ExtractInputSpec + _output_spec = ExtractOutputSpec _cmd = 'mincextract' @@ -344,8 +344,8 @@ class ToRaw(StdOutCommandLine): >>> toraw.run() # doctest: +SKIP """ - input_spec = ToRawInputSpec - output_spec = ToRawOutputSpec + _input_spec = ToRawInputSpec + _output_spec = ToRawOutputSpec _cmd = 'minctoraw' @@ -419,8 +419,8 @@ class Convert(CommandLine): >>> c.run() # doctest: +SKIP """ - input_spec = ConvertInputSpec - output_spec = ConvertOutputSpec + _input_spec = ConvertInputSpec + _output_spec = ConvertOutputSpec _cmd = 'mincconvert' @@ -470,8 +470,8 @@ class Copy(CommandLine): with caution. """ - input_spec = CopyInputSpec - output_spec = CopyOutputSpec + _input_spec = CopyInputSpec + _output_spec = CopyOutputSpec _cmd = 'minccopy' @@ -550,8 +550,8 @@ class ToEcat(CommandLine): """ - input_spec = ToEcatInputSpec - output_spec = ToEcatOutputSpec + _input_spec = ToEcatInputSpec + _output_spec = ToEcatOutputSpec _cmd = 'minctoecat' @@ -644,8 +644,8 @@ class Dump(StdOutCommandLine): """ - input_spec = DumpInputSpec - output_spec = DumpOutputSpec + _input_spec = DumpInputSpec + _output_spec = DumpOutputSpec _cmd = 'mincdump' def _format_arg(self, name, spec, value): @@ -855,8 +855,8 @@ class Average(CommandLine): """ - input_spec = AverageInputSpec - output_spec = AverageOutputSpec + _input_spec = AverageInputSpec + _output_spec = AverageOutputSpec _cmd = 'mincaverage' @@ -908,8 +908,8 @@ class Blob(CommandLine): >>> blob.run() # doctest: +SKIP """ - input_spec = BlobInputSpec - output_spec = BlobOutputSpec + _input_spec = BlobInputSpec + _output_spec = BlobOutputSpec _cmd = 'mincblob' @@ -1123,8 +1123,8 @@ class Calc(CommandLine): >>> calc.run() # doctest: +SKIP """ - input_spec = CalcInputSpec - output_spec = CalcOutputSpec + _input_spec = CalcInputSpec + _output_spec = CalcOutputSpec _cmd = 'minccalc' @@ -1206,8 +1206,8 @@ class BBox(StdOutCommandLine): >>> bbox.run() # doctest: +SKIP """ - input_spec = BBoxInputSpec - output_spec = BBoxOutputSpec + _input_spec = BBoxInputSpec + _output_spec = BBoxOutputSpec _cmd = 'mincbbox' @@ -1369,8 +1369,8 @@ class Beast(CommandLine): >>> beast .run() # doctest: +SKIP """ - input_spec = BeastInputSpec - output_spec = BeastOutputSpec + _input_spec = BeastInputSpec + _output_spec = BeastOutputSpec _cmd = 'mincbeast' @@ -1536,8 +1536,8 @@ class Pik(CommandLine): """ - input_spec = PikInputSpec - output_spec = PikOutputSpec + _input_spec = PikInputSpec + _output_spec = PikOutputSpec _cmd = 'mincpik' def _format_arg(self, name, spec, value): @@ -1675,8 +1675,8 @@ class Blur(StdOutCommandLine): /tmp/out_6_dy.mnc, /tmp/out_6_dz.mnc and /tmp/out_6_dxyz.mnc. """ - input_spec = BlurInputSpec - output_spec = BlurOutputSpec + _input_spec = BlurInputSpec + _output_spec = BlurOutputSpec _cmd = 'mincblur' def _gen_output_base(self): @@ -1697,24 +1697,23 @@ def _gen_output_base(self): # '_bluroutput' return output_base - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + output_file_base = self._gen_output_base() - outputs['output_file'] = output_file_base + '_blur.mnc' + self.outputs.output_file = output_file_base + '_blur.mnc' if isdefined(self.inputs.gradient): - outputs['gradient_dxyz'] = output_file_base + '_dxyz.mnc' + self.outputs.gradient_dxyz = output_file_base + '_dxyz.mnc' if isdefined(self.inputs.partial): - outputs['partial_dx'] = output_file_base + '_dx.mnc' - outputs['partial_dy'] = output_file_base + '_dy.mnc' - outputs['partial_dz'] = output_file_base + '_dz.mnc' - outputs['partial_dxyz'] = output_file_base + '_dxyz.mnc' - - return outputs + self.outputs.partial_dx = output_file_base + '_dx.mnc' + self.outputs.partial_dy = output_file_base + '_dy.mnc' + self.outputs.partial_dz = output_file_base + '_dz.mnc' + self.outputs.partial_dxyz = output_file_base + '_dxyz.mnc' + @property def cmdline(self): output_file_base = self.inputs.output_file_base @@ -1968,7 +1967,7 @@ class MathInputSpec(CommandLineInputSpec): 'segment', 'nsegment', 'isnan', - 'isnan'] # FIXME enforce this in _parse_inputs and check for other members + 'isnan'] # FIXME enforce this in parse_args and check for other members invert = traits.Either( traits.Float(), @@ -2070,14 +2069,14 @@ class Math(StdOutCommandLine): >>> gt.run() # doctest: +SKIP """ - input_spec = MathInputSpec - output_spec = MathOutputSpec + _input_spec = MathInputSpec + _output_spec = MathOutputSpec _cmd = 'mincmath' def _format_arg(self, name, spec, value): assert value is not None - if name in self.input_spec.bool_or_const_traits: + if name in self._input_spec.bool_or_const_traits: # t is unused, what was I trying to do with it? # t = self.inputs.__getattribute__(name) @@ -2094,13 +2093,13 @@ def _format_arg(self, name, spec, value): return super(Math, self)._format_arg(name, spec, value) - def _parse_inputs(self): + def parse_args(self): """A number of the command line options expect precisely one or two files. """ nr_input_files = len(self.inputs.input_files) - for n in self.input_spec.bool_or_const_traits: + for n in self._input_spec.bool_or_const_traits: t = self.inputs.__getattribute__(n) if isdefined(t): @@ -2119,7 +2118,7 @@ def _parse_inputs(self): 'Argument should be a bool or const, but got: %s' % t) - for n in self.input_spec.single_volume_traits: + for n in self._input_spec.single_volume_traits: t = self.inputs.__getattribute__(n) if isdefined(t): @@ -2128,7 +2127,7 @@ def _parse_inputs(self): 'Due to the %s option we expected 1 file but input_files is of length %d' % (n, nr_input_files,)) - for n in self.input_spec.two_volume_traits: + for n in self._input_spec.two_volume_traits: t = self.inputs.__getattribute__(n) if isdefined(t): @@ -2137,7 +2136,7 @@ def _parse_inputs(self): 'Due to the %s option we expected 2 files but input_files is of length %d' % (n, nr_input_files,)) - for n in self.input_spec.n_volume_traits: + for n in self._input_spec.n_volume_traits: t = self.inputs.__getattribute__(n) if isdefined(t): @@ -2146,7 +2145,7 @@ def _parse_inputs(self): 'Due to the %s option we expected at least one file but input_files is of length %d' % (n, nr_input_files,)) - return super(Math, self)._parse_inputs() + return super(Math, self).parse_args() class ResampleInputSpec(CommandLineInputSpec): @@ -2545,8 +2544,8 @@ class Resample(StdOutCommandLine): """ - input_spec = ResampleInputSpec - output_spec = ResampleOutputSpec + _input_spec = ResampleInputSpec + _output_spec = ResampleOutputSpec _cmd = 'mincresample' @@ -2659,8 +2658,8 @@ class Norm(CommandLine): >>> n.run() # doctest: +SKIP """ - input_spec = NormInputSpec - output_spec = NormOutputSpec + _input_spec = NormInputSpec + _output_spec = NormOutputSpec _cmd = 'mincnorm' @@ -2756,8 +2755,8 @@ class Volcentre(CommandLine): >>> vc.run() # doctest: +SKIP """ - input_spec = VolcentreInputSpec - output_spec = VolcentreOutputSpec + _input_spec = VolcentreInputSpec + _output_spec = VolcentreOutputSpec _cmd = 'volcentre' @@ -2847,8 +2846,8 @@ class Volpad(CommandLine): >>> vp.run() # doctest: +SKIP """ - input_spec = VolpadInputSpec - output_spec = VolpadOutputSpec + _input_spec = VolpadInputSpec + _output_spec = VolpadOutputSpec _cmd = 'volpad' @@ -2909,8 +2908,8 @@ class Voliso(CommandLine): >>> viso.run() # doctest: +SKIP """ - input_spec = VolisoInputSpec - output_spec = VolisoOutputSpec + _input_spec = VolisoInputSpec + _output_spec = VolisoOutputSpec _cmd = 'voliso' @@ -2968,16 +2967,15 @@ class Gennlxfm(CommandLine): """ - input_spec = GennlxfmInputSpec - output_spec = GennlxfmOutputSpec + _input_spec = GennlxfmInputSpec + _output_spec = GennlxfmOutputSpec _cmd = 'gennlxfm' - def _list_outputs(self): + def _post_run(self): outputs = super(Gennlxfm, self)._list_outputs() - outputs['output_grid'] = re.sub( - '.(nlxfm|xfm)$', '_grid_0.mnc', outputs['output_file']) - return outputs - + self.outputs.output_grid = re.sub( + '.(nlxfm|xfm)$', '_grid_0.mnc', self.outputs.output_file) + class XfmConcatInputSpec(CommandLineInputSpec): input_files = InputMultiPath( @@ -3032,23 +3030,22 @@ class XfmConcat(CommandLine): >>> conc.run() # doctest: +SKIP """ - input_spec = XfmConcatInputSpec - output_spec = XfmConcatOutputSpec + _input_spec = XfmConcatInputSpec + _output_spec = XfmConcatOutputSpec _cmd = 'xfmconcat' - def _list_outputs(self): + def _post_run(self): outputs = super(XfmConcat, self)._list_outputs() - if os.path.exists(outputs['output_file']): - if 'grid' in open(outputs['output_file'], 'r').read(): - outputs['output_grids'] = glob.glob( + if os.path.exists(self.outputs.output_file): + if 'grid' in open(self.outputs.output_file, 'r').read(): + self.outputs.output_grids = glob.glob( re.sub( '.(nlxfm|xfm)$', '_grid_*.mnc', - outputs['output_file'])) - - return outputs + self.outputs.output_file)) + class BestLinRegInputSpec(CommandLineInputSpec): source = File( @@ -3129,8 +3126,8 @@ class BestLinReg(CommandLine): >>> linreg.run() # doctest: +SKIP """ - input_spec = BestLinRegInputSpec - output_spec = BestLinRegOutputSpec + _input_spec = BestLinRegInputSpec + _output_spec = BestLinRegOutputSpec _cmd = 'bestlinreg' @@ -3216,8 +3213,8 @@ class NlpFit(CommandLine): >>> nlpfit.run() # doctest: +SKIP """ - input_spec = NlpFitInputSpec - output_spec = NlpFitOutputSpec + _input_spec = NlpFitInputSpec + _output_spec = NlpFitOutputSpec _cmd = 'nlpfit' def _gen_filename(self, name): @@ -3232,18 +3229,17 @@ def _gen_filename(self, name): else: raise NotImplemented - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['output_xfm'] = os.path.abspath( + def _post_run(self): + + self.outputs.output_xfm = os.path.abspath( self._gen_filename('output_xfm')) - assert os.path.exists(outputs['output_xfm']) - if 'grid' in open(outputs['output_xfm'], 'r').read(): - outputs['output_grid'] = re.sub( - '.(nlxfm|xfm)$', '_grid_0.mnc', outputs['output_xfm']) - - return outputs + assert os.path.exists(self.outputs.output_xfm) + if 'grid' in open(self.outputs.output_xfm, 'r').read(): + self.outputs.output_grid = re.sub( + '.(nlxfm|xfm)$', '_grid_0.mnc', self.outputs.output_xfm) + class XfmAvgInputSpec(CommandLineInputSpec): input_files = InputMultiPath( @@ -3318,8 +3314,8 @@ class XfmAvg(CommandLine): >>> xfmavg.run() # doctest: +SKIP """ - input_spec = XfmAvgInputSpec - output_spec = XfmAvgOutputSpec + _input_spec = XfmAvgInputSpec + _output_spec = XfmAvgOutputSpec _cmd = 'xfmavg' def _gen_filename(self, name): @@ -3337,17 +3333,16 @@ def _gen_filename(self, name): def _gen_outfilename(self): return self._gen_filename('output_file') - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['output_file'] = os.path.abspath(self._gen_outfilename()) - - assert os.path.exists(outputs['output_file']) - if 'grid' in open(outputs['output_file'], 'r').read(): - outputs['output_grid'] = re.sub( - '.(nlxfm|xfm)$', '_grid_0.mnc', outputs['output_file']) + def _post_run(self): + + self.outputs.output_file = os.path.abspath(self._gen_outfilename()) - return outputs + assert os.path.exists(self.outputs.output_file) + if 'grid' in open(self.outputs.output_file, 'r').read(): + self.outputs.output_grid = re.sub( + '.(nlxfm|xfm)$', '_grid_0.mnc', self.outputs.output_file) + class XfmInvertInputSpec(CommandLineInputSpec): input_file = traits.File( @@ -3392,8 +3387,8 @@ class XfmInvert(CommandLine): >>> invert.run() # doctest: +SKIP """ - input_spec = XfmInvertInputSpec - output_spec = XfmInvertOutputSpec + _input_spec = XfmInvertInputSpec + _output_spec = XfmInvertOutputSpec _cmd = 'xfminvert' def _gen_filename(self, name): @@ -3411,17 +3406,16 @@ def _gen_filename(self, name): def _gen_outfilename(self): return self._gen_filename('output_file') - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['output_file'] = os.path.abspath(self._gen_outfilename()) - - assert os.path.exists(outputs['output_file']) - if 'grid' in open(outputs['output_file'], 'r').read(): - outputs['output_grid'] = re.sub( - '.(nlxfm|xfm)$', '_grid_0.mnc', outputs['output_file']) + def _post_run(self): + + self.outputs.output_file = os.path.abspath(self._gen_outfilename()) - return outputs + assert os.path.exists(self.outputs.output_file) + if 'grid' in open(self.outputs.output_file, 'r').read(): + self.outputs.output_grid = re.sub( + '.(nlxfm|xfm)$', '_grid_0.mnc', self.outputs.output_file) + class BigAverageInputSpec(CommandLineInputSpec): input_files = InputMultiPath( @@ -3512,8 +3506,8 @@ class BigAverage(CommandLine): >>> average.run() # doctest: +SKIP """ - input_spec = BigAverageInputSpec - output_spec = BigAverageOutputSpec + _input_spec = BigAverageInputSpec + _output_spec = BigAverageOutputSpec _cmd = 'mincbigaverage' @@ -3572,8 +3566,8 @@ class Reshape(CommandLine): """ - input_spec = ReshapeInputSpec - output_spec = ReshapeOutputSpec + _input_spec = ReshapeInputSpec + _output_spec = ReshapeOutputSpec _cmd = 'mincreshape' @@ -3669,17 +3663,17 @@ class VolSymm(CommandLine): """ - input_spec = VolSymmInputSpec - output_spec = VolSymmOutputSpec + _input_spec = VolSymmInputSpec + _output_spec = VolSymmOutputSpec _cmd = 'volsymm' - def _list_outputs(self): + def _post_run(self): outputs = super(VolSymm, self)._list_outputs() # Have to manually check for the grid files. - if os.path.exists(outputs['trans_file']): - if 'grid' in open(outputs['trans_file'], 'r').read(): - outputs['output_grid'] = re.sub( - '.(nlxfm|xfm)$', '_grid_0.mnc', outputs['trans_file']) + if os.path.exists(self.outputs.trans_file): + if 'grid' in open(self.outputs.trans_file, 'r').read(): + self.outputs.output_grid = re.sub( + '.(nlxfm|xfm)$', '_grid_0.mnc', self.outputs.trans_file) - return outputs + \ No newline at end of file diff --git a/nipype/interfaces/minc/tests/test_auto_Average.py b/nipype/interfaces/minc/tests/test_auto_Average.py index 7eb22fb4b9..c8fb1aaa63 100644 --- a/nipype/interfaces/minc/tests/test_auto_Average.py +++ b/nipype/interfaces/minc/tests/test_auto_Average.py @@ -25,9 +25,6 @@ def test_Average_inputs(): ), debug=dict(argstr='-debug', ), - environ=dict(nohash=True, - usedefault=True, - ), filelist=dict(argstr='-filelist %s', mandatory=True, xor=('input_files', 'filelist'), @@ -59,9 +56,6 @@ def test_Average_inputs(): format_unsigned=dict(argstr='-unsigned', xor=('format_filetype', 'format_byte', 'format_short', 'format_int', 'format_long', 'format_float', 'format_double', 'format_signed', 'format_unsigned'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_files=dict(argstr='%s', exists=True, mandatory=True, @@ -95,8 +89,6 @@ def test_Average_inputs(): ), sdfile=dict(argstr='-sdfile %s', ), - terminal_output=dict(nohash=True, - ), two=dict(argstr='-2', ), verbose=dict(argstr='-verbose', @@ -111,7 +103,7 @@ def test_Average_inputs(): requires=('avgdim',), ), ) - inputs = Average.input_spec() + inputs = Average._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -121,7 +113,7 @@ def test_Average_inputs(): def test_Average_outputs(): output_map = dict(output_file=dict(), ) - outputs = Average.output_spec() + outputs = Average._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_BBox.py b/nipype/interfaces/minc/tests/test_auto_BBox.py index 8ea5f0b34b..2d3b776a68 100644 --- a/nipype/interfaces/minc/tests/test_auto_BBox.py +++ b/nipype/interfaces/minc/tests/test_auto_BBox.py @@ -6,18 +6,12 @@ def test_BBox_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), format_minccrop=dict(argstr='-minccrop', ), format_mincresample=dict(argstr='-mincresample', ), format_mincreshape=dict(argstr='-mincreshape', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -26,8 +20,8 @@ def test_BBox_inputs(): xor=('one_line', 'two_lines'), ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), output_file=dict(hash_files=False, keep_extension=False, @@ -35,15 +29,13 @@ def test_BBox_inputs(): name_template='%s_bbox.txt', position=-1, ), - terminal_output=dict(nohash=True, - ), threshold=dict(argstr='-threshold', ), two_lines=dict(argstr='-two_lines', xor=('one_line', 'two_lines'), ), ) - inputs = BBox.input_spec() + inputs = BBox._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +45,7 @@ def test_BBox_inputs(): def test_BBox_outputs(): output_map = dict(output_file=dict(), ) - outputs = BBox.output_spec() + outputs = BBox._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Beast.py b/nipype/interfaces/minc/tests/test_auto_Beast.py index 563fa1eb79..7e30806e79 100644 --- a/nipype/interfaces/minc/tests/test_auto_Beast.py +++ b/nipype/interfaces/minc/tests/test_auto_Beast.py @@ -16,16 +16,10 @@ def test_Beast_inputs(): ), configuration_file=dict(argstr='-configuration %s', ), - environ=dict(nohash=True, - usedefault=True, - ), fill_holes=dict(argstr='-fill', ), flip_images=dict(argstr='-flip', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -58,14 +52,12 @@ def test_Beast_inputs(): ), smoothness_factor_beta=dict(argstr='-beta %s', ), - terminal_output=dict(nohash=True, - ), threshold_patch_selection=dict(argstr='-threshold %s', ), voxel_size=dict(argstr='-voxel_size %s', ), ) - inputs = Beast.input_spec() + inputs = Beast._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -75,7 +67,7 @@ def test_Beast_inputs(): def test_Beast_outputs(): output_map = dict(output_file=dict(), ) - outputs = Beast.output_spec() + outputs = Beast._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_BestLinReg.py b/nipype/interfaces/minc/tests/test_auto_BestLinReg.py index 394a7d753a..9aa16f4971 100644 --- a/nipype/interfaces/minc/tests/test_auto_BestLinReg.py +++ b/nipype/interfaces/minc/tests/test_auto_BestLinReg.py @@ -9,12 +9,6 @@ def test_BestLinReg_inputs(): clobber=dict(argstr='-clobber', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), output_mnc=dict(argstr='%s', genfile=True, hash_files=False, @@ -39,12 +33,10 @@ def test_BestLinReg_inputs(): mandatory=True, position=-3, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-verbose', ), ) - inputs = BestLinReg.input_spec() + inputs = BestLinReg._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_BestLinReg_outputs(): output_map = dict(output_mnc=dict(), output_xfm=dict(), ) - outputs = BestLinReg.output_spec() + outputs = BestLinReg._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_BigAverage.py b/nipype/interfaces/minc/tests/test_auto_BigAverage.py index fb71302049..0f56592c72 100644 --- a/nipype/interfaces/minc/tests/test_auto_BigAverage.py +++ b/nipype/interfaces/minc/tests/test_auto_BigAverage.py @@ -9,12 +9,6 @@ def test_BigAverage_inputs(): clobber=dict(argstr='--clobber', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_files=dict(argstr='%s', exists=True, mandatory=True, @@ -37,14 +31,12 @@ def test_BigAverage_inputs(): name_source=['input_files'], name_template='%s_bigaverage_stdev.mnc', ), - terminal_output=dict(nohash=True, - ), tmpdir=dict(argstr='-tmpdir %s', ), verbose=dict(argstr='--verbose', ), ) - inputs = BigAverage.input_spec() + inputs = BigAverage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_BigAverage_outputs(): output_map = dict(output_file=dict(), sd_file=dict(), ) - outputs = BigAverage.output_spec() + outputs = BigAverage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Blob.py b/nipype/interfaces/minc/tests/test_auto_Blob.py index 96050e4746..e416836ee6 100644 --- a/nipype/interfaces/minc/tests/test_auto_Blob.py +++ b/nipype/interfaces/minc/tests/test_auto_Blob.py @@ -8,12 +8,6 @@ def test_Blob_inputs(): ), determinant=dict(argstr='-determinant', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -27,14 +21,12 @@ def test_Blob_inputs(): name_template='%s_blob.mnc', position=-1, ), - terminal_output=dict(nohash=True, - ), trace=dict(argstr='-trace', ), translation=dict(argstr='-translation', ), ) - inputs = Blob.input_spec() + inputs = Blob._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +36,7 @@ def test_Blob_inputs(): def test_Blob_outputs(): output_map = dict(output_file=dict(), ) - outputs = Blob.output_spec() + outputs = Blob._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Blur.py b/nipype/interfaces/minc/tests/test_auto_Blur.py index 340523b0f4..07f188d1b6 100644 --- a/nipype/interfaces/minc/tests/test_auto_Blur.py +++ b/nipype/interfaces/minc/tests/test_auto_Blur.py @@ -11,9 +11,6 @@ def test_Blur_inputs(): ), dimensions=dict(argstr='-dimensions %s', ), - environ=dict(nohash=True, - usedefault=True, - ), fwhm=dict(argstr='-fwhm %s', mandatory=True, xor=('fwhm', 'fwhm3d', 'standard_dev'), @@ -27,9 +24,6 @@ def test_Blur_inputs(): ), gradient=dict(argstr='-gradient', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -48,10 +42,8 @@ def test_Blur_inputs(): mandatory=True, xor=('fwhm', 'fwhm3d', 'standard_dev'), ), - terminal_output=dict(nohash=True, - ), ) - inputs = Blur.input_spec() + inputs = Blur._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -66,7 +58,7 @@ def test_Blur_outputs(): partial_dy=dict(), partial_dz=dict(), ) - outputs = Blur.output_spec() + outputs = Blur._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Calc.py b/nipype/interfaces/minc/tests/test_auto_Calc.py index c5d39cdb38..10b2230cda 100644 --- a/nipype/interfaces/minc/tests/test_auto_Calc.py +++ b/nipype/interfaces/minc/tests/test_auto_Calc.py @@ -17,9 +17,6 @@ def test_Calc_inputs(): ), debug=dict(argstr='-debug', ), - environ=dict(nohash=True, - usedefault=True, - ), eval_width=dict(argstr='-eval_width %s', usedefault=False, ), @@ -62,9 +59,6 @@ def test_Calc_inputs(): format_unsigned=dict(argstr='-unsigned', xor=('format_filetype', 'format_byte', 'format_short', 'format_int', 'format_long', 'format_float', 'format_double', 'format_signed', 'format_unsigned'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), ignore_nan=dict(argstr='-ignore_nan', ), input_files=dict(argstr='%s', @@ -104,8 +98,6 @@ def test_Calc_inputs(): quiet=dict(argstr='-quiet', xor=('verbose', 'quiet'), ), - terminal_output=dict(nohash=True, - ), two=dict(argstr='-2', ), verbose=dict(argstr='-verbose', @@ -114,7 +106,7 @@ def test_Calc_inputs(): voxel_range=dict(argstr='-range %d %d', ), ) - inputs = Calc.input_spec() + inputs = Calc._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -124,7 +116,7 @@ def test_Calc_inputs(): def test_Calc_outputs(): output_map = dict(output_file=dict(), ) - outputs = Calc.output_spec() + outputs = Calc._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Convert.py b/nipype/interfaces/minc/tests/test_auto_Convert.py index 74928bc100..f99c1231f4 100644 --- a/nipype/interfaces/minc/tests/test_auto_Convert.py +++ b/nipype/interfaces/minc/tests/test_auto_Convert.py @@ -14,12 +14,6 @@ def test_Convert_inputs(): ), compression=dict(argstr='-compress %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -33,12 +27,10 @@ def test_Convert_inputs(): ), template=dict(argstr='-template', ), - terminal_output=dict(nohash=True, - ), two=dict(argstr='-2', ), ) - inputs = Convert.input_spec() + inputs = Convert._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -48,7 +40,7 @@ def test_Convert_inputs(): def test_Convert_outputs(): output_map = dict(output_file=dict(), ) - outputs = Convert.output_spec() + outputs = Convert._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Copy.py b/nipype/interfaces/minc/tests/test_auto_Copy.py index a3f2edff48..b439c06f9b 100644 --- a/nipype/interfaces/minc/tests/test_auto_Copy.py +++ b/nipype/interfaces/minc/tests/test_auto_Copy.py @@ -6,12 +6,6 @@ def test_Copy_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -29,10 +23,8 @@ def test_Copy_inputs(): real_values=dict(argstr='-real_values', xor=('pixel_values', 'real_values'), ), - terminal_output=dict(nohash=True, - ), ) - inputs = Copy.input_spec() + inputs = Copy._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_Copy_inputs(): def test_Copy_outputs(): output_map = dict(output_file=dict(), ) - outputs = Copy.output_spec() + outputs = Copy._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Dump.py b/nipype/interfaces/minc/tests/test_auto_Dump.py index 0a41c74c90..98f4112ffb 100644 --- a/nipype/interfaces/minc/tests/test_auto_Dump.py +++ b/nipype/interfaces/minc/tests/test_auto_Dump.py @@ -15,15 +15,9 @@ def test_Dump_inputs(): coordinate_data=dict(argstr='-c', xor=('coordinate_data', 'header_data'), ), - environ=dict(nohash=True, - usedefault=True, - ), header_data=dict(argstr='-h', xor=('coordinate_data', 'header_data'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -34,8 +28,8 @@ def test_Dump_inputs(): netcdf_name=dict(argstr='-n %s', ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), output_file=dict(hash_files=False, keep_extension=False, @@ -45,13 +39,11 @@ def test_Dump_inputs(): ), precision=dict(argstr='%s', ), - terminal_output=dict(nohash=True, - ), variables=dict(argstr='-v %s', sep=',', ), ) - inputs = Dump.input_spec() + inputs = Dump._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -61,7 +53,7 @@ def test_Dump_inputs(): def test_Dump_outputs(): output_map = dict(output_file=dict(), ) - outputs = Dump.output_spec() + outputs = Dump._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Extract.py b/nipype/interfaces/minc/tests/test_auto_Extract.py index 04ecb3b7d3..24a4878e06 100644 --- a/nipype/interfaces/minc/tests/test_auto_Extract.py +++ b/nipype/interfaces/minc/tests/test_auto_Extract.py @@ -9,9 +9,6 @@ def test_Extract_inputs(): count=dict(argstr='-count %s', sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), flip_any_direction=dict(argstr='-any_direction', xor=('flip_positive_direction', 'flip_negative_direction', 'flip_any_direction'), ), @@ -48,9 +45,6 @@ def test_Extract_inputs(): flip_z_positive=dict(argstr='+zdirection', xor=('flip_z_positive', 'flip_z_negative', 'flip_z_any'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_maximum=dict(argstr='-image_maximum %s', ), image_minimum=dict(argstr='-image_minimum %s', @@ -68,8 +62,8 @@ def test_Extract_inputs(): xor=('normalize', 'nonormalize'), ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), output_file=dict(hash_files=False, keep_extension=False, @@ -80,8 +74,6 @@ def test_Extract_inputs(): start=dict(argstr='-start %s', sep=',', ), - terminal_output=dict(nohash=True, - ), write_ascii=dict(argstr='-ascii', xor=('write_ascii', 'write_ascii', 'write_byte', 'write_short', 'write_int', 'write_long', 'write_float', 'write_double', 'write_signed', 'write_unsigned'), ), @@ -112,7 +104,7 @@ def test_Extract_inputs(): xor=('write_signed', 'write_unsigned'), ), ) - inputs = Extract.input_spec() + inputs = Extract._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -122,7 +114,7 @@ def test_Extract_inputs(): def test_Extract_outputs(): output_map = dict(output_file=dict(), ) - outputs = Extract.output_spec() + outputs = Extract._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Gennlxfm.py b/nipype/interfaces/minc/tests/test_auto_Gennlxfm.py index 97d67c454a..44f5797cd4 100644 --- a/nipype/interfaces/minc/tests/test_auto_Gennlxfm.py +++ b/nipype/interfaces/minc/tests/test_auto_Gennlxfm.py @@ -9,14 +9,8 @@ def test_Gennlxfm_inputs(): clobber=dict(argstr='-clobber', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), ident=dict(argstr='-ident', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), like=dict(argstr='-like %s', ), output_file=dict(argstr='%s', @@ -28,12 +22,10 @@ def test_Gennlxfm_inputs(): ), step=dict(argstr='-step %s', ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-verbose', ), ) - inputs = Gennlxfm.input_spec() + inputs = Gennlxfm._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +36,7 @@ def test_Gennlxfm_outputs(): output_map = dict(output_file=dict(), output_grid=dict(), ) - outputs = Gennlxfm.output_spec() + outputs = Gennlxfm._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Math.py b/nipype/interfaces/minc/tests/test_auto_Math.py index 95e8ac30c4..209b9b8183 100644 --- a/nipype/interfaces/minc/tests/test_auto_Math.py +++ b/nipype/interfaces/minc/tests/test_auto_Math.py @@ -37,9 +37,6 @@ def test_Math_inputs(): ), dimension=dict(argstr='-dimension %s', ), - environ=dict(nohash=True, - usedefault=True, - ), exp=dict(argstr='-exp -const2 %s %s', ), filelist=dict(argstr='-filelist %s', @@ -73,9 +70,6 @@ def test_Math_inputs(): format_unsigned=dict(argstr='-unsigned', xor=('format_filetype', 'format_byte', 'format_short', 'format_int', 'format_long', 'format_float', 'format_double', 'format_signed', 'format_unsigned'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), ignore_nan=dict(argstr='-ignore_nan', ), input_files=dict(argstr='%s', @@ -135,8 +129,6 @@ def test_Math_inputs(): ), square=dict(argstr='-square', ), - terminal_output=dict(nohash=True, - ), test_eq=dict(argstr='-eq', ), test_ge=dict(argstr='-ge', @@ -154,7 +146,7 @@ def test_Math_inputs(): voxel_range=dict(argstr='-range %d %d', ), ) - inputs = Math.input_spec() + inputs = Math._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -164,7 +156,7 @@ def test_Math_inputs(): def test_Math_outputs(): output_map = dict(output_file=dict(), ) - outputs = Math.output_spec() + outputs = Math._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_NlpFit.py b/nipype/interfaces/minc/tests/test_auto_NlpFit.py index 5423d564a0..d5c467559b 100644 --- a/nipype/interfaces/minc/tests/test_auto_NlpFit.py +++ b/nipype/interfaces/minc/tests/test_auto_NlpFit.py @@ -12,12 +12,6 @@ def test_NlpFit_inputs(): config_file=dict(argstr='-config_file %s', mandatory=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), init_xfm=dict(argstr='-init_xfm %s', mandatory=True, ), @@ -37,12 +31,10 @@ def test_NlpFit_inputs(): mandatory=True, position=-2, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-verbose', ), ) - inputs = NlpFit.input_spec() + inputs = NlpFit._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +45,7 @@ def test_NlpFit_outputs(): output_map = dict(output_grid=dict(), output_xfm=dict(), ) - outputs = NlpFit.output_spec() + outputs = NlpFit._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Norm.py b/nipype/interfaces/minc/tests/test_auto_Norm.py index a7deaca0ea..70f7207d9c 100644 --- a/nipype/interfaces/minc/tests/test_auto_Norm.py +++ b/nipype/interfaces/minc/tests/test_auto_Norm.py @@ -16,12 +16,6 @@ def test_Norm_inputs(): max=100, min=0, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -46,8 +40,6 @@ def test_Norm_inputs(): name_source=['input_file'], name_template='%s_norm_threshold_mask.mnc', ), - terminal_output=dict(nohash=True, - ), threshold=dict(argstr='-threshold', ), threshold_blur=dict(argstr='-threshold_blur %s', @@ -61,7 +53,7 @@ def test_Norm_inputs(): upper=dict(argstr='-upper %s', ), ) - inputs = Norm.input_spec() + inputs = Norm._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -72,7 +64,7 @@ def test_Norm_outputs(): output_map = dict(output_file=dict(), output_threshold_mask=dict(), ) - outputs = Norm.output_spec() + outputs = Norm._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Pik.py b/nipype/interfaces/minc/tests/test_auto_Pik.py index 89242d649b..2d3883ed82 100644 --- a/nipype/interfaces/minc/tests/test_auto_Pik.py +++ b/nipype/interfaces/minc/tests/test_auto_Pik.py @@ -16,15 +16,9 @@ def test_Pik_inputs(): ), depth=dict(argstr='--depth %s', ), - environ=dict(nohash=True, - usedefault=True, - ), horizontal_triplanar_view=dict(argstr='--horizontal', xor=('vertical_triplanar_view', 'horizontal_triplanar_view'), ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_range=dict(argstr='--image_range %s %s', xor=('image_range', 'auto_range'), ), @@ -65,8 +59,6 @@ def test_Pik_inputs(): ), start=dict(argstr='--slice %s', ), - terminal_output=dict(nohash=True, - ), tile_size=dict(argstr='--tilesize %s', ), title=dict(argstr='%s', @@ -82,7 +74,7 @@ def test_Pik_inputs(): width=dict(argstr='--width %s', ), ) - inputs = Pik.input_spec() + inputs = Pik._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -92,7 +84,7 @@ def test_Pik_inputs(): def test_Pik_outputs(): output_map = dict(output_file=dict(), ) - outputs = Pik.output_spec() + outputs = Pik._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Resample.py b/nipype/interfaces/minc/tests/test_auto_Resample.py index 38c3ac1e8f..d4f38ab981 100644 --- a/nipype/interfaces/minc/tests/test_auto_Resample.py +++ b/nipype/interfaces/minc/tests/test_auto_Resample.py @@ -15,9 +15,6 @@ def test_Resample_inputs(): dircos=dict(argstr='-dircos %s %s %s', xor=('nelements', 'nelements_x_y_or_z'), ), - environ=dict(nohash=True, - usedefault=True, - ), fill=dict(argstr='-fill', xor=('nofill', 'fill'), ), @@ -51,9 +48,6 @@ def test_Resample_inputs(): half_width_sinc_window=dict(argstr='-width %s', requires=['sinc_interpolation'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -118,8 +112,6 @@ def test_Resample_inputs(): ), talairach=dict(argstr='-talairach', ), - terminal_output=dict(nohash=True, - ), transformation=dict(argstr='-transformation %s', ), transverse_slices=dict(argstr='-transverse', @@ -187,7 +179,7 @@ def test_Resample_inputs(): xor=('step', 'step_x_y_or_z'), ), ) - inputs = Resample.input_spec() + inputs = Resample._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -197,7 +189,7 @@ def test_Resample_inputs(): def test_Resample_outputs(): output_map = dict(output_file=dict(), ) - outputs = Resample.output_spec() + outputs = Resample._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Reshape.py b/nipype/interfaces/minc/tests/test_auto_Reshape.py index 89fe7b10d8..d2e628279d 100644 --- a/nipype/interfaces/minc/tests/test_auto_Reshape.py +++ b/nipype/interfaces/minc/tests/test_auto_Reshape.py @@ -9,12 +9,6 @@ def test_Reshape_inputs(): clobber=dict(argstr='-clobber', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -26,14 +20,12 @@ def test_Reshape_inputs(): name_template='%s_reshape.mnc', position=-1, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-verbose', ), write_short=dict(argstr='-short', ), ) - inputs = Reshape.input_spec() + inputs = Reshape._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +35,7 @@ def test_Reshape_inputs(): def test_Reshape_outputs(): output_map = dict(output_file=dict(), ) - outputs = Reshape.output_spec() + outputs = Reshape._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_ToEcat.py b/nipype/interfaces/minc/tests/test_auto_ToEcat.py index 27349fc805..f820b59f5b 100644 --- a/nipype/interfaces/minc/tests/test_auto_ToEcat.py +++ b/nipype/interfaces/minc/tests/test_auto_ToEcat.py @@ -6,9 +6,6 @@ def test_ToEcat_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), ignore_acquisition_variable=dict(argstr='-ignore_acquisition_variable', ), ignore_ecat_acquisition_variable=dict(argstr='-ignore_ecat_acquisition_variable', @@ -17,9 +14,6 @@ def test_ToEcat_inputs(): ), ignore_ecat_subheader_variable=dict(argstr='-ignore_ecat_subheader_variable', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), ignore_patient_variable=dict(argstr='-ignore_patient_variable', ), ignore_study_variable=dict(argstr='-ignore_study_variable', @@ -39,12 +33,10 @@ def test_ToEcat_inputs(): name_template='%s_to_ecat.v', position=-1, ), - terminal_output=dict(nohash=True, - ), voxels_as_integers=dict(argstr='-label', ), ) - inputs = ToEcat.input_spec() + inputs = ToEcat._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -54,7 +46,7 @@ def test_ToEcat_inputs(): def test_ToEcat_outputs(): output_map = dict(output_file=dict(), ) - outputs = ToEcat.output_spec() + outputs = ToEcat._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_ToRaw.py b/nipype/interfaces/minc/tests/test_auto_ToRaw.py index a647ed48d0..c8539dfa87 100644 --- a/nipype/interfaces/minc/tests/test_auto_ToRaw.py +++ b/nipype/interfaces/minc/tests/test_auto_ToRaw.py @@ -6,12 +6,6 @@ def test_ToRaw_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -23,8 +17,8 @@ def test_ToRaw_inputs(): xor=('normalize', 'nonormalize'), ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), output_file=dict(hash_files=False, keep_extension=False, @@ -32,8 +26,6 @@ def test_ToRaw_inputs(): name_template='%s.raw', position=-1, ), - terminal_output=dict(nohash=True, - ), write_byte=dict(argstr='-byte', xor=('write_byte', 'write_short', 'write_int', 'write_long', 'write_float', 'write_double'), ), @@ -61,7 +53,7 @@ def test_ToRaw_inputs(): xor=('write_signed', 'write_unsigned'), ), ) - inputs = ToRaw.input_spec() + inputs = ToRaw._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -71,7 +63,7 @@ def test_ToRaw_inputs(): def test_ToRaw_outputs(): output_map = dict(output_file=dict(), ) - outputs = ToRaw.output_spec() + outputs = ToRaw._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_VolSymm.py b/nipype/interfaces/minc/tests/test_auto_VolSymm.py index 6200880c93..5b6464b2f2 100644 --- a/nipype/interfaces/minc/tests/test_auto_VolSymm.py +++ b/nipype/interfaces/minc/tests/test_auto_VolSymm.py @@ -11,16 +11,10 @@ def test_VolSymm_inputs(): ), config_file=dict(argstr='-config_file %s', ), - environ=dict(nohash=True, - usedefault=True, - ), fit_linear=dict(argstr='-linear', ), fit_nonlinear=dict(argstr='-nonlinear', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-3, @@ -35,8 +29,6 @@ def test_VolSymm_inputs(): name_template='%s_vol_symm.mnc', position=-1, ), - terminal_output=dict(nohash=True, - ), trans_file=dict(argstr='%s', genfile=True, hash_files=False, @@ -54,7 +46,7 @@ def test_VolSymm_inputs(): z=dict(argstr='-z', ), ) - inputs = VolSymm.input_spec() + inputs = VolSymm._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -66,7 +58,7 @@ def test_VolSymm_outputs(): output_grid=dict(), trans_file=dict(), ) - outputs = VolSymm.output_spec() + outputs = VolSymm._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Volcentre.py b/nipype/interfaces/minc/tests/test_auto_Volcentre.py index 02afcf871e..94ce61ff07 100644 --- a/nipype/interfaces/minc/tests/test_auto_Volcentre.py +++ b/nipype/interfaces/minc/tests/test_auto_Volcentre.py @@ -13,12 +13,6 @@ def test_Volcentre_inputs(): ), com=dict(argstr='-com', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -30,14 +24,12 @@ def test_Volcentre_inputs(): name_template='%s_volcentre.mnc', position=-1, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-verbose', ), zero_dircos=dict(argstr='-zero_dircos', ), ) - inputs = Volcentre.input_spec() + inputs = Volcentre._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_Volcentre_inputs(): def test_Volcentre_outputs(): output_map = dict(output_file=dict(), ) - outputs = Volcentre.output_spec() + outputs = Volcentre._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Voliso.py b/nipype/interfaces/minc/tests/test_auto_Voliso.py index e64d8f8dc1..efbfec3016 100644 --- a/nipype/interfaces/minc/tests/test_auto_Voliso.py +++ b/nipype/interfaces/minc/tests/test_auto_Voliso.py @@ -11,12 +11,6 @@ def test_Voliso_inputs(): clobber=dict(argstr='--clobber', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -32,12 +26,10 @@ def test_Voliso_inputs(): name_template='%s_voliso.mnc', position=-1, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose', ), ) - inputs = Voliso.input_spec() + inputs = Voliso._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_Voliso_inputs(): def test_Voliso_outputs(): output_map = dict(output_file=dict(), ) - outputs = Voliso.output_spec() + outputs = Voliso._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_Volpad.py b/nipype/interfaces/minc/tests/test_auto_Volpad.py index d7adf256f0..0c37e5ee3b 100644 --- a/nipype/interfaces/minc/tests/test_auto_Volpad.py +++ b/nipype/interfaces/minc/tests/test_auto_Volpad.py @@ -15,12 +15,6 @@ def test_Volpad_inputs(): ), distance=dict(argstr='-distance %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -36,12 +30,10 @@ def test_Volpad_inputs(): ), smooth_distance=dict(argstr='-smooth_distance %s', ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-verbose', ), ) - inputs = Volpad.input_spec() + inputs = Volpad._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -51,7 +43,7 @@ def test_Volpad_inputs(): def test_Volpad_outputs(): output_map = dict(output_file=dict(), ) - outputs = Volpad.output_spec() + outputs = Volpad._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_XfmAvg.py b/nipype/interfaces/minc/tests/test_auto_XfmAvg.py index 1721e861fc..dcdc5d5479 100644 --- a/nipype/interfaces/minc/tests/test_auto_XfmAvg.py +++ b/nipype/interfaces/minc/tests/test_auto_XfmAvg.py @@ -13,12 +13,6 @@ def test_XfmAvg_inputs(): clobber=dict(argstr='-clobber', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), ignore_linear=dict(argstr='-ignore_linear', ), ignore_nonlinear=dict(argstr='-ignore_nonline', @@ -34,12 +28,10 @@ def test_XfmAvg_inputs(): genfile=True, position=-1, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-verbose', ), ) - inputs = XfmAvg.input_spec() + inputs = XfmAvg._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +42,7 @@ def test_XfmAvg_outputs(): output_map = dict(output_file=dict(), output_grid=dict(), ) - outputs = XfmAvg.output_spec() + outputs = XfmAvg._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_XfmConcat.py b/nipype/interfaces/minc/tests/test_auto_XfmConcat.py index 5ae6b6bef1..01d11cdcbf 100644 --- a/nipype/interfaces/minc/tests/test_auto_XfmConcat.py +++ b/nipype/interfaces/minc/tests/test_auto_XfmConcat.py @@ -9,12 +9,6 @@ def test_XfmConcat_inputs(): clobber=dict(argstr='-clobber', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_files=dict(argstr='%s', exists=True, mandatory=True, @@ -29,12 +23,10 @@ def test_XfmConcat_inputs(): name_template='%s_xfmconcat.xfm', position=-1, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-verbose', ), ) - inputs = XfmConcat.input_spec() + inputs = XfmConcat._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +38,7 @@ def test_XfmConcat_outputs(): output_grids=dict(exists=True, ), ) - outputs = XfmConcat.output_spec() + outputs = XfmConcat._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/minc/tests/test_auto_XfmInvert.py b/nipype/interfaces/minc/tests/test_auto_XfmInvert.py index 873850c6b0..4e42261fd6 100644 --- a/nipype/interfaces/minc/tests/test_auto_XfmInvert.py +++ b/nipype/interfaces/minc/tests/test_auto_XfmInvert.py @@ -9,12 +9,6 @@ def test_XfmInvert_inputs(): clobber=dict(argstr='-clobber', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_file=dict(argstr='%s', mandatory=True, position=-2, @@ -23,12 +17,10 @@ def test_XfmInvert_inputs(): genfile=True, position=-1, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='-verbose', ), ) - inputs = XfmInvert.input_spec() + inputs = XfmInvert._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_XfmInvert_outputs(): output_map = dict(output_file=dict(), output_grid=dict(), ) - outputs = XfmInvert.output_spec() + outputs = XfmInvert._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/developer.py b/nipype/interfaces/mipav/developer.py index c0762332cb..39b238ae4d 100644 --- a/nipype/interfaces/mipav/developer.py +++ b/nipype/interfaces/mipav/developer.py @@ -50,8 +50,8 @@ class JistLaminarVolumetricLayering(SEMLikeCommandLine): """ - input_spec = JistLaminarVolumetricLayeringInputSpec - output_spec = JistLaminarVolumetricLayeringOutputSpec + _input_spec = JistLaminarVolumetricLayeringInputSpec + _output_spec = JistLaminarVolumetricLayeringOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.laminar.JistLaminarVolumetricLayering " _outputs_filenames = {'outContinuous': 'outContinuous.nii', 'outLayer': 'outLayer.nii', 'outDiscrete': 'outDiscrete.nii'} _redirect_x = True @@ -102,8 +102,8 @@ class JistBrainMgdmSegmentation(SEMLikeCommandLine): """ - input_spec = JistBrainMgdmSegmentationInputSpec - output_spec = JistBrainMgdmSegmentationOutputSpec + _input_spec = JistBrainMgdmSegmentationInputSpec + _output_spec = JistBrainMgdmSegmentationOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.brain.JistBrainMgdmSegmentation " _outputs_filenames = {'outSegmented': 'outSegmented.nii', 'outPosterior2': 'outPosterior2.nii', 'outPosterior3': 'outPosterior3.nii', 'outLevelset': 'outLevelset.nii'} _redirect_x = True @@ -137,8 +137,8 @@ class JistLaminarProfileGeometry(SEMLikeCommandLine): """ - input_spec = JistLaminarProfileGeometryInputSpec - output_spec = JistLaminarProfileGeometryOutputSpec + _input_spec = JistLaminarProfileGeometryInputSpec + _output_spec = JistLaminarProfileGeometryOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.laminar.JistLaminarProfileGeometry " _outputs_filenames = {'outResult': 'outResult.nii'} _redirect_x = True @@ -170,8 +170,8 @@ class JistLaminarProfileCalculator(SEMLikeCommandLine): """ - input_spec = JistLaminarProfileCalculatorInputSpec - output_spec = JistLaminarProfileCalculatorOutputSpec + _input_spec = JistLaminarProfileCalculatorInputSpec + _output_spec = JistLaminarProfileCalculatorOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.laminar.JistLaminarProfileCalculator " _outputs_filenames = {'outResult': 'outResult.nii'} _redirect_x = True @@ -211,8 +211,8 @@ class MedicAlgorithmN3(SEMLikeCommandLine): """ - input_spec = MedicAlgorithmN3InputSpec - output_spec = MedicAlgorithmN3OutputSpec + _input_spec = MedicAlgorithmN3InputSpec + _output_spec = MedicAlgorithmN3OutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run edu.jhu.ece.iacl.plugins.classification.MedicAlgorithmN3 " _outputs_filenames = {'outInhomogeneity2': 'outInhomogeneity2.nii', 'outInhomogeneity': 'outInhomogeneity.nii'} _redirect_x = True @@ -245,8 +245,8 @@ class JistLaminarROIAveraging(SEMLikeCommandLine): """ - input_spec = JistLaminarROIAveragingInputSpec - output_spec = JistLaminarROIAveragingOutputSpec + _input_spec = JistLaminarROIAveragingInputSpec + _output_spec = JistLaminarROIAveragingOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.laminar.JistLaminarROIAveraging " _outputs_filenames = {'outROI3': 'outROI3'} _redirect_x = True @@ -315,8 +315,8 @@ class MedicAlgorithmLesionToads(SEMLikeCommandLine): """ - input_spec = MedicAlgorithmLesionToadsInputSpec - output_spec = MedicAlgorithmLesionToadsOutputSpec + _input_spec = MedicAlgorithmLesionToadsInputSpec + _output_spec = MedicAlgorithmLesionToadsOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run edu.jhu.ece.iacl.plugins.classification.MedicAlgorithmLesionToads " _outputs_filenames = {'outWM': 'outWM.nii', 'outHard': 'outHard.nii', 'outFilled': 'outFilled.nii', 'outMembership': 'outMembership.nii', 'outInhomogeneity': 'outInhomogeneity.nii', 'outCortical': 'outCortical.nii', 'outHard2': 'outHard2.nii', 'outLesion': 'outLesion.nii', 'outSulcal': 'outSulcal.nii'} _redirect_x = True @@ -356,8 +356,8 @@ class JistBrainMp2rageSkullStripping(SEMLikeCommandLine): """ - input_spec = JistBrainMp2rageSkullStrippingInputSpec - output_spec = JistBrainMp2rageSkullStrippingOutputSpec + _input_spec = JistBrainMp2rageSkullStrippingInputSpec + _output_spec = JistBrainMp2rageSkullStrippingOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.brain.JistBrainMp2rageSkullStripping " _outputs_filenames = {'outBrain': 'outBrain.nii', 'outMasked3': 'outMasked3.nii', 'outMasked2': 'outMasked2.nii', 'outMasked': 'outMasked.nii'} _redirect_x = True @@ -398,8 +398,8 @@ class JistCortexSurfaceMeshInflation(SEMLikeCommandLine): """ - input_spec = JistCortexSurfaceMeshInflationInputSpec - output_spec = JistCortexSurfaceMeshInflationOutputSpec + _input_spec = JistCortexSurfaceMeshInflationInputSpec + _output_spec = JistCortexSurfaceMeshInflationOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.cortex.JistCortexSurfaceMeshInflation " _outputs_filenames = {'outOriginal': 'outOriginal', 'outInflated': 'outInflated'} _redirect_x = True @@ -439,8 +439,8 @@ class RandomVol(SEMLikeCommandLine): """ - input_spec = RandomVolInputSpec - output_spec = RandomVolOutputSpec + _input_spec = RandomVolInputSpec + _output_spec = RandomVolOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run edu.jhu.bme.smile.demo.RandomVol " _outputs_filenames = {'outRand1': 'outRand1.nii'} _redirect_x = True @@ -474,8 +474,8 @@ class MedicAlgorithmImageCalculator(SEMLikeCommandLine): """ - input_spec = MedicAlgorithmImageCalculatorInputSpec - output_spec = MedicAlgorithmImageCalculatorOutputSpec + _input_spec = MedicAlgorithmImageCalculatorInputSpec + _output_spec = MedicAlgorithmImageCalculatorOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run edu.jhu.ece.iacl.plugins.utilities.math.MedicAlgorithmImageCalculator " _outputs_filenames = {'outResult': 'outResult.nii'} _redirect_x = True @@ -508,8 +508,8 @@ class JistBrainMp2rageDuraEstimation(SEMLikeCommandLine): """ - input_spec = JistBrainMp2rageDuraEstimationInputSpec - output_spec = JistBrainMp2rageDuraEstimationOutputSpec + _input_spec = JistBrainMp2rageDuraEstimationInputSpec + _output_spec = JistBrainMp2rageDuraEstimationOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.brain.JistBrainMp2rageDuraEstimation " _outputs_filenames = {'outDura': 'outDura.nii'} _redirect_x = True @@ -543,8 +543,8 @@ class JistLaminarProfileSampling(SEMLikeCommandLine): """ - input_spec = JistLaminarProfileSamplingInputSpec - output_spec = JistLaminarProfileSamplingOutputSpec + _input_spec = JistLaminarProfileSamplingInputSpec + _output_spec = JistLaminarProfileSamplingOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.laminar.JistLaminarProfileSampling " _outputs_filenames = {'outProfile2': 'outProfile2.nii', 'outProfilemapped': 'outProfilemapped.nii'} _redirect_x = True @@ -582,8 +582,8 @@ class MedicAlgorithmMipavReorient(SEMLikeCommandLine): """ - input_spec = MedicAlgorithmMipavReorientInputSpec - output_spec = MedicAlgorithmMipavReorientOutputSpec + _input_spec = MedicAlgorithmMipavReorientInputSpec + _output_spec = MedicAlgorithmMipavReorientOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run edu.jhu.ece.iacl.plugins.utilities.volume.MedicAlgorithmMipavReorient " _outputs_filenames = {} _redirect_x = True @@ -673,8 +673,8 @@ class MedicAlgorithmSPECTRE2010(SEMLikeCommandLine): """ - input_spec = MedicAlgorithmSPECTRE2010InputSpec - output_spec = MedicAlgorithmSPECTRE2010OutputSpec + _input_spec = MedicAlgorithmSPECTRE2010InputSpec + _output_spec = MedicAlgorithmSPECTRE2010OutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run edu.jhu.ece.iacl.plugins.segmentation.skull_strip.MedicAlgorithmSPECTRE2010 " _outputs_filenames = {'outd0': 'outd0.nii', 'outOriginal': 'outOriginal.nii', 'outMask': 'outMask.nii', 'outSplitHalves': 'outSplitHalves.nii', 'outMidsagittal': 'outMidsagittal.nii', 'outPrior': 'outPrior.nii', 'outFANTASM': 'outFANTASM.nii', 'outSegmentation': 'outSegmentation.nii', 'outStripped': 'outStripped.nii'} _redirect_x = True @@ -706,8 +706,8 @@ class JistBrainPartialVolumeFilter(SEMLikeCommandLine): """ - input_spec = JistBrainPartialVolumeFilterInputSpec - output_spec = JistBrainPartialVolumeFilterOutputSpec + _input_spec = JistBrainPartialVolumeFilterInputSpec + _output_spec = JistBrainPartialVolumeFilterOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.brain.JistBrainPartialVolumeFilter " _outputs_filenames = {'outPartial': 'outPartial.nii'} _redirect_x = True @@ -748,8 +748,8 @@ class JistIntensityMp2rageMasking(SEMLikeCommandLine): """ - input_spec = JistIntensityMp2rageMaskingInputSpec - output_spec = JistIntensityMp2rageMaskingOutputSpec + _input_spec = JistIntensityMp2rageMaskingInputSpec + _output_spec = JistIntensityMp2rageMaskingOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run de.mpg.cbs.jist.intensity.JistIntensityMp2rageMasking " _outputs_filenames = {'outSignal2': 'outSignal2.nii', 'outSignal': 'outSignal.nii', 'outMasked2': 'outMasked2.nii', 'outMasked': 'outMasked.nii'} _redirect_x = True @@ -784,8 +784,8 @@ class MedicAlgorithmThresholdToBinaryMask(SEMLikeCommandLine): """ - input_spec = MedicAlgorithmThresholdToBinaryMaskInputSpec - output_spec = MedicAlgorithmThresholdToBinaryMaskOutputSpec + _input_spec = MedicAlgorithmThresholdToBinaryMaskInputSpec + _output_spec = MedicAlgorithmThresholdToBinaryMaskOutputSpec _cmd = "java edu.jhu.ece.iacl.jist.cli.run edu.jhu.ece.iacl.plugins.utilities.volume.MedicAlgorithmThresholdToBinaryMask " _outputs_filenames = {} _redirect_x = True diff --git a/nipype/interfaces/mipav/tests/test_auto_JistBrainMgdmSegmentation.py b/nipype/interfaces/mipav/tests/test_auto_JistBrainMgdmSegmentation.py index e326a579a2..b5c97f1f85 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistBrainMgdmSegmentation.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistBrainMgdmSegmentation.py @@ -6,12 +6,6 @@ def test_JistBrainMgdmSegmentation_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inAdjust=dict(argstr='--inAdjust %s', ), inAtlas=dict(argstr='--inAtlas %s', @@ -58,8 +52,6 @@ def test_JistBrainMgdmSegmentation_inputs(): outSegmented=dict(argstr='--outSegmented %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -68,7 +60,7 @@ def test_JistBrainMgdmSegmentation_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistBrainMgdmSegmentation.input_spec() + inputs = JistBrainMgdmSegmentation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -81,7 +73,7 @@ def test_JistBrainMgdmSegmentation_outputs(): outPosterior3=dict(), outSegmented=dict(), ) - outputs = JistBrainMgdmSegmentation.output_spec() + outputs = JistBrainMgdmSegmentation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistBrainMp2rageDuraEstimation.py b/nipype/interfaces/mipav/tests/test_auto_JistBrainMp2rageDuraEstimation.py index d8fab93f50..7fd9a2fc81 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistBrainMp2rageDuraEstimation.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistBrainMp2rageDuraEstimation.py @@ -6,12 +6,6 @@ def test_JistBrainMp2rageDuraEstimation_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inDistance=dict(argstr='--inDistance %f', ), inSecond=dict(argstr='--inSecond %s', @@ -25,8 +19,6 @@ def test_JistBrainMp2rageDuraEstimation_inputs(): outDura=dict(argstr='--outDura %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -35,7 +27,7 @@ def test_JistBrainMp2rageDuraEstimation_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistBrainMp2rageDuraEstimation.input_spec() + inputs = JistBrainMp2rageDuraEstimation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_JistBrainMp2rageDuraEstimation_inputs(): def test_JistBrainMp2rageDuraEstimation_outputs(): output_map = dict(outDura=dict(), ) - outputs = JistBrainMp2rageDuraEstimation.output_spec() + outputs = JistBrainMp2rageDuraEstimation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistBrainMp2rageSkullStripping.py b/nipype/interfaces/mipav/tests/test_auto_JistBrainMp2rageSkullStripping.py index 12b3232fa7..febf1c3149 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistBrainMp2rageSkullStripping.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistBrainMp2rageSkullStripping.py @@ -6,12 +6,6 @@ def test_JistBrainMp2rageSkullStripping_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inFilter=dict(argstr='--inFilter %s', ), inSecond=dict(argstr='--inSecond %s', @@ -36,8 +30,6 @@ def test_JistBrainMp2rageSkullStripping_inputs(): outMasked3=dict(argstr='--outMasked3 %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -46,7 +38,7 @@ def test_JistBrainMp2rageSkullStripping_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistBrainMp2rageSkullStripping.input_spec() + inputs = JistBrainMp2rageSkullStripping._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -59,7 +51,7 @@ def test_JistBrainMp2rageSkullStripping_outputs(): outMasked2=dict(), outMasked3=dict(), ) - outputs = JistBrainMp2rageSkullStripping.output_spec() + outputs = JistBrainMp2rageSkullStripping._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistBrainPartialVolumeFilter.py b/nipype/interfaces/mipav/tests/test_auto_JistBrainPartialVolumeFilter.py index 659b4672b0..7d14f83e2a 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistBrainPartialVolumeFilter.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistBrainPartialVolumeFilter.py @@ -6,12 +6,6 @@ def test_JistBrainPartialVolumeFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inInput=dict(argstr='--inInput %s', ), inPV=dict(argstr='--inPV %s', @@ -23,8 +17,6 @@ def test_JistBrainPartialVolumeFilter_inputs(): outPartial=dict(argstr='--outPartial %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -33,7 +25,7 @@ def test_JistBrainPartialVolumeFilter_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistBrainPartialVolumeFilter.input_spec() + inputs = JistBrainPartialVolumeFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +35,7 @@ def test_JistBrainPartialVolumeFilter_inputs(): def test_JistBrainPartialVolumeFilter_outputs(): output_map = dict(outPartial=dict(), ) - outputs = JistBrainPartialVolumeFilter.output_spec() + outputs = JistBrainPartialVolumeFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistCortexSurfaceMeshInflation.py b/nipype/interfaces/mipav/tests/test_auto_JistCortexSurfaceMeshInflation.py index c4bf2b4c64..35b3714a14 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistCortexSurfaceMeshInflation.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistCortexSurfaceMeshInflation.py @@ -6,12 +6,6 @@ def test_JistCortexSurfaceMeshInflation_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inLevelset=dict(argstr='--inLevelset %s', ), inLorentzian=dict(argstr='--inLorentzian %s', @@ -34,8 +28,6 @@ def test_JistCortexSurfaceMeshInflation_inputs(): outOriginal=dict(argstr='--outOriginal %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -44,7 +36,7 @@ def test_JistCortexSurfaceMeshInflation_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistCortexSurfaceMeshInflation.input_spec() + inputs = JistCortexSurfaceMeshInflation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_JistCortexSurfaceMeshInflation_outputs(): output_map = dict(outInflated=dict(), outOriginal=dict(), ) - outputs = JistCortexSurfaceMeshInflation.output_spec() + outputs = JistCortexSurfaceMeshInflation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistIntensityMp2rageMasking.py b/nipype/interfaces/mipav/tests/test_auto_JistIntensityMp2rageMasking.py index e5eb472c0f..bf19468cd5 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistIntensityMp2rageMasking.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistIntensityMp2rageMasking.py @@ -6,12 +6,6 @@ def test_JistIntensityMp2rageMasking_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inBackground=dict(argstr='--inBackground %s', ), inMasking=dict(argstr='--inMasking %s', @@ -38,8 +32,6 @@ def test_JistIntensityMp2rageMasking_inputs(): outSignal2=dict(argstr='--outSignal2 %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -48,7 +40,7 @@ def test_JistIntensityMp2rageMasking_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistIntensityMp2rageMasking.input_spec() + inputs = JistIntensityMp2rageMasking._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -61,7 +53,7 @@ def test_JistIntensityMp2rageMasking_outputs(): outSignal=dict(), outSignal2=dict(), ) - outputs = JistIntensityMp2rageMasking.output_spec() + outputs = JistIntensityMp2rageMasking._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileCalculator.py b/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileCalculator.py index c00adac81c..e9efab1eae 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileCalculator.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileCalculator.py @@ -6,12 +6,6 @@ def test_JistLaminarProfileCalculator_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inIntensity=dict(argstr='--inIntensity %s', ), inMask=dict(argstr='--inMask %s', @@ -23,8 +17,6 @@ def test_JistLaminarProfileCalculator_inputs(): outResult=dict(argstr='--outResult %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -33,7 +25,7 @@ def test_JistLaminarProfileCalculator_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistLaminarProfileCalculator.input_spec() + inputs = JistLaminarProfileCalculator._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +35,7 @@ def test_JistLaminarProfileCalculator_inputs(): def test_JistLaminarProfileCalculator_outputs(): output_map = dict(outResult=dict(), ) - outputs = JistLaminarProfileCalculator.output_spec() + outputs = JistLaminarProfileCalculator._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileGeometry.py b/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileGeometry.py index b251f594db..1eccbf1a04 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileGeometry.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileGeometry.py @@ -6,12 +6,6 @@ def test_JistLaminarProfileGeometry_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inProfile=dict(argstr='--inProfile %s', ), incomputed=dict(argstr='--incomputed %s', @@ -27,8 +21,6 @@ def test_JistLaminarProfileGeometry_inputs(): outResult=dict(argstr='--outResult %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -37,7 +29,7 @@ def test_JistLaminarProfileGeometry_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistLaminarProfileGeometry.input_spec() + inputs = JistLaminarProfileGeometry._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_JistLaminarProfileGeometry_inputs(): def test_JistLaminarProfileGeometry_outputs(): output_map = dict(outResult=dict(), ) - outputs = JistLaminarProfileGeometry.output_spec() + outputs = JistLaminarProfileGeometry._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileSampling.py b/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileSampling.py index b9d5a067ec..8c82f168ca 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileSampling.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistLaminarProfileSampling.py @@ -6,12 +6,6 @@ def test_JistLaminarProfileSampling_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inCortex=dict(argstr='--inCortex %s', ), inIntensity=dict(argstr='--inIntensity %s', @@ -26,8 +20,6 @@ def test_JistLaminarProfileSampling_inputs(): outProfilemapped=dict(argstr='--outProfilemapped %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -36,7 +28,7 @@ def test_JistLaminarProfileSampling_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistLaminarProfileSampling.input_spec() + inputs = JistLaminarProfileSampling._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_JistLaminarProfileSampling_outputs(): output_map = dict(outProfile2=dict(), outProfilemapped=dict(), ) - outputs = JistLaminarProfileSampling.output_spec() + outputs = JistLaminarProfileSampling._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistLaminarROIAveraging.py b/nipype/interfaces/mipav/tests/test_auto_JistLaminarROIAveraging.py index 2c22ad0e70..8f43b4dec9 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistLaminarROIAveraging.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistLaminarROIAveraging.py @@ -6,12 +6,6 @@ def test_JistLaminarROIAveraging_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inIntensity=dict(argstr='--inIntensity %s', ), inMask=dict(argstr='--inMask %s', @@ -25,8 +19,6 @@ def test_JistLaminarROIAveraging_inputs(): outROI3=dict(argstr='--outROI3 %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -35,7 +27,7 @@ def test_JistLaminarROIAveraging_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistLaminarROIAveraging.input_spec() + inputs = JistLaminarROIAveraging._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_JistLaminarROIAveraging_inputs(): def test_JistLaminarROIAveraging_outputs(): output_map = dict(outROI3=dict(), ) - outputs = JistLaminarROIAveraging.output_spec() + outputs = JistLaminarROIAveraging._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_JistLaminarVolumetricLayering.py b/nipype/interfaces/mipav/tests/test_auto_JistLaminarVolumetricLayering.py index 40ff811855..95203ed9e7 100644 --- a/nipype/interfaces/mipav/tests/test_auto_JistLaminarVolumetricLayering.py +++ b/nipype/interfaces/mipav/tests/test_auto_JistLaminarVolumetricLayering.py @@ -6,12 +6,6 @@ def test_JistLaminarVolumetricLayering_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inInner=dict(argstr='--inInner %s', ), inLayering=dict(argstr='--inLayering %s', @@ -45,8 +39,6 @@ def test_JistLaminarVolumetricLayering_inputs(): outLayer=dict(argstr='--outLayer %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -55,7 +47,7 @@ def test_JistLaminarVolumetricLayering_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = JistLaminarVolumetricLayering.input_spec() + inputs = JistLaminarVolumetricLayering._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -67,7 +59,7 @@ def test_JistLaminarVolumetricLayering_outputs(): outDiscrete=dict(), outLayer=dict(), ) - outputs = JistLaminarVolumetricLayering.output_spec() + outputs = JistLaminarVolumetricLayering._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmImageCalculator.py b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmImageCalculator.py index 802669247f..771296e8be 100644 --- a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmImageCalculator.py +++ b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmImageCalculator.py @@ -6,12 +6,6 @@ def test_MedicAlgorithmImageCalculator_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inOperation=dict(argstr='--inOperation %s', ), inVolume=dict(argstr='--inVolume %s', @@ -23,8 +17,6 @@ def test_MedicAlgorithmImageCalculator_inputs(): outResult=dict(argstr='--outResult %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -33,7 +25,7 @@ def test_MedicAlgorithmImageCalculator_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = MedicAlgorithmImageCalculator.input_spec() + inputs = MedicAlgorithmImageCalculator._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +35,7 @@ def test_MedicAlgorithmImageCalculator_inputs(): def test_MedicAlgorithmImageCalculator_outputs(): output_map = dict(outResult=dict(), ) - outputs = MedicAlgorithmImageCalculator.output_spec() + outputs = MedicAlgorithmImageCalculator._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmLesionToads.py b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmLesionToads.py index 232d6a1362..1977d04dd5 100644 --- a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmLesionToads.py +++ b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmLesionToads.py @@ -6,12 +6,6 @@ def test_MedicAlgorithmLesionToads_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inAtlas=dict(argstr='--inAtlas %s', ), inAtlas2=dict(argstr='--inAtlas2 %s', @@ -83,8 +77,6 @@ def test_MedicAlgorithmLesionToads_inputs(): outWM=dict(argstr='--outWM %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -93,7 +85,7 @@ def test_MedicAlgorithmLesionToads_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = MedicAlgorithmLesionToads.input_spec() + inputs = MedicAlgorithmLesionToads._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -111,7 +103,7 @@ def test_MedicAlgorithmLesionToads_outputs(): outSulcal=dict(), outWM=dict(), ) - outputs = MedicAlgorithmLesionToads.output_spec() + outputs = MedicAlgorithmLesionToads._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmMipavReorient.py b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmMipavReorient.py index a9e43b3b04..a0dd338048 100644 --- a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmMipavReorient.py +++ b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmMipavReorient.py @@ -6,12 +6,6 @@ def test_MedicAlgorithmMipavReorient_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inInterpolation=dict(argstr='--inInterpolation %s', ), inNew=dict(argstr='--inNew %s', @@ -36,8 +30,6 @@ def test_MedicAlgorithmMipavReorient_inputs(): outReoriented=dict(argstr='--outReoriented %s', sep=';', ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -46,7 +38,7 @@ def test_MedicAlgorithmMipavReorient_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = MedicAlgorithmMipavReorient.input_spec() + inputs = MedicAlgorithmMipavReorient._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_MedicAlgorithmMipavReorient_inputs(): def test_MedicAlgorithmMipavReorient_outputs(): output_map = dict() - outputs = MedicAlgorithmMipavReorient.output_spec() + outputs = MedicAlgorithmMipavReorient._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmN3.py b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmN3.py index 58b3daa96f..b23191aead 100644 --- a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmN3.py +++ b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmN3.py @@ -6,12 +6,6 @@ def test_MedicAlgorithmN3_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inAutomatic=dict(argstr='--inAutomatic %s', ), inEnd=dict(argstr='--inEnd %f', @@ -38,8 +32,6 @@ def test_MedicAlgorithmN3_inputs(): outInhomogeneity2=dict(argstr='--outInhomogeneity2 %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -48,7 +40,7 @@ def test_MedicAlgorithmN3_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = MedicAlgorithmN3.input_spec() + inputs = MedicAlgorithmN3._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -59,7 +51,7 @@ def test_MedicAlgorithmN3_outputs(): output_map = dict(outInhomogeneity=dict(), outInhomogeneity2=dict(), ) - outputs = MedicAlgorithmN3.output_spec() + outputs = MedicAlgorithmN3._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmSPECTRE2010.py b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmSPECTRE2010.py index c8e005123b..d564684428 100644 --- a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmSPECTRE2010.py +++ b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmSPECTRE2010.py @@ -6,12 +6,6 @@ def test_MedicAlgorithmSPECTRE2010_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inApply=dict(argstr='--inApply %s', ), inAtlas=dict(argstr='--inAtlas %s', @@ -109,8 +103,6 @@ def test_MedicAlgorithmSPECTRE2010_inputs(): outd0=dict(argstr='--outd0 %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -119,7 +111,7 @@ def test_MedicAlgorithmSPECTRE2010_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = MedicAlgorithmSPECTRE2010.input_spec() + inputs = MedicAlgorithmSPECTRE2010._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -137,7 +129,7 @@ def test_MedicAlgorithmSPECTRE2010_outputs(): outStripped=dict(), outd0=dict(), ) - outputs = MedicAlgorithmSPECTRE2010.output_spec() + outputs = MedicAlgorithmSPECTRE2010._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmThresholdToBinaryMask.py b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmThresholdToBinaryMask.py index f472c7043f..ff2115de58 100644 --- a/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmThresholdToBinaryMask.py +++ b/nipype/interfaces/mipav/tests/test_auto_MedicAlgorithmThresholdToBinaryMask.py @@ -6,12 +6,6 @@ def test_MedicAlgorithmThresholdToBinaryMask_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inLabel=dict(argstr='--inLabel %s', sep=';', ), @@ -26,8 +20,6 @@ def test_MedicAlgorithmThresholdToBinaryMask_inputs(): outBinary=dict(argstr='--outBinary %s', sep=';', ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -36,7 +28,7 @@ def test_MedicAlgorithmThresholdToBinaryMask_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = MedicAlgorithmThresholdToBinaryMask.input_spec() + inputs = MedicAlgorithmThresholdToBinaryMask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_MedicAlgorithmThresholdToBinaryMask_inputs(): def test_MedicAlgorithmThresholdToBinaryMask_outputs(): output_map = dict() - outputs = MedicAlgorithmThresholdToBinaryMask.output_spec() + outputs = MedicAlgorithmThresholdToBinaryMask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mipav/tests/test_auto_RandomVol.py b/nipype/interfaces/mipav/tests/test_auto_RandomVol.py index be6839e209..c618d9bd8f 100644 --- a/nipype/interfaces/mipav/tests/test_auto_RandomVol.py +++ b/nipype/interfaces/mipav/tests/test_auto_RandomVol.py @@ -6,12 +6,6 @@ def test_RandomVol_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inField=dict(argstr='--inField %s', ), inLambda=dict(argstr='--inLambda %f', @@ -35,8 +29,6 @@ def test_RandomVol_inputs(): outRand1=dict(argstr='--outRand1 %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), xDefaultMem=dict(argstr='-xDefaultMem %d', ), xMaxProcess=dict(argstr='-xMaxProcess %d', @@ -45,7 +37,7 @@ def test_RandomVol_inputs(): xPrefExt=dict(argstr='--xPrefExt %s', ), ) - inputs = RandomVol.input_spec() + inputs = RandomVol._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_RandomVol_inputs(): def test_RandomVol_outputs(): output_map = dict(outRand1=dict(), ) - outputs = RandomVol.output_spec() + outputs = RandomVol._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mne/base.py b/nipype/interfaces/mne/base.py index 96d238f8ef..4855b04956 100644 --- a/nipype/interfaces/mne/base.py +++ b/nipype/interfaces/mne/base.py @@ -60,8 +60,8 @@ class WatershedBEM(FSCommand): """ _cmd = 'mne_watershed_bem' - input_spec = WatershedBEMInputSpec - output_spec = WatershedBEMOutputSpec + _input_spec = WatershedBEMInputSpec + _output_spec = WatershedBEMOutputSpec _additional_metadata = ['loc', 'altkey'] def _get_files(self, path, key, dirval, altkey=None): @@ -73,8 +73,8 @@ def _get_files(self, path, key, dirval, altkey=None): globpattern = op.join(keydir, ''.join((globprefix, key, globsuffix))) return glob.glob(globpattern) - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + subjects_dir = self.inputs.subjects_dir subject_path = op.join(subjects_dir, self.inputs.subject_id) output_traits = self._outputs() @@ -94,8 +94,8 @@ def _list_outputs(self): out_files = op.abspath(value_list) else: raise TypeError - outputs[k] = out_files + setattr(self.outputs, k, out_files) if not k.rfind('surface') == -1: mesh_paths.append(out_files) - outputs['mesh_files'] = mesh_paths - return outputs + self.outputs.mesh_files = mesh_paths + diff --git a/nipype/interfaces/mne/tests/test_auto_WatershedBEM.py b/nipype/interfaces/mne/tests/test_auto_WatershedBEM.py index 28c42e1c6d..81f3ef4f36 100644 --- a/nipype/interfaces/mne/tests/test_auto_WatershedBEM.py +++ b/nipype/interfaces/mne/tests/test_auto_WatershedBEM.py @@ -8,12 +8,6 @@ def test_WatershedBEM_inputs(): ), atlas_mode=dict(argstr='--atlas', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), overwrite=dict(argstr='--overwrite', usedefault=True, ), @@ -23,13 +17,11 @@ def test_WatershedBEM_inputs(): subjects_dir=dict(mandatory=True, usedefault=True, ), - terminal_output=dict(nohash=True, - ), volume=dict(argstr='--volume %s', usedefault=True, ), ) - inputs = WatershedBEM.input_spec() + inputs = WatershedBEM._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +45,7 @@ def test_WatershedBEM_outputs(): outer_skull_surface=dict(loc='bem/watershed', ), ) - outputs = WatershedBEM.output_spec() + outputs = WatershedBEM._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/convert.py b/nipype/interfaces/mrtrix/convert.py index 89cf1c2299..f33f4154c6 100644 --- a/nipype/interfaces/mrtrix/convert.py +++ b/nipype/interfaces/mrtrix/convert.py @@ -19,7 +19,7 @@ from nibabel.trackvis import HeaderError from nibabel.volumeutils import native_code -from ..base import (TraitedSpec, BaseInterface, BaseInterfaceInputSpec, +from ..base import (TraitedSpec, BaseInterface, BaseInputSpec, File, isdefined, traits) from ...utils.filemanip import split_filename from ...utils.misc import package_check @@ -177,8 +177,8 @@ class MRTrix2TrackVis(BaseInterface): >>> tck2trk.inputs.image_file = 'diffusion.nii' >>> tck2trk.run() # doctest: +SKIP """ - input_spec = MRTrix2TrackVisInputSpec - output_spec = MRTrix2TrackVisOutputSpec + _input_spec = MRTrix2TrackVisInputSpec + _output_spec = MRTrix2TrackVisOutputSpec def _run_interface(self, runtime): dx, dy, dz = get_data_dims(self.inputs.image_file) @@ -239,11 +239,9 @@ def _run_interface(self, runtime): iflogger.info(trk_header) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = op.abspath(self.inputs.out_filename) - return outputs - + def _post_run(self): + self.outputs.out_file = op.abspath(self.inputs.out_filename) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() diff --git a/nipype/interfaces/mrtrix/preprocess.py b/nipype/interfaces/mrtrix/preprocess.py index 67242e9705..7b894ec353 100644 --- a/nipype/interfaces/mrtrix/preprocess.py +++ b/nipype/interfaces/mrtrix/preprocess.py @@ -64,18 +64,17 @@ class MRConvert(CommandLine): """ _cmd = 'mrconvert' - input_spec = MRConvertInputSpec - output_spec = MRConvertOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['converted'] = self.inputs.out_filename - if not isdefined(outputs['converted']): - outputs['converted'] = op.abspath(self._gen_outfilename()) + _input_spec = MRConvertInputSpec + _output_spec = MRConvertOutputSpec + + def _post_run(self): + + self.outputs.converted = self.inputs.out_filename + if not isdefined(self.outputs.converted): + self.outputs.converted = op.abspath(self._gen_outfilename()) else: - outputs['converted'] = op.abspath(outputs['converted']) - return outputs - + self.outputs.converted = op.abspath(self.outputs.converted) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -147,8 +146,8 @@ class DWI2Tensor(CommandLine): """ _cmd = 'dwi2tensor' - input_spec = DWI2TensorInputSpec - output_spec = DWI2TensorOutputSpec + _input_spec = DWI2TensorInputSpec + _output_spec = DWI2TensorOutputSpec class Tensor2VectorInputSpec(CommandLineInputSpec): @@ -177,18 +176,17 @@ class Tensor2Vector(CommandLine): """ _cmd = 'tensor2vector' - input_spec = Tensor2VectorInputSpec - output_spec = Tensor2VectorOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['vector'] = self.inputs.out_filename - if not isdefined(outputs['vector']): - outputs['vector'] = op.abspath(self._gen_outfilename()) + _input_spec = Tensor2VectorInputSpec + _output_spec = Tensor2VectorOutputSpec + + def _post_run(self): + + self.outputs.vector = self.inputs.out_filename + if not isdefined(self.outputs.vector): + self.outputs.vector = op.abspath(self._gen_outfilename()) else: - outputs['vector'] = op.abspath(outputs['vector']) - return outputs - + self.outputs.vector = op.abspath(self.outputs.vector) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -226,18 +224,17 @@ class Tensor2FractionalAnisotropy(CommandLine): """ _cmd = 'tensor2FA' - input_spec = Tensor2FractionalAnisotropyInputSpec - output_spec = Tensor2FractionalAnisotropyOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['FA'] = self.inputs.out_filename - if not isdefined(outputs['FA']): - outputs['FA'] = op.abspath(self._gen_outfilename()) + _input_spec = Tensor2FractionalAnisotropyInputSpec + _output_spec = Tensor2FractionalAnisotropyOutputSpec + + def _post_run(self): + + self.outputs.FA = self.inputs.out_filename + if not isdefined(self.outputs.FA): + self.outputs.FA = op.abspath(self._gen_outfilename()) else: - outputs['FA'] = op.abspath(outputs['FA']) - return outputs - + self.outputs.FA = op.abspath(self.outputs.FA) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -275,18 +272,17 @@ class Tensor2ApparentDiffusion(CommandLine): """ _cmd = 'tensor2ADC' - input_spec = Tensor2ApparentDiffusionInputSpec - output_spec = Tensor2ApparentDiffusionOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['ADC'] = self.inputs.out_filename - if not isdefined(outputs['ADC']): - outputs['ADC'] = op.abspath(self._gen_outfilename()) + _input_spec = Tensor2ApparentDiffusionInputSpec + _output_spec = Tensor2ApparentDiffusionOutputSpec + + def _post_run(self): + + self.outputs.ADC = self.inputs.out_filename + if not isdefined(self.outputs.ADC): + self.outputs.ADC = op.abspath(self._gen_outfilename()) else: - outputs['ADC'] = op.abspath(outputs['ADC']) - return outputs - + self.outputs.ADC = op.abspath(self.outputs.ADC) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -325,18 +321,17 @@ class MRMultiply(CommandLine): """ _cmd = 'mrmult' - input_spec = MRMultiplyInputSpec - output_spec = MRMultiplyOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_filename - if not isdefined(outputs['out_file']): - outputs['out_file'] = op.abspath(self._gen_outfilename()) + _input_spec = MRMultiplyInputSpec + _output_spec = MRMultiplyOutputSpec + + def _post_run(self): + + self.outputs.out_file = self.inputs.out_filename + if not isdefined(self.outputs.out_file): + self.outputs.out_file = op.abspath(self._gen_outfilename()) else: - outputs['out_file'] = op.abspath(outputs['out_file']) - return outputs - + self.outputs.out_file = op.abspath(self.outputs.out_file) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -374,10 +369,10 @@ class MRTrixViewer(CommandLine): """ _cmd = 'mrview' - input_spec = MRTrixViewerInputSpec - output_spec = MRTrixViewerOutputSpec + _input_spec = MRTrixViewerInputSpec + _output_spec = MRTrixViewerOutputSpec - def _list_outputs(self): + def _post_run(self): return @@ -404,10 +399,10 @@ class MRTrixInfo(CommandLine): """ _cmd = 'mrinfo' - input_spec = MRTrixInfoInputSpec - output_spec = MRTrixInfoOutputSpec + _input_spec = MRTrixInfoInputSpec + _output_spec = MRTrixInfoOutputSpec - def _list_outputs(self): + def _post_run(self): return @@ -439,14 +434,13 @@ class GenerateWhiteMatterMask(CommandLine): """ _cmd = 'gen_WM_mask' - input_spec = GenerateWhiteMatterMaskInputSpec - output_spec = GenerateWhiteMatterMaskOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['WMprobabilitymap'] = op.abspath(self._gen_outfilename()) - return outputs + _input_spec = GenerateWhiteMatterMaskInputSpec + _output_spec = GenerateWhiteMatterMaskOutputSpec + def _post_run(self): + + self.outputs.WMprobabilitymap = op.abspath(self._gen_outfilename()) + def _gen_filename(self, name): if name is 'out_WMProb_filename': return self._gen_outfilename() @@ -485,18 +479,17 @@ class Erode(CommandLine): >>> erode.run() # doctest: +SKIP """ _cmd = 'erode' - input_spec = ErodeInputSpec - output_spec = ErodeOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_filename - if not isdefined(outputs['out_file']): - outputs['out_file'] = op.abspath(self._gen_outfilename()) + _input_spec = ErodeInputSpec + _output_spec = ErodeOutputSpec + + def _post_run(self): + + self.outputs.out_file = self.inputs.out_filename + if not isdefined(self.outputs.out_file): + self.outputs.out_file = op.abspath(self._gen_outfilename()) else: - outputs['out_file'] = op.abspath(outputs['out_file']) - return outputs - + self.outputs.out_file = op.abspath(self.outputs.out_file) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -543,18 +536,17 @@ class Threshold(CommandLine): """ _cmd = 'threshold' - input_spec = ThresholdInputSpec - output_spec = ThresholdOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_filename - if not isdefined(outputs['out_file']): - outputs['out_file'] = op.abspath(self._gen_outfilename()) + _input_spec = ThresholdInputSpec + _output_spec = ThresholdOutputSpec + + def _post_run(self): + + self.outputs.out_file = self.inputs.out_filename + if not isdefined(self.outputs.out_file): + self.outputs.out_file = op.abspath(self._gen_outfilename()) else: - outputs['out_file'] = op.abspath(outputs['out_file']) - return outputs - + self.outputs.out_file = op.abspath(self.outputs.out_file) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -592,18 +584,17 @@ class MedianFilter3D(CommandLine): """ _cmd = 'median3D' - input_spec = MedianFilter3DInputSpec - output_spec = MedianFilter3DOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_filename - if not isdefined(outputs['out_file']): - outputs['out_file'] = op.abspath(self._gen_outfilename()) + _input_spec = MedianFilter3DInputSpec + _output_spec = MedianFilter3DOutputSpec + + def _post_run(self): + + self.outputs.out_file = self.inputs.out_filename + if not isdefined(self.outputs.out_file): + self.outputs.out_file = op.abspath(self._gen_outfilename()) else: - outputs['out_file'] = op.abspath(outputs['out_file']) - return outputs - + self.outputs.out_file = op.abspath(self.outputs.out_file) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -650,18 +641,17 @@ class MRTransform(CommandLine): """ _cmd = 'mrtransform' - input_spec = MRTransformInputSpec - output_spec = MRTransformOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_filename - if not isdefined(outputs['out_file']): - outputs['out_file'] = op.abspath(self._gen_outfilename()) + _input_spec = MRTransformInputSpec + _output_spec = MRTransformOutputSpec + + def _post_run(self): + + self.outputs.out_file = self.inputs.out_filename + if not isdefined(self.outputs.out_file): + self.outputs.out_file = op.abspath(self._gen_outfilename()) else: - outputs['out_file'] = op.abspath(outputs['out_file']) - return outputs - + self.outputs.out_file = op.abspath(self.outputs.out_file) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() diff --git a/nipype/interfaces/mrtrix/tensors.py b/nipype/interfaces/mrtrix/tensors.py index 3ef2ecc901..d70a863acd 100644 --- a/nipype/interfaces/mrtrix/tensors.py +++ b/nipype/interfaces/mrtrix/tensors.py @@ -13,7 +13,7 @@ import numpy as np from ..base import (CommandLineInputSpec, CommandLine, BaseInterface, - BaseInterfaceInputSpec, traits, File, TraitedSpec, + BaseInputSpec, traits, File, TraitedSpec, Directory, InputMultiPath, OutputMultiPath, isdefined) from ...utils.filemanip import split_filename from ... import logging @@ -72,18 +72,17 @@ class DWI2SphericalHarmonicsImage(CommandLine): >>> dwi2SH.run() # doctest: +SKIP """ _cmd = 'dwi2SH' - input_spec = DWI2SphericalHarmonicsImageInputSpec - output_spec = DWI2SphericalHarmonicsImageOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['spherical_harmonics_image'] = self.inputs.out_filename - if not isdefined(outputs['spherical_harmonics_image']): - outputs['spherical_harmonics_image'] = op.abspath(self._gen_outfilename()) + _input_spec = DWI2SphericalHarmonicsImageInputSpec + _output_spec = DWI2SphericalHarmonicsImageOutputSpec + + def _post_run(self): + + self.outputs.spherical_harmonics_image = self.inputs.out_filename + if not isdefined(self.outputs.spherical_harmonics_image): + self.outputs.spherical_harmonics_image = op.abspath(self._gen_outfilename()) else: - outputs['spherical_harmonics_image'] = op.abspath(outputs['spherical_harmonics_image']) - return outputs - + self.outputs.spherical_harmonics_image = op.abspath(self.outputs.spherical_harmonics_image) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -155,18 +154,17 @@ class ConstrainedSphericalDeconvolution(CommandLine): """ _cmd = 'csdeconv' - input_spec = ConstrainedSphericalDeconvolutionInputSpec - output_spec = ConstrainedSphericalDeconvolutionOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['spherical_harmonics_image'] = self.inputs.out_filename - if not isdefined(outputs['spherical_harmonics_image']): - outputs['spherical_harmonics_image'] = op.abspath(self._gen_outfilename()) + _input_spec = ConstrainedSphericalDeconvolutionInputSpec + _output_spec = ConstrainedSphericalDeconvolutionOutputSpec + + def _post_run(self): + + self.outputs.spherical_harmonics_image = self.inputs.out_filename + if not isdefined(self.outputs.spherical_harmonics_image): + self.outputs.spherical_harmonics_image = op.abspath(self._gen_outfilename()) else: - outputs['spherical_harmonics_image'] = op.abspath(outputs['spherical_harmonics_image']) - return outputs - + self.outputs.spherical_harmonics_image = op.abspath(self.outputs.spherical_harmonics_image) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -209,18 +207,17 @@ class EstimateResponseForSH(CommandLine): >>> estresp.run() # doctest: +SKIP """ _cmd = 'estimate_response' - input_spec = EstimateResponseForSHInputSpec - output_spec = EstimateResponseForSHOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['response'] = self.inputs.out_filename - if not isdefined(outputs['response']): - outputs['response'] = op.abspath(self._gen_outfilename()) + _input_spec = EstimateResponseForSHInputSpec + _output_spec = EstimateResponseForSHOutputSpec + + def _post_run(self): + + self.outputs.response = self.inputs.out_filename + if not isdefined(self.outputs.response): + self.outputs.response = op.abspath(self._gen_outfilename()) else: - outputs['response'] = op.abspath(outputs['response']) - return outputs - + self.outputs.response = op.abspath(self.outputs.response) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -289,18 +286,17 @@ class FSL2MRTrix(BaseInterface): >>> fsl2mrtrix.inputs.invert_y = True >>> fsl2mrtrix.run() # doctest: +SKIP """ - input_spec = FSL2MRTrixInputSpec - output_spec = FSL2MRTrixOutputSpec + _input_spec = FSL2MRTrixInputSpec + _output_spec = FSL2MRTrixOutputSpec def _run_interface(self, runtime): encoding = concat_files(self.inputs.bvec_file, self.inputs.bval_file, self.inputs.invert_x, self.inputs.invert_y, self.inputs.invert_z) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['encoding_file'] = op.abspath(self._gen_filename('out_encoding_file')) - return outputs - + def _post_run(self): + + self.outputs.encoding_file = op.abspath(self._gen_filename('out_encoding_file')) + def _gen_filename(self, name): if name is 'out_encoding_file': return self._gen_outfilename() @@ -343,8 +339,8 @@ class GenerateDirections(CommandLine): """ _cmd = 'gendir' - input_spec = GenerateDirectionsInputSpec - output_spec = GenerateDirectionsOutputSpec + _input_spec = GenerateDirectionsInputSpec + _output_spec = GenerateDirectionsOutputSpec class FindShPeaksInputSpec(CommandLineInputSpec): @@ -383,8 +379,8 @@ class FindShPeaks(CommandLine): """ _cmd = 'find_SH_peaks' - input_spec = FindShPeaksInputSpec - output_spec = FindShPeaksOutputSpec + _input_spec = FindShPeaksInputSpec + _output_spec = FindShPeaksOutputSpec class Directions2AmplitudeInputSpec(CommandLineInputSpec): @@ -419,5 +415,5 @@ class Directions2Amplitude(CommandLine): """ _cmd = 'dir2amp' - input_spec = Directions2AmplitudeInputSpec - output_spec = Directions2AmplitudeOutputSpec + _input_spec = Directions2AmplitudeInputSpec + _output_spec = Directions2AmplitudeOutputSpec diff --git a/nipype/interfaces/mrtrix/tests/test_auto_ConstrainedSphericalDeconvolution.py b/nipype/interfaces/mrtrix/tests/test_auto_ConstrainedSphericalDeconvolution.py index 4bf97e42f7..2104a09415 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_ConstrainedSphericalDeconvolution.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_ConstrainedSphericalDeconvolution.py @@ -14,15 +14,9 @@ def test_ConstrainedSphericalDeconvolution_inputs(): encoding_file=dict(argstr='-grad %s', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), filter_file=dict(argstr='-filter %s', position=-2, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-3, @@ -47,12 +41,10 @@ def test_ConstrainedSphericalDeconvolution_inputs(): mandatory=True, position=-2, ), - terminal_output=dict(nohash=True, - ), threshold_value=dict(argstr='-threshold %s', ), ) - inputs = ConstrainedSphericalDeconvolution.input_spec() + inputs = ConstrainedSphericalDeconvolution._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -62,7 +54,7 @@ def test_ConstrainedSphericalDeconvolution_inputs(): def test_ConstrainedSphericalDeconvolution_outputs(): output_map = dict(spherical_harmonics_image=dict(), ) - outputs = ConstrainedSphericalDeconvolution.output_spec() + outputs = ConstrainedSphericalDeconvolution._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_DWI2SphericalHarmonicsImage.py b/nipype/interfaces/mrtrix/tests/test_auto_DWI2SphericalHarmonicsImage.py index 28d3c97831..1124a1cba7 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_DWI2SphericalHarmonicsImage.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_DWI2SphericalHarmonicsImage.py @@ -10,12 +10,6 @@ def test_DWI2SphericalHarmonicsImage_inputs(): mandatory=True, position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -29,10 +23,8 @@ def test_DWI2SphericalHarmonicsImage_inputs(): genfile=True, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DWI2SphericalHarmonicsImage.input_spec() + inputs = DWI2SphericalHarmonicsImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_DWI2SphericalHarmonicsImage_inputs(): def test_DWI2SphericalHarmonicsImage_outputs(): output_map = dict(spherical_harmonics_image=dict(), ) - outputs = DWI2SphericalHarmonicsImage.output_spec() + outputs = DWI2SphericalHarmonicsImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_DWI2Tensor.py b/nipype/interfaces/mrtrix/tests/test_auto_DWI2Tensor.py index 1062277c13..63b3fffacb 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_DWI2Tensor.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_DWI2Tensor.py @@ -12,12 +12,6 @@ def test_DWI2Tensor_inputs(): encoding_file=dict(argstr='-grad %s', position=2, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), ignore_slice_by_volume=dict(argstr='-ignoreslices %s', position=2, sep=' ', @@ -39,10 +33,8 @@ def test_DWI2Tensor_inputs(): quiet=dict(argstr='-quiet', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DWI2Tensor.input_spec() + inputs = DWI2Tensor._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_DWI2Tensor_inputs(): def test_DWI2Tensor_outputs(): output_map = dict(tensor=dict(), ) - outputs = DWI2Tensor.output_spec() + outputs = DWI2Tensor._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_DiffusionTensorStreamlineTrack.py b/nipype/interfaces/mrtrix/tests/test_auto_DiffusionTensorStreamlineTrack.py index 42cb14de9f..1b34fa1d2d 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_DiffusionTensorStreamlineTrack.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_DiffusionTensorStreamlineTrack.py @@ -13,9 +13,6 @@ def test_DiffusionTensorStreamlineTrack_inputs(): ), do_not_precompute=dict(argstr='-noprecomputed', ), - environ=dict(nohash=True, - usedefault=True, - ), exclude_file=dict(argstr='-exclude %s', xor=['exclude_file', 'exclude_spec'], ), @@ -29,9 +26,6 @@ def test_DiffusionTensorStreamlineTrack_inputs(): mandatory=True, position=-2, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -97,12 +91,10 @@ def test_DiffusionTensorStreamlineTrack_inputs(): ), stop=dict(argstr='-stop', ), - terminal_output=dict(nohash=True, - ), unidirectional=dict(argstr='-unidirectional', ), ) - inputs = DiffusionTensorStreamlineTrack.input_spec() + inputs = DiffusionTensorStreamlineTrack._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -112,7 +104,7 @@ def test_DiffusionTensorStreamlineTrack_inputs(): def test_DiffusionTensorStreamlineTrack_outputs(): output_map = dict(tracked=dict(), ) - outputs = DiffusionTensorStreamlineTrack.output_spec() + outputs = DiffusionTensorStreamlineTrack._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_Directions2Amplitude.py b/nipype/interfaces/mrtrix/tests/test_auto_Directions2Amplitude.py index 1fb1d8d764..c6044d9b3f 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_Directions2Amplitude.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_Directions2Amplitude.py @@ -10,12 +10,6 @@ def test_Directions2Amplitude_inputs(): ), display_info=dict(argstr='-info', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -36,10 +30,8 @@ def test_Directions2Amplitude_inputs(): ), quiet_display=dict(argstr='-quiet', ), - terminal_output=dict(nohash=True, - ), ) - inputs = Directions2Amplitude.input_spec() + inputs = Directions2Amplitude._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -49,7 +41,7 @@ def test_Directions2Amplitude_inputs(): def test_Directions2Amplitude_outputs(): output_map = dict(out_file=dict(), ) - outputs = Directions2Amplitude.output_spec() + outputs = Directions2Amplitude._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_Erode.py b/nipype/interfaces/mrtrix/tests/test_auto_Erode.py index 3161e6e0fd..6bb4dc9749 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_Erode.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_Erode.py @@ -12,12 +12,6 @@ def test_Erode_inputs(): dilate=dict(argstr='-dilate', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -31,10 +25,8 @@ def test_Erode_inputs(): quiet=dict(argstr='-quiet', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Erode.input_spec() + inputs = Erode._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +36,7 @@ def test_Erode_inputs(): def test_Erode_outputs(): output_map = dict(out_file=dict(), ) - outputs = Erode.output_spec() + outputs = Erode._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_EstimateResponseForSH.py b/nipype/interfaces/mrtrix/tests/test_auto_EstimateResponseForSH.py index ff6a638f14..56c72ab0b4 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_EstimateResponseForSH.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_EstimateResponseForSH.py @@ -12,12 +12,6 @@ def test_EstimateResponseForSH_inputs(): mandatory=True, position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-3, @@ -36,10 +30,8 @@ def test_EstimateResponseForSH_inputs(): ), quiet=dict(argstr='-quiet', ), - terminal_output=dict(nohash=True, - ), ) - inputs = EstimateResponseForSH.input_spec() + inputs = EstimateResponseForSH._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -49,7 +41,7 @@ def test_EstimateResponseForSH_inputs(): def test_EstimateResponseForSH_outputs(): output_map = dict(response=dict(), ) - outputs = EstimateResponseForSH.output_spec() + outputs = EstimateResponseForSH._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_FSL2MRTrix.py b/nipype/interfaces/mrtrix/tests/test_auto_FSL2MRTrix.py index 03cc06b2ed..980dfeaee0 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_FSL2MRTrix.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_FSL2MRTrix.py @@ -17,7 +17,7 @@ def test_FSL2MRTrix_inputs(): out_encoding_file=dict(genfile=True, ), ) - inputs = FSL2MRTrix.input_spec() + inputs = FSL2MRTrix._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -27,7 +27,7 @@ def test_FSL2MRTrix_inputs(): def test_FSL2MRTrix_outputs(): output_map = dict(encoding_file=dict(), ) - outputs = FSL2MRTrix.output_spec() + outputs = FSL2MRTrix._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_FilterTracks.py b/nipype/interfaces/mrtrix/tests/test_auto_FilterTracks.py index 099d08c2de..261daf6be2 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_FilterTracks.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_FilterTracks.py @@ -9,9 +9,6 @@ def test_FilterTracks_inputs(): debug=dict(argstr='-debug', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), exclude_file=dict(argstr='-exclude %s', xor=['exclude_file', 'exclude_spec'], ), @@ -21,9 +18,6 @@ def test_FilterTracks_inputs(): units='mm', xor=['exclude_file', 'exclude_spec'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -53,10 +47,8 @@ def test_FilterTracks_inputs(): quiet=dict(argstr='-quiet', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = FilterTracks.input_spec() + inputs = FilterTracks._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -66,7 +58,7 @@ def test_FilterTracks_inputs(): def test_FilterTracks_outputs(): output_map = dict(out_file=dict(), ) - outputs = FilterTracks.output_spec() + outputs = FilterTracks._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_FindShPeaks.py b/nipype/interfaces/mrtrix/tests/test_auto_FindShPeaks.py index d4776cb4b3..43cc5d4627 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_FindShPeaks.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_FindShPeaks.py @@ -14,12 +14,6 @@ def test_FindShPeaks_inputs(): ), display_info=dict(argstr='-info', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-3, @@ -42,10 +36,8 @@ def test_FindShPeaks_inputs(): ), quiet_display=dict(argstr='-quiet', ), - terminal_output=dict(nohash=True, - ), ) - inputs = FindShPeaks.input_spec() + inputs = FindShPeaks._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_FindShPeaks_inputs(): def test_FindShPeaks_outputs(): output_map = dict(out_file=dict(), ) - outputs = FindShPeaks.output_spec() + outputs = FindShPeaks._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_GenerateDirections.py b/nipype/interfaces/mrtrix/tests/test_auto_GenerateDirections.py index bd54f78fb3..9c32884b97 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_GenerateDirections.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_GenerateDirections.py @@ -10,12 +10,6 @@ def test_GenerateDirections_inputs(): ), display_info=dict(argstr='-info', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), niter=dict(argstr='-niter %s', ), num_dirs=dict(argstr='%s', @@ -32,10 +26,8 @@ def test_GenerateDirections_inputs(): ), quiet_display=dict(argstr='-quiet', ), - terminal_output=dict(nohash=True, - ), ) - inputs = GenerateDirections.input_spec() + inputs = GenerateDirections._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_GenerateDirections_inputs(): def test_GenerateDirections_outputs(): output_map = dict(out_file=dict(), ) - outputs = GenerateDirections.output_spec() + outputs = GenerateDirections._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_GenerateWhiteMatterMask.py b/nipype/interfaces/mrtrix/tests/test_auto_GenerateWhiteMatterMask.py index 909015a608..6e57789400 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_GenerateWhiteMatterMask.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_GenerateWhiteMatterMask.py @@ -14,12 +14,6 @@ def test_GenerateWhiteMatterMask_inputs(): mandatory=True, position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-3, @@ -30,10 +24,8 @@ def test_GenerateWhiteMatterMask_inputs(): genfile=True, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = GenerateWhiteMatterMask.input_spec() + inputs = GenerateWhiteMatterMask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +35,7 @@ def test_GenerateWhiteMatterMask_inputs(): def test_GenerateWhiteMatterMask_outputs(): output_map = dict(WMprobabilitymap=dict(), ) - outputs = GenerateWhiteMatterMask.output_spec() + outputs = GenerateWhiteMatterMask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_MRConvert.py b/nipype/interfaces/mrtrix/tests/test_auto_MRConvert.py index 75cb4ff985..cf75765206 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_MRConvert.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_MRConvert.py @@ -6,9 +6,6 @@ def test_MRConvert_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), extension=dict(position=2, usedefault=True, ), @@ -19,9 +16,6 @@ def test_MRConvert_inputs(): position=2, sep=',', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -50,14 +44,12 @@ def test_MRConvert_inputs(): position=3, units='mm', ), - terminal_output=dict(nohash=True, - ), voxel_dims=dict(argstr='-vox %s', position=3, sep=',', ), ) - inputs = MRConvert.input_spec() + inputs = MRConvert._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -67,7 +59,7 @@ def test_MRConvert_inputs(): def test_MRConvert_outputs(): output_map = dict(converted=dict(), ) - outputs = MRConvert.output_spec() + outputs = MRConvert._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_MRMultiply.py b/nipype/interfaces/mrtrix/tests/test_auto_MRMultiply.py index 4c76a6f96c..59a788867f 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_MRMultiply.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_MRMultiply.py @@ -9,12 +9,6 @@ def test_MRMultiply_inputs(): debug=dict(argstr='-debug', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='%s', mandatory=True, position=-2, @@ -26,10 +20,8 @@ def test_MRMultiply_inputs(): quiet=dict(argstr='-quiet', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = MRMultiply.input_spec() + inputs = MRMultiply._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_MRMultiply_inputs(): def test_MRMultiply_outputs(): output_map = dict(out_file=dict(), ) - outputs = MRMultiply.output_spec() + outputs = MRMultiply._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_MRTransform.py b/nipype/interfaces/mrtrix/tests/test_auto_MRTransform.py index 0376e9b4e1..1d0751fcf1 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_MRTransform.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_MRTransform.py @@ -9,15 +9,9 @@ def test_MRTransform_inputs(): debug=dict(argstr='-debug', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), flip_x=dict(argstr='-flipx', position=1, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='%s', mandatory=True, position=-2, @@ -41,13 +35,11 @@ def test_MRTransform_inputs(): template_image=dict(argstr='-template %s', position=1, ), - terminal_output=dict(nohash=True, - ), transformation_file=dict(argstr='-transform %s', position=1, ), ) - inputs = MRTransform.input_spec() + inputs = MRTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -57,7 +49,7 @@ def test_MRTransform_inputs(): def test_MRTransform_outputs(): output_map = dict(out_file=dict(), ) - outputs = MRTransform.output_spec() + outputs = MRTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_MRTrix2TrackVis.py b/nipype/interfaces/mrtrix/tests/test_auto_MRTrix2TrackVis.py index d7da413c92..69ab46acea 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_MRTrix2TrackVis.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_MRTrix2TrackVis.py @@ -13,7 +13,7 @@ def test_MRTrix2TrackVis_inputs(): ), registration_image_file=dict(), ) - inputs = MRTrix2TrackVis.input_spec() + inputs = MRTrix2TrackVis._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -23,7 +23,7 @@ def test_MRTrix2TrackVis_inputs(): def test_MRTrix2TrackVis_outputs(): output_map = dict(out_file=dict(), ) - outputs = MRTrix2TrackVis.output_spec() + outputs = MRTrix2TrackVis._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_MRTrixInfo.py b/nipype/interfaces/mrtrix/tests/test_auto_MRTrixInfo.py index 73671df40c..a245b5caf6 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_MRTrixInfo.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_MRTrixInfo.py @@ -6,20 +6,12 @@ def test_MRTrixInfo_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = MRTrixInfo.input_spec() + inputs = MRTrixInfo._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +20,7 @@ def test_MRTrixInfo_inputs(): def test_MRTrixInfo_outputs(): output_map = dict() - outputs = MRTrixInfo.output_spec() + outputs = MRTrixInfo._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_MRTrixViewer.py b/nipype/interfaces/mrtrix/tests/test_auto_MRTrixViewer.py index d0e99f2348..e935043c6f 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_MRTrixViewer.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_MRTrixViewer.py @@ -9,12 +9,6 @@ def test_MRTrixViewer_inputs(): debug=dict(argstr='-debug', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(argstr='%s', mandatory=True, position=-2, @@ -22,10 +16,8 @@ def test_MRTrixViewer_inputs(): quiet=dict(argstr='-quiet', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = MRTrixViewer.input_spec() + inputs = MRTrixViewer._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_MRTrixViewer_inputs(): def test_MRTrixViewer_outputs(): output_map = dict() - outputs = MRTrixViewer.output_spec() + outputs = MRTrixViewer._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_MedianFilter3D.py b/nipype/interfaces/mrtrix/tests/test_auto_MedianFilter3D.py index 7010acfda5..6505623455 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_MedianFilter3D.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_MedianFilter3D.py @@ -9,12 +9,6 @@ def test_MedianFilter3D_inputs(): debug=dict(argstr='-debug', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -26,10 +20,8 @@ def test_MedianFilter3D_inputs(): quiet=dict(argstr='-quiet', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = MedianFilter3D.input_spec() + inputs = MedianFilter3D._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_MedianFilter3D_inputs(): def test_MedianFilter3D_outputs(): output_map = dict(out_file=dict(), ) - outputs = MedianFilter3D.output_spec() + outputs = MedianFilter3D._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_ProbabilisticSphericallyDeconvolutedStreamlineTrack.py b/nipype/interfaces/mrtrix/tests/test_auto_ProbabilisticSphericallyDeconvolutedStreamlineTrack.py index dfb1b57ddc..2914e02590 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_ProbabilisticSphericallyDeconvolutedStreamlineTrack.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_ProbabilisticSphericallyDeconvolutedStreamlineTrack.py @@ -13,9 +13,6 @@ def test_ProbabilisticSphericallyDeconvolutedStreamlineTrack_inputs(): ), do_not_precompute=dict(argstr='-noprecomputed', ), - environ=dict(nohash=True, - usedefault=True, - ), exclude_file=dict(argstr='-exclude %s', xor=['exclude_file', 'exclude_spec'], ), @@ -25,9 +22,6 @@ def test_ProbabilisticSphericallyDeconvolutedStreamlineTrack_inputs(): units='mm', xor=['exclude_file', 'exclude_spec'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -95,12 +89,10 @@ def test_ProbabilisticSphericallyDeconvolutedStreamlineTrack_inputs(): ), stop=dict(argstr='-stop', ), - terminal_output=dict(nohash=True, - ), unidirectional=dict(argstr='-unidirectional', ), ) - inputs = ProbabilisticSphericallyDeconvolutedStreamlineTrack.input_spec() + inputs = ProbabilisticSphericallyDeconvolutedStreamlineTrack._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -110,7 +102,7 @@ def test_ProbabilisticSphericallyDeconvolutedStreamlineTrack_inputs(): def test_ProbabilisticSphericallyDeconvolutedStreamlineTrack_outputs(): output_map = dict(tracked=dict(), ) - outputs = ProbabilisticSphericallyDeconvolutedStreamlineTrack.output_spec() + outputs = ProbabilisticSphericallyDeconvolutedStreamlineTrack._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_SphericallyDeconvolutedStreamlineTrack.py b/nipype/interfaces/mrtrix/tests/test_auto_SphericallyDeconvolutedStreamlineTrack.py index 2180af33eb..f20d05a870 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_SphericallyDeconvolutedStreamlineTrack.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_SphericallyDeconvolutedStreamlineTrack.py @@ -13,9 +13,6 @@ def test_SphericallyDeconvolutedStreamlineTrack_inputs(): ), do_not_precompute=dict(argstr='-noprecomputed', ), - environ=dict(nohash=True, - usedefault=True, - ), exclude_file=dict(argstr='-exclude %s', xor=['exclude_file', 'exclude_spec'], ), @@ -25,9 +22,6 @@ def test_SphericallyDeconvolutedStreamlineTrack_inputs(): units='mm', xor=['exclude_file', 'exclude_spec'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -93,12 +87,10 @@ def test_SphericallyDeconvolutedStreamlineTrack_inputs(): ), stop=dict(argstr='-stop', ), - terminal_output=dict(nohash=True, - ), unidirectional=dict(argstr='-unidirectional', ), ) - inputs = SphericallyDeconvolutedStreamlineTrack.input_spec() + inputs = SphericallyDeconvolutedStreamlineTrack._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -108,7 +100,7 @@ def test_SphericallyDeconvolutedStreamlineTrack_inputs(): def test_SphericallyDeconvolutedStreamlineTrack_outputs(): output_map = dict(tracked=dict(), ) - outputs = SphericallyDeconvolutedStreamlineTrack.output_spec() + outputs = SphericallyDeconvolutedStreamlineTrack._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_StreamlineTrack.py b/nipype/interfaces/mrtrix/tests/test_auto_StreamlineTrack.py index 86f3607f34..1e3ae0252a 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_StreamlineTrack.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_StreamlineTrack.py @@ -13,9 +13,6 @@ def test_StreamlineTrack_inputs(): ), do_not_precompute=dict(argstr='-noprecomputed', ), - environ=dict(nohash=True, - usedefault=True, - ), exclude_file=dict(argstr='-exclude %s', xor=['exclude_file', 'exclude_spec'], ), @@ -25,9 +22,6 @@ def test_StreamlineTrack_inputs(): units='mm', xor=['exclude_file', 'exclude_spec'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -93,12 +87,10 @@ def test_StreamlineTrack_inputs(): ), stop=dict(argstr='-stop', ), - terminal_output=dict(nohash=True, - ), unidirectional=dict(argstr='-unidirectional', ), ) - inputs = StreamlineTrack.input_spec() + inputs = StreamlineTrack._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -108,7 +100,7 @@ def test_StreamlineTrack_inputs(): def test_StreamlineTrack_outputs(): output_map = dict(tracked=dict(), ) - outputs = StreamlineTrack.output_spec() + outputs = StreamlineTrack._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_Tensor2ApparentDiffusion.py b/nipype/interfaces/mrtrix/tests/test_auto_Tensor2ApparentDiffusion.py index c7bd91a610..5963d50531 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_Tensor2ApparentDiffusion.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_Tensor2ApparentDiffusion.py @@ -9,12 +9,6 @@ def test_Tensor2ApparentDiffusion_inputs(): debug=dict(argstr='-debug', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -26,10 +20,8 @@ def test_Tensor2ApparentDiffusion_inputs(): quiet=dict(argstr='-quiet', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Tensor2ApparentDiffusion.input_spec() + inputs = Tensor2ApparentDiffusion._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_Tensor2ApparentDiffusion_inputs(): def test_Tensor2ApparentDiffusion_outputs(): output_map = dict(ADC=dict(), ) - outputs = Tensor2ApparentDiffusion.output_spec() + outputs = Tensor2ApparentDiffusion._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_Tensor2FractionalAnisotropy.py b/nipype/interfaces/mrtrix/tests/test_auto_Tensor2FractionalAnisotropy.py index 07a9fadc2f..e1710f54ee 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_Tensor2FractionalAnisotropy.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_Tensor2FractionalAnisotropy.py @@ -9,12 +9,6 @@ def test_Tensor2FractionalAnisotropy_inputs(): debug=dict(argstr='-debug', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -26,10 +20,8 @@ def test_Tensor2FractionalAnisotropy_inputs(): quiet=dict(argstr='-quiet', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Tensor2FractionalAnisotropy.input_spec() + inputs = Tensor2FractionalAnisotropy._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_Tensor2FractionalAnisotropy_inputs(): def test_Tensor2FractionalAnisotropy_outputs(): output_map = dict(FA=dict(), ) - outputs = Tensor2FractionalAnisotropy.output_spec() + outputs = Tensor2FractionalAnisotropy._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_Tensor2Vector.py b/nipype/interfaces/mrtrix/tests/test_auto_Tensor2Vector.py index cc84f35f3a..3c532ee53f 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_Tensor2Vector.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_Tensor2Vector.py @@ -9,12 +9,6 @@ def test_Tensor2Vector_inputs(): debug=dict(argstr='-debug', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -26,10 +20,8 @@ def test_Tensor2Vector_inputs(): quiet=dict(argstr='-quiet', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Tensor2Vector.input_spec() + inputs = Tensor2Vector._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_Tensor2Vector_inputs(): def test_Tensor2Vector_outputs(): output_map = dict(vector=dict(), ) - outputs = Tensor2Vector.output_spec() + outputs = Tensor2Vector._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_Threshold.py b/nipype/interfaces/mrtrix/tests/test_auto_Threshold.py index c45e38f714..af1aface53 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_Threshold.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_Threshold.py @@ -11,12 +11,6 @@ def test_Threshold_inputs(): debug=dict(argstr='-debug', position=1, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -36,10 +30,8 @@ def test_Threshold_inputs(): replace_zeros_with_NaN=dict(argstr='-nan', position=1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Threshold.input_spec() + inputs = Threshold._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -49,7 +41,7 @@ def test_Threshold_inputs(): def test_Threshold_outputs(): output_map = dict(out_file=dict(), ) - outputs = Threshold.output_spec() + outputs = Threshold._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tests/test_auto_Tracks2Prob.py b/nipype/interfaces/mrtrix/tests/test_auto_Tracks2Prob.py index 5460b7b18e..0657c9c721 100644 --- a/nipype/interfaces/mrtrix/tests/test_auto_Tracks2Prob.py +++ b/nipype/interfaces/mrtrix/tests/test_auto_Tracks2Prob.py @@ -9,15 +9,9 @@ def test_Tracks2Prob_inputs(): colour=dict(argstr='-colour', position=3, ), - environ=dict(nohash=True, - usedefault=True, - ), fraction=dict(argstr='-fraction', position=3, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -36,14 +30,12 @@ def test_Tracks2Prob_inputs(): template_file=dict(argstr='-template %s', position=1, ), - terminal_output=dict(nohash=True, - ), voxel_dims=dict(argstr='-vox %s', position=2, sep=',', ), ) - inputs = Tracks2Prob.input_spec() + inputs = Tracks2Prob._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +45,7 @@ def test_Tracks2Prob_inputs(): def test_Tracks2Prob_outputs(): output_map = dict(tract_image=dict(), ) - outputs = Tracks2Prob.output_spec() + outputs = Tracks2Prob._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix/tracking.py b/nipype/interfaces/mrtrix/tracking.py index c4d49118a8..79b8efbec0 100644 --- a/nipype/interfaces/mrtrix/tracking.py +++ b/nipype/interfaces/mrtrix/tracking.py @@ -62,8 +62,8 @@ class FilterTracks(CommandLine): """ _cmd = 'filter_tracks' - input_spec = FilterTracksInputSpec - output_spec = FilterTracksOutputSpec + _input_spec = FilterTracksInputSpec + _output_spec = FilterTracksOutputSpec class Tracks2ProbInputSpec(CommandLineInputSpec): @@ -104,18 +104,17 @@ class Tracks2Prob(CommandLine): """ _cmd = 'tracks2prob' - input_spec = Tracks2ProbInputSpec - output_spec = Tracks2ProbOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['tract_image'] = self.inputs.out_filename - if not isdefined(outputs['tract_image']): - outputs['tract_image'] = op.abspath(self._gen_outfilename()) + _input_spec = Tracks2ProbInputSpec + _output_spec = Tracks2ProbOutputSpec + + def _post_run(self): + + self.outputs.tract_image = self.inputs.out_filename + if not isdefined(self.outputs.tract_image): + self.outputs.tract_image = op.abspath(self._gen_outfilename()) else: - outputs['tract_image'] = os.path.abspath(outputs['tract_image']) - return outputs - + self.outputs.tract_image = os.path.abspath(self.outputs.tract_image) + def _gen_filename(self, name): if name is 'out_filename': return self._gen_outfilename() @@ -212,8 +211,8 @@ class StreamlineTrack(CommandLine): >>> strack.run() # doctest: +SKIP """ _cmd = 'streamtrack' - input_spec = StreamlineTrackInputSpec - output_spec = StreamlineTrackOutputSpec + _input_spec = StreamlineTrackInputSpec + _output_spec = StreamlineTrackOutputSpec class DiffusionTensorStreamlineTrackInputSpec(StreamlineTrackInputSpec): @@ -237,7 +236,7 @@ class DiffusionTensorStreamlineTrack(StreamlineTrack): >>> dtstrack.run() # doctest: +SKIP """ - input_spec = DiffusionTensorStreamlineTrackInputSpec + _input_spec = DiffusionTensorStreamlineTrackInputSpec def __init__(self, command=None, **inputs): inputs["inputmodel"] = "DT_STREAM" @@ -266,7 +265,7 @@ class ProbabilisticSphericallyDeconvolutedStreamlineTrack(StreamlineTrack): >>> sdprobtrack.inputs.seed_file = 'seed_mask.nii' >>> sdprobtrack.run() # doctest: +SKIP """ - input_spec = ProbabilisticSphericallyDeconvolutedStreamlineTrackInputSpec + _input_spec = ProbabilisticSphericallyDeconvolutedStreamlineTrackInputSpec def __init__(self, command=None, **inputs): inputs["inputmodel"] = "SD_PROB" @@ -290,7 +289,7 @@ class SphericallyDeconvolutedStreamlineTrack(StreamlineTrack): >>> sdtrack.inputs.seed_file = 'seed_mask.nii' >>> sdtrack.run() # doctest: +SKIP """ - input_spec = StreamlineTrackInputSpec + _input_spec = StreamlineTrackInputSpec def __init__(self, command=None, **inputs): inputs["inputmodel"] = "SD_STREAM" diff --git a/nipype/interfaces/mrtrix3/base.py b/nipype/interfaces/mrtrix3/base.py index 40a8e93a88..615e97b0f7 100644 --- a/nipype/interfaces/mrtrix3/base.py +++ b/nipype/interfaces/mrtrix3/base.py @@ -64,7 +64,7 @@ def _format_arg(self, name, trait_spec, value): return super(MRTrix3Base, self)._format_arg(name, trait_spec, value) - def _parse_inputs(self, skip=None): + def parse_args(self, skip=None): if skip is None: skip = [] @@ -83,4 +83,4 @@ def _parse_inputs(self, skip=None): except AttributeError: pass - return super(MRTrix3Base, self)._parse_inputs(skip=skip) + return super(MRTrix3Base, self).parse_args(skip=skip) diff --git a/nipype/interfaces/mrtrix3/connectivity.py b/nipype/interfaces/mrtrix3/connectivity.py index 64e73f8069..dc9dad2365 100644 --- a/nipype/interfaces/mrtrix3/connectivity.py +++ b/nipype/interfaces/mrtrix3/connectivity.py @@ -101,14 +101,13 @@ class BuildConnectome(MRTrix3Base): """ _cmd = 'tck2connectome' - input_spec = BuildConnectomeInputSpec - output_spec = BuildConnectomeOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + _input_spec = BuildConnectomeInputSpec + _output_spec = BuildConnectomeOutputSpec + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) + class LabelConfigInputSpec(CommandLineInputSpec): in_file = File(exists=True, argstr='%s', mandatory=True, position=-3, @@ -160,10 +159,10 @@ class LabelConfig(MRTrix3Base): """ _cmd = 'labelconfig' - input_spec = LabelConfigInputSpec - output_spec = LabelConfigOutputSpec + _input_spec = LabelConfigInputSpec + _output_spec = LabelConfigOutputSpec - def _parse_inputs(self, skip=None): + def parse_args(self, skip=None): if skip is None: skip = [] @@ -179,9 +178,9 @@ def _parse_inputs(self, skip=None): path, 'src/dwi/tractography/connectomics/' 'example_configs/fs_default.txt') - return super(LabelConfig, self)._parse_inputs(skip=skip) + return super(LabelConfig, self).parse_args(skip=skip) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) + \ No newline at end of file diff --git a/nipype/interfaces/mrtrix3/preprocess.py b/nipype/interfaces/mrtrix3/preprocess.py index e52c84071d..5a3e43ee1e 100644 --- a/nipype/interfaces/mrtrix3/preprocess.py +++ b/nipype/interfaces/mrtrix3/preprocess.py @@ -102,17 +102,16 @@ class ResponseSD(MRTrix3Base): """ _cmd = 'dwi2response' - input_spec = ResponseSDInputSpec - output_spec = ResponseSDOutputSpec + _input_spec = ResponseSDInputSpec + _output_spec = ResponseSDOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) if isdefined(self.inputs.out_sf): - outputs['out_sf'] = op.abspath(self.inputs.out_sf) - return outputs - + self.outputs.out_sf = op.abspath(self.inputs.out_sf) + class ACTPrepareFSLInputSpec(CommandLineInputSpec): in_file = File(exists=True, argstr='%s', mandatory=True, position=-2, @@ -145,14 +144,13 @@ class ACTPrepareFSL(CommandLine): """ _cmd = 'act_anat_prepare_fsl' - input_spec = ACTPrepareFSLInputSpec - output_spec = ACTPrepareFSLOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + _input_spec = ACTPrepareFSLInputSpec + _output_spec = ACTPrepareFSLOutputSpec + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) + class ReplaceFSwithFIRSTInputSpec(CommandLineInputSpec): in_file = File(exists=True, argstr='%s', mandatory=True, position=-4, @@ -192,10 +190,10 @@ class ReplaceFSwithFIRST(CommandLine): """ _cmd = 'fs_parc_replace_sgm_first' - input_spec = ReplaceFSwithFIRSTInputSpec - output_spec = ReplaceFSwithFIRSTOutputSpec + _input_spec = ReplaceFSwithFIRSTInputSpec + _output_spec = ReplaceFSwithFIRSTOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) + \ No newline at end of file diff --git a/nipype/interfaces/mrtrix3/reconst.py b/nipype/interfaces/mrtrix3/reconst.py index ce023fbdef..7afe946933 100644 --- a/nipype/interfaces/mrtrix3/reconst.py +++ b/nipype/interfaces/mrtrix3/reconst.py @@ -68,14 +68,13 @@ class FitTensor(MRTrix3Base): """ _cmd = 'dwi2tensor' - input_spec = FitTensorInputSpec - output_spec = FitTensorOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + _input_spec = FitTensorInputSpec + _output_spec = FitTensorOutputSpec + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) + class EstimateFODInputSpec(MRTrix3BaseInputSpec): in_file = File(exists=True, argstr='%s', mandatory=True, position=-3, @@ -184,10 +183,10 @@ class EstimateFOD(MRTrix3Base): """ _cmd = 'dwi2fod' - input_spec = EstimateFODInputSpec - output_spec = EstimateFODOutputSpec + _input_spec = EstimateFODInputSpec + _output_spec = EstimateFODOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) + \ No newline at end of file diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_ACTPrepareFSL.py b/nipype/interfaces/mrtrix3/tests/test_auto_ACTPrepareFSL.py index 45a1a9fef0..685f72d50b 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_ACTPrepareFSL.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_ACTPrepareFSL.py @@ -6,12 +6,6 @@ def test_ACTPrepareFSL_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -21,10 +15,8 @@ def test_ACTPrepareFSL_inputs(): position=-1, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ACTPrepareFSL.input_spec() + inputs = ACTPrepareFSL._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_ACTPrepareFSL_inputs(): def test_ACTPrepareFSL_outputs(): output_map = dict(out_file=dict(), ) - outputs = ACTPrepareFSL.output_spec() + outputs = ACTPrepareFSL._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_BrainMask.py b/nipype/interfaces/mrtrix3/tests/test_auto_BrainMask.py index 7581fe6059..28b48c1fd9 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_BrainMask.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_BrainMask.py @@ -8,16 +8,10 @@ def test_BrainMask_inputs(): ), bval_scale=dict(argstr='-bvalue_scaling %s', ), - environ=dict(nohash=True, - usedefault=True, - ), grad_file=dict(argstr='-grad %s', ), grad_fsl=dict(argstr='-fslgrad %s %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(), in_bvec=dict(argstr='-fslgrad %s %s', ), @@ -33,10 +27,8 @@ def test_BrainMask_inputs(): position=-1, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = BrainMask.input_spec() + inputs = BrainMask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +38,7 @@ def test_BrainMask_inputs(): def test_BrainMask_outputs(): output_map = dict(out_file=dict(), ) - outputs = BrainMask.output_spec() + outputs = BrainMask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_BuildConnectome.py b/nipype/interfaces/mrtrix3/tests/test_auto_BuildConnectome.py index e4b97f4381..7b8b2deb43 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_BuildConnectome.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_BuildConnectome.py @@ -6,12 +6,6 @@ def test_BuildConnectome_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-3, @@ -41,14 +35,12 @@ def test_BuildConnectome_inputs(): ), search_reverse=dict(argstr='-assignment_reverse_search %f', ), - terminal_output=dict(nohash=True, - ), vox_lookup=dict(argstr='-assignment_voxel_lookup', ), zero_diagonal=dict(argstr='-zero_diagonal', ), ) - inputs = BuildConnectome.input_spec() + inputs = BuildConnectome._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +50,7 @@ def test_BuildConnectome_inputs(): def test_BuildConnectome_outputs(): output_map = dict(out_file=dict(), ) - outputs = BuildConnectome.output_spec() + outputs = BuildConnectome._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_ComputeTDI.py b/nipype/interfaces/mrtrix3/tests/test_auto_ComputeTDI.py index ef2fec18a5..cf9bf001cc 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_ComputeTDI.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_ComputeTDI.py @@ -14,14 +14,8 @@ def test_ComputeTDI_inputs(): ), ends_only=dict(argstr='-ends_only', ), - environ=dict(nohash=True, - usedefault=True, - ), fwhm_tck=dict(argstr='-fwhm_tck %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -49,8 +43,6 @@ def test_ComputeTDI_inputs(): ), tck_weights=dict(argstr='-tck_weights_in %s', ), - terminal_output=dict(nohash=True, - ), upsample=dict(argstr='-upsample %d', ), use_dec=dict(argstr='-dec', @@ -59,7 +51,7 @@ def test_ComputeTDI_inputs(): sep=',', ), ) - inputs = ComputeTDI.input_spec() + inputs = ComputeTDI._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -69,7 +61,7 @@ def test_ComputeTDI_inputs(): def test_ComputeTDI_outputs(): output_map = dict(out_file=dict(), ) - outputs = ComputeTDI.output_spec() + outputs = ComputeTDI._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_EstimateFOD.py b/nipype/interfaces/mrtrix3/tests/test_auto_EstimateFOD.py index 1f8b434843..caa84b328d 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_EstimateFOD.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_EstimateFOD.py @@ -8,16 +8,10 @@ def test_EstimateFOD_inputs(): ), bval_scale=dict(argstr='-bvalue_scaling %s', ), - environ=dict(nohash=True, - usedefault=True, - ), grad_file=dict(argstr='-grad %s', ), grad_fsl=dict(argstr='-fslgrad %s %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(), in_bvec=dict(argstr='-fslgrad %s %s', ), @@ -52,12 +46,10 @@ def test_EstimateFOD_inputs(): shell=dict(argstr='-shell %s', sep=',', ), - terminal_output=dict(nohash=True, - ), thres=dict(argstr='-threshold %f', ), ) - inputs = EstimateFOD.input_spec() + inputs = EstimateFOD._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -67,7 +59,7 @@ def test_EstimateFOD_inputs(): def test_EstimateFOD_outputs(): output_map = dict(out_file=dict(), ) - outputs = EstimateFOD.output_spec() + outputs = EstimateFOD._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_FitTensor.py b/nipype/interfaces/mrtrix3/tests/test_auto_FitTensor.py index 3d926e3bd3..2d9a9f758c 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_FitTensor.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_FitTensor.py @@ -8,16 +8,10 @@ def test_FitTensor_inputs(): ), bval_scale=dict(argstr='-bvalue_scaling %s', ), - environ=dict(nohash=True, - usedefault=True, - ), grad_file=dict(argstr='-grad %s', ), grad_fsl=dict(argstr='-fslgrad %s %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(), in_bvec=dict(argstr='-fslgrad %s %s', ), @@ -39,10 +33,8 @@ def test_FitTensor_inputs(): ), reg_term=dict(argstr='-regularisation %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = FitTensor.input_spec() + inputs = FitTensor._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_FitTensor_inputs(): def test_FitTensor_outputs(): output_map = dict(out_file=dict(), ) - outputs = FitTensor.output_spec() + outputs = FitTensor._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_Generate5tt.py b/nipype/interfaces/mrtrix3/tests/test_auto_Generate5tt.py index b06b6362ab..6f5a76e9f1 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_Generate5tt.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_Generate5tt.py @@ -6,12 +6,6 @@ def test_Generate5tt_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_fast=dict(argstr='%s', mandatory=True, position=-3, @@ -24,10 +18,8 @@ def test_Generate5tt_inputs(): position=-1, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Generate5tt.input_spec() + inputs = Generate5tt._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +29,7 @@ def test_Generate5tt_inputs(): def test_Generate5tt_outputs(): output_map = dict(out_file=dict(), ) - outputs = Generate5tt.output_spec() + outputs = Generate5tt._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_LabelConfig.py b/nipype/interfaces/mrtrix3/tests/test_auto_LabelConfig.py index 4f57c6246d..d2ad2c7a89 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_LabelConfig.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_LabelConfig.py @@ -6,12 +6,6 @@ def test_LabelConfig_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_config=dict(argstr='%s', position=-2, ), @@ -37,10 +31,8 @@ def test_LabelConfig_inputs(): ), spine=dict(argstr='-spine %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = LabelConfig.input_spec() + inputs = LabelConfig._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +42,7 @@ def test_LabelConfig_inputs(): def test_LabelConfig_outputs(): output_map = dict(out_file=dict(), ) - outputs = LabelConfig.output_spec() + outputs = LabelConfig._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_MRTrix3Base.py b/nipype/interfaces/mrtrix3/tests/test_auto_MRTrix3Base.py index c03da343e2..abe18f0000 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_MRTrix3Base.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_MRTrix3Base.py @@ -6,18 +6,18 @@ def test_MRTrix3Base_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - terminal_output=dict(nohash=True, - ), ) - inputs = MRTrix3Base.input_spec() + inputs = MRTrix3Base._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_MRTrix3Base_outputs(): + output_map = dict() + outputs = MRTrix3Base._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/mrtrix3/tests/test_auto_Mesh2PVE.py b/nipype/interfaces/mrtrix3/tests/test_auto_Mesh2PVE.py index 781d8b2e98..61b7ebb65b 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_Mesh2PVE.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_Mesh2PVE.py @@ -6,12 +6,6 @@ def test_Mesh2PVE_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-3, @@ -27,10 +21,8 @@ def test_Mesh2PVE_inputs(): mandatory=True, position=-2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Mesh2PVE.input_spec() + inputs = Mesh2PVE._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_Mesh2PVE_inputs(): def test_Mesh2PVE_outputs(): output_map = dict(out_file=dict(), ) - outputs = Mesh2PVE.output_spec() + outputs = Mesh2PVE._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_ReplaceFSwithFIRST.py b/nipype/interfaces/mrtrix3/tests/test_auto_ReplaceFSwithFIRST.py index cb33fda95b..541296651c 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_ReplaceFSwithFIRST.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_ReplaceFSwithFIRST.py @@ -6,12 +6,6 @@ def test_ReplaceFSwithFIRST_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_config=dict(argstr='%s', position=-2, ), @@ -28,10 +22,8 @@ def test_ReplaceFSwithFIRST_inputs(): position=-1, usedefault=True, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ReplaceFSwithFIRST.input_spec() + inputs = ReplaceFSwithFIRST._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +33,7 @@ def test_ReplaceFSwithFIRST_inputs(): def test_ReplaceFSwithFIRST_outputs(): output_map = dict(out_file=dict(), ) - outputs = ReplaceFSwithFIRST.output_spec() + outputs = ReplaceFSwithFIRST._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_ResponseSD.py b/nipype/interfaces/mrtrix3/tests/test_auto_ResponseSD.py index cb78159156..f8489b0249 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_ResponseSD.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_ResponseSD.py @@ -10,16 +10,10 @@ def test_ResponseSD_inputs(): ), disp_mult=dict(argstr='-dispersion_multiplier %f', ), - environ=dict(nohash=True, - usedefault=True, - ), grad_file=dict(argstr='-grad %s', ), grad_fsl=dict(argstr='-fslgrad %s %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(), in_bvec=dict(argstr='-fslgrad %s %s', ), @@ -50,14 +44,12 @@ def test_ResponseSD_inputs(): shell=dict(argstr='-shell %s', sep=',', ), - terminal_output=dict(nohash=True, - ), test_all=dict(argstr='-test_all', ), vol_ratio=dict(argstr='-volume_ratio %f', ), ) - inputs = ResponseSD.input_spec() + inputs = ResponseSD._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -68,7 +60,7 @@ def test_ResponseSD_outputs(): output_map = dict(out_file=dict(), out_sf=dict(), ) - outputs = ResponseSD.output_spec() + outputs = ResponseSD._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_TCK2VTK.py b/nipype/interfaces/mrtrix3/tests/test_auto_TCK2VTK.py index d80b749fee..d7d7f2f4e4 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_TCK2VTK.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_TCK2VTK.py @@ -6,12 +6,6 @@ def test_TCK2VTK_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-2, @@ -25,12 +19,10 @@ def test_TCK2VTK_inputs(): ), reference=dict(argstr='-image %s', ), - terminal_output=dict(nohash=True, - ), voxel=dict(argstr='-image %s', ), ) - inputs = TCK2VTK.input_spec() + inputs = TCK2VTK._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_TCK2VTK_inputs(): def test_TCK2VTK_outputs(): output_map = dict(out_file=dict(), ) - outputs = TCK2VTK.output_spec() + outputs = TCK2VTK._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_TensorMetrics.py b/nipype/interfaces/mrtrix3/tests/test_auto_TensorMetrics.py index 6be2bccab0..bce0e23a4c 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_TensorMetrics.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_TensorMetrics.py @@ -9,12 +9,6 @@ def test_TensorMetrics_inputs(): component=dict(argstr='-num %s', sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='%s', mandatory=True, position=-1, @@ -31,10 +25,8 @@ def test_TensorMetrics_inputs(): ), out_fa=dict(argstr='-fa %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = TensorMetrics.input_spec() + inputs = TensorMetrics._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_TensorMetrics_outputs(): out_evec=dict(), out_fa=dict(), ) - outputs = TensorMetrics.output_spec() + outputs = TensorMetrics._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_Tractography.py b/nipype/interfaces/mrtrix3/tests/test_auto_Tractography.py index aeaff9b599..dfbea9dc6d 100644 --- a/nipype/interfaces/mrtrix3/tests/test_auto_Tractography.py +++ b/nipype/interfaces/mrtrix3/tests/test_auto_Tractography.py @@ -25,16 +25,10 @@ def test_Tractography_inputs(): ), downsample=dict(argstr='-downsample %f', ), - environ=dict(nohash=True, - usedefault=True, - ), grad_file=dict(argstr='-grad %s', ), grad_fsl=dict(argstr='-fslgrad %s %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_bval=dict(), in_bvec=dict(argstr='-fslgrad %s %s', ), @@ -101,14 +95,12 @@ def test_Tractography_inputs(): ), stop=dict(argstr='-stop', ), - terminal_output=dict(nohash=True, - ), unidirectional=dict(argstr='-unidirectional', ), use_rk4=dict(argstr='-rk4', ), ) - inputs = Tractography.input_spec() + inputs = Tractography._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -119,7 +111,7 @@ def test_Tractography_outputs(): output_map = dict(out_file=dict(), out_seeds=dict(), ) - outputs = Tractography.output_spec() + outputs = Tractography._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/mrtrix3/tracking.py b/nipype/interfaces/mrtrix3/tracking.py index 7495211543..34e747e3dd 100644 --- a/nipype/interfaces/mrtrix3/tracking.py +++ b/nipype/interfaces/mrtrix3/tracking.py @@ -238,8 +238,8 @@ class Tractography(MRTrix3Base): """ _cmd = 'tckgen' - input_spec = TractographyInputSpec - output_spec = TractographyOutputSpec + _input_spec = TractographyInputSpec + _output_spec = TractographyOutputSpec def _format_arg(self, name, trait_spec, value): if 'roi_' in name and isinstance(value, tuple): @@ -248,7 +248,7 @@ def _format_arg(self, name, trait_spec, value): return super(Tractography, self)._format_arg(name, trait_spec, value) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) + \ No newline at end of file diff --git a/nipype/interfaces/mrtrix3/utils.py b/nipype/interfaces/mrtrix3/utils.py index 6a5b68f521..589010f2c8 100644 --- a/nipype/interfaces/mrtrix3/utils.py +++ b/nipype/interfaces/mrtrix3/utils.py @@ -53,13 +53,12 @@ class BrainMask(CommandLine): """ _cmd = 'dwi2mask' - input_spec = BrainMaskInputSpec - output_spec = BrainMaskOutputSpec + _input_spec = BrainMaskInputSpec + _output_spec = BrainMaskOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) class Mesh2PVEInputSpec(CommandLineInputSpec): @@ -100,13 +99,12 @@ class Mesh2PVE(CommandLine): """ _cmd = 'mesh2pve' - input_spec = Mesh2PVEInputSpec - output_spec = Mesh2PVEOutputSpec + _input_spec = Mesh2PVEInputSpec + _output_spec = Mesh2PVEOutputSpec + + def _post_run(self): - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + self.outputs.out_file = op.abspath(self.inputs.out_file) class Generate5ttInputSpec(CommandLineInputSpec): @@ -147,13 +145,12 @@ class Generate5tt(CommandLine): """ _cmd = '5ttgen' - input_spec = Generate5ttInputSpec - output_spec = Generate5ttOutputSpec + _input_spec = Generate5ttInputSpec + _output_spec = Generate5ttOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) class TensorMetricsInputSpec(CommandLineInputSpec): @@ -204,17 +201,14 @@ class TensorMetrics(CommandLine): """ _cmd = 'tensor2metric' - input_spec = TensorMetricsInputSpec - output_spec = TensorMetricsOutputSpec - - def _list_outputs(self): - outputs = self.output_spec().get() + _input_spec = TensorMetricsInputSpec + _output_spec = TensorMetricsOutputSpec + def _post_run(self): for k in list(outputs.keys()): if isdefined(getattr(self.inputs, k)): - outputs[k] = op.abspath(getattr(self.inputs, k)) + setattr(self.outputs, k, op.abspath(getattr(self.inputs, k))) - return outputs class ComputeTDIInputSpec(CommandLineInputSpec): @@ -344,13 +338,12 @@ class ComputeTDI(MRTrix3Base): """ _cmd = 'tckmap' - input_spec = ComputeTDIInputSpec - output_spec = ComputeTDIOutputSpec + _input_spec = ComputeTDIInputSpec + _output_spec = ComputeTDIOutputSpec - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) class TCK2VTKInputSpec(CommandLineInputSpec): @@ -395,10 +388,10 @@ class TCK2VTK(MRTrix3Base): """ _cmd = 'tck2vtk' - input_spec = TCK2VTKInputSpec - output_spec = TCK2VTKOutputSpec + _input_spec = TCK2VTKInputSpec + _output_spec = TCK2VTKOutputSpec + + def _post_run(self): + + self.outputs.out_file = op.abspath(self.inputs.out_file) - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = op.abspath(self.inputs.out_file) - return outputs diff --git a/nipype/interfaces/nipy/model.py b/nipype/interfaces/nipy/model.py index f6ff113530..c7a240daf5 100644 --- a/nipype/interfaces/nipy/model.py +++ b/nipype/interfaces/nipy/model.py @@ -24,10 +24,10 @@ from nipy.modalities.fmri.experimental_paradigm import BlockParadigm from ..base import (BaseInterface, TraitedSpec, traits, File, OutputMultiPath, - BaseInterfaceInputSpec, isdefined) + BaseInputSpec, isdefined) -class FitGLMInputSpec(BaseInterfaceInputSpec): +class FitGLMInputSpec(BaseInputSpec): session_info = traits.List(minlen=1, maxlen=1, mandatory=True, desc=('Session specific information generated by' ' ``modelgen.SpecifyModel``, FitGLM does ' @@ -73,11 +73,11 @@ class FitGLMOutputSpec(TraitedSpec): class FitGLM(BaseInterface): - ''' + """ Fit GLM model based on the specified design. Supports only single or concatenated runs. - ''' - input_spec = FitGLMInputSpec - output_spec = FitGLMOutputSpec + """ + _input_spec = FitGLMInputSpec + _output_spec = FitGLMOutputSpec def _run_interface(self, runtime): @@ -192,23 +192,21 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs["beta"] = self._beta_file - outputs["nvbeta"] = self._nvbeta - outputs["s2"] = self._s2_file - outputs["dof"] = self._dof - outputs["constants"] = self._constants - outputs["axis"] = self._axis - outputs["reg_names"] = self._reg_names + def _post_run(self): + self.outputs.beta = self._beta_file + self.outputs.nvbeta = self._nvbeta + self.outputs.s2 = self._s2_file + self.outputs.dof = self._dof + self.outputs.constants = self._constants + self.outputs.axis = self._axis + self.outputs.reg_names = self._reg_names if self.inputs.model == "ar1": - outputs["a"] = self._a_file + self.outputs.a = self._a_file if self.inputs.save_residuals: - outputs["residuals"] = self._residuals_file - return outputs + self.outputs.residuals = self._residuals_file + - -class EstimateContrastInputSpec(BaseInterfaceInputSpec): +class EstimateContrastInputSpec(BaseInputSpec): contrasts = traits.List( traits.Either(traits.Tuple(traits.Str, traits.Enum('T'), @@ -252,11 +250,11 @@ class EstimateContrastOutputSpec(TraitedSpec): class EstimateContrast(BaseInterface): - ''' + """ Estimate contrast of a fitted model. - ''' - input_spec = EstimateContrastInputSpec - output_spec = EstimateContrastOutputSpec + """ + _input_spec = EstimateContrastInputSpec + _output_spec = EstimateContrastOutputSpec def _run_interface(self, runtime): @@ -312,9 +310,8 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs["stat_maps"] = self._stat_maps - outputs["p_maps"] = self._p_maps - outputs["z_maps"] = self._z_maps - return outputs + def _post_run(self): + self.outputs.stat_maps = self._stat_maps + self.outputs.p_maps = self._p_maps + self.outputs.z_maps = self._z_maps + \ No newline at end of file diff --git a/nipype/interfaces/nipy/preprocess.py b/nipype/interfaces/nipy/preprocess.py index 49a493f02c..43ce3128f7 100644 --- a/nipype/interfaces/nipy/preprocess.py +++ b/nipype/interfaces/nipy/preprocess.py @@ -27,11 +27,11 @@ nipy_version = nipy.__version__ from ..base import (TraitedSpec, BaseInterface, traits, - BaseInterfaceInputSpec, isdefined, File, + BaseInputSpec, isdefined, File, InputMultiPath, OutputMultiPath) -class ComputeMaskInputSpec(BaseInterfaceInputSpec): +class ComputeMaskInputSpec(BaseInputSpec): mean_volume = File(exists=True, mandatory=True, desc="mean EPI image, used to compute the threshold for the mask") reference_volume = File(exists=True, @@ -47,14 +47,14 @@ class ComputeMaskOutputSpec(TraitedSpec): class ComputeMask(BaseInterface): - input_spec = ComputeMaskInputSpec - output_spec = ComputeMaskOutputSpec + _input_spec = ComputeMaskInputSpec + _output_spec = ComputeMaskOutputSpec def _run_interface(self, runtime): from nipy.labs.mask import compute_mask args = {} for key in [k for k, _ in list(self.inputs.items()) - if k not in BaseInterfaceInputSpec().trait_names()]: + if k not in BaseInputSpec().trait_names()]: value = getattr(self.inputs, key) if isdefined(value): if key in ['mean_volume', 'reference_volume']: @@ -70,13 +70,11 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs["brain_mask"] = self._brain_mask_path - return outputs + def _post_run(self): + self.outputs.brain_mask = self._brain_mask_path + - -class FmriRealign4dInputSpec(BaseInterfaceInputSpec): +class FmriRealign4dInputSpec(BaseInputSpec): in_file = InputMultiPath(File(exists=True), mandatory=True, @@ -142,8 +140,8 @@ class FmriRealign4d(BaseInterface): """ - input_spec = FmriRealign4dInputSpec - output_spec = FmriRealign4dOutputSpec + _input_spec = FmriRealign4dInputSpec + _output_spec = FmriRealign4dOutputSpec keywords = ['slice timing', 'motion correction'] def _run_interface(self, runtime): @@ -190,14 +188,12 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = self._out_file_path - outputs['par_file'] = self._par_file_path - return outputs - + def _post_run(self): + self.outputs.out_file = self._out_file_path + self.outputs.par_file = self._par_file_path + -class SpaceTimeRealignerInputSpec(BaseInterfaceInputSpec): +class SpaceTimeRealignerInputSpec(BaseInputSpec): in_file = InputMultiPath(File(exists=True), mandatory=True, min_ver='0.4.0.dev', @@ -271,8 +267,8 @@ class SpaceTimeRealigner(BaseInterface): """ - input_spec = SpaceTimeRealignerInputSpec - output_spec = SpaceTimeRealignerOutputSpec + _input_spec = SpaceTimeRealignerInputSpec + _output_spec = SpaceTimeRealignerOutputSpec keywords = ['slice timing', 'motion correction'] @property @@ -321,14 +317,12 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = self._out_file_path - outputs['par_file'] = self._par_file_path - return outputs - + def _post_run(self): + self.outputs.out_file = self._out_file_path + self.outputs.par_file = self._par_file_path + -class TrimInputSpec(BaseInterfaceInputSpec): +class TrimInputSpec(BaseInputSpec): in_file = File( exists=True, mandatory=True, desc="EPI image to trim") @@ -361,11 +355,11 @@ class Trim(BaseInterface): """ - input_spec = TrimInputSpec - output_spec = TrimOutputSpec + _input_spec = TrimInputSpec + _output_spec = TrimOutputSpec def _run_interface(self, runtime): - out_file = self._list_outputs()['out_file'] + out_file = self.outputs.out_file nii = nb.load(self.inputs.in_file) if self.inputs.end_index == 0: s = slice(self.inputs.begin_index, nii.shape[3]) @@ -375,13 +369,13 @@ def _run_interface(self, runtime): nb.save(nii2, out_file) return runtime - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_file - if not isdefined(outputs['out_file']): - outputs['out_file'] = fname_presuffix( + def _post_run(self): + + self.outputs.out_file = self.inputs.out_file + if not isdefined(self.outputs.out_file): + self.outputs.out_file = fname_presuffix( self.inputs.in_file, newpath=os.getcwd(), suffix=self.inputs.suffix) - outputs['out_file'] = os.path.abspath(outputs['out_file']) - return outputs + self.outputs.out_file = os.path.abspath(self.outputs.out_file) + \ No newline at end of file diff --git a/nipype/interfaces/nipy/tests/test_auto_ComputeMask.py b/nipype/interfaces/nipy/tests/test_auto_ComputeMask.py index 607c2b1f9d..0e5b9eb1b8 100644 --- a/nipype/interfaces/nipy/tests/test_auto_ComputeMask.py +++ b/nipype/interfaces/nipy/tests/test_auto_ComputeMask.py @@ -6,15 +6,12 @@ def test_ComputeMask_inputs(): input_map = dict(M=dict(), cc=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), m=dict(), mean_volume=dict(mandatory=True, ), reference_volume=dict(), ) - inputs = ComputeMask.input_spec() + inputs = ComputeMask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -24,7 +21,7 @@ def test_ComputeMask_inputs(): def test_ComputeMask_outputs(): output_map = dict(brain_mask=dict(), ) - outputs = ComputeMask.output_spec() + outputs = ComputeMask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/nipy/tests/test_auto_EstimateContrast.py b/nipype/interfaces/nipy/tests/test_auto_EstimateContrast.py index 61e6d42146..b57af2c429 100644 --- a/nipype/interfaces/nipy/tests/test_auto_EstimateContrast.py +++ b/nipype/interfaces/nipy/tests/test_auto_EstimateContrast.py @@ -14,9 +14,6 @@ def test_EstimateContrast_inputs(): ), dof=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), mask=dict(), nvbeta=dict(mandatory=True, ), @@ -25,7 +22,7 @@ def test_EstimateContrast_inputs(): s2=dict(mandatory=True, ), ) - inputs = EstimateContrast.input_spec() + inputs = EstimateContrast._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +34,7 @@ def test_EstimateContrast_outputs(): stat_maps=dict(), z_maps=dict(), ) - outputs = EstimateContrast.output_spec() + outputs = EstimateContrast._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/nipy/tests/test_auto_FitGLM.py b/nipype/interfaces/nipy/tests/test_auto_FitGLM.py index 0f15facdb1..ad20a6b23d 100644 --- a/nipype/interfaces/nipy/tests/test_auto_FitGLM.py +++ b/nipype/interfaces/nipy/tests/test_auto_FitGLM.py @@ -10,9 +10,6 @@ def test_FitGLM_inputs(): ), hrf_model=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), mask=dict(), method=dict(usedefault=True, ), @@ -27,7 +24,7 @@ def test_FitGLM_inputs(): session_info=dict(mandatory=True, ), ) - inputs = FitGLM.input_spec() + inputs = FitGLM._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +42,7 @@ def test_FitGLM_outputs(): residuals=dict(), s2=dict(), ) - outputs = FitGLM.output_spec() + outputs = FitGLM._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/nipy/tests/test_auto_FmriRealign4d.py b/nipype/interfaces/nipy/tests/test_auto_FmriRealign4d.py index 917c1bbe9c..1daf519313 100644 --- a/nipype/interfaces/nipy/tests/test_auto_FmriRealign4d.py +++ b/nipype/interfaces/nipy/tests/test_auto_FmriRealign4d.py @@ -6,9 +6,6 @@ def test_FmriRealign4d_inputs(): input_map = dict(between_loops=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(mandatory=True, ), loops=dict(usedefault=True, @@ -26,7 +23,7 @@ def test_FmriRealign4d_inputs(): tr_slices=dict(requires=['time_interp'], ), ) - inputs = FmriRealign4d.input_spec() + inputs = FmriRealign4d._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +34,7 @@ def test_FmriRealign4d_outputs(): output_map = dict(out_file=dict(), par_file=dict(), ) - outputs = FmriRealign4d.output_spec() + outputs = FmriRealign4d._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/nipy/tests/test_auto_Similarity.py b/nipype/interfaces/nipy/tests/test_auto_Similarity.py index ef370639ce..e597414b3a 100644 --- a/nipype/interfaces/nipy/tests/test_auto_Similarity.py +++ b/nipype/interfaces/nipy/tests/test_auto_Similarity.py @@ -4,10 +4,7 @@ def test_Similarity_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - mask1=dict(), + input_map = dict(mask1=dict(), mask2=dict(), metric=dict(usedefault=True, ), @@ -16,7 +13,7 @@ def test_Similarity_inputs(): volume2=dict(mandatory=True, ), ) - inputs = Similarity.input_spec() + inputs = Similarity._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -26,7 +23,7 @@ def test_Similarity_inputs(): def test_Similarity_outputs(): output_map = dict(similarity=dict(), ) - outputs = Similarity.output_spec() + outputs = Similarity._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/nipy/tests/test_auto_SpaceTimeRealigner.py b/nipype/interfaces/nipy/tests/test_auto_SpaceTimeRealigner.py index 1dc0a5e6df..5a33910a5c 100644 --- a/nipype/interfaces/nipy/tests/test_auto_SpaceTimeRealigner.py +++ b/nipype/interfaces/nipy/tests/test_auto_SpaceTimeRealigner.py @@ -4,10 +4,7 @@ def test_SpaceTimeRealigner_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - in_file=dict(mandatory=True, + input_map = dict(in_file=dict(mandatory=True, min_ver='0.4.0.dev', ), slice_info=dict(requires=['slice_times'], @@ -16,7 +13,7 @@ def test_SpaceTimeRealigner_inputs(): tr=dict(requires=['slice_times'], ), ) - inputs = SpaceTimeRealigner.input_spec() + inputs = SpaceTimeRealigner._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -27,7 +24,7 @@ def test_SpaceTimeRealigner_outputs(): output_map = dict(out_file=dict(), par_file=dict(), ) - outputs = SpaceTimeRealigner.output_spec() + outputs = SpaceTimeRealigner._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/nipy/tests/test_auto_Trim.py b/nipype/interfaces/nipy/tests/test_auto_Trim.py index 98c8d0dea1..d43ee09c56 100644 --- a/nipype/interfaces/nipy/tests/test_auto_Trim.py +++ b/nipype/interfaces/nipy/tests/test_auto_Trim.py @@ -8,16 +8,13 @@ def test_Trim_inputs(): ), end_index=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(mandatory=True, ), out_file=dict(), suffix=dict(usedefault=True, ), ) - inputs = Trim.input_spec() + inputs = Trim._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -27,7 +24,7 @@ def test_Trim_inputs(): def test_Trim_outputs(): output_map = dict(out_file=dict(), ) - outputs = Trim.output_spec() + outputs = Trim._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/nipy/utils.py b/nipype/interfaces/nipy/utils.py index 0e78111c0e..8a4f2ad39e 100644 --- a/nipype/interfaces/nipy/utils.py +++ b/nipype/interfaces/nipy/utils.py @@ -22,10 +22,10 @@ from nipy.algorithms.registration.affine import Affine from ..base import (TraitedSpec, BaseInterface, traits, - BaseInterfaceInputSpec, File, isdefined) + BaseInputSpec, File, isdefined) -class SimilarityInputSpec(BaseInterfaceInputSpec): +class SimilarityInputSpec(BaseInputSpec): volume1 = File(exists=True, desc="3D volume", mandatory=True) volume2 = File(exists=True, desc="3D volume", mandatory=True) mask1 = File(exists=True, desc="3D volume") @@ -66,8 +66,8 @@ class Similarity(BaseInterface): >>> res = similarity.run() # doctest: +SKIP """ - input_spec = SimilarityInputSpec - output_spec = SimilarityOutputSpec + _input_spec = SimilarityInputSpec + _output_spec = SimilarityOutputSpec def __init__(self, **inputs): warnings.warn(("This interface is deprecated since 0.10.0." @@ -99,7 +99,6 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['similarity'] = self._similarity - return outputs + def _post_run(self): + self.outputs.similarity = self._similarity + \ No newline at end of file diff --git a/nipype/interfaces/nitime/analysis.py b/nipype/interfaces/nitime/analysis.py index da76a5882f..8b1987bed0 100644 --- a/nipype/interfaces/nitime/analysis.py +++ b/nipype/interfaces/nitime/analysis.py @@ -19,7 +19,7 @@ from ...utils.misc import package_check from ..base import (TraitedSpec, File, Undefined, traits, - BaseInterface, isdefined, BaseInterfaceInputSpec) + BaseInterface, isdefined, BaseInputSpec) from ...utils.filemanip import fname_presuffix @@ -34,7 +34,7 @@ import nitime.viz as viz -class CoherenceAnalyzerInputSpec(BaseInterfaceInputSpec): +class CoherenceAnalyzerInputSpec(BaseInputSpec): # Input either csv file, or time-series object and use _xor_inputs to # discriminate @@ -96,8 +96,8 @@ class CoherenceAnalyzerOutputSpec(TraitedSpec): class CoherenceAnalyzer(BaseInterface): - input_spec = CoherenceAnalyzerInputSpec - output_spec = CoherenceAnalyzerOutputSpec + _input_spec = CoherenceAnalyzerInputSpec + _output_spec = CoherenceAnalyzerOutputSpec def _read_csv(self): """ @@ -167,8 +167,8 @@ def _run_interface(self, runtime): return runtime # Rewrite _list_outputs (look at BET) - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + # if isdefined(self.inputs.output_csv_file): @@ -176,8 +176,8 @@ def _list_outputs(self): # file name + path) # Always defined (the arrays): - outputs['coherence_array'] = self.coherence - outputs['timedelay_array'] = self.delay + self.outputs.coherence_array = self.coherence + self.outputs.timedelay_array = self.delay # Conditional if isdefined(self.inputs.output_csv_file) and hasattr(self, 'coherence'): @@ -185,18 +185,17 @@ def _list_outputs(self): # coherence values to this file "coherence_csv" and makes the # time_delay csv file?? self._make_output_files() - outputs['coherence_csv'] = fname_presuffix(self.inputs.output_csv_file, suffix='_coherence') + self.outputs.coherence_csv = fname_presuffix(self.inputs.output_csv_file, suffix='_coherence') - outputs['timedelay_csv'] = fname_presuffix(self.inputs.output_csv_file, suffix='_delay') + self.outputs.timedelay_csv = fname_presuffix(self.inputs.output_csv_file, suffix='_delay') if isdefined(self.inputs.output_figure_file) and hasattr(self, 'coherence'): self._make_output_figures() - outputs['coherence_fig'] = fname_presuffix(self.inputs.output_figure_file, suffix='_coherence') - outputs['timedelay_fig'] = fname_presuffix(self.inputs.output_figure_file, suffix='_delay') - - return outputs + self.outputs.coherence_fig = fname_presuffix(self.inputs.output_figure_file, suffix='_coherence') + self.outputs.timedelay_fig = fname_presuffix(self.inputs.output_figure_file, suffix='_delay') + def _make_output_files(self): """ Generate the output csv files. diff --git a/nipype/interfaces/nitime/tests/test_auto_CoherenceAnalyzer.py b/nipype/interfaces/nitime/tests/test_auto_CoherenceAnalyzer.py index 2303b647c0..200d3d8f95 100644 --- a/nipype/interfaces/nitime/tests/test_auto_CoherenceAnalyzer.py +++ b/nipype/interfaces/nitime/tests/test_auto_CoherenceAnalyzer.py @@ -11,9 +11,6 @@ def test_CoherenceAnalyzer_inputs(): ), frequency_range=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_TS=dict(), in_file=dict(requires=('TR',), ), @@ -22,7 +19,7 @@ def test_CoherenceAnalyzer_inputs(): output_csv_file=dict(), output_figure_file=dict(), ) - inputs = CoherenceAnalyzer.input_spec() + inputs = CoherenceAnalyzer._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +34,7 @@ def test_CoherenceAnalyzer_outputs(): timedelay_csv=dict(), timedelay_fig=dict(), ) - outputs = CoherenceAnalyzer.output_spec() + outputs = CoherenceAnalyzer._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/petpvc.py b/nipype/interfaces/petpvc.py index 00dbbfb3ea..5592770e7c 100644 --- a/nipype/interfaces/petpvc.py +++ b/nipype/interfaces/petpvc.py @@ -158,21 +158,20 @@ class PETPVC(CommandLine): >>> pvc.inputs.fwhm_z = 2.0 >>> outs = pvc.run() #doctest: +SKIP """ - input_spec = PETPVCInputSpec - output_spec = PETPVCOutputSpec + _input_spec = PETPVCInputSpec + _output_spec = PETPVCOutputSpec _cmd = 'petpvc' - def _list_outputs(self): - outputs = self.output_spec().get() - outputs['out_file'] = self.inputs.out_file - if not isdefined(outputs['out_file']): + def _post_run(self): + + self.outputs.out_file = self.inputs.out_file + if not isdefined(self.outputs.out_file): method_name = self.inputs.pvc.lower() - outputs['out_file'] = self._gen_fname(self.inputs.in_file, + self.outputs.out_file = self._gen_fname(self.inputs.in_file, suffix='_{}_pvc'.format(method_name)) - outputs['out_file'] = os.path.abspath(outputs['out_file']) - return outputs - + self.outputs.out_file = os.path.abspath(self.outputs.out_file) + def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True, ext='.nii.gz'): """Generate a filename based on the given parameters. @@ -220,5 +219,5 @@ def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True, def _gen_filename(self, name): if name == 'out_file': - return self._list_outputs()['out_file'] + return self.outputs.out_file return None diff --git a/nipype/interfaces/semtools/brains/classify.py b/nipype/interfaces/semtools/brains/classify.py index 191284b104..e6bc7211fe 100644 --- a/nipype/interfaces/semtools/brains/classify.py +++ b/nipype/interfaces/semtools/brains/classify.py @@ -44,8 +44,8 @@ class BRAINSPosteriorToContinuousClass(SEMLikeCommandLine): """ - input_spec = BRAINSPosteriorToContinuousClassInputSpec - output_spec = BRAINSPosteriorToContinuousClassOutputSpec + _input_spec = BRAINSPosteriorToContinuousClassInputSpec + _output_spec = BRAINSPosteriorToContinuousClassOutputSpec _cmd = " BRAINSPosteriorToContinuousClass " _outputs_filenames = {'outputVolume': 'outputVolume'} _redirect_x = False diff --git a/nipype/interfaces/semtools/brains/segmentation.py b/nipype/interfaces/semtools/brains/segmentation.py index a5f5c0031c..103dda499c 100644 --- a/nipype/interfaces/semtools/brains/segmentation.py +++ b/nipype/interfaces/semtools/brains/segmentation.py @@ -36,8 +36,8 @@ class SimilarityIndex(SEMLikeCommandLine): """ - input_spec = SimilarityIndexInputSpec - output_spec = SimilarityIndexOutputSpec + _input_spec = SimilarityIndexInputSpec + _output_spec = SimilarityIndexOutputSpec _cmd = " SimilarityIndex " _outputs_filenames = {} _redirect_x = False @@ -82,8 +82,8 @@ class BRAINSTalairach(SEMLikeCommandLine): """ - input_spec = BRAINSTalairachInputSpec - output_spec = BRAINSTalairachOutputSpec + _input_spec = BRAINSTalairachInputSpec + _output_spec = BRAINSTalairachOutputSpec _cmd = " BRAINSTalairach " _outputs_filenames = {'outputGrid': 'outputGrid', 'outputBox': 'outputBox'} _redirect_x = False @@ -122,8 +122,8 @@ class BRAINSTalairachMask(SEMLikeCommandLine): """ - input_spec = BRAINSTalairachMaskInputSpec - output_spec = BRAINSTalairachMaskOutputSpec + _input_spec = BRAINSTalairachMaskInputSpec + _output_spec = BRAINSTalairachMaskOutputSpec _cmd = " BRAINSTalairachMask " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False diff --git a/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSPosteriorToContinuousClass.py b/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSPosteriorToContinuousClass.py index 7fa7c6db0b..a6fadf11ab 100644 --- a/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSPosteriorToContinuousClass.py +++ b/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSPosteriorToContinuousClass.py @@ -6,12 +6,6 @@ def test_BRAINSPosteriorToContinuousClass_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputBasalGmVolume=dict(argstr='--inputBasalGmVolume %s', ), inputCrblGmVolume=dict(argstr='--inputCrblGmVolume %s', @@ -29,10 +23,8 @@ def test_BRAINSPosteriorToContinuousClass_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSPosteriorToContinuousClass.input_spec() + inputs = BRAINSPosteriorToContinuousClass._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_BRAINSPosteriorToContinuousClass_inputs(): def test_BRAINSPosteriorToContinuousClass_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = BRAINSPosteriorToContinuousClass.output_spec() + outputs = BRAINSPosteriorToContinuousClass._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSTalairach.py b/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSTalairach.py index 51a08d06e2..4227e82583 100644 --- a/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSTalairach.py +++ b/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSTalairach.py @@ -26,12 +26,6 @@ def test_BRAINSTalairach_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), outputBox=dict(argstr='--outputBox %s', @@ -40,10 +34,8 @@ def test_BRAINSTalairach_inputs(): outputGrid=dict(argstr='--outputGrid %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSTalairach.input_spec() + inputs = BRAINSTalairach._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -54,7 +46,7 @@ def test_BRAINSTalairach_outputs(): output_map = dict(outputBox=dict(), outputGrid=dict(), ) - outputs = BRAINSTalairach.output_spec() + outputs = BRAINSTalairach._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSTalairachMask.py b/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSTalairachMask.py index e4eaa93073..b6da22b951 100644 --- a/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSTalairachMask.py +++ b/nipype/interfaces/semtools/brains/tests/test_auto_BRAINSTalairachMask.py @@ -6,16 +6,10 @@ def test_BRAINSTalairachMask_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), expand=dict(argstr='--expand ', ), hemisphereMode=dict(argstr='--hemisphereMode %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), outputVolume=dict(argstr='--outputVolume %s', @@ -25,10 +19,8 @@ def test_BRAINSTalairachMask_inputs(): ), talairachParameters=dict(argstr='--talairachParameters %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSTalairachMask.input_spec() + inputs = BRAINSTalairachMask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_BRAINSTalairachMask_inputs(): def test_BRAINSTalairachMask_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = BRAINSTalairachMask.output_spec() + outputs = BRAINSTalairachMask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/brains/tests/test_auto_HistogramMatchingFilter.py b/nipype/interfaces/semtools/brains/tests/test_auto_HistogramMatchingFilter.py index 41c4fb832f..1b9bf81d43 100644 --- a/nipype/interfaces/semtools/brains/tests/test_auto_HistogramMatchingFilter.py +++ b/nipype/interfaces/semtools/brains/tests/test_auto_HistogramMatchingFilter.py @@ -6,14 +6,8 @@ def test_HistogramMatchingFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), histogramAlgorithm=dict(argstr='--histogramAlgorithm %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputBinaryVolume=dict(argstr='--inputBinaryVolume %s', ), inputVolume=dict(argstr='--inputVolume %s', @@ -29,14 +23,12 @@ def test_HistogramMatchingFilter_inputs(): ), referenceVolume=dict(argstr='--referenceVolume %s', ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose ', ), writeHistogram=dict(argstr='--writeHistogram %s', ), ) - inputs = HistogramMatchingFilter.input_spec() + inputs = HistogramMatchingFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +38,7 @@ def test_HistogramMatchingFilter_inputs(): def test_HistogramMatchingFilter_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = HistogramMatchingFilter.output_spec() + outputs = HistogramMatchingFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/brains/tests/test_auto_SimilarityIndex.py b/nipype/interfaces/semtools/brains/tests/test_auto_SimilarityIndex.py index 3fbbbace73..463d92eaa0 100644 --- a/nipype/interfaces/semtools/brains/tests/test_auto_SimilarityIndex.py +++ b/nipype/interfaces/semtools/brains/tests/test_auto_SimilarityIndex.py @@ -8,22 +8,14 @@ def test_SimilarityIndex_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputManualVolume=dict(argstr='--inputManualVolume %s', ), outputCSVFilename=dict(argstr='--outputCSVFilename %s', ), - terminal_output=dict(nohash=True, - ), thresholdInterval=dict(argstr='--thresholdInterval %f', ), ) - inputs = SimilarityIndex.input_spec() + inputs = SimilarityIndex._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +24,7 @@ def test_SimilarityIndex_inputs(): def test_SimilarityIndex_outputs(): output_map = dict() - outputs = SimilarityIndex.output_spec() + outputs = SimilarityIndex._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/brains/utilities.py b/nipype/interfaces/semtools/brains/utilities.py index a296be671c..5ddf4ca071 100644 --- a/nipype/interfaces/semtools/brains/utilities.py +++ b/nipype/interfaces/semtools/brains/utilities.py @@ -40,8 +40,8 @@ class HistogramMatchingFilter(SEMLikeCommandLine): """ - input_spec = HistogramMatchingFilterInputSpec - output_spec = HistogramMatchingFilterOutputSpec + _input_spec = HistogramMatchingFilterInputSpec + _output_spec = HistogramMatchingFilterOutputSpec _cmd = " HistogramMatchingFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False diff --git a/nipype/interfaces/semtools/converters.py b/nipype/interfaces/semtools/converters.py index 01ef06967b..4d3dad9340 100644 --- a/nipype/interfaces/semtools/converters.py +++ b/nipype/interfaces/semtools/converters.py @@ -39,8 +39,8 @@ class DWISimpleCompare(SEMLikeCommandLine): """ - input_spec = DWISimpleCompareInputSpec - output_spec = DWISimpleCompareOutputSpec + _input_spec = DWISimpleCompareInputSpec + _output_spec = DWISimpleCompareOutputSpec _cmd = " DWISimpleCompare " _outputs_filenames = {} _redirect_x = False @@ -75,8 +75,8 @@ class DWICompare(SEMLikeCommandLine): """ - input_spec = DWICompareInputSpec - output_spec = DWICompareOutputSpec + _input_spec = DWICompareInputSpec + _output_spec = DWICompareOutputSpec _cmd = " DWICompare " _outputs_filenames = {} _redirect_x = False diff --git a/nipype/interfaces/semtools/diffusion/diffusion.py b/nipype/interfaces/semtools/diffusion/diffusion.py index 6d30e1fc44..f8ce16d2c6 100644 --- a/nipype/interfaces/semtools/diffusion/diffusion.py +++ b/nipype/interfaces/semtools/diffusion/diffusion.py @@ -43,8 +43,8 @@ class dtiaverage(SEMLikeCommandLine): """ - input_spec = dtiaverageInputSpec - output_spec = dtiaverageOutputSpec + _input_spec = dtiaverageInputSpec + _output_spec = dtiaverageOutputSpec _cmd = " dtiaverage " _outputs_filenames = {'tensor_output': 'tensor_output.nii'} _redirect_x = False @@ -125,8 +125,8 @@ class dtiestim(SEMLikeCommandLine): """ - input_spec = dtiestimInputSpec - output_spec = dtiestimOutputSpec + _input_spec = dtiestimInputSpec + _output_spec = dtiestimOutputSpec _cmd = " dtiestim " _outputs_filenames = {'B0': 'B0.nii', 'idwi': 'idwi.nii', 'tensor_output': 'tensor_output.nii', 'B0_mask_output': 'B0_mask_output.nii'} _redirect_x = False @@ -216,8 +216,8 @@ class dtiprocess(SEMLikeCommandLine): """ - input_spec = dtiprocessInputSpec - output_spec = dtiprocessOutputSpec + _input_spec = dtiprocessInputSpec + _output_spec = dtiprocessOutputSpec _cmd = " dtiprocess " _outputs_filenames = {'fa_gradmag_output': 'fa_gradmag_output.nii', 'fa_gradient_output': 'fa_gradient_output.nii', 'lambda1_output': 'lambda1_output.nii', 'lambda2_output': 'lambda2_output.nii', 'color_fa_output': 'color_fa_output.nii', 'fa_output': 'fa_output.nii', 'frobenius_norm_output': 'frobenius_norm_output.nii', 'principal_eigenvector_output': 'principal_eigenvector_output.nii', 'outmask': 'outmask.nii', 'lambda3_output': 'lambda3_output.nii', 'negative_eigenvector_output': 'negative_eigenvector_output.nii', 'md_output': 'md_output.nii', 'RD_output': 'RD_output.nii', 'deformation_output': 'deformation_output.nii', 'rot_output': 'rot_output.nii'} @@ -274,8 +274,8 @@ class DWIConvert(SEMLikeCommandLine): """ - input_spec = DWIConvertInputSpec - output_spec = DWIConvertOutputSpec + _input_spec = DWIConvertInputSpec + _output_spec = DWIConvertOutputSpec _cmd = " DWIConvert " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'outputDirectory': 'outputDirectory', 'outputBValues': 'outputBValues.bval', 'gradientVectorFile': 'gradientVectorFile', 'outputBVectors': 'outputBVectors.bvec'} _redirect_x = False diff --git a/nipype/interfaces/semtools/diffusion/gtract.py b/nipype/interfaces/semtools/diffusion/gtract.py index c7f2db432c..93724faf8c 100644 --- a/nipype/interfaces/semtools/diffusion/gtract.py +++ b/nipype/interfaces/semtools/diffusion/gtract.py @@ -40,8 +40,8 @@ class gtractTransformToDisplacementField(SEMLikeCommandLine): """ - input_spec = gtractTransformToDisplacementFieldInputSpec - output_spec = gtractTransformToDisplacementFieldOutputSpec + _input_spec = gtractTransformToDisplacementFieldInputSpec + _output_spec = gtractTransformToDisplacementFieldOutputSpec _cmd = " gtractTransformToDisplacementField " _outputs_filenames = {'outputDeformationFieldVolume': 'outputDeformationFieldVolume.nii'} _redirect_x = False @@ -79,8 +79,8 @@ class gtractInvertBSplineTransform(SEMLikeCommandLine): """ - input_spec = gtractInvertBSplineTransformInputSpec - output_spec = gtractInvertBSplineTransformOutputSpec + _input_spec = gtractInvertBSplineTransformInputSpec + _output_spec = gtractInvertBSplineTransformOutputSpec _cmd = " gtractInvertBSplineTransform " _outputs_filenames = {'outputTransform': 'outputTransform.h5'} _redirect_x = False @@ -117,8 +117,8 @@ class gtractConcatDwi(SEMLikeCommandLine): """ - input_spec = gtractConcatDwiInputSpec - output_spec = gtractConcatDwiOutputSpec + _input_spec = gtractConcatDwiInputSpec + _output_spec = gtractConcatDwiOutputSpec _cmd = " gtractConcatDwi " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -156,8 +156,8 @@ class gtractAverageBvalues(SEMLikeCommandLine): """ - input_spec = gtractAverageBvaluesInputSpec - output_spec = gtractAverageBvaluesOutputSpec + _input_spec = gtractAverageBvaluesInputSpec + _output_spec = gtractAverageBvaluesOutputSpec _cmd = " gtractAverageBvalues " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -209,8 +209,8 @@ class gtractCoregBvalues(SEMLikeCommandLine): """ - input_spec = gtractCoregBvaluesInputSpec - output_spec = gtractCoregBvaluesOutputSpec + _input_spec = gtractCoregBvaluesInputSpec + _output_spec = gtractCoregBvaluesOutputSpec _cmd = " gtractCoregBvalues " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd', 'outputTransform': 'outputTransform.h5'} _redirect_x = False @@ -249,8 +249,8 @@ class gtractResampleAnisotropy(SEMLikeCommandLine): """ - input_spec = gtractResampleAnisotropyInputSpec - output_spec = gtractResampleAnisotropyOutputSpec + _input_spec = gtractResampleAnisotropyInputSpec + _output_spec = gtractResampleAnisotropyOutputSpec _cmd = " gtractResampleAnisotropy " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -289,8 +289,8 @@ class gtractResampleCodeImage(SEMLikeCommandLine): """ - input_spec = gtractResampleCodeImageInputSpec - output_spec = gtractResampleCodeImageOutputSpec + _input_spec = gtractResampleCodeImageInputSpec + _output_spec = gtractResampleCodeImageOutputSpec _cmd = " gtractResampleCodeImage " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -327,8 +327,8 @@ class gtractCopyImageOrientation(SEMLikeCommandLine): """ - input_spec = gtractCopyImageOrientationInputSpec - output_spec = gtractCopyImageOrientationOutputSpec + _input_spec = gtractCopyImageOrientationInputSpec + _output_spec = gtractCopyImageOrientationOutputSpec _cmd = " gtractCopyImageOrientation " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -366,8 +366,8 @@ class gtractCreateGuideFiber(SEMLikeCommandLine): """ - input_spec = gtractCreateGuideFiberInputSpec - output_spec = gtractCreateGuideFiberOutputSpec + _input_spec = gtractCreateGuideFiberInputSpec + _output_spec = gtractCreateGuideFiberOutputSpec _cmd = " gtractCreateGuideFiber " _outputs_filenames = {'outputFiber': 'outputFiber.vtk'} _redirect_x = False @@ -404,8 +404,8 @@ class gtractAnisotropyMap(SEMLikeCommandLine): """ - input_spec = gtractAnisotropyMapInputSpec - output_spec = gtractAnisotropyMapOutputSpec + _input_spec = gtractAnisotropyMapInputSpec + _output_spec = gtractAnisotropyMapOutputSpec _cmd = " gtractAnisotropyMap " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -443,8 +443,8 @@ class gtractClipAnisotropy(SEMLikeCommandLine): """ - input_spec = gtractClipAnisotropyInputSpec - output_spec = gtractClipAnisotropyOutputSpec + _input_spec = gtractClipAnisotropyInputSpec + _output_spec = gtractClipAnisotropyOutputSpec _cmd = " gtractClipAnisotropy " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -484,8 +484,8 @@ class gtractResampleB0(SEMLikeCommandLine): """ - input_spec = gtractResampleB0InputSpec - output_spec = gtractResampleB0OutputSpec + _input_spec = gtractResampleB0InputSpec + _output_spec = gtractResampleB0OutputSpec _cmd = " gtractResampleB0 " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -521,8 +521,8 @@ class gtractInvertRigidTransform(SEMLikeCommandLine): """ - input_spec = gtractInvertRigidTransformInputSpec - output_spec = gtractInvertRigidTransformOutputSpec + _input_spec = gtractInvertRigidTransformInputSpec + _output_spec = gtractInvertRigidTransformOutputSpec _cmd = " gtractInvertRigidTransform " _outputs_filenames = {'outputTransform': 'outputTransform.h5'} _redirect_x = False @@ -559,8 +559,8 @@ class gtractImageConformity(SEMLikeCommandLine): """ - input_spec = gtractImageConformityInputSpec - output_spec = gtractImageConformityOutputSpec + _input_spec = gtractImageConformityInputSpec + _output_spec = gtractImageConformityOutputSpec _cmd = " gtractImageConformity " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -601,8 +601,8 @@ class compareTractInclusion(SEMLikeCommandLine): """ - input_spec = compareTractInclusionInputSpec - output_spec = compareTractInclusionOutputSpec + _input_spec = compareTractInclusionInputSpec + _output_spec = compareTractInclusionOutputSpec _cmd = " compareTractInclusion " _outputs_filenames = {} _redirect_x = False @@ -649,8 +649,8 @@ class gtractFastMarchingTracking(SEMLikeCommandLine): """ - input_spec = gtractFastMarchingTrackingInputSpec - output_spec = gtractFastMarchingTrackingOutputSpec + _input_spec = gtractFastMarchingTrackingInputSpec + _output_spec = gtractFastMarchingTrackingOutputSpec _cmd = " gtractFastMarchingTracking " _outputs_filenames = {'outputTract': 'outputTract.vtk'} _redirect_x = False @@ -688,8 +688,8 @@ class gtractInvertDisplacementField(SEMLikeCommandLine): """ - input_spec = gtractInvertDisplacementFieldInputSpec - output_spec = gtractInvertDisplacementFieldOutputSpec + _input_spec = gtractInvertDisplacementFieldInputSpec + _output_spec = gtractInvertDisplacementFieldOutputSpec _cmd = " gtractInvertDisplacementField " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False @@ -752,8 +752,8 @@ class gtractCoRegAnatomy(SEMLikeCommandLine): """ - input_spec = gtractCoRegAnatomyInputSpec - output_spec = gtractCoRegAnatomyOutputSpec + _input_spec = gtractCoRegAnatomyInputSpec + _output_spec = gtractCoRegAnatomyOutputSpec _cmd = " gtractCoRegAnatomy " _outputs_filenames = {'outputTransformName': 'outputTransformName.h5'} _redirect_x = False @@ -796,8 +796,8 @@ class gtractResampleDWIInPlace(SEMLikeCommandLine): """ - input_spec = gtractResampleDWIInPlaceInputSpec - output_spec = gtractResampleDWIInPlaceOutputSpec + _input_spec = gtractResampleDWIInPlaceInputSpec + _output_spec = gtractResampleDWIInPlaceOutputSpec _cmd = " gtractResampleDWIInPlace " _outputs_filenames = {'outputResampledB0': 'outputResampledB0.nii', 'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -841,8 +841,8 @@ class gtractCostFastMarching(SEMLikeCommandLine): """ - input_spec = gtractCostFastMarchingInputSpec - output_spec = gtractCostFastMarchingOutputSpec + _input_spec = gtractCostFastMarchingInputSpec + _output_spec = gtractCostFastMarchingOutputSpec _cmd = " gtractCostFastMarching " _outputs_filenames = {'outputCostVolume': 'outputCostVolume.nrrd', 'outputSpeedVolume': 'outputSpeedVolume.nrrd'} _redirect_x = False @@ -903,8 +903,8 @@ class gtractFiberTracking(SEMLikeCommandLine): """ - input_spec = gtractFiberTrackingInputSpec - output_spec = gtractFiberTrackingOutputSpec + _input_spec = gtractFiberTrackingInputSpec + _output_spec = gtractFiberTrackingOutputSpec _cmd = " gtractFiberTracking " _outputs_filenames = {'outputTract': 'outputTract.vtk'} _redirect_x = False @@ -942,8 +942,8 @@ class extractNrrdVectorIndex(SEMLikeCommandLine): """ - input_spec = extractNrrdVectorIndexInputSpec - output_spec = extractNrrdVectorIndexOutputSpec + _input_spec = extractNrrdVectorIndexInputSpec + _output_spec = extractNrrdVectorIndexOutputSpec _cmd = " extractNrrdVectorIndex " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -982,8 +982,8 @@ class gtractResampleFibers(SEMLikeCommandLine): """ - input_spec = gtractResampleFibersInputSpec - output_spec = gtractResampleFibersOutputSpec + _input_spec = gtractResampleFibersInputSpec + _output_spec = gtractResampleFibersOutputSpec _cmd = " gtractResampleFibers " _outputs_filenames = {'outputTract': 'outputTract.vtk'} _redirect_x = False @@ -1031,8 +1031,8 @@ class gtractTensor(SEMLikeCommandLine): """ - input_spec = gtractTensorInputSpec - output_spec = gtractTensorOutputSpec + _input_spec = gtractTensorInputSpec + _output_spec = gtractTensorOutputSpec _cmd = " gtractTensor " _outputs_filenames = {'outputVolume': 'outputVolume.nrrd'} _redirect_x = False diff --git a/nipype/interfaces/semtools/diffusion/maxcurvature.py b/nipype/interfaces/semtools/diffusion/maxcurvature.py index 4206844ea2..21b382ac7d 100644 --- a/nipype/interfaces/semtools/diffusion/maxcurvature.py +++ b/nipype/interfaces/semtools/diffusion/maxcurvature.py @@ -44,8 +44,8 @@ class maxcurvature(SEMLikeCommandLine): """ - input_spec = maxcurvatureInputSpec - output_spec = maxcurvatureOutputSpec + _input_spec = maxcurvatureInputSpec + _output_spec = maxcurvatureOutputSpec _cmd = " maxcurvature " _outputs_filenames = {'output': 'output.nii'} _redirect_x = False diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_DWIConvert.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_DWIConvert.py index 15e293f3aa..a8facba396 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_DWIConvert.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_DWIConvert.py @@ -8,9 +8,6 @@ def test_DWIConvert_inputs(): ), conversionMode=dict(argstr='--conversionMode %s', ), - environ=dict(nohash=True, - usedefault=True, - ), fMRI=dict(argstr='--fMRI ', ), fslNIFTIFile=dict(argstr='--fslNIFTIFile %s', @@ -18,9 +15,6 @@ def test_DWIConvert_inputs(): gradientVectorFile=dict(argstr='--gradientVectorFile %s', hash_files=False, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputBValues=dict(argstr='--inputBValues %s', ), inputBVectors=dict(argstr='--inputBVectors %s', @@ -43,8 +37,6 @@ def test_DWIConvert_inputs(): ), smallGradientThreshold=dict(argstr='--smallGradientThreshold %f', ), - terminal_output=dict(nohash=True, - ), useBMatrixGradientDirections=dict(argstr='--useBMatrixGradientDirections ', ), useIdentityMeaseurementFrame=dict(argstr='--useIdentityMeaseurementFrame ', @@ -52,7 +44,7 @@ def test_DWIConvert_inputs(): writeProtocolGradientsFile=dict(argstr='--writeProtocolGradientsFile ', ), ) - inputs = DWIConvert.input_spec() + inputs = DWIConvert._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -66,7 +58,7 @@ def test_DWIConvert_outputs(): outputDirectory=dict(), outputVolume=dict(), ) - outputs = DWIConvert.output_spec() + outputs = DWIConvert._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_compareTractInclusion.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_compareTractInclusion.py index 1a46be411a..8c9b0ea737 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_compareTractInclusion.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_compareTractInclusion.py @@ -8,20 +8,12 @@ def test_compareTractInclusion_inputs(): ), closeness=dict(argstr='--closeness %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), numberOfPoints=dict(argstr='--numberOfPoints %d', ), numberOfThreads=dict(argstr='--numberOfThreads %d', ), standardFiber=dict(argstr='--standardFiber %s', ), - terminal_output=dict(nohash=True, - ), testFiber=dict(argstr='--testFiber %s', ), testForBijection=dict(argstr='--testForBijection ', @@ -31,7 +23,7 @@ def test_compareTractInclusion_inputs(): writeXMLPolyDataFile=dict(argstr='--writeXMLPolyDataFile ', ), ) - inputs = compareTractInclusion.input_spec() + inputs = compareTractInclusion._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_compareTractInclusion_inputs(): def test_compareTractInclusion_outputs(): output_map = dict() - outputs = compareTractInclusion.output_spec() + outputs = compareTractInclusion._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiaverage.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiaverage.py index 7988994224..6b9dd9303e 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiaverage.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiaverage.py @@ -8,23 +8,15 @@ def test_dtiaverage_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputs=dict(argstr='--inputs %s...', ), tensor_output=dict(argstr='--tensor_output %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose ', ), ) - inputs = dtiaverage.input_spec() + inputs = dtiaverage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_dtiaverage_inputs(): def test_dtiaverage_outputs(): output_map = dict(tensor_output=dict(), ) - outputs = dtiaverage.output_spec() + outputs = dtiaverage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiestim.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiestim.py index 1b488807b9..3ed8c89ece 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiestim.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiestim.py @@ -25,15 +25,9 @@ def test_dtiestim_inputs(): ), dwi_image=dict(argstr='--dwi_image %s', ), - environ=dict(nohash=True, - usedefault=True, - ), idwi=dict(argstr='--idwi %s', hash_files=False, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), method=dict(argstr='--method %s', ), shiftNeg=dict(argstr='--shiftNeg ', @@ -47,8 +41,6 @@ def test_dtiestim_inputs(): tensor_output=dict(argstr='--tensor_output %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), threshold=dict(argstr='--threshold %d', ), verbose=dict(argstr='--verbose ', @@ -56,7 +48,7 @@ def test_dtiestim_inputs(): weight_iterations=dict(argstr='--weight_iterations %d', ), ) - inputs = dtiestim.input_spec() + inputs = dtiestim._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -69,7 +61,7 @@ def test_dtiestim_outputs(): idwi=dict(), tensor_output=dict(), ) - outputs = dtiestim.output_spec() + outputs = dtiestim._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiprocess.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiprocess.py index 94bd061f75..df0ff674c2 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiprocess.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_dtiprocess.py @@ -25,9 +25,6 @@ def test_dtiprocess_inputs(): ), dti_image=dict(argstr='--dti_image %s', ), - environ=dict(nohash=True, - usedefault=True, - ), fa_gradient_output=dict(argstr='--fa_gradient_output %s', hash_files=False, ), @@ -44,9 +41,6 @@ def test_dtiprocess_inputs(): ), hField=dict(argstr='--hField ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), interpolation=dict(argstr='--interpolation %s', ), lambda1_output=dict(argstr='--lambda1_output %s', @@ -83,12 +77,10 @@ def test_dtiprocess_inputs(): ), sigma=dict(argstr='--sigma %f', ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose ', ), ) - inputs = dtiprocess.input_spec() + inputs = dtiprocess._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -112,7 +104,7 @@ def test_dtiprocess_outputs(): principal_eigenvector_output=dict(), rot_output=dict(), ) - outputs = dtiprocess.output_spec() + outputs = dtiprocess._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_extractNrrdVectorIndex.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_extractNrrdVectorIndex.py index 79400fea82..c780c815b2 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_extractNrrdVectorIndex.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_extractNrrdVectorIndex.py @@ -6,12 +6,6 @@ def test_extractNrrdVectorIndex_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -21,12 +15,10 @@ def test_extractNrrdVectorIndex_inputs(): ), setImageOrientation=dict(argstr='--setImageOrientation %s', ), - terminal_output=dict(nohash=True, - ), vectorIndex=dict(argstr='--vectorIndex %d', ), ) - inputs = extractNrrdVectorIndex.input_spec() + inputs = extractNrrdVectorIndex._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_extractNrrdVectorIndex_inputs(): def test_extractNrrdVectorIndex_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = extractNrrdVectorIndex.output_spec() + outputs = extractNrrdVectorIndex._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractAnisotropyMap.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractAnisotropyMap.py index eccf216089..cc4bec623d 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractAnisotropyMap.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractAnisotropyMap.py @@ -8,12 +8,6 @@ def test_gtractAnisotropyMap_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputTensorVolume=dict(argstr='--inputTensorVolume %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -21,10 +15,8 @@ def test_gtractAnisotropyMap_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractAnisotropyMap.input_spec() + inputs = gtractAnisotropyMap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_gtractAnisotropyMap_inputs(): def test_gtractAnisotropyMap_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractAnisotropyMap.output_spec() + outputs = gtractAnisotropyMap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractAverageBvalues.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractAverageBvalues.py index 3c00c388cf..bd231b4514 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractAverageBvalues.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractAverageBvalues.py @@ -10,12 +10,6 @@ def test_gtractAverageBvalues_inputs(): ), directionsTolerance=dict(argstr='--directionsTolerance %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -23,10 +17,8 @@ def test_gtractAverageBvalues_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractAverageBvalues.input_spec() + inputs = gtractAverageBvalues._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_gtractAverageBvalues_inputs(): def test_gtractAverageBvalues_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractAverageBvalues.output_spec() + outputs = gtractAverageBvalues._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractClipAnisotropy.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractClipAnisotropy.py index 95970529ef..a5e53ce28e 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractClipAnisotropy.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractClipAnisotropy.py @@ -10,12 +10,6 @@ def test_gtractClipAnisotropy_inputs(): ), clipLastSlice=dict(argstr='--clipLastSlice ', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -23,10 +17,8 @@ def test_gtractClipAnisotropy_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractClipAnisotropy.input_spec() + inputs = gtractClipAnisotropy._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_gtractClipAnisotropy_inputs(): def test_gtractClipAnisotropy_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractClipAnisotropy.output_spec() + outputs = gtractClipAnisotropy._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCoRegAnatomy.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCoRegAnatomy.py index 60ce5e72a4..a143be3de3 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCoRegAnatomy.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCoRegAnatomy.py @@ -10,17 +10,11 @@ def test_gtractCoRegAnatomy_inputs(): ), convergence=dict(argstr='--convergence %f', ), - environ=dict(nohash=True, - usedefault=True, - ), gradientTolerance=dict(argstr='--gradientTolerance %f', ), gridSize=dict(argstr='--gridSize %s', sep=',', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputAnatomicalVolume=dict(argstr='--inputAnatomicalVolume %s', ), inputRigidTransform=dict(argstr='--inputRigidTransform %s', @@ -50,8 +44,6 @@ def test_gtractCoRegAnatomy_inputs(): ), spatialScale=dict(argstr='--spatialScale %d', ), - terminal_output=dict(nohash=True, - ), transformType=dict(argstr='--transformType %s', ), translationScale=dict(argstr='--translationScale %f', @@ -65,7 +57,7 @@ def test_gtractCoRegAnatomy_inputs(): vectorIndex=dict(argstr='--vectorIndex %d', ), ) - inputs = gtractCoRegAnatomy.input_spec() + inputs = gtractCoRegAnatomy._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -75,7 +67,7 @@ def test_gtractCoRegAnatomy_inputs(): def test_gtractCoRegAnatomy_outputs(): output_map = dict(outputTransformName=dict(), ) - outputs = gtractCoRegAnatomy.output_spec() + outputs = gtractCoRegAnatomy._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractConcatDwi.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractConcatDwi.py index 0cfe65e61d..1039a8492d 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractConcatDwi.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractConcatDwi.py @@ -6,14 +6,8 @@ def test_gtractConcatDwi_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), ignoreOrigins=dict(argstr='--ignoreOrigins ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s...', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -21,10 +15,8 @@ def test_gtractConcatDwi_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractConcatDwi.input_spec() + inputs = gtractConcatDwi._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_gtractConcatDwi_inputs(): def test_gtractConcatDwi_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractConcatDwi.output_spec() + outputs = gtractConcatDwi._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCopyImageOrientation.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCopyImageOrientation.py index e16d80814d..7ad4c2468c 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCopyImageOrientation.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCopyImageOrientation.py @@ -6,12 +6,6 @@ def test_gtractCopyImageOrientation_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputReferenceVolume=dict(argstr='--inputReferenceVolume %s', ), inputVolume=dict(argstr='--inputVolume %s', @@ -21,10 +15,8 @@ def test_gtractCopyImageOrientation_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractCopyImageOrientation.input_spec() + inputs = gtractCopyImageOrientation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_gtractCopyImageOrientation_inputs(): def test_gtractCopyImageOrientation_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractCopyImageOrientation.output_spec() + outputs = gtractCopyImageOrientation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCoregBvalues.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCoregBvalues.py index c6b69bc116..9665f59a15 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCoregBvalues.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCoregBvalues.py @@ -10,16 +10,10 @@ def test_gtractCoregBvalues_inputs(): ), eddyCurrentCorrection=dict(argstr='--eddyCurrentCorrection ', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedVolume=dict(argstr='--fixedVolume %s', ), fixedVolumeIndex=dict(argstr='--fixedVolumeIndex %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), maximumStepSize=dict(argstr='--maximumStepSize %f', ), minimumStepSize=dict(argstr='--minimumStepSize %f', @@ -46,10 +40,8 @@ def test_gtractCoregBvalues_inputs(): ), spatialScale=dict(argstr='--spatialScale %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractCoregBvalues.input_spec() + inputs = gtractCoregBvalues._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -60,7 +52,7 @@ def test_gtractCoregBvalues_outputs(): output_map = dict(outputTransform=dict(), outputVolume=dict(), ) - outputs = gtractCoregBvalues.output_spec() + outputs = gtractCoregBvalues._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCostFastMarching.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCostFastMarching.py index 84b91e79dc..77e89b251d 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCostFastMarching.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCostFastMarching.py @@ -8,12 +8,6 @@ def test_gtractCostFastMarching_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputAnisotropyVolume=dict(argstr='--inputAnisotropyVolume %s', ), inputStartingSeedsLabelMapVolume=dict(argstr='--inputStartingSeedsLabelMapVolume %s', @@ -34,10 +28,8 @@ def test_gtractCostFastMarching_inputs(): ), stoppingValue=dict(argstr='--stoppingValue %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractCostFastMarching.input_spec() + inputs = gtractCostFastMarching._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -48,7 +40,7 @@ def test_gtractCostFastMarching_outputs(): output_map = dict(outputCostVolume=dict(), outputSpeedVolume=dict(), ) - outputs = gtractCostFastMarching.output_spec() + outputs = gtractCostFastMarching._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCreateGuideFiber.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCreateGuideFiber.py index ed4c3a7891..be1afa86f3 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCreateGuideFiber.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractCreateGuideFiber.py @@ -6,12 +6,6 @@ def test_gtractCreateGuideFiber_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputFiber=dict(argstr='--inputFiber %s', ), numberOfPoints=dict(argstr='--numberOfPoints %d', @@ -21,12 +15,10 @@ def test_gtractCreateGuideFiber_inputs(): outputFiber=dict(argstr='--outputFiber %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), writeXMLPolyDataFile=dict(argstr='--writeXMLPolyDataFile ', ), ) - inputs = gtractCreateGuideFiber.input_spec() + inputs = gtractCreateGuideFiber._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_gtractCreateGuideFiber_inputs(): def test_gtractCreateGuideFiber_outputs(): output_map = dict(outputFiber=dict(), ) - outputs = gtractCreateGuideFiber.output_spec() + outputs = gtractCreateGuideFiber._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractFastMarchingTracking.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractFastMarchingTracking.py index 80b431b91d..52b23fa2c5 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractFastMarchingTracking.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractFastMarchingTracking.py @@ -8,12 +8,6 @@ def test_gtractFastMarchingTracking_inputs(): ), costStepSize=dict(argstr='--costStepSize %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputAnisotropyVolume=dict(argstr='--inputAnisotropyVolume %s', ), inputCostVolume=dict(argstr='--inputCostVolume %s', @@ -37,14 +31,12 @@ def test_gtractFastMarchingTracking_inputs(): ), startingSeedsLabel=dict(argstr='--startingSeedsLabel %d', ), - terminal_output=dict(nohash=True, - ), trackingThreshold=dict(argstr='--trackingThreshold %f', ), writeXMLPolyDataFile=dict(argstr='--writeXMLPolyDataFile ', ), ) - inputs = gtractFastMarchingTracking.input_spec() + inputs = gtractFastMarchingTracking._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -54,7 +46,7 @@ def test_gtractFastMarchingTracking_inputs(): def test_gtractFastMarchingTracking_outputs(): output_map = dict(outputTract=dict(), ) - outputs = gtractFastMarchingTracking.output_spec() + outputs = gtractFastMarchingTracking._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractFiberTracking.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractFiberTracking.py index e9aa021e41..bbc122d710 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractFiberTracking.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractFiberTracking.py @@ -14,14 +14,8 @@ def test_gtractFiberTracking_inputs(): ), endingSeedsLabel=dict(argstr='--endingSeedsLabel %d', ), - environ=dict(nohash=True, - usedefault=True, - ), guidedCurvatureThreshold=dict(argstr='--guidedCurvatureThreshold %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputAnisotropyVolume=dict(argstr='--inputAnisotropyVolume %s', ), inputEndingSeedsLabelMapVolume=dict(argstr='--inputEndingSeedsLabelMapVolume %s', @@ -57,8 +51,6 @@ def test_gtractFiberTracking_inputs(): ), tendG=dict(argstr='--tendG %f', ), - terminal_output=dict(nohash=True, - ), trackingMethod=dict(argstr='--trackingMethod %s', ), trackingThreshold=dict(argstr='--trackingThreshold %f', @@ -72,7 +64,7 @@ def test_gtractFiberTracking_inputs(): writeXMLPolyDataFile=dict(argstr='--writeXMLPolyDataFile ', ), ) - inputs = gtractFiberTracking.input_spec() + inputs = gtractFiberTracking._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -82,7 +74,7 @@ def test_gtractFiberTracking_inputs(): def test_gtractFiberTracking_outputs(): output_map = dict(outputTract=dict(), ) - outputs = gtractFiberTracking.output_spec() + outputs = gtractFiberTracking._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractImageConformity.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractImageConformity.py index f14f17359a..895243866a 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractImageConformity.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractImageConformity.py @@ -6,12 +6,6 @@ def test_gtractImageConformity_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputReferenceVolume=dict(argstr='--inputReferenceVolume %s', ), inputVolume=dict(argstr='--inputVolume %s', @@ -21,10 +15,8 @@ def test_gtractImageConformity_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractImageConformity.input_spec() + inputs = gtractImageConformity._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_gtractImageConformity_inputs(): def test_gtractImageConformity_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractImageConformity.output_spec() + outputs = gtractImageConformity._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertBSplineTransform.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertBSplineTransform.py index 476a05e6ec..43e855a557 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertBSplineTransform.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertBSplineTransform.py @@ -6,12 +6,6 @@ def test_gtractInvertBSplineTransform_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputReferenceVolume=dict(argstr='--inputReferenceVolume %s', ), inputTransform=dict(argstr='--inputTransform %s', @@ -24,10 +18,8 @@ def test_gtractInvertBSplineTransform_inputs(): outputTransform=dict(argstr='--outputTransform %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractInvertBSplineTransform.input_spec() + inputs = gtractInvertBSplineTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +29,7 @@ def test_gtractInvertBSplineTransform_inputs(): def test_gtractInvertBSplineTransform_outputs(): output_map = dict(outputTransform=dict(), ) - outputs = gtractInvertBSplineTransform.output_spec() + outputs = gtractInvertBSplineTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertDisplacementField.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertDisplacementField.py index db5b1e8b7a..e2c4692b53 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertDisplacementField.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertDisplacementField.py @@ -10,12 +10,6 @@ def test_gtractInvertDisplacementField_inputs(): ), deformationImage=dict(argstr='--deformationImage %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), numberOfThreads=dict(argstr='--numberOfThreads %d', ), outputVolume=dict(argstr='--outputVolume %s', @@ -23,10 +17,8 @@ def test_gtractInvertDisplacementField_inputs(): ), subsamplingFactor=dict(argstr='--subsamplingFactor %d', ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractInvertDisplacementField.input_spec() + inputs = gtractInvertDisplacementField._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_gtractInvertDisplacementField_inputs(): def test_gtractInvertDisplacementField_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractInvertDisplacementField.output_spec() + outputs = gtractInvertDisplacementField._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertRigidTransform.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertRigidTransform.py index 4286c0769e..4766bc8cca 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertRigidTransform.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractInvertRigidTransform.py @@ -6,12 +6,6 @@ def test_gtractInvertRigidTransform_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputTransform=dict(argstr='--inputTransform %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -19,10 +13,8 @@ def test_gtractInvertRigidTransform_inputs(): outputTransform=dict(argstr='--outputTransform %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractInvertRigidTransform.input_spec() + inputs = gtractInvertRigidTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +24,7 @@ def test_gtractInvertRigidTransform_inputs(): def test_gtractInvertRigidTransform_outputs(): output_map = dict(outputTransform=dict(), ) - outputs = gtractInvertRigidTransform.output_spec() + outputs = gtractInvertRigidTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleAnisotropy.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleAnisotropy.py index 1887a216b9..8ae3e110ba 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleAnisotropy.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleAnisotropy.py @@ -6,12 +6,6 @@ def test_gtractResampleAnisotropy_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputAnatomicalVolume=dict(argstr='--inputAnatomicalVolume %s', ), inputAnisotropyVolume=dict(argstr='--inputAnisotropyVolume %s', @@ -23,12 +17,10 @@ def test_gtractResampleAnisotropy_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), transformType=dict(argstr='--transformType %s', ), ) - inputs = gtractResampleAnisotropy.input_spec() + inputs = gtractResampleAnisotropy._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_gtractResampleAnisotropy_inputs(): def test_gtractResampleAnisotropy_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractResampleAnisotropy.output_spec() + outputs = gtractResampleAnisotropy._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleB0.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleB0.py index 1623574a96..afbd61786a 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleB0.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleB0.py @@ -6,12 +6,6 @@ def test_gtractResampleB0_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputAnatomicalVolume=dict(argstr='--inputAnatomicalVolume %s', ), inputTransform=dict(argstr='--inputTransform %s', @@ -23,14 +17,12 @@ def test_gtractResampleB0_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), transformType=dict(argstr='--transformType %s', ), vectorIndex=dict(argstr='--vectorIndex %d', ), ) - inputs = gtractResampleB0.input_spec() + inputs = gtractResampleB0._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_gtractResampleB0_inputs(): def test_gtractResampleB0_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractResampleB0.output_spec() + outputs = gtractResampleB0._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleCodeImage.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleCodeImage.py index 78fc493bb0..283b803720 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleCodeImage.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleCodeImage.py @@ -6,12 +6,6 @@ def test_gtractResampleCodeImage_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputCodeVolume=dict(argstr='--inputCodeVolume %s', ), inputReferenceVolume=dict(argstr='--inputReferenceVolume %s', @@ -23,12 +17,10 @@ def test_gtractResampleCodeImage_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), transformType=dict(argstr='--transformType %s', ), ) - inputs = gtractResampleCodeImage.input_spec() + inputs = gtractResampleCodeImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_gtractResampleCodeImage_inputs(): def test_gtractResampleCodeImage_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractResampleCodeImage.output_spec() + outputs = gtractResampleCodeImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleDWIInPlace.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleDWIInPlace.py index da647cf1f0..1455ba872a 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleDWIInPlace.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleDWIInPlace.py @@ -8,12 +8,6 @@ def test_gtractResampleDWIInPlace_inputs(): ), debugLevel=dict(argstr='--debugLevel %d', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), imageOutputSize=dict(argstr='--imageOutputSize %s', sep=',', ), @@ -31,12 +25,10 @@ def test_gtractResampleDWIInPlace_inputs(): ), referenceVolume=dict(argstr='--referenceVolume %s', ), - terminal_output=dict(nohash=True, - ), warpDWITransform=dict(argstr='--warpDWITransform %s', ), ) - inputs = gtractResampleDWIInPlace.input_spec() + inputs = gtractResampleDWIInPlace._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_gtractResampleDWIInPlace_outputs(): output_map = dict(outputResampledB0=dict(), outputVolume=dict(), ) - outputs = gtractResampleDWIInPlace.output_spec() + outputs = gtractResampleDWIInPlace._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleFibers.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleFibers.py index f8954b20fb..c70b3f022b 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleFibers.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractResampleFibers.py @@ -6,12 +6,6 @@ def test_gtractResampleFibers_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputForwardDeformationFieldVolume=dict(argstr='--inputForwardDeformationFieldVolume %s', ), inputReverseDeformationFieldVolume=dict(argstr='--inputReverseDeformationFieldVolume %s', @@ -23,12 +17,10 @@ def test_gtractResampleFibers_inputs(): outputTract=dict(argstr='--outputTract %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), writeXMLPolyDataFile=dict(argstr='--writeXMLPolyDataFile ', ), ) - inputs = gtractResampleFibers.input_spec() + inputs = gtractResampleFibers._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_gtractResampleFibers_inputs(): def test_gtractResampleFibers_outputs(): output_map = dict(outputTract=dict(), ) - outputs = gtractResampleFibers.output_spec() + outputs = gtractResampleFibers._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractTensor.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractTensor.py index 9b35d8ffd5..c5e9405b45 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractTensor.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractTensor.py @@ -12,15 +12,9 @@ def test_gtractTensor_inputs(): ), backgroundSuppressingThreshold=dict(argstr='--backgroundSuppressingThreshold %d', ), - environ=dict(nohash=True, - usedefault=True, - ), ignoreIndex=dict(argstr='--ignoreIndex %s', sep=',', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), maskProcessingMode=dict(argstr='--maskProcessingMode %s', @@ -39,10 +33,8 @@ def test_gtractTensor_inputs(): ), size=dict(argstr='--size %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractTensor.input_spec() + inputs = gtractTensor._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_gtractTensor_inputs(): def test_gtractTensor_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = gtractTensor.output_spec() + outputs = gtractTensor._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractTransformToDisplacementField.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractTransformToDisplacementField.py index 1e74ff01ee..187f90a046 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractTransformToDisplacementField.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_gtractTransformToDisplacementField.py @@ -6,12 +6,6 @@ def test_gtractTransformToDisplacementField_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputReferenceVolume=dict(argstr='--inputReferenceVolume %s', ), inputTransform=dict(argstr='--inputTransform %s', @@ -21,10 +15,8 @@ def test_gtractTransformToDisplacementField_inputs(): outputDeformationFieldVolume=dict(argstr='--outputDeformationFieldVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = gtractTransformToDisplacementField.input_spec() + inputs = gtractTransformToDisplacementField._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_gtractTransformToDisplacementField_inputs(): def test_gtractTransformToDisplacementField_outputs(): output_map = dict(outputDeformationFieldVolume=dict(), ) - outputs = gtractTransformToDisplacementField.output_spec() + outputs = gtractTransformToDisplacementField._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tests/test_auto_maxcurvature.py b/nipype/interfaces/semtools/diffusion/tests/test_auto_maxcurvature.py index 12958f9a32..5d6605be36 100644 --- a/nipype/interfaces/semtools/diffusion/tests/test_auto_maxcurvature.py +++ b/nipype/interfaces/semtools/diffusion/tests/test_auto_maxcurvature.py @@ -6,12 +6,6 @@ def test_maxcurvature_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image=dict(argstr='--image %s', ), output=dict(argstr='--output %s', @@ -19,12 +13,10 @@ def test_maxcurvature_inputs(): ), sigma=dict(argstr='--sigma %f', ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose ', ), ) - inputs = maxcurvature.input_spec() + inputs = maxcurvature._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_maxcurvature_inputs(): def test_maxcurvature_outputs(): output_map = dict(output=dict(), ) - outputs = maxcurvature.output_spec() + outputs = maxcurvature._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tractography/commandlineonly.py b/nipype/interfaces/semtools/diffusion/tractography/commandlineonly.py index edf2f089a9..07ebe57c42 100644 --- a/nipype/interfaces/semtools/diffusion/tractography/commandlineonly.py +++ b/nipype/interfaces/semtools/diffusion/tractography/commandlineonly.py @@ -42,8 +42,8 @@ class fiberstats(SEMLikeCommandLine): """ - input_spec = fiberstatsInputSpec - output_spec = fiberstatsOutputSpec + _input_spec = fiberstatsInputSpec + _output_spec = fiberstatsOutputSpec _cmd = " fiberstats " _outputs_filenames = {} _redirect_x = False diff --git a/nipype/interfaces/semtools/diffusion/tractography/fiberprocess.py b/nipype/interfaces/semtools/diffusion/tractography/fiberprocess.py index 28fbac5b24..1ce24766ac 100644 --- a/nipype/interfaces/semtools/diffusion/tractography/fiberprocess.py +++ b/nipype/interfaces/semtools/diffusion/tractography/fiberprocess.py @@ -56,8 +56,8 @@ class fiberprocess(SEMLikeCommandLine): """ - input_spec = fiberprocessInputSpec - output_spec = fiberprocessOutputSpec + _input_spec = fiberprocessInputSpec + _output_spec = fiberprocessOutputSpec _cmd = " fiberprocess " _outputs_filenames = {'fiber_output': 'fiber_output.vtk', 'voxelize': 'voxelize.nii'} _redirect_x = False diff --git a/nipype/interfaces/semtools/diffusion/tractography/fibertrack.py b/nipype/interfaces/semtools/diffusion/tractography/fibertrack.py index 893f3a9b7b..bf6d60e00d 100644 --- a/nipype/interfaces/semtools/diffusion/tractography/fibertrack.py +++ b/nipype/interfaces/semtools/diffusion/tractography/fibertrack.py @@ -56,8 +56,8 @@ class fibertrack(SEMLikeCommandLine): """ - input_spec = fibertrackInputSpec - output_spec = fibertrackOutputSpec + _input_spec = fibertrackInputSpec + _output_spec = fibertrackOutputSpec _cmd = " fibertrack " _outputs_filenames = {'output_fiber_file': 'output_fiber_file.vtk'} _redirect_x = False diff --git a/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_UKFTractography.py b/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_UKFTractography.py index 5550a1e903..c3e0fb5098 100644 --- a/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_UKFTractography.py +++ b/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_UKFTractography.py @@ -16,16 +16,10 @@ def test_UKFTractography_inputs(): ), dwiFile=dict(argstr='--dwiFile %s', ), - environ=dict(nohash=True, - usedefault=True, - ), freeWater=dict(argstr='--freeWater ', ), fullTensorModel=dict(argstr='--fullTensorModel ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), labels=dict(argstr='--labels %s', sep=',', ), @@ -71,8 +65,6 @@ def test_UKFTractography_inputs(): ), storeGlyphs=dict(argstr='--storeGlyphs ', ), - terminal_output=dict(nohash=True, - ), tracts=dict(argstr='--tracts %s', hash_files=False, ), @@ -84,7 +76,7 @@ def test_UKFTractography_inputs(): writeUncompressedTracts=dict(argstr='--writeUncompressedTracts ', ), ) - inputs = UKFTractography.input_spec() + inputs = UKFTractography._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -95,7 +87,7 @@ def test_UKFTractography_outputs(): output_map = dict(tracts=dict(), tractsWithSecondTensor=dict(), ) - outputs = UKFTractography.output_spec() + outputs = UKFTractography._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fiberprocess.py b/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fiberprocess.py index b607a189d7..cf6a9bca14 100644 --- a/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fiberprocess.py +++ b/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fiberprocess.py @@ -8,9 +8,6 @@ def test_fiberprocess_inputs(): ), displacement_field=dict(argstr='--displacement_field %s', ), - environ=dict(nohash=True, - usedefault=True, - ), fiber_file=dict(argstr='--fiber_file %s', ), fiber_output=dict(argstr='--fiber_output %s', @@ -20,9 +17,6 @@ def test_fiberprocess_inputs(): ), h_field=dict(argstr='--h_field %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), index_space=dict(argstr='--index_space ', ), noDataChange=dict(argstr='--noDataChange ', @@ -33,8 +27,6 @@ def test_fiberprocess_inputs(): ), tensor_volume=dict(argstr='--tensor_volume %s', ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose ', ), voxel_label=dict(argstr='--voxel_label %d', @@ -45,7 +37,7 @@ def test_fiberprocess_inputs(): voxelize_count_fibers=dict(argstr='--voxelize_count_fibers ', ), ) - inputs = fiberprocess.input_spec() + inputs = fiberprocess._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -56,7 +48,7 @@ def test_fiberprocess_outputs(): output_map = dict(fiber_output=dict(), voxelize=dict(), ) - outputs = fiberprocess.output_spec() + outputs = fiberprocess._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fiberstats.py b/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fiberstats.py index 8521e59239..0ebc9de81a 100644 --- a/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fiberstats.py +++ b/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fiberstats.py @@ -6,20 +6,12 @@ def test_fiberstats_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fiber_file=dict(argstr='--fiber_file %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose ', ), ) - inputs = fiberstats.input_spec() + inputs = fiberstats._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +20,7 @@ def test_fiberstats_inputs(): def test_fiberstats_outputs(): output_map = dict() - outputs = fiberstats.output_spec() + outputs = fiberstats._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fibertrack.py b/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fibertrack.py index d12c437f1c..688b3cd3e1 100644 --- a/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fibertrack.py +++ b/nipype/interfaces/semtools/diffusion/tractography/tests/test_auto_fibertrack.py @@ -6,16 +6,10 @@ def test_fibertrack_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), forbidden_label=dict(argstr='--forbidden_label %d', ), force=dict(argstr='--force ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_roi_file=dict(argstr='--input_roi_file %s', ), input_tensor_file=dict(argstr='--input_tensor_file %s', @@ -35,14 +29,12 @@ def test_fibertrack_inputs(): ), target_label=dict(argstr='--target_label %d', ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose ', ), whole_brain=dict(argstr='--whole_brain ', ), ) - inputs = fibertrack.input_spec() + inputs = fibertrack._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_fibertrack_inputs(): def test_fibertrack_outputs(): output_map = dict(output_fiber_file=dict(), ) - outputs = fibertrack.output_spec() + outputs = fibertrack._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/diffusion/tractography/ukftractography.py b/nipype/interfaces/semtools/diffusion/tractography/ukftractography.py index 63b1ecb33c..bfec9f0c7f 100644 --- a/nipype/interfaces/semtools/diffusion/tractography/ukftractography.py +++ b/nipype/interfaces/semtools/diffusion/tractography/ukftractography.py @@ -69,8 +69,8 @@ class UKFTractography(SEMLikeCommandLine): """ - input_spec = UKFTractographyInputSpec - output_spec = UKFTractographyOutputSpec + _input_spec = UKFTractographyInputSpec + _output_spec = UKFTractographyOutputSpec _cmd = " UKFTractography " _outputs_filenames = {'tracts': 'tracts.vtp', 'tractsWithSecondTensor': 'tractsWithSecondTensor.vtp'} _redirect_x = False diff --git a/nipype/interfaces/semtools/featurecreator.py b/nipype/interfaces/semtools/featurecreator.py index 4147832b77..29cb6fc725 100644 --- a/nipype/interfaces/semtools/featurecreator.py +++ b/nipype/interfaces/semtools/featurecreator.py @@ -36,8 +36,8 @@ class GenerateCsfClippedFromClassifiedImage(SEMLikeCommandLine): """ - input_spec = GenerateCsfClippedFromClassifiedImageInputSpec - output_spec = GenerateCsfClippedFromClassifiedImageOutputSpec + _input_spec = GenerateCsfClippedFromClassifiedImageInputSpec + _output_spec = GenerateCsfClippedFromClassifiedImageOutputSpec _cmd = " GenerateCsfClippedFromClassifiedImage " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False diff --git a/nipype/interfaces/semtools/filtering/denoising.py b/nipype/interfaces/semtools/filtering/denoising.py index 03536fd643..16430b45f7 100644 --- a/nipype/interfaces/semtools/filtering/denoising.py +++ b/nipype/interfaces/semtools/filtering/denoising.py @@ -49,8 +49,8 @@ class UnbiasedNonLocalMeans(SEMLikeCommandLine): """ - input_spec = UnbiasedNonLocalMeansInputSpec - output_spec = UnbiasedNonLocalMeansOutputSpec + _input_spec = UnbiasedNonLocalMeansInputSpec + _output_spec = UnbiasedNonLocalMeansOutputSpec _cmd = " UnbiasedNonLocalMeans " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False diff --git a/nipype/interfaces/semtools/filtering/featuredetection.py b/nipype/interfaces/semtools/filtering/featuredetection.py index 6f66a39ae4..23e75245bd 100644 --- a/nipype/interfaces/semtools/filtering/featuredetection.py +++ b/nipype/interfaces/semtools/filtering/featuredetection.py @@ -37,8 +37,8 @@ class GenerateSummedGradientImage(SEMLikeCommandLine): """ - input_spec = GenerateSummedGradientImageInputSpec - output_spec = GenerateSummedGradientImageOutputSpec + _input_spec = GenerateSummedGradientImageInputSpec + _output_spec = GenerateSummedGradientImageOutputSpec _cmd = " GenerateSummedGradientImage " _outputs_filenames = {'outputFileName': 'outputFileName'} _redirect_x = False @@ -79,8 +79,8 @@ class CannySegmentationLevelSetImageFilter(SEMLikeCommandLine): """ - input_spec = CannySegmentationLevelSetImageFilterInputSpec - output_spec = CannySegmentationLevelSetImageFilterOutputSpec + _input_spec = CannySegmentationLevelSetImageFilterInputSpec + _output_spec = CannySegmentationLevelSetImageFilterOutputSpec _cmd = " CannySegmentationLevelSetImageFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'outputSpeedVolume': 'outputSpeedVolume.nii'} _redirect_x = False @@ -115,8 +115,8 @@ class DilateImage(SEMLikeCommandLine): """ - input_spec = DilateImageInputSpec - output_spec = DilateImageOutputSpec + _input_spec = DilateImageInputSpec + _output_spec = DilateImageOutputSpec _cmd = " DilateImage " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -150,8 +150,8 @@ class TextureFromNoiseImageFilter(SEMLikeCommandLine): """ - input_spec = TextureFromNoiseImageFilterInputSpec - output_spec = TextureFromNoiseImageFilterOutputSpec + _input_spec = TextureFromNoiseImageFilterInputSpec + _output_spec = TextureFromNoiseImageFilterOutputSpec _cmd = " TextureFromNoiseImageFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -185,8 +185,8 @@ class FlippedDifference(SEMLikeCommandLine): """ - input_spec = FlippedDifferenceInputSpec - output_spec = FlippedDifferenceOutputSpec + _input_spec = FlippedDifferenceInputSpec + _output_spec = FlippedDifferenceOutputSpec _cmd = " FlippedDifference " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -221,8 +221,8 @@ class ErodeImage(SEMLikeCommandLine): """ - input_spec = ErodeImageInputSpec - output_spec = ErodeImageOutputSpec + _input_spec = ErodeImageInputSpec + _output_spec = ErodeImageOutputSpec _cmd = " ErodeImage " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -255,8 +255,8 @@ class GenerateBrainClippedImage(SEMLikeCommandLine): """ - input_spec = GenerateBrainClippedImageInputSpec - output_spec = GenerateBrainClippedImageOutputSpec + _input_spec = GenerateBrainClippedImageInputSpec + _output_spec = GenerateBrainClippedImageOutputSpec _cmd = " GenerateBrainClippedImage " _outputs_filenames = {'outputFileName': 'outputFileName'} _redirect_x = False @@ -291,8 +291,8 @@ class NeighborhoodMedian(SEMLikeCommandLine): """ - input_spec = NeighborhoodMedianInputSpec - output_spec = NeighborhoodMedianOutputSpec + _input_spec = NeighborhoodMedianInputSpec + _output_spec = NeighborhoodMedianOutputSpec _cmd = " NeighborhoodMedian " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -326,8 +326,8 @@ class GenerateTestImage(SEMLikeCommandLine): """ - input_spec = GenerateTestImageInputSpec - output_spec = GenerateTestImageOutputSpec + _input_spec = GenerateTestImageInputSpec + _output_spec = GenerateTestImageOutputSpec _cmd = " GenerateTestImage " _outputs_filenames = {'outputVolume': 'outputVolume'} _redirect_x = False @@ -362,8 +362,8 @@ class NeighborhoodMean(SEMLikeCommandLine): """ - input_spec = NeighborhoodMeanInputSpec - output_spec = NeighborhoodMeanOutputSpec + _input_spec = NeighborhoodMeanInputSpec + _output_spec = NeighborhoodMeanOutputSpec _cmd = " NeighborhoodMean " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -400,8 +400,8 @@ class HammerAttributeCreator(SEMLikeCommandLine): """ - input_spec = HammerAttributeCreatorInputSpec - output_spec = HammerAttributeCreatorOutputSpec + _input_spec = HammerAttributeCreatorInputSpec + _output_spec = HammerAttributeCreatorOutputSpec _cmd = " HammerAttributeCreator " _outputs_filenames = {} _redirect_x = False @@ -437,8 +437,8 @@ class TextureMeasureFilter(SEMLikeCommandLine): """ - input_spec = TextureMeasureFilterInputSpec - output_spec = TextureMeasureFilterOutputSpec + _input_spec = TextureMeasureFilterInputSpec + _output_spec = TextureMeasureFilterOutputSpec _cmd = " TextureMeasureFilter " _outputs_filenames = {'outputFilename': 'outputFilename'} _redirect_x = False @@ -474,8 +474,8 @@ class DilateMask(SEMLikeCommandLine): """ - input_spec = DilateMaskInputSpec - output_spec = DilateMaskOutputSpec + _input_spec = DilateMaskInputSpec + _output_spec = DilateMaskOutputSpec _cmd = " DilateMask " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -508,8 +508,8 @@ class DumpBinaryTrainingVectors(SEMLikeCommandLine): """ - input_spec = DumpBinaryTrainingVectorsInputSpec - output_spec = DumpBinaryTrainingVectorsOutputSpec + _input_spec = DumpBinaryTrainingVectorsInputSpec + _output_spec = DumpBinaryTrainingVectorsOutputSpec _cmd = " DumpBinaryTrainingVectors " _outputs_filenames = {} _redirect_x = False @@ -544,8 +544,8 @@ class DistanceMaps(SEMLikeCommandLine): """ - input_spec = DistanceMapsInputSpec - output_spec = DistanceMapsOutputSpec + _input_spec = DistanceMapsInputSpec + _output_spec = DistanceMapsOutputSpec _cmd = " DistanceMaps " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -579,8 +579,8 @@ class STAPLEAnalysis(SEMLikeCommandLine): """ - input_spec = STAPLEAnalysisInputSpec - output_spec = STAPLEAnalysisOutputSpec + _input_spec = STAPLEAnalysisInputSpec + _output_spec = STAPLEAnalysisOutputSpec _cmd = " STAPLEAnalysis " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -610,8 +610,8 @@ class GradientAnisotropicDiffusionImageFilter(SEMLikeCommandLine): """ - input_spec = GradientAnisotropicDiffusionImageFilterInputSpec - output_spec = GradientAnisotropicDiffusionImageFilterOutputSpec + _input_spec = GradientAnisotropicDiffusionImageFilterInputSpec + _output_spec = GradientAnisotropicDiffusionImageFilterOutputSpec _cmd = " GradientAnisotropicDiffusionImageFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -649,8 +649,8 @@ class CannyEdge(SEMLikeCommandLine): """ - input_spec = CannyEdgeInputSpec - output_spec = CannyEdgeOutputSpec + _input_spec = CannyEdgeInputSpec + _output_spec = CannyEdgeOutputSpec _cmd = " CannyEdge " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_CannyEdge.py b/nipype/interfaces/semtools/filtering/tests/test_auto_CannyEdge.py index f09e7e139a..cb1cd2fa7f 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_CannyEdge.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_CannyEdge.py @@ -6,12 +6,6 @@ def test_CannyEdge_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), lowerThreshold=dict(argstr='--lowerThreshold %f', @@ -19,14 +13,12 @@ def test_CannyEdge_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), upperThreshold=dict(argstr='--upperThreshold %f', ), variance=dict(argstr='--variance %f', ), ) - inputs = CannyEdge.input_spec() + inputs = CannyEdge._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_CannyEdge_inputs(): def test_CannyEdge_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = CannyEdge.output_spec() + outputs = CannyEdge._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_CannySegmentationLevelSetImageFilter.py b/nipype/interfaces/semtools/filtering/tests/test_auto_CannySegmentationLevelSetImageFilter.py index 5dd69484aa..c7829d29c4 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_CannySegmentationLevelSetImageFilter.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_CannySegmentationLevelSetImageFilter.py @@ -12,12 +12,6 @@ def test_CannySegmentationLevelSetImageFilter_inputs(): ), cannyVariance=dict(argstr='--cannyVariance %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initialModel=dict(argstr='--initialModel %s', ), initialModelIsovalue=dict(argstr='--initialModelIsovalue %f', @@ -32,10 +26,8 @@ def test_CannySegmentationLevelSetImageFilter_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = CannySegmentationLevelSetImageFilter.input_spec() + inputs = CannySegmentationLevelSetImageFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +38,7 @@ def test_CannySegmentationLevelSetImageFilter_outputs(): output_map = dict(outputSpeedVolume=dict(), outputVolume=dict(), ) - outputs = CannySegmentationLevelSetImageFilter.output_spec() + outputs = CannySegmentationLevelSetImageFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_DilateImage.py b/nipype/interfaces/semtools/filtering/tests/test_auto_DilateImage.py index 353924d80f..87536804f8 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_DilateImage.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_DilateImage.py @@ -6,12 +6,6 @@ def test_DilateImage_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputMaskVolume=dict(argstr='--inputMaskVolume %s', ), inputRadius=dict(argstr='--inputRadius %d', @@ -21,10 +15,8 @@ def test_DilateImage_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DilateImage.input_spec() + inputs = DilateImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_DilateImage_inputs(): def test_DilateImage_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = DilateImage.output_spec() + outputs = DilateImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_DilateMask.py b/nipype/interfaces/semtools/filtering/tests/test_auto_DilateMask.py index 91fb032420..18feff3a8b 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_DilateMask.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_DilateMask.py @@ -6,12 +6,6 @@ def test_DilateMask_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputBinaryVolume=dict(argstr='--inputBinaryVolume %s', ), inputVolume=dict(argstr='--inputVolume %s', @@ -23,10 +17,8 @@ def test_DilateMask_inputs(): ), sizeStructuralElement=dict(argstr='--sizeStructuralElement %d', ), - terminal_output=dict(nohash=True, - ), ) - inputs = DilateMask.input_spec() + inputs = DilateMask._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_DilateMask_inputs(): def test_DilateMask_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = DilateMask.output_spec() + outputs = DilateMask._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_DistanceMaps.py b/nipype/interfaces/semtools/filtering/tests/test_auto_DistanceMaps.py index 6e43ad16ee..f21f208e90 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_DistanceMaps.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_DistanceMaps.py @@ -6,12 +6,6 @@ def test_DistanceMaps_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputLabelVolume=dict(argstr='--inputLabelVolume %s', ), inputMaskVolume=dict(argstr='--inputMaskVolume %s', @@ -21,10 +15,8 @@ def test_DistanceMaps_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DistanceMaps.input_spec() + inputs = DistanceMaps._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_DistanceMaps_inputs(): def test_DistanceMaps_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = DistanceMaps.output_spec() + outputs = DistanceMaps._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_DumpBinaryTrainingVectors.py b/nipype/interfaces/semtools/filtering/tests/test_auto_DumpBinaryTrainingVectors.py index b588e4bcf6..bef26f53e8 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_DumpBinaryTrainingVectors.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_DumpBinaryTrainingVectors.py @@ -6,20 +6,12 @@ def test_DumpBinaryTrainingVectors_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputHeaderFilename=dict(argstr='--inputHeaderFilename %s', ), inputVectorFilename=dict(argstr='--inputVectorFilename %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = DumpBinaryTrainingVectors.input_spec() + inputs = DumpBinaryTrainingVectors._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +20,7 @@ def test_DumpBinaryTrainingVectors_inputs(): def test_DumpBinaryTrainingVectors_outputs(): output_map = dict() - outputs = DumpBinaryTrainingVectors.output_spec() + outputs = DumpBinaryTrainingVectors._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_ErodeImage.py b/nipype/interfaces/semtools/filtering/tests/test_auto_ErodeImage.py index 81c8429e13..f0f57ed286 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_ErodeImage.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_ErodeImage.py @@ -6,12 +6,6 @@ def test_ErodeImage_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputMaskVolume=dict(argstr='--inputMaskVolume %s', ), inputRadius=dict(argstr='--inputRadius %d', @@ -21,10 +15,8 @@ def test_ErodeImage_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ErodeImage.input_spec() + inputs = ErodeImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_ErodeImage_inputs(): def test_ErodeImage_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = ErodeImage.output_spec() + outputs = ErodeImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_FlippedDifference.py b/nipype/interfaces/semtools/filtering/tests/test_auto_FlippedDifference.py index 3c86f288fa..46b4ed8781 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_FlippedDifference.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_FlippedDifference.py @@ -6,12 +6,6 @@ def test_FlippedDifference_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputMaskVolume=dict(argstr='--inputMaskVolume %s', ), inputVolume=dict(argstr='--inputVolume %s', @@ -19,10 +13,8 @@ def test_FlippedDifference_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = FlippedDifference.input_spec() + inputs = FlippedDifference._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +24,7 @@ def test_FlippedDifference_inputs(): def test_FlippedDifference_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = FlippedDifference.output_spec() + outputs = FlippedDifference._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateBrainClippedImage.py b/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateBrainClippedImage.py index c605f8deea..c84b0bc1bb 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateBrainClippedImage.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateBrainClippedImage.py @@ -6,12 +6,6 @@ def test_GenerateBrainClippedImage_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputImg=dict(argstr='--inputImg %s', ), inputMsk=dict(argstr='--inputMsk %s', @@ -21,10 +15,8 @@ def test_GenerateBrainClippedImage_inputs(): outputFileName=dict(argstr='--outputFileName %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = GenerateBrainClippedImage.input_spec() + inputs = GenerateBrainClippedImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_GenerateBrainClippedImage_inputs(): def test_GenerateBrainClippedImage_outputs(): output_map = dict(outputFileName=dict(), ) - outputs = GenerateBrainClippedImage.output_spec() + outputs = GenerateBrainClippedImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateSummedGradientImage.py b/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateSummedGradientImage.py index fe720a4850..ce76a48e05 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateSummedGradientImage.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateSummedGradientImage.py @@ -8,12 +8,6 @@ def test_GenerateSummedGradientImage_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume1=dict(argstr='--inputVolume1 %s', ), inputVolume2=dict(argstr='--inputVolume2 %s', @@ -23,10 +17,8 @@ def test_GenerateSummedGradientImage_inputs(): outputFileName=dict(argstr='--outputFileName %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = GenerateSummedGradientImage.input_spec() + inputs = GenerateSummedGradientImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_GenerateSummedGradientImage_inputs(): def test_GenerateSummedGradientImage_outputs(): output_map = dict(outputFileName=dict(), ) - outputs = GenerateSummedGradientImage.output_spec() + outputs = GenerateSummedGradientImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateTestImage.py b/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateTestImage.py index 869788f527..de818fcc49 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateTestImage.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_GenerateTestImage.py @@ -6,12 +6,6 @@ def test_GenerateTestImage_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), lowerBoundOfOutputVolume=dict(argstr='--lowerBoundOfOutputVolume %f', @@ -21,12 +15,10 @@ def test_GenerateTestImage_inputs(): ), outputVolumeSize=dict(argstr='--outputVolumeSize %f', ), - terminal_output=dict(nohash=True, - ), upperBoundOfOutputVolume=dict(argstr='--upperBoundOfOutputVolume %f', ), ) - inputs = GenerateTestImage.input_spec() + inputs = GenerateTestImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_GenerateTestImage_inputs(): def test_GenerateTestImage_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = GenerateTestImage.output_spec() + outputs = GenerateTestImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_GradientAnisotropicDiffusionImageFilter.py b/nipype/interfaces/semtools/filtering/tests/test_auto_GradientAnisotropicDiffusionImageFilter.py index d31e178ccb..20fd6cebf7 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_GradientAnisotropicDiffusionImageFilter.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_GradientAnisotropicDiffusionImageFilter.py @@ -8,12 +8,6 @@ def test_GradientAnisotropicDiffusionImageFilter_inputs(): ), conductance=dict(argstr='--conductance %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), numberOfIterations=dict(argstr='--numberOfIterations %d', @@ -21,12 +15,10 @@ def test_GradientAnisotropicDiffusionImageFilter_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), timeStep=dict(argstr='--timeStep %f', ), ) - inputs = GradientAnisotropicDiffusionImageFilter.input_spec() + inputs = GradientAnisotropicDiffusionImageFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_GradientAnisotropicDiffusionImageFilter_inputs(): def test_GradientAnisotropicDiffusionImageFilter_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = GradientAnisotropicDiffusionImageFilter.output_spec() + outputs = GradientAnisotropicDiffusionImageFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_HammerAttributeCreator.py b/nipype/interfaces/semtools/filtering/tests/test_auto_HammerAttributeCreator.py index 2d7cfa38a8..1f8ea07a9b 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_HammerAttributeCreator.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_HammerAttributeCreator.py @@ -10,12 +10,6 @@ def test_HammerAttributeCreator_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputCSFVolume=dict(argstr='--inputCSFVolume %s', ), inputGMVolume=dict(argstr='--inputGMVolume %s', @@ -24,10 +18,8 @@ def test_HammerAttributeCreator_inputs(): ), outputVolumeBase=dict(argstr='--outputVolumeBase %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = HammerAttributeCreator.input_spec() + inputs = HammerAttributeCreator._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_HammerAttributeCreator_inputs(): def test_HammerAttributeCreator_outputs(): output_map = dict() - outputs = HammerAttributeCreator.output_spec() + outputs = HammerAttributeCreator._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_NeighborhoodMean.py b/nipype/interfaces/semtools/filtering/tests/test_auto_NeighborhoodMean.py index 82b34513f5..714a2acbeb 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_NeighborhoodMean.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_NeighborhoodMean.py @@ -6,12 +6,6 @@ def test_NeighborhoodMean_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputMaskVolume=dict(argstr='--inputMaskVolume %s', ), inputRadius=dict(argstr='--inputRadius %d', @@ -21,10 +15,8 @@ def test_NeighborhoodMean_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = NeighborhoodMean.input_spec() + inputs = NeighborhoodMean._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_NeighborhoodMean_inputs(): def test_NeighborhoodMean_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = NeighborhoodMean.output_spec() + outputs = NeighborhoodMean._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_NeighborhoodMedian.py b/nipype/interfaces/semtools/filtering/tests/test_auto_NeighborhoodMedian.py index 3c22450067..a68aabcd8f 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_NeighborhoodMedian.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_NeighborhoodMedian.py @@ -6,12 +6,6 @@ def test_NeighborhoodMedian_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputMaskVolume=dict(argstr='--inputMaskVolume %s', ), inputRadius=dict(argstr='--inputRadius %d', @@ -21,10 +15,8 @@ def test_NeighborhoodMedian_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = NeighborhoodMedian.input_spec() + inputs = NeighborhoodMedian._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_NeighborhoodMedian_inputs(): def test_NeighborhoodMedian_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = NeighborhoodMedian.output_spec() + outputs = NeighborhoodMedian._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_STAPLEAnalysis.py b/nipype/interfaces/semtools/filtering/tests/test_auto_STAPLEAnalysis.py index 410cfc40b7..157b78ca0d 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_STAPLEAnalysis.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_STAPLEAnalysis.py @@ -6,12 +6,6 @@ def test_STAPLEAnalysis_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputDimension=dict(argstr='--inputDimension %d', ), inputLabelVolume=dict(argstr='--inputLabelVolume %s...', @@ -19,10 +13,8 @@ def test_STAPLEAnalysis_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = STAPLEAnalysis.input_spec() + inputs = STAPLEAnalysis._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +24,7 @@ def test_STAPLEAnalysis_inputs(): def test_STAPLEAnalysis_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = STAPLEAnalysis.output_spec() + outputs = STAPLEAnalysis._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_TextureFromNoiseImageFilter.py b/nipype/interfaces/semtools/filtering/tests/test_auto_TextureFromNoiseImageFilter.py index 2b20435355..28c38daf2f 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_TextureFromNoiseImageFilter.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_TextureFromNoiseImageFilter.py @@ -6,12 +6,6 @@ def test_TextureFromNoiseImageFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputRadius=dict(argstr='--inputRadius %d', ), inputVolume=dict(argstr='--inputVolume %s', @@ -19,10 +13,8 @@ def test_TextureFromNoiseImageFilter_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = TextureFromNoiseImageFilter.input_spec() + inputs = TextureFromNoiseImageFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +24,7 @@ def test_TextureFromNoiseImageFilter_inputs(): def test_TextureFromNoiseImageFilter_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = TextureFromNoiseImageFilter.output_spec() + outputs = TextureFromNoiseImageFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_TextureMeasureFilter.py b/nipype/interfaces/semtools/filtering/tests/test_auto_TextureMeasureFilter.py index 77c1f8220d..d2d5a871ef 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_TextureMeasureFilter.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_TextureMeasureFilter.py @@ -8,12 +8,6 @@ def test_TextureMeasureFilter_inputs(): ), distance=dict(argstr='--distance %d', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputMaskVolume=dict(argstr='--inputMaskVolume %s', ), inputVolume=dict(argstr='--inputVolume %s', @@ -23,10 +17,8 @@ def test_TextureMeasureFilter_inputs(): outputFilename=dict(argstr='--outputFilename %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = TextureMeasureFilter.input_spec() + inputs = TextureMeasureFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_TextureMeasureFilter_inputs(): def test_TextureMeasureFilter_outputs(): output_map = dict(outputFilename=dict(), ) - outputs = TextureMeasureFilter.output_spec() + outputs = TextureMeasureFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/filtering/tests/test_auto_UnbiasedNonLocalMeans.py b/nipype/interfaces/semtools/filtering/tests/test_auto_UnbiasedNonLocalMeans.py index 9d4de6b37b..e0179ce311 100644 --- a/nipype/interfaces/semtools/filtering/tests/test_auto_UnbiasedNonLocalMeans.py +++ b/nipype/interfaces/semtools/filtering/tests/test_auto_UnbiasedNonLocalMeans.py @@ -6,14 +6,8 @@ def test_UnbiasedNonLocalMeans_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), hp=dict(argstr='--hp %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -31,10 +25,8 @@ def test_UnbiasedNonLocalMeans_inputs(): ), sigma=dict(argstr='--sigma %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = UnbiasedNonLocalMeans.input_spec() + inputs = UnbiasedNonLocalMeans._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_UnbiasedNonLocalMeans_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = UnbiasedNonLocalMeans.output_spec() + outputs = UnbiasedNonLocalMeans._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/legacy/registration.py b/nipype/interfaces/semtools/legacy/registration.py index 8af1e20bfd..a75bfb63a0 100644 --- a/nipype/interfaces/semtools/legacy/registration.py +++ b/nipype/interfaces/semtools/legacy/registration.py @@ -44,8 +44,8 @@ class scalartransform(SEMLikeCommandLine): """ - input_spec = scalartransformInputSpec - output_spec = scalartransformOutputSpec + _input_spec = scalartransformInputSpec + _output_spec = scalartransformOutputSpec _cmd = " scalartransform " _outputs_filenames = {'output_image': 'output_image.nii', 'transformation': 'transformation'} _redirect_x = False diff --git a/nipype/interfaces/semtools/legacy/tests/test_auto_scalartransform.py b/nipype/interfaces/semtools/legacy/tests/test_auto_scalartransform.py index 5885b351e0..de2b88de44 100644 --- a/nipype/interfaces/semtools/legacy/tests/test_auto_scalartransform.py +++ b/nipype/interfaces/semtools/legacy/tests/test_auto_scalartransform.py @@ -8,14 +8,8 @@ def test_scalartransform_inputs(): ), deformation=dict(argstr='--deformation %s', ), - environ=dict(nohash=True, - usedefault=True, - ), h_field=dict(argstr='--h_field ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), input_image=dict(argstr='--input_image %s', ), interpolation=dict(argstr='--interpolation %s', @@ -25,13 +19,11 @@ def test_scalartransform_inputs(): output_image=dict(argstr='--output_image %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), transformation=dict(argstr='--transformation %s', hash_files=False, ), ) - inputs = scalartransform.input_spec() + inputs = scalartransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_scalartransform_outputs(): output_map = dict(output_image=dict(), transformation=dict(), ) - outputs = scalartransform.output_spec() + outputs = scalartransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/registration/brainsfit.py b/nipype/interfaces/semtools/registration/brainsfit.py index f80750d09a..10751db96e 100644 --- a/nipype/interfaces/semtools/registration/brainsfit.py +++ b/nipype/interfaces/semtools/registration/brainsfit.py @@ -129,8 +129,8 @@ class BRAINSFit(SEMLikeCommandLine): """ - input_spec = BRAINSFitInputSpec - output_spec = BRAINSFitOutputSpec + _input_spec = BRAINSFitInputSpec + _output_spec = BRAINSFitOutputSpec _cmd = " BRAINSFit " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'bsplineTransform': 'bsplineTransform.h5', 'outputTransform': 'outputTransform.h5', 'outputFixedVolumeROI': 'outputFixedVolumeROI.nii', 'strippedOutputTransform': 'strippedOutputTransform.h5', 'outputMovingVolumeROI': 'outputMovingVolumeROI.nii', 'linearTransform': 'linearTransform.h5', 'logFileReport': 'logFileReport'} diff --git a/nipype/interfaces/semtools/registration/brainsresample.py b/nipype/interfaces/semtools/registration/brainsresample.py index 9a14b48589..5bf0f7c42d 100644 --- a/nipype/interfaces/semtools/registration/brainsresample.py +++ b/nipype/interfaces/semtools/registration/brainsresample.py @@ -50,8 +50,8 @@ class BRAINSResample(SEMLikeCommandLine): """ - input_spec = BRAINSResampleInputSpec - output_spec = BRAINSResampleOutputSpec + _input_spec = BRAINSResampleInputSpec + _output_spec = BRAINSResampleOutputSpec _cmd = " BRAINSResample " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False diff --git a/nipype/interfaces/semtools/registration/brainsresize.py b/nipype/interfaces/semtools/registration/brainsresize.py index dac094b6e4..ff46b643cc 100644 --- a/nipype/interfaces/semtools/registration/brainsresize.py +++ b/nipype/interfaces/semtools/registration/brainsresize.py @@ -39,8 +39,8 @@ class BRAINSResize(SEMLikeCommandLine): """ - input_spec = BRAINSResizeInputSpec - output_spec = BRAINSResizeOutputSpec + _input_spec = BRAINSResizeInputSpec + _output_spec = BRAINSResizeOutputSpec _cmd = " BRAINSResize " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False diff --git a/nipype/interfaces/semtools/registration/specialized.py b/nipype/interfaces/semtools/registration/specialized.py index ed6e6c76d7..2dbe3c9e9a 100644 --- a/nipype/interfaces/semtools/registration/specialized.py +++ b/nipype/interfaces/semtools/registration/specialized.py @@ -80,8 +80,8 @@ class VBRAINSDemonWarp(SEMLikeCommandLine): """ - input_spec = VBRAINSDemonWarpInputSpec - output_spec = VBRAINSDemonWarpOutputSpec + _input_spec = VBRAINSDemonWarpInputSpec + _output_spec = VBRAINSDemonWarpOutputSpec _cmd = " VBRAINSDemonWarp " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'outputCheckerboardVolume': 'outputCheckerboardVolume.nii', 'outputDisplacementFieldVolume': 'outputDisplacementFieldVolume.nrrd'} _redirect_x = False @@ -158,8 +158,8 @@ class BRAINSDemonWarp(SEMLikeCommandLine): """ - input_spec = BRAINSDemonWarpInputSpec - output_spec = BRAINSDemonWarpOutputSpec + _input_spec = BRAINSDemonWarpInputSpec + _output_spec = BRAINSDemonWarpOutputSpec _cmd = " BRAINSDemonWarp " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'outputCheckerboardVolume': 'outputCheckerboardVolume.nii', 'outputDisplacementFieldVolume': 'outputDisplacementFieldVolume.nrrd'} _redirect_x = False @@ -197,8 +197,8 @@ class BRAINSTransformFromFiducials(SEMLikeCommandLine): """ - input_spec = BRAINSTransformFromFiducialsInputSpec - output_spec = BRAINSTransformFromFiducialsOutputSpec + _input_spec = BRAINSTransformFromFiducialsInputSpec + _output_spec = BRAINSTransformFromFiducialsOutputSpec _cmd = " BRAINSTransformFromFiducials " _outputs_filenames = {'saveTransform': 'saveTransform.h5'} _redirect_x = False diff --git a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSDemonWarp.py b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSDemonWarp.py index fa3caa8d79..4c61038378 100644 --- a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSDemonWarp.py +++ b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSDemonWarp.py @@ -14,9 +14,6 @@ def test_BRAINSDemonWarp_inputs(): checkerboardPatternSubdivisions=dict(argstr='--checkerboardPatternSubdivisions %s', sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedBinaryVolume=dict(argstr='--fixedBinaryVolume %s', ), fixedVolume=dict(argstr='--fixedVolume %s', @@ -27,9 +24,6 @@ def test_BRAINSDemonWarp_inputs(): ), histogramMatch=dict(argstr='--histogramMatch ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initializeWithDisplacementField=dict(argstr='--initializeWithDisplacementField %s', ), initializeWithTransform=dict(argstr='--initializeWithTransform %s', @@ -96,8 +90,6 @@ def test_BRAINSDemonWarp_inputs(): ), smoothDisplacementFieldSigma=dict(argstr='--smoothDisplacementFieldSigma %f', ), - terminal_output=dict(nohash=True, - ), upFieldSmoothing=dict(argstr='--upFieldSmoothing %f', ), upperThresholdForBOBF=dict(argstr='--upperThresholdForBOBF %d', @@ -105,7 +97,7 @@ def test_BRAINSDemonWarp_inputs(): use_vanilla_dem=dict(argstr='--use_vanilla_dem ', ), ) - inputs = BRAINSDemonWarp.input_spec() + inputs = BRAINSDemonWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -117,7 +109,7 @@ def test_BRAINSDemonWarp_outputs(): outputDisplacementFieldVolume=dict(), outputVolume=dict(), ) - outputs = BRAINSDemonWarp.output_spec() + outputs = BRAINSDemonWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSFit.py b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSFit.py index feb165f1e2..86f84a062d 100644 --- a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSFit.py +++ b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSFit.py @@ -21,9 +21,6 @@ def test_BRAINSFit_inputs(): ), debugLevel=dict(argstr='--debugLevel %d', ), - environ=dict(nohash=True, - usedefault=True, - ), failureExitCode=dict(argstr='--failureExitCode %d', ), fixedBinaryVolume=dict(argstr='--fixedBinaryVolume %s', @@ -38,9 +35,6 @@ def test_BRAINSFit_inputs(): ), histogramMatch=dict(argstr='--histogramMatch ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initialTransform=dict(argstr='--initialTransform %s', ), initializeRegistrationByCurrentGenericTransform=dict(argstr='--initializeRegistrationByCurrentGenericTransform ', @@ -130,8 +124,6 @@ def test_BRAINSFit_inputs(): strippedOutputTransform=dict(argstr='--strippedOutputTransform %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), transformType=dict(argstr='--transformType %s', sep=',', ), @@ -158,7 +150,7 @@ def test_BRAINSFit_inputs(): writeTransformOnFailure=dict(argstr='--writeTransformOnFailure ', ), ) - inputs = BRAINSFit.input_spec() + inputs = BRAINSFit._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -175,7 +167,7 @@ def test_BRAINSFit_outputs(): outputVolume=dict(), strippedOutputTransform=dict(), ) - outputs = BRAINSFit.output_spec() + outputs = BRAINSFit._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSResample.py b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSResample.py index e6d8c39ae8..470e7d3cee 100644 --- a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSResample.py +++ b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSResample.py @@ -10,15 +10,9 @@ def test_BRAINSResample_inputs(): ), deformationVolume=dict(argstr='--deformationVolume %s', ), - environ=dict(nohash=True, - usedefault=True, - ), gridSpacing=dict(argstr='--gridSpacing %s', sep=',', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), interpolationMode=dict(argstr='--interpolationMode %s', @@ -34,12 +28,10 @@ def test_BRAINSResample_inputs(): ), referenceVolume=dict(argstr='--referenceVolume %s', ), - terminal_output=dict(nohash=True, - ), warpTransform=dict(argstr='--warpTransform %s', ), ) - inputs = BRAINSResample.input_spec() + inputs = BRAINSResample._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -49,7 +41,7 @@ def test_BRAINSResample_inputs(): def test_BRAINSResample_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = BRAINSResample.output_spec() + outputs = BRAINSResample._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSResize.py b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSResize.py index 8ea205c2c6..d1fc5c116e 100644 --- a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSResize.py +++ b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSResize.py @@ -6,12 +6,6 @@ def test_BRAINSResize_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), outputVolume=dict(argstr='--outputVolume %s', @@ -21,10 +15,8 @@ def test_BRAINSResize_inputs(): ), scaleFactor=dict(argstr='--scaleFactor %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSResize.input_spec() + inputs = BRAINSResize._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_BRAINSResize_inputs(): def test_BRAINSResize_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = BRAINSResize.output_spec() + outputs = BRAINSResize._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSTransformFromFiducials.py b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSTransformFromFiducials.py index f7e228e28d..07f887b96e 100644 --- a/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSTransformFromFiducials.py +++ b/nipype/interfaces/semtools/registration/tests/test_auto_BRAINSTransformFromFiducials.py @@ -6,16 +6,10 @@ def test_BRAINSTransformFromFiducials_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedLandmarks=dict(argstr='--fixedLandmarks %s...', ), fixedLandmarksFile=dict(argstr='--fixedLandmarksFile %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), movingLandmarks=dict(argstr='--movingLandmarks %s...', ), movingLandmarksFile=dict(argstr='--movingLandmarksFile %s', @@ -25,12 +19,10 @@ def test_BRAINSTransformFromFiducials_inputs(): saveTransform=dict(argstr='--saveTransform %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), transformType=dict(argstr='--transformType %s', ), ) - inputs = BRAINSTransformFromFiducials.input_spec() + inputs = BRAINSTransformFromFiducials._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_BRAINSTransformFromFiducials_inputs(): def test_BRAINSTransformFromFiducials_outputs(): output_map = dict(saveTransform=dict(), ) - outputs = BRAINSTransformFromFiducials.output_spec() + outputs = BRAINSTransformFromFiducials._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/registration/tests/test_auto_VBRAINSDemonWarp.py b/nipype/interfaces/semtools/registration/tests/test_auto_VBRAINSDemonWarp.py index 50df05872a..a29428faaf 100644 --- a/nipype/interfaces/semtools/registration/tests/test_auto_VBRAINSDemonWarp.py +++ b/nipype/interfaces/semtools/registration/tests/test_auto_VBRAINSDemonWarp.py @@ -14,9 +14,6 @@ def test_VBRAINSDemonWarp_inputs(): checkerboardPatternSubdivisions=dict(argstr='--checkerboardPatternSubdivisions %s', sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedBinaryVolume=dict(argstr='--fixedBinaryVolume %s', ), fixedVolume=dict(argstr='--fixedVolume %s...', @@ -27,9 +24,6 @@ def test_VBRAINSDemonWarp_inputs(): ), histogramMatch=dict(argstr='--histogramMatch ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initializeWithDisplacementField=dict(argstr='--initializeWithDisplacementField %s', ), initializeWithTransform=dict(argstr='--initializeWithTransform %s', @@ -96,8 +90,6 @@ def test_VBRAINSDemonWarp_inputs(): ), smoothDisplacementFieldSigma=dict(argstr='--smoothDisplacementFieldSigma %f', ), - terminal_output=dict(nohash=True, - ), upFieldSmoothing=dict(argstr='--upFieldSmoothing %f', ), upperThresholdForBOBF=dict(argstr='--upperThresholdForBOBF %d', @@ -108,7 +100,7 @@ def test_VBRAINSDemonWarp_inputs(): sep=',', ), ) - inputs = VBRAINSDemonWarp.input_spec() + inputs = VBRAINSDemonWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -120,7 +112,7 @@ def test_VBRAINSDemonWarp_outputs(): outputDisplacementFieldVolume=dict(), outputVolume=dict(), ) - outputs = VBRAINSDemonWarp.output_spec() + outputs = VBRAINSDemonWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/segmentation/specialized.py b/nipype/interfaces/semtools/segmentation/specialized.py index ec2395a200..087077416b 100644 --- a/nipype/interfaces/semtools/segmentation/specialized.py +++ b/nipype/interfaces/semtools/segmentation/specialized.py @@ -49,8 +49,8 @@ class BRAINSCut(SEMLikeCommandLine): """ - input_spec = BRAINSCutInputSpec - output_spec = BRAINSCutOutputSpec + _input_spec = BRAINSCutInputSpec + _output_spec = BRAINSCutOutputSpec _cmd = " BRAINSCut " _outputs_filenames = {} _redirect_x = False @@ -94,8 +94,8 @@ class BRAINSROIAuto(SEMLikeCommandLine): """ - input_spec = BRAINSROIAutoInputSpec - output_spec = BRAINSROIAutoOutputSpec + _input_spec = BRAINSROIAutoInputSpec + _output_spec = BRAINSROIAutoOutputSpec _cmd = " BRAINSROIAuto " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'outputROIMaskVolume': 'outputROIMaskVolume.nii'} _redirect_x = False @@ -185,8 +185,8 @@ class BRAINSConstellationDetector(SEMLikeCommandLine): """ - input_spec = BRAINSConstellationDetectorInputSpec - output_spec = BRAINSConstellationDetectorOutputSpec + _input_spec = BRAINSConstellationDetectorInputSpec + _output_spec = BRAINSConstellationDetectorOutputSpec _cmd = " BRAINSConstellationDetector " _outputs_filenames = {'outputVolume': 'outputVolume.nii.gz', 'outputMRML': 'outputMRML.mrml', 'resultsDir': 'resultsDir', 'outputResampledVolume': 'outputResampledVolume.nii.gz', 'outputTransform': 'outputTransform.h5', 'writeBranded2DImage': 'writeBranded2DImage.png', 'outputLandmarksInACPCAlignedSpace': 'outputLandmarksInACPCAlignedSpace.fcsv', 'outputLandmarksInInputSpace': 'outputLandmarksInInputSpace.fcsv', 'outputUntransformedClippedVolume': 'outputUntransformedClippedVolume.nii.gz', 'outputVerificationScript': 'outputVerificationScript.sh'} @@ -218,8 +218,8 @@ class BRAINSCreateLabelMapFromProbabilityMaps(SEMLikeCommandLine): """ - input_spec = BRAINSCreateLabelMapFromProbabilityMapsInputSpec - output_spec = BRAINSCreateLabelMapFromProbabilityMapsOutputSpec + _input_spec = BRAINSCreateLabelMapFromProbabilityMapsInputSpec + _output_spec = BRAINSCreateLabelMapFromProbabilityMapsOutputSpec _cmd = " BRAINSCreateLabelMapFromProbabilityMaps " _outputs_filenames = {'dirtyLabelVolume': 'dirtyLabelVolume.nii', 'cleanLabelVolume': 'cleanLabelVolume.nii'} _redirect_x = False @@ -253,8 +253,8 @@ class BinaryMaskEditorBasedOnLandmarks(SEMLikeCommandLine): """ - input_spec = BinaryMaskEditorBasedOnLandmarksInputSpec - output_spec = BinaryMaskEditorBasedOnLandmarksOutputSpec + _input_spec = BinaryMaskEditorBasedOnLandmarksInputSpec + _output_spec = BinaryMaskEditorBasedOnLandmarksOutputSpec _cmd = " BinaryMaskEditorBasedOnLandmarks " _outputs_filenames = {'outputBinaryVolume': 'outputBinaryVolume.nii'} _redirect_x = False @@ -286,8 +286,8 @@ class BRAINSMultiSTAPLE(SEMLikeCommandLine): """ - input_spec = BRAINSMultiSTAPLEInputSpec - output_spec = BRAINSMultiSTAPLEOutputSpec + _input_spec = BRAINSMultiSTAPLEInputSpec + _output_spec = BRAINSMultiSTAPLEOutputSpec _cmd = " BRAINSMultiSTAPLE " _outputs_filenames = {'outputMultiSTAPLE': 'outputMultiSTAPLE.nii', 'outputConfusionMatrix': 'outputConfusionMatrixh5|mat|txt'} _redirect_x = False @@ -352,8 +352,8 @@ class BRAINSABC(SEMLikeCommandLine): """ - input_spec = BRAINSABCInputSpec - output_spec = BRAINSABCOutputSpec + _input_spec = BRAINSABCInputSpec + _output_spec = BRAINSABCOutputSpec _cmd = " BRAINSABC " _outputs_filenames = {'saveState': 'saveState.h5', 'outputLabels': 'outputLabels.nii.gz', 'atlasToSubjectTransform': 'atlasToSubjectTransform.h5', 'atlasToSubjectInitialTransform': 'atlasToSubjectInitialTransform.h5', 'outputDirtyLabels': 'outputDirtyLabels.nii.gz', 'outputVolumes': 'outputVolumes.nii.gz', 'outputDir': 'outputDir', 'implicitOutputs': 'implicitOutputs.nii.gz'} @@ -386,8 +386,8 @@ class ESLR(SEMLikeCommandLine): """ - input_spec = ESLRInputSpec - output_spec = ESLROutputSpec + _input_spec = ESLRInputSpec + _output_spec = ESLROutputSpec _cmd = " ESLR " _outputs_filenames = {'outputVolume': 'outputVolume.nii.gz'} _redirect_x = False diff --git a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSABC.py b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSABC.py index 871e5df311..ae37dbbc42 100644 --- a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSABC.py +++ b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSABC.py @@ -22,9 +22,6 @@ def test_BRAINSABC_inputs(): ), defaultSuffix=dict(argstr='--defaultSuffix %s', ), - environ=dict(nohash=True, - usedefault=True, - ), filterIteration=dict(argstr='--filterIteration %d', ), filterMethod=dict(argstr='--filterMethod %s', @@ -34,9 +31,6 @@ def test_BRAINSABC_inputs(): gridSize=dict(argstr='--gridSize %s', sep=',', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), implicitOutputs=dict(argstr='--implicitOutputs %s...', hash_files=False, ), @@ -84,14 +78,12 @@ def test_BRAINSABC_inputs(): ), subjectIntermodeTransformType=dict(argstr='--subjectIntermodeTransformType %s', ), - terminal_output=dict(nohash=True, - ), useKNN=dict(argstr='--useKNN ', ), writeLess=dict(argstr='--writeLess ', ), ) - inputs = BRAINSABC.input_spec() + inputs = BRAINSABC._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -108,7 +100,7 @@ def test_BRAINSABC_outputs(): outputVolumes=dict(), saveState=dict(), ) - outputs = BRAINSABC.output_spec() + outputs = BRAINSABC._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSConstellationDetector.py b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSConstellationDetector.py index 39556f42d0..9b86feccf9 100644 --- a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSConstellationDetector.py +++ b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSConstellationDetector.py @@ -22,9 +22,6 @@ def test_BRAINSConstellationDetector_inputs(): ), debug=dict(argstr='--debug ', ), - environ=dict(nohash=True, - usedefault=True, - ), forceACPoint=dict(argstr='--forceACPoint %s', sep=',', ), @@ -41,9 +38,6 @@ def test_BRAINSConstellationDetector_inputs(): ), houghEyeDetectorMode=dict(argstr='--houghEyeDetectorMode %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputLandmarksEMSP=dict(argstr='--inputLandmarksEMSP %s', ), inputTemplateModel=dict(argstr='--inputTemplateModel %s', @@ -98,8 +92,6 @@ def test_BRAINSConstellationDetector_inputs(): ), rpc=dict(argstr='--rpc %f', ), - terminal_output=dict(nohash=True, - ), trimRescaledIntensities=dict(argstr='--trimRescaledIntensities %f', ), verbose=dict(argstr='--verbose ', @@ -110,7 +102,7 @@ def test_BRAINSConstellationDetector_inputs(): writedebuggingImagesLevel=dict(argstr='--writedebuggingImagesLevel %d', ), ) - inputs = BRAINSConstellationDetector.input_spec() + inputs = BRAINSConstellationDetector._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -129,7 +121,7 @@ def test_BRAINSConstellationDetector_outputs(): resultsDir=dict(), writeBranded2DImage=dict(), ) - outputs = BRAINSConstellationDetector.output_spec() + outputs = BRAINSConstellationDetector._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSCreateLabelMapFromProbabilityMaps.py b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSCreateLabelMapFromProbabilityMaps.py index 88ce476209..82c5f1fc13 100644 --- a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSCreateLabelMapFromProbabilityMaps.py +++ b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSCreateLabelMapFromProbabilityMaps.py @@ -12,15 +12,9 @@ def test_BRAINSCreateLabelMapFromProbabilityMaps_inputs(): dirtyLabelVolume=dict(argstr='--dirtyLabelVolume %s', hash_files=False, ), - environ=dict(nohash=True, - usedefault=True, - ), foregroundPriors=dict(argstr='--foregroundPriors %s', sep=',', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inclusionThreshold=dict(argstr='--inclusionThreshold %f', ), inputProbabilityVolume=dict(argstr='--inputProbabilityVolume %s...', @@ -30,10 +24,8 @@ def test_BRAINSCreateLabelMapFromProbabilityMaps_inputs(): priorLabelCodes=dict(argstr='--priorLabelCodes %s', sep=',', ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSCreateLabelMapFromProbabilityMaps.input_spec() + inputs = BRAINSCreateLabelMapFromProbabilityMaps._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +36,7 @@ def test_BRAINSCreateLabelMapFromProbabilityMaps_outputs(): output_map = dict(cleanLabelVolume=dict(), dirtyLabelVolume=dict(), ) - outputs = BRAINSCreateLabelMapFromProbabilityMaps.output_spec() + outputs = BRAINSCreateLabelMapFromProbabilityMaps._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSCut.py b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSCut.py index 7efdf9a1cc..0d891fd837 100644 --- a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSCut.py +++ b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSCut.py @@ -14,16 +14,10 @@ def test_BRAINSCut_inputs(): ), createVectors=dict(argstr='--createVectors ', ), - environ=dict(nohash=True, - usedefault=True, - ), generateProbability=dict(argstr='--generateProbability ', ), histogramEqualization=dict(argstr='--histogramEqualization ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), method=dict(argstr='--method %s', ), modelConfigurationFilename=dict(argstr='--modelConfigurationFilename %s', @@ -38,8 +32,6 @@ def test_BRAINSCut_inputs(): ), randomTreeDepth=dict(argstr='--randomTreeDepth %d', ), - terminal_output=dict(nohash=True, - ), trainModel=dict(argstr='--trainModel ', ), trainModelStartIndex=dict(argstr='--trainModelStartIndex %d', @@ -49,7 +41,7 @@ def test_BRAINSCut_inputs(): verbose=dict(argstr='--verbose %d', ), ) - inputs = BRAINSCut.input_spec() + inputs = BRAINSCut._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +50,7 @@ def test_BRAINSCut_inputs(): def test_BRAINSCut_outputs(): output_map = dict() - outputs = BRAINSCut.output_spec() + outputs = BRAINSCut._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSMultiSTAPLE.py b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSMultiSTAPLE.py index 86daa0bb17..6fee3b5bbe 100644 --- a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSMultiSTAPLE.py +++ b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSMultiSTAPLE.py @@ -6,12 +6,6 @@ def test_BRAINSMultiSTAPLE_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputCompositeT1Volume=dict(argstr='--inputCompositeT1Volume %s', ), inputLabelVolume=dict(argstr='--inputLabelVolume %s...', @@ -30,10 +24,8 @@ def test_BRAINSMultiSTAPLE_inputs(): ), skipResampling=dict(argstr='--skipResampling ', ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSMultiSTAPLE.input_spec() + inputs = BRAINSMultiSTAPLE._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +36,7 @@ def test_BRAINSMultiSTAPLE_outputs(): output_map = dict(outputConfusionMatrix=dict(), outputMultiSTAPLE=dict(), ) - outputs = BRAINSMultiSTAPLE.output_spec() + outputs = BRAINSMultiSTAPLE._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSROIAuto.py b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSROIAuto.py index eaffbf7909..e6daaaf6ed 100644 --- a/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSROIAuto.py +++ b/nipype/interfaces/semtools/segmentation/tests/test_auto_BRAINSROIAuto.py @@ -12,12 +12,6 @@ def test_BRAINSROIAuto_inputs(): ), cropOutput=dict(argstr='--cropOutput ', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), maskOutput=dict(argstr='--maskOutput ', @@ -34,12 +28,10 @@ def test_BRAINSROIAuto_inputs(): ), outputVolumePixelType=dict(argstr='--outputVolumePixelType %s', ), - terminal_output=dict(nohash=True, - ), thresholdCorrectionFactor=dict(argstr='--thresholdCorrectionFactor %f', ), ) - inputs = BRAINSROIAuto.input_spec() + inputs = BRAINSROIAuto._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +42,7 @@ def test_BRAINSROIAuto_outputs(): output_map = dict(outputROIMaskVolume=dict(), outputVolume=dict(), ) - outputs = BRAINSROIAuto.output_spec() + outputs = BRAINSROIAuto._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/segmentation/tests/test_auto_BinaryMaskEditorBasedOnLandmarks.py b/nipype/interfaces/semtools/segmentation/tests/test_auto_BinaryMaskEditorBasedOnLandmarks.py index 85ae45ffa7..0715400a5a 100644 --- a/nipype/interfaces/semtools/segmentation/tests/test_auto_BinaryMaskEditorBasedOnLandmarks.py +++ b/nipype/interfaces/semtools/segmentation/tests/test_auto_BinaryMaskEditorBasedOnLandmarks.py @@ -6,12 +6,6 @@ def test_BinaryMaskEditorBasedOnLandmarks_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputBinaryVolume=dict(argstr='--inputBinaryVolume %s', ), inputLandmarkNames=dict(argstr='--inputLandmarkNames %s', @@ -31,10 +25,8 @@ def test_BinaryMaskEditorBasedOnLandmarks_inputs(): setCutDirectionForObliquePlane=dict(argstr='--setCutDirectionForObliquePlane %s', sep=',', ), - terminal_output=dict(nohash=True, - ), ) - inputs = BinaryMaskEditorBasedOnLandmarks.input_spec() + inputs = BinaryMaskEditorBasedOnLandmarks._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +36,7 @@ def test_BinaryMaskEditorBasedOnLandmarks_inputs(): def test_BinaryMaskEditorBasedOnLandmarks_outputs(): output_map = dict(outputBinaryVolume=dict(), ) - outputs = BinaryMaskEditorBasedOnLandmarks.output_spec() + outputs = BinaryMaskEditorBasedOnLandmarks._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/segmentation/tests/test_auto_ESLR.py b/nipype/interfaces/semtools/segmentation/tests/test_auto_ESLR.py index 943e609b99..3ad669591b 100644 --- a/nipype/interfaces/semtools/segmentation/tests/test_auto_ESLR.py +++ b/nipype/interfaces/semtools/segmentation/tests/test_auto_ESLR.py @@ -8,14 +8,8 @@ def test_ESLR_inputs(): ), closingSize=dict(argstr='--closingSize %d', ), - environ=dict(nohash=True, - usedefault=True, - ), high=dict(argstr='--high %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), low=dict(argstr='--low %d', @@ -31,10 +25,8 @@ def test_ESLR_inputs(): ), safetySize=dict(argstr='--safetySize %d', ), - terminal_output=dict(nohash=True, - ), ) - inputs = ESLR.input_spec() + inputs = ESLR._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +36,7 @@ def test_ESLR_inputs(): def test_ESLR_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = ESLR.output_spec() + outputs = ESLR._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/testing/featuredetection.py b/nipype/interfaces/semtools/testing/featuredetection.py index 2985e5bf1b..5922163e28 100644 --- a/nipype/interfaces/semtools/testing/featuredetection.py +++ b/nipype/interfaces/semtools/testing/featuredetection.py @@ -29,8 +29,8 @@ class SphericalCoordinateGeneration(SEMLikeCommandLine): """ - input_spec = SphericalCoordinateGenerationInputSpec - output_spec = SphericalCoordinateGenerationOutputSpec + _input_spec = SphericalCoordinateGenerationInputSpec + _output_spec = SphericalCoordinateGenerationOutputSpec _cmd = " SphericalCoordinateGeneration " _outputs_filenames = {} _redirect_x = False diff --git a/nipype/interfaces/semtools/testing/generateaveragelmkfile.py b/nipype/interfaces/semtools/testing/generateaveragelmkfile.py index 0bd8188269..4276ef6907 100644 --- a/nipype/interfaces/semtools/testing/generateaveragelmkfile.py +++ b/nipype/interfaces/semtools/testing/generateaveragelmkfile.py @@ -27,8 +27,8 @@ class GenerateAverageLmkFile(SEMLikeCommandLine): """ - input_spec = GenerateAverageLmkFileInputSpec - output_spec = GenerateAverageLmkFileOutputSpec + _input_spec = GenerateAverageLmkFileInputSpec + _output_spec = GenerateAverageLmkFileOutputSpec _cmd = " GenerateAverageLmkFile " _outputs_filenames = {'outputLandmarkFile': 'outputLandmarkFile'} _redirect_x = False diff --git a/nipype/interfaces/semtools/testing/landmarkscompare.py b/nipype/interfaces/semtools/testing/landmarkscompare.py index 1370bcb419..103d61f3a2 100644 --- a/nipype/interfaces/semtools/testing/landmarkscompare.py +++ b/nipype/interfaces/semtools/testing/landmarkscompare.py @@ -28,8 +28,8 @@ class LandmarksCompare(SEMLikeCommandLine): """ - input_spec = LandmarksCompareInputSpec - output_spec = LandmarksCompareOutputSpec + _input_spec = LandmarksCompareInputSpec + _output_spec = LandmarksCompareOutputSpec _cmd = " LandmarksCompare " _outputs_filenames = {} _redirect_x = False diff --git a/nipype/interfaces/semtools/tests/test_auto_DWICompare.py b/nipype/interfaces/semtools/tests/test_auto_DWICompare.py index 264ebfbd86..f1b21dea21 100644 --- a/nipype/interfaces/semtools/tests/test_auto_DWICompare.py +++ b/nipype/interfaces/semtools/tests/test_auto_DWICompare.py @@ -6,20 +6,12 @@ def test_DWICompare_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume1=dict(argstr='--inputVolume1 %s', ), inputVolume2=dict(argstr='--inputVolume2 %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = DWICompare.input_spec() + inputs = DWICompare._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +20,7 @@ def test_DWICompare_inputs(): def test_DWICompare_outputs(): output_map = dict() - outputs = DWICompare.output_spec() + outputs = DWICompare._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/tests/test_auto_DWISimpleCompare.py b/nipype/interfaces/semtools/tests/test_auto_DWISimpleCompare.py index 017abf83af..9e3980dc55 100644 --- a/nipype/interfaces/semtools/tests/test_auto_DWISimpleCompare.py +++ b/nipype/interfaces/semtools/tests/test_auto_DWISimpleCompare.py @@ -8,20 +8,12 @@ def test_DWISimpleCompare_inputs(): ), checkDWIData=dict(argstr='--checkDWIData ', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume1=dict(argstr='--inputVolume1 %s', ), inputVolume2=dict(argstr='--inputVolume2 %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = DWISimpleCompare.input_spec() + inputs = DWISimpleCompare._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -30,7 +22,7 @@ def test_DWISimpleCompare_inputs(): def test_DWISimpleCompare_outputs(): output_map = dict() - outputs = DWISimpleCompare.output_spec() + outputs = DWISimpleCompare._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/tests/test_auto_GenerateCsfClippedFromClassifiedImage.py b/nipype/interfaces/semtools/tests/test_auto_GenerateCsfClippedFromClassifiedImage.py index ccb2e8abd6..d48adb3213 100644 --- a/nipype/interfaces/semtools/tests/test_auto_GenerateCsfClippedFromClassifiedImage.py +++ b/nipype/interfaces/semtools/tests/test_auto_GenerateCsfClippedFromClassifiedImage.py @@ -6,21 +6,13 @@ def test_GenerateCsfClippedFromClassifiedImage_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputCassifiedVolume=dict(argstr='--inputCassifiedVolume %s', ), outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = GenerateCsfClippedFromClassifiedImage.input_spec() + inputs = GenerateCsfClippedFromClassifiedImage._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -30,7 +22,7 @@ def test_GenerateCsfClippedFromClassifiedImage_inputs(): def test_GenerateCsfClippedFromClassifiedImage_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = GenerateCsfClippedFromClassifiedImage.output_spec() + outputs = GenerateCsfClippedFromClassifiedImage._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/brains.py b/nipype/interfaces/semtools/utilities/brains.py index e7402da5a4..7cc1305765 100644 --- a/nipype/interfaces/semtools/utilities/brains.py +++ b/nipype/interfaces/semtools/utilities/brains.py @@ -44,8 +44,8 @@ class BRAINSConstellationModeler(SEMLikeCommandLine): """ - input_spec = BRAINSConstellationModelerInputSpec - output_spec = BRAINSConstellationModelerOutputSpec + _input_spec = BRAINSConstellationModelerInputSpec + _output_spec = BRAINSConstellationModelerOutputSpec _cmd = " BRAINSConstellationModeler " _outputs_filenames = {'outputModel': 'outputModel.mdl', 'resultsDir': 'resultsDir'} _redirect_x = False @@ -72,8 +72,8 @@ class landmarksConstellationWeights(SEMLikeCommandLine): """ - input_spec = landmarksConstellationWeightsInputSpec - output_spec = landmarksConstellationWeightsOutputSpec + _input_spec = landmarksConstellationWeightsInputSpec + _output_spec = landmarksConstellationWeightsOutputSpec _cmd = " landmarksConstellationWeights " _outputs_filenames = {'outputWeightsList': 'outputWeightsList.wts'} _redirect_x = False @@ -108,8 +108,8 @@ class BRAINSTrimForegroundInDirection(SEMLikeCommandLine): """ - input_spec = BRAINSTrimForegroundInDirectionInputSpec - output_spec = BRAINSTrimForegroundInDirectionOutputSpec + _input_spec = BRAINSTrimForegroundInDirectionInputSpec + _output_spec = BRAINSTrimForegroundInDirectionOutputSpec _cmd = " BRAINSTrimForegroundInDirection " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -144,8 +144,8 @@ class BRAINSLmkTransform(SEMLikeCommandLine): """ - input_spec = BRAINSLmkTransformInputSpec - output_spec = BRAINSLmkTransformOutputSpec + _input_spec = BRAINSLmkTransformInputSpec + _output_spec = BRAINSLmkTransformOutputSpec _cmd = " BRAINSLmkTransform " _outputs_filenames = {'outputResampledVolume': 'outputResampledVolume.nii', 'outputAffineTransform': 'outputAffineTransform.h5'} _redirect_x = False @@ -196,8 +196,8 @@ class BRAINSMush(SEMLikeCommandLine): """ - input_spec = BRAINSMushInputSpec - output_spec = BRAINSMushOutputSpec + _input_spec = BRAINSMushInputSpec + _output_spec = BRAINSMushOutputSpec _cmd = " BRAINSMush " _outputs_filenames = {'outputMask': 'outputMask.nii.gz', 'outputWeightsFile': 'outputWeightsFile.txt', 'outputVolume': 'outputVolume.nii.gz'} _redirect_x = False @@ -235,8 +235,8 @@ class BRAINSTransformConvert(SEMLikeCommandLine): """ - input_spec = BRAINSTransformConvertInputSpec - output_spec = BRAINSTransformConvertOutputSpec + _input_spec = BRAINSTransformConvertInputSpec + _output_spec = BRAINSTransformConvertOutputSpec _cmd = " BRAINSTransformConvert " _outputs_filenames = {'displacementVolume': 'displacementVolume.nii', 'outputTransform': 'outputTransform.mat'} _redirect_x = False @@ -263,8 +263,8 @@ class landmarksConstellationAligner(SEMLikeCommandLine): """ - input_spec = landmarksConstellationAlignerInputSpec - output_spec = landmarksConstellationAlignerOutputSpec + _input_spec = landmarksConstellationAlignerInputSpec + _output_spec = landmarksConstellationAlignerOutputSpec _cmd = " landmarksConstellationAligner " _outputs_filenames = {'outputLandmarksPaired': 'outputLandmarksPaired'} _redirect_x = False @@ -293,8 +293,8 @@ class BRAINSEyeDetector(SEMLikeCommandLine): """ - input_spec = BRAINSEyeDetectorInputSpec - output_spec = BRAINSEyeDetectorOutputSpec + _input_spec = BRAINSEyeDetectorInputSpec + _output_spec = BRAINSEyeDetectorOutputSpec _cmd = " BRAINSEyeDetector " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -323,8 +323,8 @@ class BRAINSLinearModelerEPCA(SEMLikeCommandLine): """ - input_spec = BRAINSLinearModelerEPCAInputSpec - output_spec = BRAINSLinearModelerEPCAOutputSpec + _input_spec = BRAINSLinearModelerEPCAInputSpec + _output_spec = BRAINSLinearModelerEPCAOutputSpec _cmd = " BRAINSLinearModelerEPCA " _outputs_filenames = {} _redirect_x = False @@ -361,8 +361,8 @@ class BRAINSInitializedControlPoints(SEMLikeCommandLine): """ - input_spec = BRAINSInitializedControlPointsInputSpec - output_spec = BRAINSInitializedControlPointsOutputSpec + _input_spec = BRAINSInitializedControlPointsInputSpec + _output_spec = BRAINSInitializedControlPointsOutputSpec _cmd = " BRAINSInitializedControlPoints " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -391,8 +391,8 @@ class CleanUpOverlapLabels(SEMLikeCommandLine): """ - input_spec = CleanUpOverlapLabelsInputSpec - output_spec = CleanUpOverlapLabelsOutputSpec + _input_spec = CleanUpOverlapLabelsInputSpec + _output_spec = CleanUpOverlapLabelsOutputSpec _cmd = " CleanUpOverlapLabels " _outputs_filenames = {'outputBinaryVolumes': 'outputBinaryVolumes.nii'} _redirect_x = False @@ -423,8 +423,8 @@ class BRAINSClipInferior(SEMLikeCommandLine): """ - input_spec = BRAINSClipInferiorInputSpec - output_spec = BRAINSClipInferiorOutputSpec + _input_spec = BRAINSClipInferiorInputSpec + _output_spec = BRAINSClipInferiorOutputSpec _cmd = " BRAINSClipInferior " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} _redirect_x = False @@ -454,8 +454,8 @@ class GenerateLabelMapFromProbabilityMap(SEMLikeCommandLine): """ - input_spec = GenerateLabelMapFromProbabilityMapInputSpec - output_spec = GenerateLabelMapFromProbabilityMapOutputSpec + _input_spec = GenerateLabelMapFromProbabilityMapInputSpec + _output_spec = GenerateLabelMapFromProbabilityMapOutputSpec _cmd = " GenerateLabelMapFromProbabilityMap " _outputs_filenames = {'outputLabelVolume': 'outputLabelVolume.nii.gz'} _redirect_x = False @@ -493,8 +493,8 @@ class BRAINSAlignMSP(SEMLikeCommandLine): """ - input_spec = BRAINSAlignMSPInputSpec - output_spec = BRAINSAlignMSPOutputSpec + _input_spec = BRAINSAlignMSPInputSpec + _output_spec = BRAINSAlignMSPOutputSpec _cmd = " BRAINSAlignMSP " _outputs_filenames = {'OutputresampleMSP': 'OutputresampleMSP.nii', 'resultsDir': 'resultsDir'} _redirect_x = False @@ -527,8 +527,8 @@ class BRAINSLandmarkInitializer(SEMLikeCommandLine): """ - input_spec = BRAINSLandmarkInitializerInputSpec - output_spec = BRAINSLandmarkInitializerOutputSpec + _input_spec = BRAINSLandmarkInitializerInputSpec + _output_spec = BRAINSLandmarkInitializerOutputSpec _cmd = " BRAINSLandmarkInitializer " _outputs_filenames = {'outputTransformFilename': 'outputTransformFilename'} _redirect_x = False @@ -555,8 +555,8 @@ class insertMidACPCpoint(SEMLikeCommandLine): """ - input_spec = insertMidACPCpointInputSpec - output_spec = insertMidACPCpointOutputSpec + _input_spec = insertMidACPCpointInputSpec + _output_spec = insertMidACPCpointOutputSpec _cmd = " insertMidACPCpoint " _outputs_filenames = {'outputLandmarkFile': 'outputLandmarkFile'} _redirect_x = False @@ -592,8 +592,8 @@ class BRAINSSnapShotWriter(SEMLikeCommandLine): """ - input_spec = BRAINSSnapShotWriterInputSpec - output_spec = BRAINSSnapShotWriterOutputSpec + _input_spec = BRAINSSnapShotWriterInputSpec + _output_spec = BRAINSSnapShotWriterOutputSpec _cmd = " BRAINSSnapShotWriter " _outputs_filenames = {'outputFilename': 'outputFilename'} _redirect_x = False @@ -626,8 +626,8 @@ class JointHistogram(SEMLikeCommandLine): """ - input_spec = JointHistogramInputSpec - output_spec = JointHistogramOutputSpec + _input_spec = JointHistogramInputSpec + _output_spec = JointHistogramOutputSpec _cmd = " JointHistogram " _outputs_filenames = {} _redirect_x = False @@ -659,8 +659,8 @@ class ShuffleVectorsModule(SEMLikeCommandLine): """ - input_spec = ShuffleVectorsModuleInputSpec - output_spec = ShuffleVectorsModuleOutputSpec + _input_spec = ShuffleVectorsModuleInputSpec + _output_spec = ShuffleVectorsModuleOutputSpec _cmd = " ShuffleVectorsModule " _outputs_filenames = {'outputVectorFileBaseName': 'outputVectorFileBaseName'} _redirect_x = False @@ -696,8 +696,8 @@ class ImageRegionPlotter(SEMLikeCommandLine): """ - input_spec = ImageRegionPlotterInputSpec - output_spec = ImageRegionPlotterOutputSpec + _input_spec = ImageRegionPlotterInputSpec + _output_spec = ImageRegionPlotterOutputSpec _cmd = " ImageRegionPlotter " _outputs_filenames = {} _redirect_x = False @@ -727,8 +727,8 @@ class fcsv_to_hdf5(SEMLikeCommandLine): """ - input_spec = fcsv_to_hdf5InputSpec - output_spec = fcsv_to_hdf5OutputSpec + _input_spec = fcsv_to_hdf5InputSpec + _output_spec = fcsv_to_hdf5OutputSpec _cmd = " fcsv_to_hdf5 " _outputs_filenames = {'modelFile': 'modelFile', 'landmarksInformationFile': 'landmarksInformationFile.h5'} _redirect_x = False @@ -780,8 +780,8 @@ class FindCenterOfBrain(SEMLikeCommandLine): """ - input_spec = FindCenterOfBrainInputSpec - output_spec = FindCenterOfBrainOutputSpec + _input_spec = FindCenterOfBrainInputSpec + _output_spec = FindCenterOfBrainOutputSpec _cmd = " FindCenterOfBrain " _outputs_filenames = {'debugClippedImageMask': 'debugClippedImageMask.nii', 'debugTrimmedImage': 'debugTrimmedImage.nii', 'debugDistanceImage': 'debugDistanceImage.nii', 'debugGridImage': 'debugGridImage.nii', 'clippedImageMask': 'clippedImageMask.nii', 'debugAfterGridComputationsForegroundImage': 'debugAfterGridComputationsForegroundImage.nii'} diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSAlignMSP.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSAlignMSP.py index 98837c75a7..4dfc5709fb 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSAlignMSP.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSAlignMSP.py @@ -11,12 +11,6 @@ def test_BRAINSAlignMSP_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), interpolationMode=dict(argstr='--interpolationMode %s', @@ -33,8 +27,6 @@ def test_BRAINSAlignMSP_inputs(): resultsDir=dict(argstr='--resultsDir %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), trimRescaledIntensities=dict(argstr='--trimRescaledIntensities %f', ), verbose=dict(argstr='--verbose ', @@ -42,7 +34,7 @@ def test_BRAINSAlignMSP_inputs(): writedebuggingImagesLevel=dict(argstr='--writedebuggingImagesLevel %d', ), ) - inputs = BRAINSAlignMSP.input_spec() + inputs = BRAINSAlignMSP._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +45,7 @@ def test_BRAINSAlignMSP_outputs(): output_map = dict(OutputresampleMSP=dict(), resultsDir=dict(), ) - outputs = BRAINSAlignMSP.output_spec() + outputs = BRAINSAlignMSP._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSClipInferior.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSClipInferior.py index f7636c95d1..d1b1fd28a8 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSClipInferior.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSClipInferior.py @@ -10,12 +10,6 @@ def test_BRAINSClipInferior_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -23,10 +17,8 @@ def test_BRAINSClipInferior_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSClipInferior.input_spec() + inputs = BRAINSClipInferior._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_BRAINSClipInferior_inputs(): def test_BRAINSClipInferior_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = BRAINSClipInferior.output_spec() + outputs = BRAINSClipInferior._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSConstellationModeler.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSConstellationModeler.py index ee8b7bb018..eaeffcf274 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSConstellationModeler.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSConstellationModeler.py @@ -8,12 +8,6 @@ def test_BRAINSConstellationModeler_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputTrainingList=dict(argstr='--inputTrainingList %s', ), mspQualityLevel=dict(argstr='--mspQualityLevel %d', @@ -35,8 +29,6 @@ def test_BRAINSConstellationModeler_inputs(): ), saveOptimizedLandmarks=dict(argstr='--saveOptimizedLandmarks ', ), - terminal_output=dict(nohash=True, - ), trimRescaledIntensities=dict(argstr='--trimRescaledIntensities %f', ), verbose=dict(argstr='--verbose ', @@ -44,7 +36,7 @@ def test_BRAINSConstellationModeler_inputs(): writedebuggingImagesLevel=dict(argstr='--writedebuggingImagesLevel %d', ), ) - inputs = BRAINSConstellationModeler.input_spec() + inputs = BRAINSConstellationModeler._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_BRAINSConstellationModeler_outputs(): output_map = dict(outputModel=dict(), resultsDir=dict(), ) - outputs = BRAINSConstellationModeler.output_spec() + outputs = BRAINSConstellationModeler._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSEyeDetector.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSEyeDetector.py index 20072ed902..488fa45340 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSEyeDetector.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSEyeDetector.py @@ -8,12 +8,6 @@ def test_BRAINSEyeDetector_inputs(): ), debugDir=dict(argstr='--debugDir %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -21,10 +15,8 @@ def test_BRAINSEyeDetector_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSEyeDetector.input_spec() + inputs = BRAINSEyeDetector._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_BRAINSEyeDetector_inputs(): def test_BRAINSEyeDetector_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = BRAINSEyeDetector.output_spec() + outputs = BRAINSEyeDetector._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSInitializedControlPoints.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSInitializedControlPoints.py index fb5d164f9b..c977bc9f63 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSInitializedControlPoints.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSInitializedControlPoints.py @@ -6,12 +6,6 @@ def test_BRAINSInitializedControlPoints_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -27,10 +21,8 @@ def test_BRAINSInitializedControlPoints_inputs(): splineGridSize=dict(argstr='--splineGridSize %s', sep=',', ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSInitializedControlPoints.input_spec() + inputs = BRAINSInitializedControlPoints._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_BRAINSInitializedControlPoints_inputs(): def test_BRAINSInitializedControlPoints_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = BRAINSInitializedControlPoints.output_spec() + outputs = BRAINSInitializedControlPoints._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLandmarkInitializer.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLandmarkInitializer.py index def6a40242..d91013daac 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLandmarkInitializer.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLandmarkInitializer.py @@ -6,12 +6,6 @@ def test_BRAINSLandmarkInitializer_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputFixedLandmarkFilename=dict(argstr='--inputFixedLandmarkFilename %s', ), inputMovingLandmarkFilename=dict(argstr='--inputMovingLandmarkFilename %s', @@ -21,10 +15,8 @@ def test_BRAINSLandmarkInitializer_inputs(): outputTransformFilename=dict(argstr='--outputTransformFilename %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSLandmarkInitializer.input_spec() + inputs = BRAINSLandmarkInitializer._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_BRAINSLandmarkInitializer_inputs(): def test_BRAINSLandmarkInitializer_outputs(): output_map = dict(outputTransformFilename=dict(), ) - outputs = BRAINSLandmarkInitializer.output_spec() + outputs = BRAINSLandmarkInitializer._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLinearModelerEPCA.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLinearModelerEPCA.py index f15061c8b4..4dcdfe2c95 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLinearModelerEPCA.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLinearModelerEPCA.py @@ -6,20 +6,12 @@ def test_BRAINSLinearModelerEPCA_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputTrainingList=dict(argstr='--inputTrainingList %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSLinearModelerEPCA.input_spec() + inputs = BRAINSLinearModelerEPCA._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -28,7 +20,7 @@ def test_BRAINSLinearModelerEPCA_inputs(): def test_BRAINSLinearModelerEPCA_outputs(): output_map = dict() - outputs = BRAINSLinearModelerEPCA.output_spec() + outputs = BRAINSLinearModelerEPCA._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLmkTransform.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLmkTransform.py index 7bda89c361..e2d8e69e0d 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLmkTransform.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSLmkTransform.py @@ -6,12 +6,6 @@ def test_BRAINSLmkTransform_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputFixedLandmarks=dict(argstr='--inputFixedLandmarks %s', ), inputMovingLandmarks=dict(argstr='--inputMovingLandmarks %s', @@ -28,10 +22,8 @@ def test_BRAINSLmkTransform_inputs(): outputResampledVolume=dict(argstr='--outputResampledVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSLmkTransform.input_spec() + inputs = BRAINSLmkTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_BRAINSLmkTransform_outputs(): output_map = dict(outputAffineTransform=dict(), outputResampledVolume=dict(), ) - outputs = BRAINSLmkTransform.output_spec() + outputs = BRAINSLmkTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSMush.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSMush.py index 4a351563d1..89a632bca4 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSMush.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSMush.py @@ -16,12 +16,6 @@ def test_BRAINSMush_inputs(): ), desiredVariance=dict(argstr='--desiredVariance %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputFirstVolume=dict(argstr='--inputFirstVolume %s', ), inputMaskVolume=dict(argstr='--inputMaskVolume %s', @@ -46,14 +40,12 @@ def test_BRAINSMush_inputs(): seed=dict(argstr='--seed %s', sep=',', ), - terminal_output=dict(nohash=True, - ), upperThresholdFactor=dict(argstr='--upperThresholdFactor %f', ), upperThresholdFactorPre=dict(argstr='--upperThresholdFactorPre %f', ), ) - inputs = BRAINSMush.input_spec() + inputs = BRAINSMush._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -65,7 +57,7 @@ def test_BRAINSMush_outputs(): outputVolume=dict(), outputWeightsFile=dict(), ) - outputs = BRAINSMush.output_spec() + outputs = BRAINSMush._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSSnapShotWriter.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSSnapShotWriter.py index 5ebceb6933..f2f246bc24 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSSnapShotWriter.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSSnapShotWriter.py @@ -6,12 +6,6 @@ def test_BRAINSSnapShotWriter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputBinaryVolumes=dict(argstr='--inputBinaryVolumes %s...', ), inputPlaneDirection=dict(argstr='--inputPlaneDirection %s', @@ -31,10 +25,8 @@ def test_BRAINSSnapShotWriter_inputs(): outputFilename=dict(argstr='--outputFilename %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSSnapShotWriter.input_spec() + inputs = BRAINSSnapShotWriter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -44,7 +36,7 @@ def test_BRAINSSnapShotWriter_inputs(): def test_BRAINSSnapShotWriter_outputs(): output_map = dict(outputFilename=dict(), ) - outputs = BRAINSSnapShotWriter.output_spec() + outputs = BRAINSSnapShotWriter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSTransformConvert.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSTransformConvert.py index dd909677cc..e8e0636e1d 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSTransformConvert.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSTransformConvert.py @@ -9,12 +9,6 @@ def test_BRAINSTransformConvert_inputs(): displacementVolume=dict(argstr='--displacementVolume %s', hash_files=False, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputTransform=dict(argstr='--inputTransform %s', ), outputPrecisionType=dict(argstr='--outputPrecisionType %s', @@ -26,10 +20,8 @@ def test_BRAINSTransformConvert_inputs(): ), referenceVolume=dict(argstr='--referenceVolume %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSTransformConvert.input_spec() + inputs = BRAINSTransformConvert._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_BRAINSTransformConvert_outputs(): output_map = dict(displacementVolume=dict(), outputTransform=dict(), ) - outputs = BRAINSTransformConvert.output_spec() + outputs = BRAINSTransformConvert._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSTrimForegroundInDirection.py b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSTrimForegroundInDirection.py index a63835efc8..8e224bd3ef 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSTrimForegroundInDirection.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_BRAINSTrimForegroundInDirection.py @@ -12,14 +12,8 @@ def test_BRAINSTrimForegroundInDirection_inputs(): ), directionCode=dict(argstr='--directionCode %d', ), - environ=dict(nohash=True, - usedefault=True, - ), headSizeLimit=dict(argstr='--headSizeLimit %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -29,10 +23,8 @@ def test_BRAINSTrimForegroundInDirection_inputs(): outputVolume=dict(argstr='--outputVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = BRAINSTrimForegroundInDirection.input_spec() + inputs = BRAINSTrimForegroundInDirection._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_BRAINSTrimForegroundInDirection_inputs(): def test_BRAINSTrimForegroundInDirection_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = BRAINSTrimForegroundInDirection.output_spec() + outputs = BRAINSTrimForegroundInDirection._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_CleanUpOverlapLabels.py b/nipype/interfaces/semtools/utilities/tests/test_auto_CleanUpOverlapLabels.py index 16e64f7910..15c4236a00 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_CleanUpOverlapLabels.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_CleanUpOverlapLabels.py @@ -6,21 +6,13 @@ def test_CleanUpOverlapLabels_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputBinaryVolumes=dict(argstr='--inputBinaryVolumes %s...', ), outputBinaryVolumes=dict(argstr='--outputBinaryVolumes %s...', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = CleanUpOverlapLabels.input_spec() + inputs = CleanUpOverlapLabels._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -30,7 +22,7 @@ def test_CleanUpOverlapLabels_inputs(): def test_CleanUpOverlapLabels_outputs(): output_map = dict(outputBinaryVolumes=dict(), ) - outputs = CleanUpOverlapLabels.output_spec() + outputs = CleanUpOverlapLabels._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_FindCenterOfBrain.py b/nipype/interfaces/semtools/utilities/tests/test_auto_FindCenterOfBrain.py index 51cd6c5b70..fec6cdb9f7 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_FindCenterOfBrain.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_FindCenterOfBrain.py @@ -30,18 +30,12 @@ def test_FindCenterOfBrain_inputs(): debugTrimmedImage=dict(argstr='--debugTrimmedImage %s', hash_files=False, ), - environ=dict(nohash=True, - usedefault=True, - ), generateDebugImages=dict(argstr='--generateDebugImages ', ), headSizeEstimate=dict(argstr='--headSizeEstimate %f', ), headSizeLimit=dict(argstr='--headSizeLimit %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), imageMask=dict(argstr='--imageMask %s', ), inputVolume=dict(argstr='--inputVolume %s', @@ -50,10 +44,8 @@ def test_FindCenterOfBrain_inputs(): ), otsuPercentileThreshold=dict(argstr='--otsuPercentileThreshold %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = FindCenterOfBrain.input_spec() + inputs = FindCenterOfBrain._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -68,7 +60,7 @@ def test_FindCenterOfBrain_outputs(): debugGridImage=dict(), debugTrimmedImage=dict(), ) - outputs = FindCenterOfBrain.output_spec() + outputs = FindCenterOfBrain._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_GenerateLabelMapFromProbabilityMap.py b/nipype/interfaces/semtools/utilities/tests/test_auto_GenerateLabelMapFromProbabilityMap.py index 28d2675275..e4f344fff1 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_GenerateLabelMapFromProbabilityMap.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_GenerateLabelMapFromProbabilityMap.py @@ -6,12 +6,6 @@ def test_GenerateLabelMapFromProbabilityMap_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolumes=dict(argstr='--inputVolumes %s...', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -19,10 +13,8 @@ def test_GenerateLabelMapFromProbabilityMap_inputs(): outputLabelVolume=dict(argstr='--outputLabelVolume %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = GenerateLabelMapFromProbabilityMap.input_spec() + inputs = GenerateLabelMapFromProbabilityMap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +24,7 @@ def test_GenerateLabelMapFromProbabilityMap_inputs(): def test_GenerateLabelMapFromProbabilityMap_outputs(): output_map = dict(outputLabelVolume=dict(), ) - outputs = GenerateLabelMapFromProbabilityMap.output_spec() + outputs = GenerateLabelMapFromProbabilityMap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_ImageRegionPlotter.py b/nipype/interfaces/semtools/utilities/tests/test_auto_ImageRegionPlotter.py index 6c7f5215f8..13cefa7c00 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_ImageRegionPlotter.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_ImageRegionPlotter.py @@ -6,12 +6,6 @@ def test_ImageRegionPlotter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputBinaryROIVolume=dict(argstr='--inputBinaryROIVolume %s', ), inputLabelVolume=dict(argstr='--inputLabelVolume %s', @@ -24,8 +18,6 @@ def test_ImageRegionPlotter_inputs(): ), outputJointHistogramData=dict(argstr='--outputJointHistogramData %s', ), - terminal_output=dict(nohash=True, - ), useIntensityForHistogram=dict(argstr='--useIntensityForHistogram ', ), useROIAUTO=dict(argstr='--useROIAUTO ', @@ -33,7 +25,7 @@ def test_ImageRegionPlotter_inputs(): verbose=dict(argstr='--verbose ', ), ) - inputs = ImageRegionPlotter.input_spec() + inputs = ImageRegionPlotter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_ImageRegionPlotter_inputs(): def test_ImageRegionPlotter_outputs(): output_map = dict() - outputs = ImageRegionPlotter.output_spec() + outputs = ImageRegionPlotter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_JointHistogram.py b/nipype/interfaces/semtools/utilities/tests/test_auto_JointHistogram.py index 5f1ddedcb8..18057644fe 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_JointHistogram.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_JointHistogram.py @@ -6,12 +6,6 @@ def test_JointHistogram_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputMaskVolumeInXAxis=dict(argstr='--inputMaskVolumeInXAxis %s', ), inputMaskVolumeInYAxis=dict(argstr='--inputMaskVolumeInYAxis %s', @@ -22,12 +16,10 @@ def test_JointHistogram_inputs(): ), outputJointHistogramImage=dict(argstr='--outputJointHistogramImage %s', ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose ', ), ) - inputs = JointHistogram.input_spec() + inputs = JointHistogram._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_JointHistogram_inputs(): def test_JointHistogram_outputs(): output_map = dict() - outputs = JointHistogram.output_spec() + outputs = JointHistogram._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_ShuffleVectorsModule.py b/nipype/interfaces/semtools/utilities/tests/test_auto_ShuffleVectorsModule.py index 8d84a541b8..a9879e815b 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_ShuffleVectorsModule.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_ShuffleVectorsModule.py @@ -6,12 +6,6 @@ def test_ShuffleVectorsModule_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVectorFileBaseName=dict(argstr='--inputVectorFileBaseName %s', ), outputVectorFileBaseName=dict(argstr='--outputVectorFileBaseName %s', @@ -19,10 +13,8 @@ def test_ShuffleVectorsModule_inputs(): ), resampleProportion=dict(argstr='--resampleProportion %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = ShuffleVectorsModule.input_spec() + inputs = ShuffleVectorsModule._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +24,7 @@ def test_ShuffleVectorsModule_inputs(): def test_ShuffleVectorsModule_outputs(): output_map = dict(outputVectorFileBaseName=dict(), ) - outputs = ShuffleVectorsModule.output_spec() + outputs = ShuffleVectorsModule._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_fcsv_to_hdf5.py b/nipype/interfaces/semtools/utilities/tests/test_auto_fcsv_to_hdf5.py index 9bee62f991..5bed14284f 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_fcsv_to_hdf5.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_fcsv_to_hdf5.py @@ -6,12 +6,6 @@ def test_fcsv_to_hdf5_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), landmarkGlobPattern=dict(argstr='--landmarkGlobPattern %s', ), landmarkTypesList=dict(argstr='--landmarkTypesList %s', @@ -24,12 +18,10 @@ def test_fcsv_to_hdf5_inputs(): ), numberOfThreads=dict(argstr='--numberOfThreads %d', ), - terminal_output=dict(nohash=True, - ), versionID=dict(argstr='--versionID %s', ), ) - inputs = fcsv_to_hdf5.input_spec() + inputs = fcsv_to_hdf5._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_fcsv_to_hdf5_outputs(): output_map = dict(landmarksInformationFile=dict(), modelFile=dict(), ) - outputs = fcsv_to_hdf5.output_spec() + outputs = fcsv_to_hdf5._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_insertMidACPCpoint.py b/nipype/interfaces/semtools/utilities/tests/test_auto_insertMidACPCpoint.py index 8803f8263b..680f8ccd4a 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_insertMidACPCpoint.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_insertMidACPCpoint.py @@ -6,21 +6,13 @@ def test_insertMidACPCpoint_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputLandmarkFile=dict(argstr='--inputLandmarkFile %s', ), outputLandmarkFile=dict(argstr='--outputLandmarkFile %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = insertMidACPCpoint.input_spec() + inputs = insertMidACPCpoint._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -30,7 +22,7 @@ def test_insertMidACPCpoint_inputs(): def test_insertMidACPCpoint_outputs(): output_map = dict(outputLandmarkFile=dict(), ) - outputs = insertMidACPCpoint.output_spec() + outputs = insertMidACPCpoint._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_landmarksConstellationAligner.py b/nipype/interfaces/semtools/utilities/tests/test_auto_landmarksConstellationAligner.py index d5b97d17b2..6b54c8fd79 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_landmarksConstellationAligner.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_landmarksConstellationAligner.py @@ -6,21 +6,13 @@ def test_landmarksConstellationAligner_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputLandmarksPaired=dict(argstr='--inputLandmarksPaired %s', ), outputLandmarksPaired=dict(argstr='--outputLandmarksPaired %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = landmarksConstellationAligner.input_spec() + inputs = landmarksConstellationAligner._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -30,7 +22,7 @@ def test_landmarksConstellationAligner_inputs(): def test_landmarksConstellationAligner_outputs(): output_map = dict(outputLandmarksPaired=dict(), ) - outputs = landmarksConstellationAligner.output_spec() + outputs = landmarksConstellationAligner._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/semtools/utilities/tests/test_auto_landmarksConstellationWeights.py b/nipype/interfaces/semtools/utilities/tests/test_auto_landmarksConstellationWeights.py index 154d17665d..6bf9e95aeb 100644 --- a/nipype/interfaces/semtools/utilities/tests/test_auto_landmarksConstellationWeights.py +++ b/nipype/interfaces/semtools/utilities/tests/test_auto_landmarksConstellationWeights.py @@ -8,12 +8,6 @@ def test_landmarksConstellationWeights_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputTemplateModel=dict(argstr='--inputTemplateModel %s', ), inputTrainingList=dict(argstr='--inputTrainingList %s', @@ -21,10 +15,8 @@ def test_landmarksConstellationWeights_inputs(): outputWeightsList=dict(argstr='--outputWeightsList %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = landmarksConstellationWeights.input_spec() + inputs = landmarksConstellationWeights._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_landmarksConstellationWeights_inputs(): def test_landmarksConstellationWeights_outputs(): output_map = dict(outputWeightsList=dict(), ) - outputs = landmarksConstellationWeights.output_spec() + outputs = landmarksConstellationWeights._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/converters.py b/nipype/interfaces/slicer/converters.py index c55656fd4b..c89d90b8ef 100644 --- a/nipype/interfaces/slicer/converters.py +++ b/nipype/interfaces/slicer/converters.py @@ -39,8 +39,8 @@ class DicomToNrrdConverter(SEMLikeCommandLine): """ - input_spec = DicomToNrrdConverterInputSpec - output_spec = DicomToNrrdConverterOutputSpec + _input_spec = DicomToNrrdConverterInputSpec + _output_spec = DicomToNrrdConverterOutputSpec _cmd = "DicomToNrrdConverter " _outputs_filenames = {'outputDirectory': 'outputDirectory'} @@ -72,7 +72,7 @@ class OrientScalarVolume(SEMLikeCommandLine): """ - input_spec = OrientScalarVolumeInputSpec - output_spec = OrientScalarVolumeOutputSpec + _input_spec = OrientScalarVolumeInputSpec + _output_spec = OrientScalarVolumeOutputSpec _cmd = "OrientScalarVolume " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/diffusion/diffusion.py b/nipype/interfaces/slicer/diffusion/diffusion.py index cb87deb4f5..794fcc0734 100644 --- a/nipype/interfaces/slicer/diffusion/diffusion.py +++ b/nipype/interfaces/slicer/diffusion/diffusion.py @@ -56,8 +56,8 @@ class ResampleDTIVolume(SEMLikeCommandLine): """ - input_spec = ResampleDTIVolumeInputSpec - output_spec = ResampleDTIVolumeOutputSpec + _input_spec = ResampleDTIVolumeInputSpec + _output_spec = ResampleDTIVolumeOutputSpec _cmd = "ResampleDTIVolume " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -101,8 +101,8 @@ class DWIRicianLMMSEFilter(SEMLikeCommandLine): """ - input_spec = DWIRicianLMMSEFilterInputSpec - output_spec = DWIRicianLMMSEFilterOutputSpec + _input_spec = DWIRicianLMMSEFilterInputSpec + _output_spec = DWIRicianLMMSEFilterOutputSpec _cmd = "DWIRicianLMMSEFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -151,8 +151,8 @@ class TractographyLabelMapSeeding(SEMLikeCommandLine): """ - input_spec = TractographyLabelMapSeedingInputSpec - output_spec = TractographyLabelMapSeedingOutputSpec + _input_spec = TractographyLabelMapSeedingInputSpec + _output_spec = TractographyLabelMapSeedingOutputSpec _cmd = "TractographyLabelMapSeeding " _outputs_filenames = {'OutputFibers': 'OutputFibers.vtk', 'outputdirectory': 'outputdirectory'} @@ -190,8 +190,8 @@ class DWIJointRicianLMMSEFilter(SEMLikeCommandLine): """ - input_spec = DWIJointRicianLMMSEFilterInputSpec - output_spec = DWIJointRicianLMMSEFilterOutputSpec + _input_spec = DWIJointRicianLMMSEFilterInputSpec + _output_spec = DWIJointRicianLMMSEFilterOutputSpec _cmd = "DWIJointRicianLMMSEFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -226,8 +226,8 @@ class DiffusionWeightedVolumeMasking(SEMLikeCommandLine): """ - input_spec = DiffusionWeightedVolumeMaskingInputSpec - output_spec = DiffusionWeightedVolumeMaskingOutputSpec + _input_spec = DiffusionWeightedVolumeMaskingInputSpec + _output_spec = DiffusionWeightedVolumeMaskingOutputSpec _cmd = "DiffusionWeightedVolumeMasking " _outputs_filenames = {'outputBaseline': 'outputBaseline.nii', 'thresholdMask': 'thresholdMask.nii'} @@ -259,8 +259,8 @@ class DTIimport(SEMLikeCommandLine): """ - input_spec = DTIimportInputSpec - output_spec = DTIimportOutputSpec + _input_spec = DTIimportInputSpec + _output_spec = DTIimportOutputSpec _cmd = "DTIimport " _outputs_filenames = {'outputTensor': 'outputTensor.nii'} @@ -300,8 +300,8 @@ class DWIToDTIEstimation(SEMLikeCommandLine): """ - input_spec = DWIToDTIEstimationInputSpec - output_spec = DWIToDTIEstimationOutputSpec + _input_spec = DWIToDTIEstimationInputSpec + _output_spec = DWIToDTIEstimationOutputSpec _cmd = "DWIToDTIEstimation " _outputs_filenames = {'outputTensor': 'outputTensor.nii', 'outputBaseline': 'outputBaseline.nii'} @@ -333,8 +333,8 @@ class DiffusionTensorScalarMeasurements(SEMLikeCommandLine): """ - input_spec = DiffusionTensorScalarMeasurementsInputSpec - output_spec = DiffusionTensorScalarMeasurementsOutputSpec + _input_spec = DiffusionTensorScalarMeasurementsInputSpec + _output_spec = DiffusionTensorScalarMeasurementsOutputSpec _cmd = "DiffusionTensorScalarMeasurements " _outputs_filenames = {'outputScalar': 'outputScalar.nii'} @@ -365,7 +365,7 @@ class DTIexport(SEMLikeCommandLine): """ - input_spec = DTIexportInputSpec - output_spec = DTIexportOutputSpec + _input_spec = DTIexportInputSpec + _output_spec = DTIexportOutputSpec _cmd = "DTIexport " _outputs_filenames = {'outputFile': 'outputFile'} diff --git a/nipype/interfaces/slicer/diffusion/tests/test_auto_DTIexport.py b/nipype/interfaces/slicer/diffusion/tests/test_auto_DTIexport.py index 1704c064f6..00a6edddec 100644 --- a/nipype/interfaces/slicer/diffusion/tests/test_auto_DTIexport.py +++ b/nipype/interfaces/slicer/diffusion/tests/test_auto_DTIexport.py @@ -6,12 +6,6 @@ def test_DTIexport_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputTensor=dict(argstr='%s', position=-2, ), @@ -19,10 +13,8 @@ def test_DTIexport_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DTIexport.input_spec() + inputs = DTIexport._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -33,7 +25,7 @@ def test_DTIexport_outputs(): output_map = dict(outputFile=dict(position=-1, ), ) - outputs = DTIexport.output_spec() + outputs = DTIexport._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/diffusion/tests/test_auto_DTIimport.py b/nipype/interfaces/slicer/diffusion/tests/test_auto_DTIimport.py index dab8788688..8c7c940d5c 100644 --- a/nipype/interfaces/slicer/diffusion/tests/test_auto_DTIimport.py +++ b/nipype/interfaces/slicer/diffusion/tests/test_auto_DTIimport.py @@ -6,12 +6,6 @@ def test_DTIimport_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputFile=dict(argstr='%s', position=-2, ), @@ -19,12 +13,10 @@ def test_DTIimport_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), testingmode=dict(argstr='--testingmode ', ), ) - inputs = DTIimport.input_spec() + inputs = DTIimport._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +27,7 @@ def test_DTIimport_outputs(): output_map = dict(outputTensor=dict(position=-1, ), ) - outputs = DTIimport.output_spec() + outputs = DTIimport._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIJointRicianLMMSEFilter.py b/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIJointRicianLMMSEFilter.py index a5215c65b5..b9f9a7fcf6 100644 --- a/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIJointRicianLMMSEFilter.py +++ b/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIJointRicianLMMSEFilter.py @@ -8,12 +8,6 @@ def test_DWIJointRicianLMMSEFilter_inputs(): ), compressOutput=dict(argstr='--compressOutput ', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -29,10 +23,8 @@ def test_DWIJointRicianLMMSEFilter_inputs(): rf=dict(argstr='--rf %s', sep=',', ), - terminal_output=dict(nohash=True, - ), ) - inputs = DWIJointRicianLMMSEFilter.input_spec() + inputs = DWIJointRicianLMMSEFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +35,7 @@ def test_DWIJointRicianLMMSEFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = DWIJointRicianLMMSEFilter.output_spec() + outputs = DWIJointRicianLMMSEFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIRicianLMMSEFilter.py b/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIRicianLMMSEFilter.py index da2e1d4d07..23c5471c76 100644 --- a/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIRicianLMMSEFilter.py +++ b/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIRicianLMMSEFilter.py @@ -8,14 +8,8 @@ def test_DWIRicianLMMSEFilter_inputs(): ), compressOutput=dict(argstr='--compressOutput ', ), - environ=dict(nohash=True, - usedefault=True, - ), hrf=dict(argstr='--hrf %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -39,12 +33,10 @@ def test_DWIRicianLMMSEFilter_inputs(): rf=dict(argstr='--rf %s', sep=',', ), - terminal_output=dict(nohash=True, - ), uav=dict(argstr='--uav ', ), ) - inputs = DWIRicianLMMSEFilter.input_spec() + inputs = DWIRicianLMMSEFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_DWIRicianLMMSEFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = DWIRicianLMMSEFilter.output_spec() + outputs = DWIRicianLMMSEFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIToDTIEstimation.py b/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIToDTIEstimation.py index be0f92c092..35a54caf79 100644 --- a/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIToDTIEstimation.py +++ b/nipype/interfaces/slicer/diffusion/tests/test_auto_DWIToDTIEstimation.py @@ -8,12 +8,6 @@ def test_DWIToDTIEstimation_inputs(): ), enumeration=dict(argstr='--enumeration %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-3, ), @@ -29,10 +23,8 @@ def test_DWIToDTIEstimation_inputs(): ), shiftNeg=dict(argstr='--shiftNeg ', ), - terminal_output=dict(nohash=True, - ), ) - inputs = DWIToDTIEstimation.input_spec() + inputs = DWIToDTIEstimation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_DWIToDTIEstimation_outputs(): outputTensor=dict(position=-2, ), ) - outputs = DWIToDTIEstimation.output_spec() + outputs = DWIToDTIEstimation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/diffusion/tests/test_auto_DiffusionTensorScalarMeasurements.py b/nipype/interfaces/slicer/diffusion/tests/test_auto_DiffusionTensorScalarMeasurements.py index 425800bd41..6796dc46de 100644 --- a/nipype/interfaces/slicer/diffusion/tests/test_auto_DiffusionTensorScalarMeasurements.py +++ b/nipype/interfaces/slicer/diffusion/tests/test_auto_DiffusionTensorScalarMeasurements.py @@ -8,12 +8,6 @@ def test_DiffusionTensorScalarMeasurements_inputs(): ), enumeration=dict(argstr='--enumeration %s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-3, ), @@ -21,10 +15,8 @@ def test_DiffusionTensorScalarMeasurements_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = DiffusionTensorScalarMeasurements.input_spec() + inputs = DiffusionTensorScalarMeasurements._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +27,7 @@ def test_DiffusionTensorScalarMeasurements_outputs(): output_map = dict(outputScalar=dict(position=-1, ), ) - outputs = DiffusionTensorScalarMeasurements.output_spec() + outputs = DiffusionTensorScalarMeasurements._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/diffusion/tests/test_auto_DiffusionWeightedVolumeMasking.py b/nipype/interfaces/slicer/diffusion/tests/test_auto_DiffusionWeightedVolumeMasking.py index d325afaf71..3224d2a4e7 100644 --- a/nipype/interfaces/slicer/diffusion/tests/test_auto_DiffusionWeightedVolumeMasking.py +++ b/nipype/interfaces/slicer/diffusion/tests/test_auto_DiffusionWeightedVolumeMasking.py @@ -6,12 +6,6 @@ def test_DiffusionWeightedVolumeMasking_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-4, ), @@ -23,14 +17,12 @@ def test_DiffusionWeightedVolumeMasking_inputs(): ), removeislands=dict(argstr='--removeislands ', ), - terminal_output=dict(nohash=True, - ), thresholdMask=dict(argstr='%s', hash_files=False, position=-1, ), ) - inputs = DiffusionWeightedVolumeMasking.input_spec() + inputs = DiffusionWeightedVolumeMasking._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +35,7 @@ def test_DiffusionWeightedVolumeMasking_outputs(): thresholdMask=dict(position=-1, ), ) - outputs = DiffusionWeightedVolumeMasking.output_spec() + outputs = DiffusionWeightedVolumeMasking._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/diffusion/tests/test_auto_ResampleDTIVolume.py b/nipype/interfaces/slicer/diffusion/tests/test_auto_ResampleDTIVolume.py index 9f7ded5f1c..9f3b17caf6 100644 --- a/nipype/interfaces/slicer/diffusion/tests/test_auto_ResampleDTIVolume.py +++ b/nipype/interfaces/slicer/diffusion/tests/test_auto_ResampleDTIVolume.py @@ -21,14 +21,8 @@ def test_ResampleDTIVolume_inputs(): direction_matrix=dict(argstr='--direction_matrix %s', sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), hfieldtype=dict(argstr='--hfieldtype %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_center=dict(argstr='--image_center %s', ), inputVolume=dict(argstr='%s', @@ -58,8 +52,6 @@ def test_ResampleDTIVolume_inputs(): ), spline_order=dict(argstr='--spline_order %d', ), - terminal_output=dict(nohash=True, - ), transform=dict(argstr='--transform %s', ), transform_matrix=dict(argstr='--transform_matrix %s', @@ -74,7 +66,7 @@ def test_ResampleDTIVolume_inputs(): window_function=dict(argstr='--window_function %s', ), ) - inputs = ResampleDTIVolume.input_spec() + inputs = ResampleDTIVolume._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -85,7 +77,7 @@ def test_ResampleDTIVolume_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = ResampleDTIVolume.output_spec() + outputs = ResampleDTIVolume._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/diffusion/tests/test_auto_TractographyLabelMapSeeding.py b/nipype/interfaces/slicer/diffusion/tests/test_auto_TractographyLabelMapSeeding.py index f368cc2275..0738ea703a 100644 --- a/nipype/interfaces/slicer/diffusion/tests/test_auto_TractographyLabelMapSeeding.py +++ b/nipype/interfaces/slicer/diffusion/tests/test_auto_TractographyLabelMapSeeding.py @@ -15,12 +15,6 @@ def test_TractographyLabelMapSeeding_inputs(): ), clthreshold=dict(argstr='--clthreshold %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputroi=dict(argstr='--inputroi %s', ), integrationsteplength=dict(argstr='--integrationsteplength %f', @@ -46,14 +40,12 @@ def test_TractographyLabelMapSeeding_inputs(): ), stoppingvalue=dict(argstr='--stoppingvalue %f', ), - terminal_output=dict(nohash=True, - ), useindexspace=dict(argstr='--useindexspace ', ), writetofile=dict(argstr='--writetofile ', ), ) - inputs = TractographyLabelMapSeeding.input_spec() + inputs = TractographyLabelMapSeeding._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -65,7 +57,7 @@ def test_TractographyLabelMapSeeding_outputs(): ), outputdirectory=dict(), ) - outputs = TractographyLabelMapSeeding.output_spec() + outputs = TractographyLabelMapSeeding._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/arithmetic.py b/nipype/interfaces/slicer/filtering/arithmetic.py index cfde7f5d02..9ab44642ab 100644 --- a/nipype/interfaces/slicer/filtering/arithmetic.py +++ b/nipype/interfaces/slicer/filtering/arithmetic.py @@ -34,8 +34,8 @@ class MultiplyScalarVolumes(SEMLikeCommandLine): """ - input_spec = MultiplyScalarVolumesInputSpec - output_spec = MultiplyScalarVolumesOutputSpec + _input_spec = MultiplyScalarVolumesInputSpec + _output_spec = MultiplyScalarVolumesOutputSpec _cmd = "MultiplyScalarVolumes " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -69,8 +69,8 @@ class MaskScalarVolume(SEMLikeCommandLine): """ - input_spec = MaskScalarVolumeInputSpec - output_spec = MaskScalarVolumeOutputSpec + _input_spec = MaskScalarVolumeInputSpec + _output_spec = MaskScalarVolumeOutputSpec _cmd = "MaskScalarVolume " _outputs_filenames = {'OutputVolume': 'OutputVolume.nii'} @@ -103,8 +103,8 @@ class SubtractScalarVolumes(SEMLikeCommandLine): """ - input_spec = SubtractScalarVolumesInputSpec - output_spec = SubtractScalarVolumesOutputSpec + _input_spec = SubtractScalarVolumesInputSpec + _output_spec = SubtractScalarVolumesOutputSpec _cmd = "SubtractScalarVolumes " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -137,8 +137,8 @@ class AddScalarVolumes(SEMLikeCommandLine): """ - input_spec = AddScalarVolumesInputSpec - output_spec = AddScalarVolumesOutputSpec + _input_spec = AddScalarVolumesInputSpec + _output_spec = AddScalarVolumesOutputSpec _cmd = "AddScalarVolumes " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -172,7 +172,7 @@ class CastScalarVolume(SEMLikeCommandLine): """ - input_spec = CastScalarVolumeInputSpec - output_spec = CastScalarVolumeOutputSpec + _input_spec = CastScalarVolumeInputSpec + _output_spec = CastScalarVolumeOutputSpec _cmd = "CastScalarVolume " _outputs_filenames = {'OutputVolume': 'OutputVolume.nii'} diff --git a/nipype/interfaces/slicer/filtering/checkerboardfilter.py b/nipype/interfaces/slicer/filtering/checkerboardfilter.py index 894777bbdf..856cdf9136 100644 --- a/nipype/interfaces/slicer/filtering/checkerboardfilter.py +++ b/nipype/interfaces/slicer/filtering/checkerboardfilter.py @@ -34,7 +34,7 @@ class CheckerBoardFilter(SEMLikeCommandLine): """ - input_spec = CheckerBoardFilterInputSpec - output_spec = CheckerBoardFilterOutputSpec + _input_spec = CheckerBoardFilterInputSpec + _output_spec = CheckerBoardFilterOutputSpec _cmd = "CheckerBoardFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/filtering/denoising.py b/nipype/interfaces/slicer/filtering/denoising.py index 7c506d4839..769cdade8a 100644 --- a/nipype/interfaces/slicer/filtering/denoising.py +++ b/nipype/interfaces/slicer/filtering/denoising.py @@ -37,8 +37,8 @@ class GradientAnisotropicDiffusion(SEMLikeCommandLine): """ - input_spec = GradientAnisotropicDiffusionInputSpec - output_spec = GradientAnisotropicDiffusionOutputSpec + _input_spec = GradientAnisotropicDiffusionInputSpec + _output_spec = GradientAnisotropicDiffusionOutputSpec _cmd = "GradientAnisotropicDiffusion " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -76,8 +76,8 @@ class CurvatureAnisotropicDiffusion(SEMLikeCommandLine): """ - input_spec = CurvatureAnisotropicDiffusionInputSpec - output_spec = CurvatureAnisotropicDiffusionOutputSpec + _input_spec = CurvatureAnisotropicDiffusionInputSpec + _output_spec = CurvatureAnisotropicDiffusionOutputSpec _cmd = "CurvatureAnisotropicDiffusion " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -109,8 +109,8 @@ class GaussianBlurImageFilter(SEMLikeCommandLine): """ - input_spec = GaussianBlurImageFilterInputSpec - output_spec = GaussianBlurImageFilterOutputSpec + _input_spec = GaussianBlurImageFilterInputSpec + _output_spec = GaussianBlurImageFilterOutputSpec _cmd = "GaussianBlurImageFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -142,7 +142,7 @@ class MedianImageFilter(SEMLikeCommandLine): """ - input_spec = MedianImageFilterInputSpec - output_spec = MedianImageFilterOutputSpec + _input_spec = MedianImageFilterInputSpec + _output_spec = MedianImageFilterOutputSpec _cmd = "MedianImageFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/filtering/extractskeleton.py b/nipype/interfaces/slicer/filtering/extractskeleton.py index 0c516850db..bc7e9bdaf2 100644 --- a/nipype/interfaces/slicer/filtering/extractskeleton.py +++ b/nipype/interfaces/slicer/filtering/extractskeleton.py @@ -36,7 +36,7 @@ class ExtractSkeleton(SEMLikeCommandLine): """ - input_spec = ExtractSkeletonInputSpec - output_spec = ExtractSkeletonOutputSpec + _input_spec = ExtractSkeletonInputSpec + _output_spec = ExtractSkeletonOutputSpec _cmd = "ExtractSkeleton " _outputs_filenames = {'OutputImageFileName': 'OutputImageFileName.nii'} diff --git a/nipype/interfaces/slicer/filtering/histogrammatching.py b/nipype/interfaces/slicer/filtering/histogrammatching.py index beaeb044bc..8c5e513109 100644 --- a/nipype/interfaces/slicer/filtering/histogrammatching.py +++ b/nipype/interfaces/slicer/filtering/histogrammatching.py @@ -42,7 +42,7 @@ class HistogramMatching(SEMLikeCommandLine): """ - input_spec = HistogramMatchingInputSpec - output_spec = HistogramMatchingOutputSpec + _input_spec = HistogramMatchingInputSpec + _output_spec = HistogramMatchingOutputSpec _cmd = "HistogramMatching " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/filtering/imagelabelcombine.py b/nipype/interfaces/slicer/filtering/imagelabelcombine.py index 36611de864..d3bc919baa 100644 --- a/nipype/interfaces/slicer/filtering/imagelabelcombine.py +++ b/nipype/interfaces/slicer/filtering/imagelabelcombine.py @@ -32,7 +32,7 @@ class ImageLabelCombine(SEMLikeCommandLine): """ - input_spec = ImageLabelCombineInputSpec - output_spec = ImageLabelCombineOutputSpec + _input_spec = ImageLabelCombineInputSpec + _output_spec = ImageLabelCombineOutputSpec _cmd = "ImageLabelCombine " _outputs_filenames = {'OutputLabelMap': 'OutputLabelMap.nii'} diff --git a/nipype/interfaces/slicer/filtering/morphology.py b/nipype/interfaces/slicer/filtering/morphology.py index 7214828d95..93451b8be0 100644 --- a/nipype/interfaces/slicer/filtering/morphology.py +++ b/nipype/interfaces/slicer/filtering/morphology.py @@ -42,8 +42,8 @@ class GrayscaleGrindPeakImageFilter(SEMLikeCommandLine): """ - input_spec = GrayscaleGrindPeakImageFilterInputSpec - output_spec = GrayscaleGrindPeakImageFilterOutputSpec + _input_spec = GrayscaleGrindPeakImageFilterInputSpec + _output_spec = GrayscaleGrindPeakImageFilterOutputSpec _cmd = "GrayscaleGrindPeakImageFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -82,7 +82,7 @@ class GrayscaleFillHoleImageFilter(SEMLikeCommandLine): """ - input_spec = GrayscaleFillHoleImageFilterInputSpec - output_spec = GrayscaleFillHoleImageFilterOutputSpec + _input_spec = GrayscaleFillHoleImageFilterInputSpec + _output_spec = GrayscaleFillHoleImageFilterOutputSpec _cmd = "GrayscaleFillHoleImageFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/filtering/n4itkbiasfieldcorrection.py b/nipype/interfaces/slicer/filtering/n4itkbiasfieldcorrection.py index b56d4d3af2..4d88ea9232 100644 --- a/nipype/interfaces/slicer/filtering/n4itkbiasfieldcorrection.py +++ b/nipype/interfaces/slicer/filtering/n4itkbiasfieldcorrection.py @@ -43,7 +43,7 @@ class N4ITKBiasFieldCorrection(SEMLikeCommandLine): """ - input_spec = N4ITKBiasFieldCorrectionInputSpec - output_spec = N4ITKBiasFieldCorrectionOutputSpec + _input_spec = N4ITKBiasFieldCorrectionInputSpec + _output_spec = N4ITKBiasFieldCorrectionOutputSpec _cmd = "N4ITKBiasFieldCorrection " _outputs_filenames = {'outputimage': 'outputimage.nii', 'outputbiasfield': 'outputbiasfield.nii'} diff --git a/nipype/interfaces/slicer/filtering/resamplescalarvectordwivolume.py b/nipype/interfaces/slicer/filtering/resamplescalarvectordwivolume.py index b90694118f..1bb4ab7aff 100644 --- a/nipype/interfaces/slicer/filtering/resamplescalarvectordwivolume.py +++ b/nipype/interfaces/slicer/filtering/resamplescalarvectordwivolume.py @@ -58,7 +58,7 @@ class ResampleScalarVectorDWIVolume(SEMLikeCommandLine): """ - input_spec = ResampleScalarVectorDWIVolumeInputSpec - output_spec = ResampleScalarVectorDWIVolumeOutputSpec + _input_spec = ResampleScalarVectorDWIVolumeInputSpec + _output_spec = ResampleScalarVectorDWIVolumeOutputSpec _cmd = "ResampleScalarVectorDWIVolume " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_AddScalarVolumes.py b/nipype/interfaces/slicer/filtering/tests/test_auto_AddScalarVolumes.py index 1b196c557a..1b9c2e3333 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_AddScalarVolumes.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_AddScalarVolumes.py @@ -6,12 +6,6 @@ def test_AddScalarVolumes_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume1=dict(argstr='%s', position=-3, ), @@ -24,10 +18,8 @@ def test_AddScalarVolumes_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = AddScalarVolumes.input_spec() + inputs = AddScalarVolumes._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_AddScalarVolumes_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = AddScalarVolumes.output_spec() + outputs = AddScalarVolumes._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_CastScalarVolume.py b/nipype/interfaces/slicer/filtering/tests/test_auto_CastScalarVolume.py index b24be436f8..d50c7d353c 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_CastScalarVolume.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_CastScalarVolume.py @@ -13,18 +13,10 @@ def test_CastScalarVolume_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - terminal_output=dict(nohash=True, - ), type=dict(argstr='--type %s', ), ) - inputs = CastScalarVolume.input_spec() + inputs = CastScalarVolume._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +27,7 @@ def test_CastScalarVolume_outputs(): output_map = dict(OutputVolume=dict(position=-1, ), ) - outputs = CastScalarVolume.output_spec() + outputs = CastScalarVolume._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_CheckerBoardFilter.py b/nipype/interfaces/slicer/filtering/tests/test_auto_CheckerBoardFilter.py index 2ddf46c861..3a021dd639 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_CheckerBoardFilter.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_CheckerBoardFilter.py @@ -9,12 +9,6 @@ def test_CheckerBoardFilter_inputs(): checkerPattern=dict(argstr='--checkerPattern %s', sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume1=dict(argstr='%s', position=-3, ), @@ -25,10 +19,8 @@ def test_CheckerBoardFilter_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = CheckerBoardFilter.input_spec() + inputs = CheckerBoardFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_CheckerBoardFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = CheckerBoardFilter.output_spec() + outputs = CheckerBoardFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_CurvatureAnisotropicDiffusion.py b/nipype/interfaces/slicer/filtering/tests/test_auto_CurvatureAnisotropicDiffusion.py index c31af700d5..1672914d3a 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_CurvatureAnisotropicDiffusion.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_CurvatureAnisotropicDiffusion.py @@ -8,12 +8,6 @@ def test_CurvatureAnisotropicDiffusion_inputs(): ), conductance=dict(argstr='--conductance %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -23,12 +17,10 @@ def test_CurvatureAnisotropicDiffusion_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), timeStep=dict(argstr='--timeStep %f', ), ) - inputs = CurvatureAnisotropicDiffusion.input_spec() + inputs = CurvatureAnisotropicDiffusion._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_CurvatureAnisotropicDiffusion_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = CurvatureAnisotropicDiffusion.output_spec() + outputs = CurvatureAnisotropicDiffusion._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_ExtractSkeleton.py b/nipype/interfaces/slicer/filtering/tests/test_auto_ExtractSkeleton.py index 05b71f76ec..4600971852 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_ExtractSkeleton.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_ExtractSkeleton.py @@ -15,22 +15,14 @@ def test_ExtractSkeleton_inputs(): ), dontPrune=dict(argstr='--dontPrune ', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), numPoints=dict(argstr='--numPoints %d', ), pointsFile=dict(argstr='--pointsFile %s', ), - terminal_output=dict(nohash=True, - ), type=dict(argstr='--type %s', ), ) - inputs = ExtractSkeleton.input_spec() + inputs = ExtractSkeleton._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +33,7 @@ def test_ExtractSkeleton_outputs(): output_map = dict(OutputImageFileName=dict(position=-1, ), ) - outputs = ExtractSkeleton.output_spec() + outputs = ExtractSkeleton._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_GaussianBlurImageFilter.py b/nipype/interfaces/slicer/filtering/tests/test_auto_GaussianBlurImageFilter.py index d5b2d21589..3da58c4528 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_GaussianBlurImageFilter.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_GaussianBlurImageFilter.py @@ -6,12 +6,6 @@ def test_GaussianBlurImageFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -21,10 +15,8 @@ def test_GaussianBlurImageFilter_inputs(): ), sigma=dict(argstr='--sigma %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = GaussianBlurImageFilter.input_spec() + inputs = GaussianBlurImageFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +27,7 @@ def test_GaussianBlurImageFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = GaussianBlurImageFilter.output_spec() + outputs = GaussianBlurImageFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_GradientAnisotropicDiffusion.py b/nipype/interfaces/slicer/filtering/tests/test_auto_GradientAnisotropicDiffusion.py index c5874901c8..d35c59b987 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_GradientAnisotropicDiffusion.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_GradientAnisotropicDiffusion.py @@ -8,12 +8,6 @@ def test_GradientAnisotropicDiffusion_inputs(): ), conductance=dict(argstr='--conductance %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -23,12 +17,10 @@ def test_GradientAnisotropicDiffusion_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), timeStep=dict(argstr='--timeStep %f', ), ) - inputs = GradientAnisotropicDiffusion.input_spec() + inputs = GradientAnisotropicDiffusion._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_GradientAnisotropicDiffusion_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = GradientAnisotropicDiffusion.output_spec() + outputs = GradientAnisotropicDiffusion._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_GrayscaleFillHoleImageFilter.py b/nipype/interfaces/slicer/filtering/tests/test_auto_GrayscaleFillHoleImageFilter.py index 794f2833ee..ef630583d7 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_GrayscaleFillHoleImageFilter.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_GrayscaleFillHoleImageFilter.py @@ -6,12 +6,6 @@ def test_GrayscaleFillHoleImageFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -19,10 +13,8 @@ def test_GrayscaleFillHoleImageFilter_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = GrayscaleFillHoleImageFilter.input_spec() + inputs = GrayscaleFillHoleImageFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -33,7 +25,7 @@ def test_GrayscaleFillHoleImageFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = GrayscaleFillHoleImageFilter.output_spec() + outputs = GrayscaleFillHoleImageFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_GrayscaleGrindPeakImageFilter.py b/nipype/interfaces/slicer/filtering/tests/test_auto_GrayscaleGrindPeakImageFilter.py index 3bcfd4145c..2656bbd242 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_GrayscaleGrindPeakImageFilter.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_GrayscaleGrindPeakImageFilter.py @@ -6,12 +6,6 @@ def test_GrayscaleGrindPeakImageFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -19,10 +13,8 @@ def test_GrayscaleGrindPeakImageFilter_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = GrayscaleGrindPeakImageFilter.input_spec() + inputs = GrayscaleGrindPeakImageFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -33,7 +25,7 @@ def test_GrayscaleGrindPeakImageFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = GrayscaleGrindPeakImageFilter.output_spec() + outputs = GrayscaleGrindPeakImageFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_HistogramMatching.py b/nipype/interfaces/slicer/filtering/tests/test_auto_HistogramMatching.py index 2d4e23c33e..59fb5cb682 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_HistogramMatching.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_HistogramMatching.py @@ -6,12 +6,6 @@ def test_HistogramMatching_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-3, ), @@ -26,12 +20,10 @@ def test_HistogramMatching_inputs(): referenceVolume=dict(argstr='%s', position=-2, ), - terminal_output=dict(nohash=True, - ), threshold=dict(argstr='--threshold ', ), ) - inputs = HistogramMatching.input_spec() + inputs = HistogramMatching._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_HistogramMatching_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = HistogramMatching.output_spec() + outputs = HistogramMatching._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_ImageLabelCombine.py b/nipype/interfaces/slicer/filtering/tests/test_auto_ImageLabelCombine.py index a02b922e86..e5796c6a90 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_ImageLabelCombine.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_ImageLabelCombine.py @@ -16,18 +16,10 @@ def test_ImageLabelCombine_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), first_overwrites=dict(argstr='--first_overwrites ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - terminal_output=dict(nohash=True, - ), ) - inputs = ImageLabelCombine.input_spec() + inputs = ImageLabelCombine._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_ImageLabelCombine_outputs(): output_map = dict(OutputLabelMap=dict(position=-1, ), ) - outputs = ImageLabelCombine.output_spec() + outputs = ImageLabelCombine._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_MaskScalarVolume.py b/nipype/interfaces/slicer/filtering/tests/test_auto_MaskScalarVolume.py index a627bae20e..c3e95526b2 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_MaskScalarVolume.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_MaskScalarVolume.py @@ -16,20 +16,12 @@ def test_MaskScalarVolume_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), label=dict(argstr='--label %d', ), replace=dict(argstr='--replace %d', ), - terminal_output=dict(nohash=True, - ), ) - inputs = MaskScalarVolume.input_spec() + inputs = MaskScalarVolume._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_MaskScalarVolume_outputs(): output_map = dict(OutputVolume=dict(position=-1, ), ) - outputs = MaskScalarVolume.output_spec() + outputs = MaskScalarVolume._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_MedianImageFilter.py b/nipype/interfaces/slicer/filtering/tests/test_auto_MedianImageFilter.py index d8f3489fcd..a807b91c2d 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_MedianImageFilter.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_MedianImageFilter.py @@ -6,12 +6,6 @@ def test_MedianImageFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -22,10 +16,8 @@ def test_MedianImageFilter_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = MedianImageFilter.input_spec() + inputs = MedianImageFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_MedianImageFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = MedianImageFilter.output_spec() + outputs = MedianImageFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_MultiplyScalarVolumes.py b/nipype/interfaces/slicer/filtering/tests/test_auto_MultiplyScalarVolumes.py index d1038d8001..1e9c7dd114 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_MultiplyScalarVolumes.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_MultiplyScalarVolumes.py @@ -6,12 +6,6 @@ def test_MultiplyScalarVolumes_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume1=dict(argstr='%s', position=-3, ), @@ -24,10 +18,8 @@ def test_MultiplyScalarVolumes_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = MultiplyScalarVolumes.input_spec() + inputs = MultiplyScalarVolumes._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_MultiplyScalarVolumes_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = MultiplyScalarVolumes.output_spec() + outputs = MultiplyScalarVolumes._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_N4ITKBiasFieldCorrection.py b/nipype/interfaces/slicer/filtering/tests/test_auto_N4ITKBiasFieldCorrection.py index 9e1b7df801..fbbce40ad5 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_N4ITKBiasFieldCorrection.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_N4ITKBiasFieldCorrection.py @@ -10,15 +10,9 @@ def test_N4ITKBiasFieldCorrection_inputs(): ), convergencethreshold=dict(argstr='--convergencethreshold %f', ), - environ=dict(nohash=True, - usedefault=True, - ), histogramsharpening=dict(argstr='--histogramsharpening %s', sep=',', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputimage=dict(argstr='--inputimage %s', ), iterations=dict(argstr='--iterations %s', @@ -39,12 +33,10 @@ def test_N4ITKBiasFieldCorrection_inputs(): ), splinedistance=dict(argstr='--splinedistance %f', ), - terminal_output=dict(nohash=True, - ), weightimage=dict(argstr='--weightimage %s', ), ) - inputs = N4ITKBiasFieldCorrection.input_spec() + inputs = N4ITKBiasFieldCorrection._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -55,7 +47,7 @@ def test_N4ITKBiasFieldCorrection_outputs(): output_map = dict(outputbiasfield=dict(), outputimage=dict(), ) - outputs = N4ITKBiasFieldCorrection.output_spec() + outputs = N4ITKBiasFieldCorrection._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_ResampleScalarVectorDWIVolume.py b/nipype/interfaces/slicer/filtering/tests/test_auto_ResampleScalarVectorDWIVolume.py index 363dfe4747..68eee6f8f3 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_ResampleScalarVectorDWIVolume.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_ResampleScalarVectorDWIVolume.py @@ -19,14 +19,8 @@ def test_ResampleScalarVectorDWIVolume_inputs(): direction_matrix=dict(argstr='--direction_matrix %s', sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), hfieldtype=dict(argstr='--hfieldtype %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_center=dict(argstr='--image_center %s', ), inputVolume=dict(argstr='%s', @@ -56,8 +50,6 @@ def test_ResampleScalarVectorDWIVolume_inputs(): ), spline_order=dict(argstr='--spline_order %d', ), - terminal_output=dict(nohash=True, - ), transform=dict(argstr='--transform %s', ), transform_matrix=dict(argstr='--transform_matrix %s', @@ -70,7 +62,7 @@ def test_ResampleScalarVectorDWIVolume_inputs(): window_function=dict(argstr='--window_function %s', ), ) - inputs = ResampleScalarVectorDWIVolume.input_spec() + inputs = ResampleScalarVectorDWIVolume._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -81,7 +73,7 @@ def test_ResampleScalarVectorDWIVolume_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = ResampleScalarVectorDWIVolume.output_spec() + outputs = ResampleScalarVectorDWIVolume._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_SubtractScalarVolumes.py b/nipype/interfaces/slicer/filtering/tests/test_auto_SubtractScalarVolumes.py index c95b4de042..9141acff1c 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_SubtractScalarVolumes.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_SubtractScalarVolumes.py @@ -6,12 +6,6 @@ def test_SubtractScalarVolumes_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume1=dict(argstr='%s', position=-3, ), @@ -24,10 +18,8 @@ def test_SubtractScalarVolumes_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = SubtractScalarVolumes.input_spec() + inputs = SubtractScalarVolumes._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_SubtractScalarVolumes_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = SubtractScalarVolumes.output_spec() + outputs = SubtractScalarVolumes._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_ThresholdScalarVolume.py b/nipype/interfaces/slicer/filtering/tests/test_auto_ThresholdScalarVolume.py index a4f6d0f64a..e9e4bc7c9b 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_ThresholdScalarVolume.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_ThresholdScalarVolume.py @@ -13,18 +13,10 @@ def test_ThresholdScalarVolume_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), lower=dict(argstr='--lower %d', ), outsidevalue=dict(argstr='--outsidevalue %d', ), - terminal_output=dict(nohash=True, - ), threshold=dict(argstr='--threshold %d', ), thresholdtype=dict(argstr='--thresholdtype %s', @@ -32,7 +24,7 @@ def test_ThresholdScalarVolume_inputs(): upper=dict(argstr='--upper %d', ), ) - inputs = ThresholdScalarVolume.input_spec() + inputs = ThresholdScalarVolume._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +35,7 @@ def test_ThresholdScalarVolume_outputs(): output_map = dict(OutputVolume=dict(position=-1, ), ) - outputs = ThresholdScalarVolume.output_spec() + outputs = ThresholdScalarVolume._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/tests/test_auto_VotingBinaryHoleFillingImageFilter.py b/nipype/interfaces/slicer/filtering/tests/test_auto_VotingBinaryHoleFillingImageFilter.py index 5c213925e0..61fd1ee5b6 100644 --- a/nipype/interfaces/slicer/filtering/tests/test_auto_VotingBinaryHoleFillingImageFilter.py +++ b/nipype/interfaces/slicer/filtering/tests/test_auto_VotingBinaryHoleFillingImageFilter.py @@ -8,14 +8,8 @@ def test_VotingBinaryHoleFillingImageFilter_inputs(): ), background=dict(argstr='--background %d', ), - environ=dict(nohash=True, - usedefault=True, - ), foreground=dict(argstr='--foreground %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -28,10 +22,8 @@ def test_VotingBinaryHoleFillingImageFilter_inputs(): radius=dict(argstr='--radius %s', sep=',', ), - terminal_output=dict(nohash=True, - ), ) - inputs = VotingBinaryHoleFillingImageFilter.input_spec() + inputs = VotingBinaryHoleFillingImageFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -42,7 +34,7 @@ def test_VotingBinaryHoleFillingImageFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = VotingBinaryHoleFillingImageFilter.output_spec() + outputs = VotingBinaryHoleFillingImageFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/filtering/thresholdscalarvolume.py b/nipype/interfaces/slicer/filtering/thresholdscalarvolume.py index 63e7e5a7b7..0c045b56f7 100644 --- a/nipype/interfaces/slicer/filtering/thresholdscalarvolume.py +++ b/nipype/interfaces/slicer/filtering/thresholdscalarvolume.py @@ -37,7 +37,7 @@ class ThresholdScalarVolume(SEMLikeCommandLine): """ - input_spec = ThresholdScalarVolumeInputSpec - output_spec = ThresholdScalarVolumeOutputSpec + _input_spec = ThresholdScalarVolumeInputSpec + _output_spec = ThresholdScalarVolumeOutputSpec _cmd = "ThresholdScalarVolume " _outputs_filenames = {'OutputVolume': 'OutputVolume.nii'} diff --git a/nipype/interfaces/slicer/filtering/votingbinaryholefillingimagefilter.py b/nipype/interfaces/slicer/filtering/votingbinaryholefillingimagefilter.py index 5dd42d9437..829956e8f1 100644 --- a/nipype/interfaces/slicer/filtering/votingbinaryholefillingimagefilter.py +++ b/nipype/interfaces/slicer/filtering/votingbinaryholefillingimagefilter.py @@ -36,7 +36,7 @@ class VotingBinaryHoleFillingImageFilter(SEMLikeCommandLine): """ - input_spec = VotingBinaryHoleFillingImageFilterInputSpec - output_spec = VotingBinaryHoleFillingImageFilterOutputSpec + _input_spec = VotingBinaryHoleFillingImageFilterInputSpec + _output_spec = VotingBinaryHoleFillingImageFilterOutputSpec _cmd = "VotingBinaryHoleFillingImageFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/generate_classes.py b/nipype/interfaces/slicer/generate_classes.py index 46b85af86a..7843a21f07 100644 --- a/nipype/interfaces/slicer/generate_classes.py +++ b/nipype/interfaces/slicer/generate_classes.py @@ -281,37 +281,37 @@ def generate_class(module, launcher, strip_module_name_prefix=True, redirect_x=F 'xMaxProcess = traits.Int(1, desc="Set default maximum number of processes.", argstr="-xMaxProcess %d", usedefault=True)'] inputTraits += compulsory_inputs - input_spec_code = "class " + module_name + "InputSpec(CommandLineInputSpec):\n" + _input_spec_code = "class " + module_name + "InputSpec(CommandLineInputSpec):\n" for trait in inputTraits: - input_spec_code += " " + trait + "\n" + _input_spec_code += " " + trait + "\n" - output_spec_code = "class " + module_name + "OutputSpec(TraitedSpec):\n" + _output_spec_code = "class " + module_name + "OutputSpec(TraitedSpec):\n" if not outputTraits: - output_spec_code += " pass\n" + _output_spec_code += " pass\n" else: for trait in outputTraits: - output_spec_code += " " + trait + "\n" + _output_spec_code += " " + trait + "\n" output_filenames_code = "_outputs_filenames = {" output_filenames_code += ",".join(["'%s':'%s'" % ( key, value) for key, value in outputs_filenames.items()]) output_filenames_code += "}" - input_spec_code += "\n\n" - output_spec_code += "\n\n" + _input_spec_code += "\n\n" + _output_spec_code += "\n\n" template = """class %module_name%(SEMLikeCommandLine): %class_str% - input_spec = %module_name%InputSpec - output_spec = %module_name%OutputSpec + _input_spec = %module_name%InputSpec + _output_spec = %module_name%OutputSpec _cmd = "%launcher% %name% " %output_filenames_code%\n""" template += " _redirect_x = {0}\n".format(str(redirect_x)) main_class = template.replace('%class_str%', class_string).replace("%module_name%", module_name).replace("%name%", module).replace("%output_filenames_code%", output_filenames_code).replace("%launcher%", " ".join(launcher)) - return category, input_spec_code + output_spec_code + main_class, module_name + return category, _input_spec_code + _output_spec_code + main_class, module_name def grab_xml(module, launcher, mipav_hacks=False): diff --git a/nipype/interfaces/slicer/legacy/converters.py b/nipype/interfaces/slicer/legacy/converters.py index fd1817c06f..84b70cbd65 100644 --- a/nipype/interfaces/slicer/legacy/converters.py +++ b/nipype/interfaces/slicer/legacy/converters.py @@ -33,7 +33,7 @@ class BSplineToDeformationField(SEMLikeCommandLine): """ - input_spec = BSplineToDeformationFieldInputSpec - output_spec = BSplineToDeformationFieldOutputSpec + _input_spec = BSplineToDeformationFieldInputSpec + _output_spec = BSplineToDeformationFieldOutputSpec _cmd = "BSplineToDeformationField " _outputs_filenames = {'defImage': 'defImage.nii'} diff --git a/nipype/interfaces/slicer/legacy/diffusion/denoising.py b/nipype/interfaces/slicer/legacy/diffusion/denoising.py index bbec5f7d9b..4c2da7d88a 100644 --- a/nipype/interfaces/slicer/legacy/diffusion/denoising.py +++ b/nipype/interfaces/slicer/legacy/diffusion/denoising.py @@ -41,7 +41,7 @@ class DWIUnbiasedNonLocalMeansFilter(SEMLikeCommandLine): """ - input_spec = DWIUnbiasedNonLocalMeansFilterInputSpec - output_spec = DWIUnbiasedNonLocalMeansFilterOutputSpec + _input_spec = DWIUnbiasedNonLocalMeansFilterInputSpec + _output_spec = DWIUnbiasedNonLocalMeansFilterOutputSpec _cmd = "DWIUnbiasedNonLocalMeansFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/legacy/diffusion/tests/test_auto_DWIUnbiasedNonLocalMeansFilter.py b/nipype/interfaces/slicer/legacy/diffusion/tests/test_auto_DWIUnbiasedNonLocalMeansFilter.py index 3f9c41c416..a767389d39 100644 --- a/nipype/interfaces/slicer/legacy/diffusion/tests/test_auto_DWIUnbiasedNonLocalMeansFilter.py +++ b/nipype/interfaces/slicer/legacy/diffusion/tests/test_auto_DWIUnbiasedNonLocalMeansFilter.py @@ -6,14 +6,8 @@ def test_DWIUnbiasedNonLocalMeansFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), hp=dict(argstr='--hp %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -32,10 +26,8 @@ def test_DWIUnbiasedNonLocalMeansFilter_inputs(): rs=dict(argstr='--rs %s', sep=',', ), - terminal_output=dict(nohash=True, - ), ) - inputs = DWIUnbiasedNonLocalMeansFilter.input_spec() + inputs = DWIUnbiasedNonLocalMeansFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +38,7 @@ def test_DWIUnbiasedNonLocalMeansFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = DWIUnbiasedNonLocalMeansFilter.output_spec() + outputs = DWIUnbiasedNonLocalMeansFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/filtering.py b/nipype/interfaces/slicer/legacy/filtering.py index b6684d2d64..930f655d0f 100644 --- a/nipype/interfaces/slicer/legacy/filtering.py +++ b/nipype/interfaces/slicer/legacy/filtering.py @@ -39,8 +39,8 @@ class OtsuThresholdImageFilter(SEMLikeCommandLine): """ - input_spec = OtsuThresholdImageFilterInputSpec - output_spec = OtsuThresholdImageFilterOutputSpec + _input_spec = OtsuThresholdImageFilterInputSpec + _output_spec = OtsuThresholdImageFilterOutputSpec _cmd = "OtsuThresholdImageFilter " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -73,7 +73,7 @@ class ResampleScalarVolume(SEMLikeCommandLine): """ - input_spec = ResampleScalarVolumeInputSpec - output_spec = ResampleScalarVolumeOutputSpec + _input_spec = ResampleScalarVolumeInputSpec + _output_spec = ResampleScalarVolumeOutputSpec _cmd = "ResampleScalarVolume " _outputs_filenames = {'OutputVolume': 'OutputVolume.nii'} diff --git a/nipype/interfaces/slicer/legacy/registration.py b/nipype/interfaces/slicer/legacy/registration.py index 5ba5baf3f5..41005f2c2f 100644 --- a/nipype/interfaces/slicer/legacy/registration.py +++ b/nipype/interfaces/slicer/legacy/registration.py @@ -45,8 +45,8 @@ class BSplineDeformableRegistration(SEMLikeCommandLine): """ - input_spec = BSplineDeformableRegistrationInputSpec - output_spec = BSplineDeformableRegistrationOutputSpec + _input_spec = BSplineDeformableRegistrationInputSpec + _output_spec = BSplineDeformableRegistrationOutputSpec _cmd = "BSplineDeformableRegistration " _outputs_filenames = {'resampledmovingfilename': 'resampledmovingfilename.nii', 'outputtransform': 'outputtransform.txt', 'outputwarp': 'outputwarp.nrrd'} @@ -93,8 +93,8 @@ class AffineRegistration(SEMLikeCommandLine): """ - input_spec = AffineRegistrationInputSpec - output_spec = AffineRegistrationOutputSpec + _input_spec = AffineRegistrationInputSpec + _output_spec = AffineRegistrationOutputSpec _cmd = "AffineRegistration " _outputs_filenames = {'resampledmovingfilename': 'resampledmovingfilename.nii', 'outputtransform': 'outputtransform.txt'} @@ -135,8 +135,8 @@ class MultiResolutionAffineRegistration(SEMLikeCommandLine): """ - input_spec = MultiResolutionAffineRegistrationInputSpec - output_spec = MultiResolutionAffineRegistrationOutputSpec + _input_spec = MultiResolutionAffineRegistrationInputSpec + _output_spec = MultiResolutionAffineRegistrationOutputSpec _cmd = "MultiResolutionAffineRegistration " _outputs_filenames = {'resampledImage': 'resampledImage.nii', 'saveTransform': 'saveTransform.txt'} @@ -189,8 +189,8 @@ class RigidRegistration(SEMLikeCommandLine): """ - input_spec = RigidRegistrationInputSpec - output_spec = RigidRegistrationOutputSpec + _input_spec = RigidRegistrationInputSpec + _output_spec = RigidRegistrationOutputSpec _cmd = "RigidRegistration " _outputs_filenames = {'resampledmovingfilename': 'resampledmovingfilename.nii', 'outputtransform': 'outputtransform.txt'} @@ -232,8 +232,8 @@ class LinearRegistration(SEMLikeCommandLine): """ - input_spec = LinearRegistrationInputSpec - output_spec = LinearRegistrationOutputSpec + _input_spec = LinearRegistrationInputSpec + _output_spec = LinearRegistrationOutputSpec _cmd = "LinearRegistration " _outputs_filenames = {'resampledmovingfilename': 'resampledmovingfilename.nii', 'outputtransform': 'outputtransform.txt'} @@ -291,7 +291,7 @@ class ExpertAutomatedRegistration(SEMLikeCommandLine): """ - input_spec = ExpertAutomatedRegistrationInputSpec - output_spec = ExpertAutomatedRegistrationOutputSpec + _input_spec = ExpertAutomatedRegistrationInputSpec + _output_spec = ExpertAutomatedRegistrationOutputSpec _cmd = "ExpertAutomatedRegistration " _outputs_filenames = {'resampledImage': 'resampledImage.nii', 'saveTransform': 'saveTransform.txt'} diff --git a/nipype/interfaces/slicer/legacy/segmentation.py b/nipype/interfaces/slicer/legacy/segmentation.py index af724c9f96..dc85fcaaac 100644 --- a/nipype/interfaces/slicer/legacy/segmentation.py +++ b/nipype/interfaces/slicer/legacy/segmentation.py @@ -36,7 +36,7 @@ class OtsuThresholdSegmentation(SEMLikeCommandLine): """ - input_spec = OtsuThresholdSegmentationInputSpec - output_spec = OtsuThresholdSegmentationOutputSpec + _input_spec = OtsuThresholdSegmentationInputSpec + _output_spec = OtsuThresholdSegmentationOutputSpec _cmd = "OtsuThresholdSegmentation " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_AffineRegistration.py b/nipype/interfaces/slicer/legacy/tests/test_auto_AffineRegistration.py index bb46ea5f58..8eb0a55d05 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_AffineRegistration.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_AffineRegistration.py @@ -12,16 +12,10 @@ def test_AffineRegistration_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedsmoothingfactor=dict(argstr='--fixedsmoothingfactor %d', ), histogrambins=dict(argstr='--histogrambins %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initialtransform=dict(argstr='--initialtransform %s', ), iterations=dict(argstr='--iterations %d', @@ -36,12 +30,10 @@ def test_AffineRegistration_inputs(): ), spatialsamples=dict(argstr='--spatialsamples %d', ), - terminal_output=dict(nohash=True, - ), translationscale=dict(argstr='--translationscale %f', ), ) - inputs = AffineRegistration.input_spec() + inputs = AffineRegistration._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_AffineRegistration_outputs(): output_map = dict(outputtransform=dict(), resampledmovingfilename=dict(), ) - outputs = AffineRegistration.output_spec() + outputs = AffineRegistration._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_BSplineDeformableRegistration.py b/nipype/interfaces/slicer/legacy/tests/test_auto_BSplineDeformableRegistration.py index 761a605c75..27a7804951 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_BSplineDeformableRegistration.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_BSplineDeformableRegistration.py @@ -16,16 +16,10 @@ def test_BSplineDeformableRegistration_inputs(): ), default=dict(argstr='--default %d', ), - environ=dict(nohash=True, - usedefault=True, - ), gridSize=dict(argstr='--gridSize %d', ), histogrambins=dict(argstr='--histogrambins %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initialtransform=dict(argstr='--initialtransform %s', ), iterations=dict(argstr='--iterations %d', @@ -43,10 +37,8 @@ def test_BSplineDeformableRegistration_inputs(): ), spatialsamples=dict(argstr='--spatialsamples %d', ), - terminal_output=dict(nohash=True, - ), ) - inputs = BSplineDeformableRegistration.input_spec() + inputs = BSplineDeformableRegistration._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +50,7 @@ def test_BSplineDeformableRegistration_outputs(): outputwarp=dict(), resampledmovingfilename=dict(), ) - outputs = BSplineDeformableRegistration.output_spec() + outputs = BSplineDeformableRegistration._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_BSplineToDeformationField.py b/nipype/interfaces/slicer/legacy/tests/test_auto_BSplineToDeformationField.py index 84173d2341..550567ed02 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_BSplineToDeformationField.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_BSplineToDeformationField.py @@ -9,20 +9,12 @@ def test_BSplineToDeformationField_inputs(): defImage=dict(argstr='--defImage %s', hash_files=False, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), refImage=dict(argstr='--refImage %s', ), - terminal_output=dict(nohash=True, - ), tfm=dict(argstr='--tfm %s', ), ) - inputs = BSplineToDeformationField.input_spec() + inputs = BSplineToDeformationField._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +24,7 @@ def test_BSplineToDeformationField_inputs(): def test_BSplineToDeformationField_outputs(): output_map = dict(defImage=dict(), ) - outputs = BSplineToDeformationField.output_spec() + outputs = BSplineToDeformationField._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_ExpertAutomatedRegistration.py b/nipype/interfaces/slicer/legacy/tests/test_auto_ExpertAutomatedRegistration.py index e0e4c5d7eb..81b2af4c43 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_ExpertAutomatedRegistration.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_ExpertAutomatedRegistration.py @@ -16,9 +16,6 @@ def test_ExpertAutomatedRegistration_inputs(): ), controlPointSpacing=dict(argstr='--controlPointSpacing %d', ), - environ=dict(nohash=True, - usedefault=True, - ), expectedOffset=dict(argstr='--expectedOffset %f', ), expectedRotation=dict(argstr='--expectedRotation %f', @@ -34,9 +31,6 @@ def test_ExpertAutomatedRegistration_inputs(): ), fixedLandmarks=dict(argstr='--fixedLandmarks %s...', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initialization=dict(argstr='--initialization %s', ), interpolation=dict(argstr='--interpolation %s', @@ -70,12 +64,10 @@ def test_ExpertAutomatedRegistration_inputs(): saveTransform=dict(argstr='--saveTransform %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), verbosityLevel=dict(argstr='--verbosityLevel %s', ), ) - inputs = ExpertAutomatedRegistration.input_spec() + inputs = ExpertAutomatedRegistration._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -86,7 +78,7 @@ def test_ExpertAutomatedRegistration_outputs(): output_map = dict(resampledImage=dict(), saveTransform=dict(), ) - outputs = ExpertAutomatedRegistration.output_spec() + outputs = ExpertAutomatedRegistration._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_LinearRegistration.py b/nipype/interfaces/slicer/legacy/tests/test_auto_LinearRegistration.py index 2945019abe..f0d0b13eb1 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_LinearRegistration.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_LinearRegistration.py @@ -12,16 +12,10 @@ def test_LinearRegistration_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedsmoothingfactor=dict(argstr='--fixedsmoothingfactor %d', ), histogrambins=dict(argstr='--histogrambins %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initialtransform=dict(argstr='--initialtransform %s', ), iterations=dict(argstr='--iterations %s', @@ -40,12 +34,10 @@ def test_LinearRegistration_inputs(): ), spatialsamples=dict(argstr='--spatialsamples %d', ), - terminal_output=dict(nohash=True, - ), translationscale=dict(argstr='--translationscale %f', ), ) - inputs = LinearRegistration.input_spec() + inputs = LinearRegistration._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -56,7 +48,7 @@ def test_LinearRegistration_outputs(): output_map = dict(outputtransform=dict(), resampledmovingfilename=dict(), ) - outputs = LinearRegistration.output_spec() + outputs = LinearRegistration._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_MultiResolutionAffineRegistration.py b/nipype/interfaces/slicer/legacy/tests/test_auto_MultiResolutionAffineRegistration.py index b8ea765938..b73c01fda7 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_MultiResolutionAffineRegistration.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_MultiResolutionAffineRegistration.py @@ -6,9 +6,6 @@ def test_MultiResolutionAffineRegistration_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedImage=dict(argstr='%s', position=-2, ), @@ -16,9 +13,6 @@ def test_MultiResolutionAffineRegistration_inputs(): ), fixedImageROI=dict(argstr='--fixedImageROI %s', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), metricTolerance=dict(argstr='--metricTolerance %f', ), movingImage=dict(argstr='%s', @@ -38,10 +32,8 @@ def test_MultiResolutionAffineRegistration_inputs(): ), stepTolerance=dict(argstr='--stepTolerance %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = MultiResolutionAffineRegistration.input_spec() + inputs = MultiResolutionAffineRegistration._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -52,7 +44,7 @@ def test_MultiResolutionAffineRegistration_outputs(): output_map = dict(resampledImage=dict(), saveTransform=dict(), ) - outputs = MultiResolutionAffineRegistration.output_spec() + outputs = MultiResolutionAffineRegistration._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_OtsuThresholdImageFilter.py b/nipype/interfaces/slicer/legacy/tests/test_auto_OtsuThresholdImageFilter.py index 0f4c9e3050..92a35d995e 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_OtsuThresholdImageFilter.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_OtsuThresholdImageFilter.py @@ -6,12 +6,6 @@ def test_OtsuThresholdImageFilter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -25,10 +19,8 @@ def test_OtsuThresholdImageFilter_inputs(): ), outsideValue=dict(argstr='--outsideValue %d', ), - terminal_output=dict(nohash=True, - ), ) - inputs = OtsuThresholdImageFilter.input_spec() + inputs = OtsuThresholdImageFilter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_OtsuThresholdImageFilter_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = OtsuThresholdImageFilter.output_spec() + outputs = OtsuThresholdImageFilter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_OtsuThresholdSegmentation.py b/nipype/interfaces/slicer/legacy/tests/test_auto_OtsuThresholdSegmentation.py index 29f00b8e5f..a8c9abfecd 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_OtsuThresholdSegmentation.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_OtsuThresholdSegmentation.py @@ -8,14 +8,8 @@ def test_OtsuThresholdSegmentation_inputs(): ), brightObjects=dict(argstr='--brightObjects ', ), - environ=dict(nohash=True, - usedefault=True, - ), faceConnected=dict(argstr='--faceConnected ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -27,10 +21,8 @@ def test_OtsuThresholdSegmentation_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = OtsuThresholdSegmentation.input_spec() + inputs = OtsuThresholdSegmentation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +33,7 @@ def test_OtsuThresholdSegmentation_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = OtsuThresholdSegmentation.output_spec() + outputs = OtsuThresholdSegmentation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_ResampleScalarVolume.py b/nipype/interfaces/slicer/legacy/tests/test_auto_ResampleScalarVolume.py index 617ea6a3df..56f321520e 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_ResampleScalarVolume.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_ResampleScalarVolume.py @@ -13,21 +13,13 @@ def test_ResampleScalarVolume_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), interpolation=dict(argstr='--interpolation %s', ), spacing=dict(argstr='--spacing %s', sep=',', ), - terminal_output=dict(nohash=True, - ), ) - inputs = ResampleScalarVolume.input_spec() + inputs = ResampleScalarVolume._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_ResampleScalarVolume_outputs(): output_map = dict(OutputVolume=dict(position=-1, ), ) - outputs = ResampleScalarVolume.output_spec() + outputs = ResampleScalarVolume._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/legacy/tests/test_auto_RigidRegistration.py b/nipype/interfaces/slicer/legacy/tests/test_auto_RigidRegistration.py index a721fd9401..ffd784ae05 100644 --- a/nipype/interfaces/slicer/legacy/tests/test_auto_RigidRegistration.py +++ b/nipype/interfaces/slicer/legacy/tests/test_auto_RigidRegistration.py @@ -12,16 +12,10 @@ def test_RigidRegistration_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedsmoothingfactor=dict(argstr='--fixedsmoothingfactor %d', ), histogrambins=dict(argstr='--histogrambins %d', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initialtransform=dict(argstr='--initialtransform %s', ), iterations=dict(argstr='--iterations %s', @@ -40,14 +34,12 @@ def test_RigidRegistration_inputs(): ), spatialsamples=dict(argstr='--spatialsamples %d', ), - terminal_output=dict(nohash=True, - ), testingmode=dict(argstr='--testingmode ', ), translationscale=dict(argstr='--translationscale %f', ), ) - inputs = RigidRegistration.input_spec() + inputs = RigidRegistration._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +50,7 @@ def test_RigidRegistration_outputs(): output_map = dict(outputtransform=dict(), resampledmovingfilename=dict(), ) - outputs = RigidRegistration.output_spec() + outputs = RigidRegistration._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/quantification/changequantification.py b/nipype/interfaces/slicer/quantification/changequantification.py index f5225065e2..3d174bf618 100644 --- a/nipype/interfaces/slicer/quantification/changequantification.py +++ b/nipype/interfaces/slicer/quantification/changequantification.py @@ -43,7 +43,7 @@ class IntensityDifferenceMetric(SEMLikeCommandLine): """ - input_spec = IntensityDifferenceMetricInputSpec - output_spec = IntensityDifferenceMetricOutputSpec + _input_spec = IntensityDifferenceMetricInputSpec + _output_spec = IntensityDifferenceMetricOutputSpec _cmd = "IntensityDifferenceMetric " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'reportFileName': 'reportFileName'} diff --git a/nipype/interfaces/slicer/quantification/petstandarduptakevaluecomputation.py b/nipype/interfaces/slicer/quantification/petstandarduptakevaluecomputation.py index 8dfe67b546..c83ae2724e 100644 --- a/nipype/interfaces/slicer/quantification/petstandarduptakevaluecomputation.py +++ b/nipype/interfaces/slicer/quantification/petstandarduptakevaluecomputation.py @@ -40,7 +40,7 @@ class PETStandardUptakeValueComputation(SEMLikeCommandLine): """ - input_spec = PETStandardUptakeValueComputationInputSpec - output_spec = PETStandardUptakeValueComputationOutputSpec + _input_spec = PETStandardUptakeValueComputationInputSpec + _output_spec = PETStandardUptakeValueComputationOutputSpec _cmd = "PETStandardUptakeValueComputation " _outputs_filenames = {'csvFile': 'csvFile.csv'} diff --git a/nipype/interfaces/slicer/quantification/tests/test_auto_IntensityDifferenceMetric.py b/nipype/interfaces/slicer/quantification/tests/test_auto_IntensityDifferenceMetric.py index bcc651a10c..cd1a3f217c 100644 --- a/nipype/interfaces/slicer/quantification/tests/test_auto_IntensityDifferenceMetric.py +++ b/nipype/interfaces/slicer/quantification/tests/test_auto_IntensityDifferenceMetric.py @@ -14,15 +14,9 @@ def test_IntensityDifferenceMetric_inputs(): ), changingBandSize=dict(argstr='--changingBandSize %d', ), - environ=dict(nohash=True, - usedefault=True, - ), followupVolume=dict(argstr='%s', position=-2, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), outputVolume=dict(argstr='%s', hash_files=False, position=-1, @@ -32,10 +26,8 @@ def test_IntensityDifferenceMetric_inputs(): ), sensitivityThreshold=dict(argstr='--sensitivityThreshold %f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = IntensityDifferenceMetric.input_spec() + inputs = IntensityDifferenceMetric._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_IntensityDifferenceMetric_outputs(): ), reportFileName=dict(), ) - outputs = IntensityDifferenceMetric.output_spec() + outputs = IntensityDifferenceMetric._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/quantification/tests/test_auto_PETStandardUptakeValueComputation.py b/nipype/interfaces/slicer/quantification/tests/test_auto_PETStandardUptakeValueComputation.py index 9794302982..bea58bbb79 100644 --- a/nipype/interfaces/slicer/quantification/tests/test_auto_PETStandardUptakeValueComputation.py +++ b/nipype/interfaces/slicer/quantification/tests/test_auto_PETStandardUptakeValueComputation.py @@ -21,22 +21,14 @@ def test_PETStandardUptakeValueComputation_inputs(): csvFile=dict(argstr='--csvFile %s', hash_files=False, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), labelMap=dict(argstr='--labelMap %s', ), petDICOMPath=dict(argstr='--petDICOMPath %s', ), petVolume=dict(argstr='--petVolume %s', ), - terminal_output=dict(nohash=True, - ), ) - inputs = PETStandardUptakeValueComputation.input_spec() + inputs = PETStandardUptakeValueComputation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +38,7 @@ def test_PETStandardUptakeValueComputation_inputs(): def test_PETStandardUptakeValueComputation_outputs(): output_map = dict(csvFile=dict(), ) - outputs = PETStandardUptakeValueComputation.output_spec() + outputs = PETStandardUptakeValueComputation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/registration/brainsfit.py b/nipype/interfaces/slicer/registration/brainsfit.py index b093235b84..58f4e47411 100644 --- a/nipype/interfaces/slicer/registration/brainsfit.py +++ b/nipype/interfaces/slicer/registration/brainsfit.py @@ -99,7 +99,7 @@ class BRAINSFit(SEMLikeCommandLine): """ - input_spec = BRAINSFitInputSpec - output_spec = BRAINSFitOutputSpec + _input_spec = BRAINSFitInputSpec + _output_spec = BRAINSFitOutputSpec _cmd = "BRAINSFit " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'bsplineTransform': 'bsplineTransform.mat', 'outputTransform': 'outputTransform.mat', 'outputFixedVolumeROI': 'outputFixedVolumeROI.nii', 'strippedOutputTransform': 'strippedOutputTransform.mat', 'outputMovingVolumeROI': 'outputMovingVolumeROI.nii', 'linearTransform': 'linearTransform.mat'} diff --git a/nipype/interfaces/slicer/registration/brainsresample.py b/nipype/interfaces/slicer/registration/brainsresample.py index c7f2ba63a2..6901f37f44 100644 --- a/nipype/interfaces/slicer/registration/brainsresample.py +++ b/nipype/interfaces/slicer/registration/brainsresample.py @@ -45,7 +45,7 @@ class BRAINSResample(SEMLikeCommandLine): """ - input_spec = BRAINSResampleInputSpec - output_spec = BRAINSResampleOutputSpec + _input_spec = BRAINSResampleInputSpec + _output_spec = BRAINSResampleOutputSpec _cmd = "BRAINSResample " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/registration/specialized.py b/nipype/interfaces/slicer/registration/specialized.py index 3123cd2e63..97a873e4b1 100644 --- a/nipype/interfaces/slicer/registration/specialized.py +++ b/nipype/interfaces/slicer/registration/specialized.py @@ -36,8 +36,8 @@ class ACPCTransform(SEMLikeCommandLine): """ - input_spec = ACPCTransformInputSpec - output_spec = ACPCTransformOutputSpec + _input_spec = ACPCTransformInputSpec + _output_spec = ACPCTransformOutputSpec _cmd = "ACPCTransform " _outputs_filenames = {'outputTransform': 'outputTransform.mat'} @@ -72,8 +72,8 @@ class FiducialRegistration(SEMLikeCommandLine): """ - input_spec = FiducialRegistrationInputSpec - output_spec = FiducialRegistrationOutputSpec + _input_spec = FiducialRegistrationInputSpec + _output_spec = FiducialRegistrationOutputSpec _cmd = "FiducialRegistration " _outputs_filenames = {'saveTransform': 'saveTransform.txt'} @@ -150,8 +150,8 @@ class VBRAINSDemonWarp(SEMLikeCommandLine): """ - input_spec = VBRAINSDemonWarpInputSpec - output_spec = VBRAINSDemonWarpOutputSpec + _input_spec = VBRAINSDemonWarpInputSpec + _output_spec = VBRAINSDemonWarpOutputSpec _cmd = "VBRAINSDemonWarp " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'outputCheckerboardVolume': 'outputCheckerboardVolume.nii', 'outputDisplacementFieldVolume': 'outputDisplacementFieldVolume.nrrd'} @@ -227,7 +227,7 @@ class BRAINSDemonWarp(SEMLikeCommandLine): """ - input_spec = BRAINSDemonWarpInputSpec - output_spec = BRAINSDemonWarpOutputSpec + _input_spec = BRAINSDemonWarpInputSpec + _output_spec = BRAINSDemonWarpOutputSpec _cmd = "BRAINSDemonWarp " _outputs_filenames = {'outputVolume': 'outputVolume.nii', 'outputCheckerboardVolume': 'outputCheckerboardVolume.nii', 'outputDisplacementFieldVolume': 'outputDisplacementFieldVolume.nrrd'} diff --git a/nipype/interfaces/slicer/registration/tests/test_auto_ACPCTransform.py b/nipype/interfaces/slicer/registration/tests/test_auto_ACPCTransform.py index a118de15c1..44e462bd6d 100644 --- a/nipype/interfaces/slicer/registration/tests/test_auto_ACPCTransform.py +++ b/nipype/interfaces/slicer/registration/tests/test_auto_ACPCTransform.py @@ -10,21 +10,13 @@ def test_ACPCTransform_inputs(): ), debugSwitch=dict(argstr='--debugSwitch ', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), midline=dict(argstr='--midline %s...', ), outputTransform=dict(argstr='--outputTransform %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ACPCTransform.input_spec() + inputs = ACPCTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +26,7 @@ def test_ACPCTransform_inputs(): def test_ACPCTransform_outputs(): output_map = dict(outputTransform=dict(), ) - outputs = ACPCTransform.output_spec() + outputs = ACPCTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSDemonWarp.py b/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSDemonWarp.py index fa3caa8d79..4c61038378 100644 --- a/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSDemonWarp.py +++ b/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSDemonWarp.py @@ -14,9 +14,6 @@ def test_BRAINSDemonWarp_inputs(): checkerboardPatternSubdivisions=dict(argstr='--checkerboardPatternSubdivisions %s', sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedBinaryVolume=dict(argstr='--fixedBinaryVolume %s', ), fixedVolume=dict(argstr='--fixedVolume %s', @@ -27,9 +24,6 @@ def test_BRAINSDemonWarp_inputs(): ), histogramMatch=dict(argstr='--histogramMatch ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initializeWithDisplacementField=dict(argstr='--initializeWithDisplacementField %s', ), initializeWithTransform=dict(argstr='--initializeWithTransform %s', @@ -96,8 +90,6 @@ def test_BRAINSDemonWarp_inputs(): ), smoothDisplacementFieldSigma=dict(argstr='--smoothDisplacementFieldSigma %f', ), - terminal_output=dict(nohash=True, - ), upFieldSmoothing=dict(argstr='--upFieldSmoothing %f', ), upperThresholdForBOBF=dict(argstr='--upperThresholdForBOBF %d', @@ -105,7 +97,7 @@ def test_BRAINSDemonWarp_inputs(): use_vanilla_dem=dict(argstr='--use_vanilla_dem ', ), ) - inputs = BRAINSDemonWarp.input_spec() + inputs = BRAINSDemonWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -117,7 +109,7 @@ def test_BRAINSDemonWarp_outputs(): outputDisplacementFieldVolume=dict(), outputVolume=dict(), ) - outputs = BRAINSDemonWarp.output_spec() + outputs = BRAINSDemonWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSFit.py b/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSFit.py index b28da552ed..870c04caae 100644 --- a/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSFit.py +++ b/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSFit.py @@ -27,9 +27,6 @@ def test_BRAINSFit_inputs(): ), debugLevel=dict(argstr='--debugLevel %d', ), - environ=dict(nohash=True, - usedefault=True, - ), failureExitCode=dict(argstr='--failureExitCode %d', ), fixedBinaryVolume=dict(argstr='--fixedBinaryVolume %s', @@ -44,9 +41,6 @@ def test_BRAINSFit_inputs(): ), histogramMatch=dict(argstr='--histogramMatch ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initialTransform=dict(argstr='--initialTransform %s', ), initializeTransformMode=dict(argstr='--initializeTransformMode %s', @@ -124,8 +118,6 @@ def test_BRAINSFit_inputs(): strippedOutputTransform=dict(argstr='--strippedOutputTransform %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), transformType=dict(argstr='--transformType %s', sep=',', ), @@ -150,7 +142,7 @@ def test_BRAINSFit_inputs(): writeTransformOnFailure=dict(argstr='--writeTransformOnFailure ', ), ) - inputs = BRAINSFit.input_spec() + inputs = BRAINSFit._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -166,7 +158,7 @@ def test_BRAINSFit_outputs(): outputVolume=dict(), strippedOutputTransform=dict(), ) - outputs = BRAINSFit.output_spec() + outputs = BRAINSFit._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSResample.py b/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSResample.py index e6d8c39ae8..470e7d3cee 100644 --- a/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSResample.py +++ b/nipype/interfaces/slicer/registration/tests/test_auto_BRAINSResample.py @@ -10,15 +10,9 @@ def test_BRAINSResample_inputs(): ), deformationVolume=dict(argstr='--deformationVolume %s', ), - environ=dict(nohash=True, - usedefault=True, - ), gridSpacing=dict(argstr='--gridSpacing %s', sep=',', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), interpolationMode=dict(argstr='--interpolationMode %s', @@ -34,12 +28,10 @@ def test_BRAINSResample_inputs(): ), referenceVolume=dict(argstr='--referenceVolume %s', ), - terminal_output=dict(nohash=True, - ), warpTransform=dict(argstr='--warpTransform %s', ), ) - inputs = BRAINSResample.input_spec() + inputs = BRAINSResample._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -49,7 +41,7 @@ def test_BRAINSResample_inputs(): def test_BRAINSResample_outputs(): output_map = dict(outputVolume=dict(), ) - outputs = BRAINSResample.output_spec() + outputs = BRAINSResample._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/registration/tests/test_auto_FiducialRegistration.py b/nipype/interfaces/slicer/registration/tests/test_auto_FiducialRegistration.py index de4cdaae40..511882a418 100644 --- a/nipype/interfaces/slicer/registration/tests/test_auto_FiducialRegistration.py +++ b/nipype/interfaces/slicer/registration/tests/test_auto_FiducialRegistration.py @@ -6,14 +6,8 @@ def test_FiducialRegistration_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedLandmarks=dict(argstr='--fixedLandmarks %s...', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), movingLandmarks=dict(argstr='--movingLandmarks %s...', ), outputMessage=dict(argstr='--outputMessage %s', @@ -23,12 +17,10 @@ def test_FiducialRegistration_inputs(): saveTransform=dict(argstr='--saveTransform %s', hash_files=False, ), - terminal_output=dict(nohash=True, - ), transformType=dict(argstr='--transformType %s', ), ) - inputs = FiducialRegistration.input_spec() + inputs = FiducialRegistration._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_FiducialRegistration_inputs(): def test_FiducialRegistration_outputs(): output_map = dict(saveTransform=dict(), ) - outputs = FiducialRegistration.output_spec() + outputs = FiducialRegistration._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/registration/tests/test_auto_VBRAINSDemonWarp.py b/nipype/interfaces/slicer/registration/tests/test_auto_VBRAINSDemonWarp.py index 50df05872a..a29428faaf 100644 --- a/nipype/interfaces/slicer/registration/tests/test_auto_VBRAINSDemonWarp.py +++ b/nipype/interfaces/slicer/registration/tests/test_auto_VBRAINSDemonWarp.py @@ -14,9 +14,6 @@ def test_VBRAINSDemonWarp_inputs(): checkerboardPatternSubdivisions=dict(argstr='--checkerboardPatternSubdivisions %s', sep=',', ), - environ=dict(nohash=True, - usedefault=True, - ), fixedBinaryVolume=dict(argstr='--fixedBinaryVolume %s', ), fixedVolume=dict(argstr='--fixedVolume %s...', @@ -27,9 +24,6 @@ def test_VBRAINSDemonWarp_inputs(): ), histogramMatch=dict(argstr='--histogramMatch ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), initializeWithDisplacementField=dict(argstr='--initializeWithDisplacementField %s', ), initializeWithTransform=dict(argstr='--initializeWithTransform %s', @@ -96,8 +90,6 @@ def test_VBRAINSDemonWarp_inputs(): ), smoothDisplacementFieldSigma=dict(argstr='--smoothDisplacementFieldSigma %f', ), - terminal_output=dict(nohash=True, - ), upFieldSmoothing=dict(argstr='--upFieldSmoothing %f', ), upperThresholdForBOBF=dict(argstr='--upperThresholdForBOBF %d', @@ -108,7 +100,7 @@ def test_VBRAINSDemonWarp_inputs(): sep=',', ), ) - inputs = VBRAINSDemonWarp.input_spec() + inputs = VBRAINSDemonWarp._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -120,7 +112,7 @@ def test_VBRAINSDemonWarp_outputs(): outputDisplacementFieldVolume=dict(), outputVolume=dict(), ) - outputs = VBRAINSDemonWarp.output_spec() + outputs = VBRAINSDemonWarp._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/segmentation/simpleregiongrowingsegmentation.py b/nipype/interfaces/slicer/segmentation/simpleregiongrowingsegmentation.py index ee2c9e11ea..718503ad1c 100644 --- a/nipype/interfaces/slicer/segmentation/simpleregiongrowingsegmentation.py +++ b/nipype/interfaces/slicer/segmentation/simpleregiongrowingsegmentation.py @@ -39,7 +39,7 @@ class SimpleRegionGrowingSegmentation(SEMLikeCommandLine): """ - input_spec = SimpleRegionGrowingSegmentationInputSpec - output_spec = SimpleRegionGrowingSegmentationOutputSpec + _input_spec = SimpleRegionGrowingSegmentationInputSpec + _output_spec = SimpleRegionGrowingSegmentationOutputSpec _cmd = "SimpleRegionGrowingSegmentation " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} diff --git a/nipype/interfaces/slicer/segmentation/specialized.py b/nipype/interfaces/slicer/segmentation/specialized.py index fef3cb7df3..cfcaea40b9 100644 --- a/nipype/interfaces/slicer/segmentation/specialized.py +++ b/nipype/interfaces/slicer/segmentation/specialized.py @@ -38,8 +38,8 @@ class RobustStatisticsSegmenter(SEMLikeCommandLine): """ - input_spec = RobustStatisticsSegmenterInputSpec - output_spec = RobustStatisticsSegmenterOutputSpec + _input_spec = RobustStatisticsSegmenterInputSpec + _output_spec = RobustStatisticsSegmenterOutputSpec _cmd = "RobustStatisticsSegmenter " _outputs_filenames = {'segmentedImageFileName': 'segmentedImageFileName.nii'} @@ -96,8 +96,8 @@ class EMSegmentCommandLine(SEMLikeCommandLine): """ - input_spec = EMSegmentCommandLineInputSpec - output_spec = EMSegmentCommandLineOutputSpec + _input_spec = EMSegmentCommandLineInputSpec + _output_spec = EMSegmentCommandLineOutputSpec _cmd = "EMSegmentCommandLine " _outputs_filenames = {'generateEmptyMRMLSceneAndQuit': 'generateEmptyMRMLSceneAndQuit', 'resultMRMLSceneFileName': 'resultMRMLSceneFileName', 'resultVolumeFileName': 'resultVolumeFileName.mhd'} @@ -137,7 +137,7 @@ class BRAINSROIAuto(SEMLikeCommandLine): """ - input_spec = BRAINSROIAutoInputSpec - output_spec = BRAINSROIAutoOutputSpec + _input_spec = BRAINSROIAutoInputSpec + _output_spec = BRAINSROIAutoOutputSpec _cmd = "BRAINSROIAuto " _outputs_filenames = {'outputROIMaskVolume': 'outputROIMaskVolume.nii', 'outputClippedVolumeROI': 'outputClippedVolumeROI.nii'} diff --git a/nipype/interfaces/slicer/segmentation/tests/test_auto_BRAINSROIAuto.py b/nipype/interfaces/slicer/segmentation/tests/test_auto_BRAINSROIAuto.py index 17d9993671..6918b1cee3 100644 --- a/nipype/interfaces/slicer/segmentation/tests/test_auto_BRAINSROIAuto.py +++ b/nipype/interfaces/slicer/segmentation/tests/test_auto_BRAINSROIAuto.py @@ -10,12 +10,6 @@ def test_BRAINSROIAuto_inputs(): ), closingSize=dict(argstr='--closingSize %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='--inputVolume %s', ), numberOfThreads=dict(argstr='--numberOfThreads %d', @@ -30,12 +24,10 @@ def test_BRAINSROIAuto_inputs(): ), outputVolumePixelType=dict(argstr='--outputVolumePixelType %s', ), - terminal_output=dict(nohash=True, - ), thresholdCorrectionFactor=dict(argstr='--thresholdCorrectionFactor %f', ), ) - inputs = BRAINSROIAuto.input_spec() + inputs = BRAINSROIAuto._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +38,7 @@ def test_BRAINSROIAuto_outputs(): output_map = dict(outputClippedVolumeROI=dict(), outputROIMaskVolume=dict(), ) - outputs = BRAINSROIAuto.output_spec() + outputs = BRAINSROIAuto._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/segmentation/tests/test_auto_EMSegmentCommandLine.py b/nipype/interfaces/slicer/segmentation/tests/test_auto_EMSegmentCommandLine.py index 3a98a84d41..a99479ce2b 100644 --- a/nipype/interfaces/slicer/segmentation/tests/test_auto_EMSegmentCommandLine.py +++ b/nipype/interfaces/slicer/segmentation/tests/test_auto_EMSegmentCommandLine.py @@ -16,15 +16,9 @@ def test_EMSegmentCommandLine_inputs(): ), dontWriteResults=dict(argstr='--dontWriteResults ', ), - environ=dict(nohash=True, - usedefault=True, - ), generateEmptyMRMLSceneAndQuit=dict(argstr='--generateEmptyMRMLSceneAndQuit %s', hash_files=False, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), intermediateResultsDirectory=dict(argstr='--intermediateResultsDirectory %s', ), keepTempFiles=dict(argstr='--keepTempFiles ', @@ -55,12 +49,10 @@ def test_EMSegmentCommandLine_inputs(): ), taskPreProcessingSetting=dict(argstr='--taskPreProcessingSetting %s', ), - terminal_output=dict(nohash=True, - ), verbose=dict(argstr='--verbose ', ), ) - inputs = EMSegmentCommandLine.input_spec() + inputs = EMSegmentCommandLine._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -72,7 +64,7 @@ def test_EMSegmentCommandLine_outputs(): resultMRMLSceneFileName=dict(), resultVolumeFileName=dict(), ) - outputs = EMSegmentCommandLine.output_spec() + outputs = EMSegmentCommandLine._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/segmentation/tests/test_auto_RobustStatisticsSegmenter.py b/nipype/interfaces/slicer/segmentation/tests/test_auto_RobustStatisticsSegmenter.py index 8c8c954c68..d7abd25dbd 100644 --- a/nipype/interfaces/slicer/segmentation/tests/test_auto_RobustStatisticsSegmenter.py +++ b/nipype/interfaces/slicer/segmentation/tests/test_auto_RobustStatisticsSegmenter.py @@ -8,14 +8,8 @@ def test_RobustStatisticsSegmenter_inputs(): ), curvatureWeight=dict(argstr='--curvatureWeight %f', ), - environ=dict(nohash=True, - usedefault=True, - ), expectedVolume=dict(argstr='--expectedVolume %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), intensityHomogeneity=dict(argstr='--intensityHomogeneity %f', ), labelImageFileName=dict(argstr='%s', @@ -32,10 +26,8 @@ def test_RobustStatisticsSegmenter_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = RobustStatisticsSegmenter.input_spec() + inputs = RobustStatisticsSegmenter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +38,7 @@ def test_RobustStatisticsSegmenter_outputs(): output_map = dict(segmentedImageFileName=dict(position=-1, ), ) - outputs = RobustStatisticsSegmenter.output_spec() + outputs = RobustStatisticsSegmenter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/segmentation/tests/test_auto_SimpleRegionGrowingSegmentation.py b/nipype/interfaces/slicer/segmentation/tests/test_auto_SimpleRegionGrowingSegmentation.py index a06926156e..cbc6dbf4b1 100644 --- a/nipype/interfaces/slicer/segmentation/tests/test_auto_SimpleRegionGrowingSegmentation.py +++ b/nipype/interfaces/slicer/segmentation/tests/test_auto_SimpleRegionGrowingSegmentation.py @@ -6,12 +6,6 @@ def test_SimpleRegionGrowingSegmentation_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -31,12 +25,10 @@ def test_SimpleRegionGrowingSegmentation_inputs(): ), smoothingIterations=dict(argstr='--smoothingIterations %d', ), - terminal_output=dict(nohash=True, - ), timestep=dict(argstr='--timestep %f', ), ) - inputs = SimpleRegionGrowingSegmentation.input_spec() + inputs = SimpleRegionGrowingSegmentation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -47,7 +39,7 @@ def test_SimpleRegionGrowingSegmentation_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = SimpleRegionGrowingSegmentation.output_spec() + outputs = SimpleRegionGrowingSegmentation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/surface.py b/nipype/interfaces/slicer/surface.py index cd8edcf2cf..aa1773463e 100644 --- a/nipype/interfaces/slicer/surface.py +++ b/nipype/interfaces/slicer/surface.py @@ -33,8 +33,8 @@ class MergeModels(SEMLikeCommandLine): """ - input_spec = MergeModelsInputSpec - output_spec = MergeModelsOutputSpec + _input_spec = MergeModelsInputSpec + _output_spec = MergeModelsOutputSpec _cmd = "MergeModels " _outputs_filenames = {'ModelOutput': 'ModelOutput.vtk'} @@ -67,8 +67,8 @@ class ModelToLabelMap(SEMLikeCommandLine): """ - input_spec = ModelToLabelMapInputSpec - output_spec = ModelToLabelMapOutputSpec + _input_spec = ModelToLabelMapInputSpec + _output_spec = ModelToLabelMapOutputSpec _cmd = "ModelToLabelMap " _outputs_filenames = {'OutputVolume': 'OutputVolume.nii'} @@ -107,8 +107,8 @@ class GrayscaleModelMaker(SEMLikeCommandLine): """ - input_spec = GrayscaleModelMakerInputSpec - output_spec = GrayscaleModelMakerOutputSpec + _input_spec = GrayscaleModelMakerInputSpec + _output_spec = GrayscaleModelMakerOutputSpec _cmd = "GrayscaleModelMaker " _outputs_filenames = {'OutputGeometry': 'OutputGeometry.vtk'} @@ -140,8 +140,8 @@ class ProbeVolumeWithModel(SEMLikeCommandLine): """ - input_spec = ProbeVolumeWithModelInputSpec - output_spec = ProbeVolumeWithModelOutputSpec + _input_spec = ProbeVolumeWithModelInputSpec + _output_spec = ProbeVolumeWithModelOutputSpec _cmd = "ProbeVolumeWithModel " _outputs_filenames = {'OutputModel': 'OutputModel.vtk'} @@ -176,8 +176,8 @@ class LabelMapSmoothing(SEMLikeCommandLine): """ - input_spec = LabelMapSmoothingInputSpec - output_spec = LabelMapSmoothingOutputSpec + _input_spec = LabelMapSmoothingInputSpec + _output_spec = LabelMapSmoothingOutputSpec _cmd = "LabelMapSmoothing " _outputs_filenames = {'outputVolume': 'outputVolume.nii'} @@ -226,7 +226,7 @@ class ModelMaker(SEMLikeCommandLine): """ - input_spec = ModelMakerInputSpec - output_spec = ModelMakerOutputSpec + _input_spec = ModelMakerInputSpec + _output_spec = ModelMakerOutputSpec _cmd = "ModelMaker " _outputs_filenames = {'modelSceneFile': 'modelSceneFile.mrml'} diff --git a/nipype/interfaces/slicer/tests/test_auto_DicomToNrrdConverter.py b/nipype/interfaces/slicer/tests/test_auto_DicomToNrrdConverter.py index e758a394f2..422e95756f 100644 --- a/nipype/interfaces/slicer/tests/test_auto_DicomToNrrdConverter.py +++ b/nipype/interfaces/slicer/tests/test_auto_DicomToNrrdConverter.py @@ -6,12 +6,6 @@ def test_DicomToNrrdConverter_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputDicomDirectory=dict(argstr='--inputDicomDirectory %s', ), outputDirectory=dict(argstr='--outputDirectory %s', @@ -21,8 +15,6 @@ def test_DicomToNrrdConverter_inputs(): ), smallGradientThreshold=dict(argstr='--smallGradientThreshold %f', ), - terminal_output=dict(nohash=True, - ), useBMatrixGradientDirections=dict(argstr='--useBMatrixGradientDirections ', ), useIdentityMeaseurementFrame=dict(argstr='--useIdentityMeaseurementFrame ', @@ -30,7 +22,7 @@ def test_DicomToNrrdConverter_inputs(): writeProtocolGradientsFile=dict(argstr='--writeProtocolGradientsFile ', ), ) - inputs = DicomToNrrdConverter.input_spec() + inputs = DicomToNrrdConverter._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +32,7 @@ def test_DicomToNrrdConverter_inputs(): def test_DicomToNrrdConverter_outputs(): output_map = dict(outputDirectory=dict(), ) - outputs = DicomToNrrdConverter.output_spec() + outputs = DicomToNrrdConverter._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/tests/test_auto_EMSegmentTransformToNewFormat.py b/nipype/interfaces/slicer/tests/test_auto_EMSegmentTransformToNewFormat.py index 3ef48595c8..9a23ccca60 100644 --- a/nipype/interfaces/slicer/tests/test_auto_EMSegmentTransformToNewFormat.py +++ b/nipype/interfaces/slicer/tests/test_auto_EMSegmentTransformToNewFormat.py @@ -6,12 +6,6 @@ def test_EMSegmentTransformToNewFormat_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputMRMLFileName=dict(argstr='--inputMRMLFileName %s', ), outputMRMLFileName=dict(argstr='--outputMRMLFileName %s', @@ -19,10 +13,8 @@ def test_EMSegmentTransformToNewFormat_inputs(): ), templateFlag=dict(argstr='--templateFlag ', ), - terminal_output=dict(nohash=True, - ), ) - inputs = EMSegmentTransformToNewFormat.input_spec() + inputs = EMSegmentTransformToNewFormat._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -32,7 +24,7 @@ def test_EMSegmentTransformToNewFormat_inputs(): def test_EMSegmentTransformToNewFormat_outputs(): output_map = dict(outputMRMLFileName=dict(), ) - outputs = EMSegmentTransformToNewFormat.output_spec() + outputs = EMSegmentTransformToNewFormat._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/tests/test_auto_GrayscaleModelMaker.py b/nipype/interfaces/slicer/tests/test_auto_GrayscaleModelMaker.py index 5d871640f5..b2ec4344cf 100644 --- a/nipype/interfaces/slicer/tests/test_auto_GrayscaleModelMaker.py +++ b/nipype/interfaces/slicer/tests/test_auto_GrayscaleModelMaker.py @@ -15,12 +15,6 @@ def test_GrayscaleModelMaker_inputs(): ), decimate=dict(argstr='--decimate %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), name=dict(argstr='--name %s', ), pointnormals=dict(argstr='--pointnormals ', @@ -29,12 +23,10 @@ def test_GrayscaleModelMaker_inputs(): ), splitnormals=dict(argstr='--splitnormals ', ), - terminal_output=dict(nohash=True, - ), threshold=dict(argstr='--threshold %f', ), ) - inputs = GrayscaleModelMaker.input_spec() + inputs = GrayscaleModelMaker._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -45,7 +37,7 @@ def test_GrayscaleModelMaker_outputs(): output_map = dict(OutputGeometry=dict(position=-1, ), ) - outputs = GrayscaleModelMaker.output_spec() + outputs = GrayscaleModelMaker._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/tests/test_auto_LabelMapSmoothing.py b/nipype/interfaces/slicer/tests/test_auto_LabelMapSmoothing.py index 44bbf0179a..db1bbbe305 100644 --- a/nipype/interfaces/slicer/tests/test_auto_LabelMapSmoothing.py +++ b/nipype/interfaces/slicer/tests/test_auto_LabelMapSmoothing.py @@ -6,14 +6,8 @@ def test_LabelMapSmoothing_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), gaussianSigma=dict(argstr='--gaussianSigma %f', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume=dict(argstr='%s', position=-2, ), @@ -27,10 +21,8 @@ def test_LabelMapSmoothing_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = LabelMapSmoothing.input_spec() + inputs = LabelMapSmoothing._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +33,7 @@ def test_LabelMapSmoothing_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = LabelMapSmoothing.output_spec() + outputs = LabelMapSmoothing._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/tests/test_auto_MergeModels.py b/nipype/interfaces/slicer/tests/test_auto_MergeModels.py index 7dfcefb5be..60bbd31137 100644 --- a/nipype/interfaces/slicer/tests/test_auto_MergeModels.py +++ b/nipype/interfaces/slicer/tests/test_auto_MergeModels.py @@ -16,16 +16,8 @@ def test_MergeModels_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - terminal_output=dict(nohash=True, - ), ) - inputs = MergeModels.input_spec() + inputs = MergeModels._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_MergeModels_outputs(): output_map = dict(ModelOutput=dict(position=-1, ), ) - outputs = MergeModels.output_spec() + outputs = MergeModels._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/tests/test_auto_ModelMaker.py b/nipype/interfaces/slicer/tests/test_auto_ModelMaker.py index 1137fe4898..0d4eb77c72 100644 --- a/nipype/interfaces/slicer/tests/test_auto_ModelMaker.py +++ b/nipype/interfaces/slicer/tests/test_auto_ModelMaker.py @@ -17,16 +17,10 @@ def test_ModelMaker_inputs(): ), end=dict(argstr='--end %d', ), - environ=dict(nohash=True, - usedefault=True, - ), filtertype=dict(argstr='--filtertype %s', ), generateAll=dict(argstr='--generateAll ', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), jointsmooth=dict(argstr='--jointsmooth ', ), labels=dict(argstr='--labels %s', @@ -51,10 +45,8 @@ def test_ModelMaker_inputs(): ), start=dict(argstr='--start %d', ), - terminal_output=dict(nohash=True, - ), ) - inputs = ModelMaker.input_spec() + inputs = ModelMaker._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -64,7 +56,7 @@ def test_ModelMaker_inputs(): def test_ModelMaker_outputs(): output_map = dict(modelSceneFile=dict(), ) - outputs = ModelMaker.output_spec() + outputs = ModelMaker._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/tests/test_auto_ModelToLabelMap.py b/nipype/interfaces/slicer/tests/test_auto_ModelToLabelMap.py index 2756e03782..2ee8418b97 100644 --- a/nipype/interfaces/slicer/tests/test_auto_ModelToLabelMap.py +++ b/nipype/interfaces/slicer/tests/test_auto_ModelToLabelMap.py @@ -15,19 +15,11 @@ def test_ModelToLabelMap_inputs(): ), distance=dict(argstr='--distance %f', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), surface=dict(argstr='%s', position=-2, ), - terminal_output=dict(nohash=True, - ), ) - inputs = ModelToLabelMap.input_spec() + inputs = ModelToLabelMap._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +30,7 @@ def test_ModelToLabelMap_outputs(): output_map = dict(OutputVolume=dict(position=-1, ), ) - outputs = ModelToLabelMap.output_spec() + outputs = ModelToLabelMap._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/tests/test_auto_OrientScalarVolume.py b/nipype/interfaces/slicer/tests/test_auto_OrientScalarVolume.py index 4477681f60..8ed9ae29ce 100644 --- a/nipype/interfaces/slicer/tests/test_auto_OrientScalarVolume.py +++ b/nipype/interfaces/slicer/tests/test_auto_OrientScalarVolume.py @@ -6,12 +6,6 @@ def test_OrientScalarVolume_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), inputVolume1=dict(argstr='%s', position=-2, ), @@ -21,10 +15,8 @@ def test_OrientScalarVolume_inputs(): hash_files=False, position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = OrientScalarVolume.input_spec() + inputs = OrientScalarVolume._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +27,7 @@ def test_OrientScalarVolume_outputs(): output_map = dict(outputVolume=dict(position=-1, ), ) - outputs = OrientScalarVolume.output_spec() + outputs = OrientScalarVolume._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/tests/test_auto_ProbeVolumeWithModel.py b/nipype/interfaces/slicer/tests/test_auto_ProbeVolumeWithModel.py index 842768fd27..a9dee777a5 100644 --- a/nipype/interfaces/slicer/tests/test_auto_ProbeVolumeWithModel.py +++ b/nipype/interfaces/slicer/tests/test_auto_ProbeVolumeWithModel.py @@ -16,16 +16,8 @@ def test_ProbeVolumeWithModel_inputs(): ), args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - terminal_output=dict(nohash=True, - ), ) - inputs = ProbeVolumeWithModel.input_spec() + inputs = ProbeVolumeWithModel._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_ProbeVolumeWithModel_outputs(): output_map = dict(OutputModel=dict(position=-1, ), ) - outputs = ProbeVolumeWithModel.output_spec() + outputs = ProbeVolumeWithModel._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/slicer/tests/test_auto_SlicerCommandLine.py b/nipype/interfaces/slicer/tests/test_auto_SlicerCommandLine.py index e480e76324..082970372b 100644 --- a/nipype/interfaces/slicer/tests/test_auto_SlicerCommandLine.py +++ b/nipype/interfaces/slicer/tests/test_auto_SlicerCommandLine.py @@ -6,18 +6,18 @@ def test_SlicerCommandLine_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), - terminal_output=dict(nohash=True, - ), ) - inputs = SlicerCommandLine.input_spec() + inputs = SlicerCommandLine._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_SlicerCommandLine_outputs(): + output_map = dict() + outputs = SlicerCommandLine._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/slicer/utilities.py b/nipype/interfaces/slicer/utilities.py index bdc675e55a..62629a689d 100644 --- a/nipype/interfaces/slicer/utilities.py +++ b/nipype/interfaces/slicer/utilities.py @@ -31,7 +31,7 @@ class EMSegmentTransformToNewFormat(SEMLikeCommandLine): """ - input_spec = EMSegmentTransformToNewFormatInputSpec - output_spec = EMSegmentTransformToNewFormatOutputSpec + _input_spec = EMSegmentTransformToNewFormatInputSpec + _output_spec = EMSegmentTransformToNewFormatOutputSpec _cmd = "EMSegmentTransformToNewFormat " _outputs_filenames = {'outputMRMLFileName': 'outputMRMLFileName.mrml'} diff --git a/nipype/interfaces/spm/base.py b/nipype/interfaces/spm/base.py index 0ca470d0ed..19a87371ea 100644 --- a/nipype/interfaces/spm/base.py +++ b/nipype/interfaces/spm/base.py @@ -31,7 +31,7 @@ # Local imports from ..base import (BaseInterface, traits, isdefined, InputMultiPath, - BaseInterfaceInputSpec, Directory, Undefined) + BaseInputSpec, Directory, Undefined) from ..matlab import MatlabCommand from ...utils import spm_docs as sd from ...external.six import string_types @@ -209,7 +209,7 @@ def no_spm(): return False -class SPMCommandInputSpec(BaseInterfaceInputSpec): +class SPMCommandInputSpec(BaseInputSpec): matlab_cmd = traits.Str(desc='matlab command to use') paths = InputMultiPath(Directory(), desc='Paths to add to matlabpath') mfile = traits.Bool(True, desc='Run m-code using m-file', @@ -225,7 +225,7 @@ class SPMCommand(BaseInterface): WARNING: Pseudo prototype class, meant to be subclassed """ - input_spec = SPMCommandInputSpec + _input_spec = SPMCommandInputSpec _additional_metadata = ['field'] _jobtype = 'basetype' @@ -307,7 +307,7 @@ def _check_mlab_inputs(self): def _run_interface(self, runtime): """Executes the SPM function using MATLAB.""" self.mlab.inputs.script = self._make_matlab_command( - deepcopy(self._parse_inputs())) + deepcopy(self.parse_args())) results = self.mlab.run() runtime.returncode = results.runtime.returncode if self.mlab.inputs.uses_mcr: @@ -318,7 +318,7 @@ def _run_interface(self, runtime): runtime.merged = results.runtime.merged return runtime - def _list_outputs(self): + def _post_run(self): """Determine the expected outputs based on inputs.""" raise NotImplementedError @@ -330,7 +330,7 @@ def _format_arg(self, opt, spec, val): else: return val - def _parse_inputs(self, skip=()): + def parse_args(self, skip=()): spmdict = {} metadata = dict(field=lambda t: t is not None) for name, spec in list(self.inputs.traits(**metadata).items()): @@ -447,7 +447,7 @@ def _make_matlab_command(self, contents, postscript=None): ---------- contents : list - a list of dicts generated by _parse_inputs + a list of dicts generated by parse_args in each subclass cwd : string diff --git a/nipype/interfaces/spm/model.py b/nipype/interfaces/spm/model.py index 2a3472a648..ac40227b3d 100644 --- a/nipype/interfaces/spm/model.py +++ b/nipype/interfaces/spm/model.py @@ -105,8 +105,8 @@ class Level1Design(SPMCommand): """ - input_spec = Level1DesignInputSpec - output_spec = Level1DesignOutputSpec + _input_spec = Level1DesignInputSpec + _output_spec = Level1DesignOutputSpec _jobtype = 'stats' _jobname = 'fmri_spec' @@ -123,10 +123,10 @@ def _format_arg(self, opt, spec, val): return val return super(Level1Design, self)._format_arg(opt, spec, val) - def _parse_inputs(self): + def parse_args(self): """validate spm realign options if set to None ignore """ - einputs = super(Level1Design, self)._parse_inputs(skip=('mask_threshold')) + einputs = super(Level1Design, self).parse_args(skip=('mask_threshold')) for sessinfo in einputs[0]['sess']: sessinfo['scans'] = scans_for_fnames(filename_to_list(sessinfo['scans']), keep4d=False) if not isdefined(self.inputs.spm_mat_dir): @@ -152,12 +152,10 @@ def _make_matlab_command(self, content): postscript = None return super(Level1Design, self)._make_matlab_command(content, postscript=postscript) - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): spm = os.path.join(os.getcwd(), 'SPM.mat') - outputs['spm_mat_file'] = spm - return outputs - + self.outputs.spm_mat_file = spm + class EstimateModelInputSpec(SPMCommandInputSpec): spm_mat_file = File(exists=True, field='spmmat', desc='absolute path to SPM.mat', @@ -189,8 +187,8 @@ class EstimateModel(SPMCommand): >>> est.inputs.spm_mat_file = 'SPM.mat' >>> est.run() # doctest: +SKIP """ - input_spec = EstimateModelInputSpec - output_spec = EstimateModelOutputSpec + _input_spec = EstimateModelInputSpec + _output_spec = EstimateModelOutputSpec _jobtype = 'stats' _jobname = 'fmri_est' @@ -206,43 +204,41 @@ def _format_arg(self, opt, spec, val): return val return super(EstimateModel, self)._format_arg(opt, spec, val) - def _parse_inputs(self): + def parse_args(self): """validate spm realign options if set to None ignore """ - einputs = super(EstimateModel, self)._parse_inputs(skip=('flags')) + einputs = super(EstimateModel, self).parse_args(skip=('flags')) if isdefined(self.inputs.flags): einputs[0].update(self.inputs.flags) return einputs - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): pth, _ = os.path.split(self.inputs.spm_mat_file) spm12 = '12' in self.version.split('.')[0] if spm12: mask = os.path.join(pth, 'mask.nii') else: mask = os.path.join(pth, 'mask.img') - outputs['mask_image'] = mask + self.outputs.mask_image = mask spm = sio.loadmat(self.inputs.spm_mat_file, struct_as_record=False) betas = [] for vbeta in spm['SPM'][0, 0].Vbeta[0]: betas.append(str(os.path.join(pth, vbeta.fname[0]))) if betas: - outputs['beta_images'] = betas + self.outputs.beta_images = betas if spm12: resms = os.path.join(pth, 'ResMS.nii') else: resms = os.path.join(pth, 'ResMS.img') - outputs['residual_image'] = resms + self.outputs.residual_image = resms if spm12: rpv = os.path.join(pth, 'RPV.nii') else: rpv = os.path.join(pth, 'RPV.img') - outputs['RPVimage'] = rpv + self.outputs.RPVimage = rpv spm = os.path.join(pth, 'SPM.mat') - outputs['spm_mat_file'] = spm - return outputs - + self.outputs.spm_mat_file = spm + class EstimateContrastInputSpec(SPMCommandInputSpec): spm_mat_file = File(exists=True, field='spmmat', @@ -313,8 +309,8 @@ class EstimateContrast(SPMCommand): """ - input_spec = EstimateContrastInputSpec - output_spec = EstimateContrastOutputSpec + _input_spec = EstimateContrastInputSpec + _output_spec = EstimateContrastOutputSpec _jobtype = 'stats' _jobname = 'con' @@ -384,8 +380,7 @@ def _make_matlab_command(self, _): script += "spm_jobman('run',jobs);" return script - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): pth, _ = os.path.split(self.inputs.spm_mat_file) spm = sio.loadmat(self.inputs.spm_mat_file, struct_as_record=False) con_images = [] @@ -394,24 +389,23 @@ def _list_outputs(self): con_images.append(str(os.path.join(pth, con.Vcon[0, 0].fname[0]))) spmT_images.append(str(os.path.join(pth, con.Vspm[0, 0].fname[0]))) if con_images: - outputs['con_images'] = con_images - outputs['spmT_images'] = spmT_images + self.outputs.con_images = con_images + self.outputs.spmT_images = spmT_images spm12 = '12' in self.version.split('.')[0] if spm12: ess = glob(os.path.join(pth, 'ess*.nii')) else: ess = glob(os.path.join(pth, 'ess*.img')) if len(ess) > 0: - outputs['ess_images'] = sorted(ess) + self.outputs.ess_images = sorted(ess) if spm12: spmf = glob(os.path.join(pth, 'spmF*.nii')) else: spmf = glob(os.path.join(pth, 'spmF*.img')) if len(spmf) > 0: - outputs['spmF_images'] = sorted(spmf) - outputs['spm_mat_file'] = self.inputs.spm_mat_file - return outputs - + self.outputs.spmF_images = sorted(spmf) + self.outputs.spm_mat_file = self.inputs.spm_mat_file + class ThresholdInputSpec(SPMCommandInputSpec): spm_mat_file = File(exists=True, desc='absolute path to SPM.mat', copyfile=True, mandatory=True) @@ -436,7 +430,7 @@ class ThresholdOutputSpec(TraitedSpec): class Threshold(SPMCommand): - '''Topological FDR thresholding based on cluster extent/size. Smoothness is + """Topological FDR thresholding based on cluster extent/size. Smoothness is estimated from GLM residuals but is assumed to be the same for all of the voxels. @@ -449,9 +443,9 @@ class Threshold(SPMCommand): >>> thresh.inputs.contrast_index = 1 >>> thresh.inputs.extent_fdr_p_threshold = 0.05 >>> thresh.run() # doctest: +SKIP - ''' - input_spec = ThresholdInputSpec - output_spec = ThresholdOutputSpec + """ + _input_spec = ThresholdInputSpec + _output_spec = ThresholdOutputSpec def _gen_thresholded_map_filename(self): _, fname, ext = split_filename(self.inputs.stat_image) @@ -588,14 +582,11 @@ def aggregate_outputs(self, runtime=None): setattr(outputs, 'pre_topo_n_clusters', int(line[len("pre_topo_n_clusters = "):].strip())) elif line.startswith("cluster_forming_thr = "): setattr(outputs, 'cluster_forming_thr', float(line[len("cluster_forming_thr = "):].strip())) - return outputs - - def _list_outputs(self): - outputs = self._outputs().get() - outputs['thresholded_map'] = self._gen_thresholded_map_filename() - outputs['pre_topo_fdr_map'] = self._gen_pre_topo_map_filename() - return outputs - + + def _post_run(self): + self.outputs.thresholded_map = self._gen_thresholded_map_filename() + self.outputs.pre_topo_fdr_map = self._gen_pre_topo_map_filename() + class ThresholdStatisticsInputSpec(SPMCommandInputSpec): spm_mat_file = File(exists=True, desc='absolute path to SPM.mat', copyfile=True, mandatory=True) @@ -615,7 +606,7 @@ class ThresholdStatisticsOutputSpec(TraitedSpec): class ThresholdStatistics(SPMCommand): - '''Given height and cluster size threshold calculate theoretical probabilities + """Given height and cluster size threshold calculate theoretical probabilities concerning false positives Examples @@ -627,9 +618,9 @@ class ThresholdStatistics(SPMCommand): >>> thresh.inputs.contrast_index = 1 >>> thresh.inputs.height_threshold = 4.56 >>> thresh.run() # doctest: +SKIP - ''' - input_spec = ThresholdStatisticsInputSpec - output_spec = ThresholdStatisticsOutputSpec + """ + _input_spec = ThresholdStatisticsInputSpec + _output_spec = ThresholdStatisticsOutputSpec def _make_matlab_command(self, _): script = "con_index = %d;\n" % self.inputs.contrast_index @@ -698,8 +689,7 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None): cur_output = line.split()[0] continue - return outputs - + class FactorialDesignInputSpec(SPMCommandInputSpec): spm_mat_dir = Directory(exists=True, field='dir', desc='directory to store SPM.mat file (opt)') @@ -747,8 +737,8 @@ class FactorialDesign(SPMCommand): """ - input_spec = FactorialDesignInputSpec - output_spec = FactorialDesignOutputSpec + _input_spec = FactorialDesignInputSpec + _output_spec = FactorialDesignOutputSpec _jobtype = 'stats' _jobname = 'factorial_design' @@ -770,20 +760,18 @@ def _format_arg(self, opt, spec, val): return outlist return super(FactorialDesign, self)._format_arg(opt, spec, val) - def _parse_inputs(self): + def parse_args(self): """validate spm realign options if set to None ignore """ - einputs = super(FactorialDesign, self)._parse_inputs() + einputs = super(FactorialDesign, self).parse_args() if not isdefined(self.inputs.spm_mat_dir): einputs[0]['dir'] = np.array([str(os.getcwd())], dtype=object) return einputs - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): spm = os.path.join(os.getcwd(), 'SPM.mat') - outputs['spm_mat_file'] = spm - return outputs - + self.outputs.spm_mat_file = spm + class OneSampleTTestDesignInputSpec(FactorialDesignInputSpec): in_files = traits.List(File(exists=True), field='des.t1.scans', @@ -802,7 +790,7 @@ class OneSampleTTestDesign(FactorialDesign): >>> ttest.run() # doctest: +SKIP """ - input_spec = OneSampleTTestDesignInputSpec + _input_spec = OneSampleTTestDesignInputSpec def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm @@ -839,7 +827,7 @@ class TwoSampleTTestDesign(FactorialDesign): >>> ttest.run() # doctest: +SKIP """ - input_spec = TwoSampleTTestDesignInputSpec + _input_spec = TwoSampleTTestDesignInputSpec def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm @@ -871,7 +859,7 @@ class PairedTTestDesign(FactorialDesign): >>> pttest.run() # doctest: +SKIP """ - input_spec = PairedTTestDesignInputSpec + _input_spec = PairedTTestDesignInputSpec def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm @@ -907,7 +895,7 @@ class MultipleRegressionDesign(FactorialDesign): >>> mreg.run() # doctest: +SKIP """ - input_spec = MultipleRegressionDesignInputSpec + _input_spec = MultipleRegressionDesignInputSpec def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm diff --git a/nipype/interfaces/spm/preprocess.py b/nipype/interfaces/spm/preprocess.py index c1af8d025c..7781c6e48f 100644 --- a/nipype/interfaces/spm/preprocess.py +++ b/nipype/interfaces/spm/preprocess.py @@ -82,8 +82,8 @@ class SliceTiming(SPMCommand): """ - input_spec = SliceTimingInputSpec - output_spec = SliceTimingOutputSpec + _input_spec = SliceTimingInputSpec + _output_spec = SliceTimingOutputSpec _jobtype = 'temporal' _jobname = 'st' @@ -97,9 +97,8 @@ def _format_arg(self, opt, spec, val): separate_sessions=True) return super(SliceTiming, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['timecorrected_files'] = [] + def _post_run(self): + self.outputs.timecorrected_files = [] filelist = filename_to_list(self.inputs.in_files) for f in filelist: @@ -107,8 +106,7 @@ def _list_outputs(self): run = [fname_presuffix(in_f, prefix=self.inputs.out_prefix) for in_f in f] else: run = fname_presuffix(f, prefix=self.inputs.out_prefix) - outputs['timecorrected_files'].append(run) - return outputs + self.outputs.timecorrected_files.append(run) class RealignInputSpec(SPMCommandInputSpec): @@ -182,8 +180,8 @@ class Realign(SPMCommand): """ - input_spec = RealignInputSpec - output_spec = RealignOutputSpec + _input_spec = RealignInputSpec + _output_spec = RealignOutputSpec _jobtype = 'spatial' _jobname = 'realign' @@ -201,35 +199,34 @@ def _format_arg(self, opt, spec, val): separate_sessions=separate_sessions) return super(Realign, self)._format_arg(opt, spec, val) - def _parse_inputs(self): + def parse_args(self): """validate spm realign options if set to None ignore """ - einputs = super(Realign, self)._parse_inputs() + einputs = super(Realign, self).parse_args() return [{'%s' % (self.inputs.jobtype): einputs[0]}] - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): resliced_all = self.inputs.write_which[0] > 0 resliced_mean = self.inputs.write_which[1] > 0 if self.inputs.jobtype != "write": if isdefined(self.inputs.in_files): - outputs['realignment_parameters'] = [] + self.outputs.realignment_parameters = [] for imgf in self.inputs.in_files: if isinstance(imgf, list): tmp_imgf = imgf[0] else: tmp_imgf = imgf - outputs['realignment_parameters'].append(fname_presuffix(tmp_imgf, + self.outputs.realignment_parameters.append(fname_presuffix(tmp_imgf, prefix='rp_', suffix='.txt', use_ext=False)) if not isinstance(imgf, list) and func_is_3d(imgf): break if self.inputs.jobtype == "estimate": - outputs['realigned_files'] = self.inputs.in_files + self.outputs.realigned_files = self.inputs.in_files if self.inputs.jobtype == "estimate" or self.inputs.jobtype == "estwrite": - outputs['modified_in_files'] = self.inputs.in_files + self.outputs.modified_in_files = self.inputs.in_files if self.inputs.jobtype == "write" or self.inputs.jobtype == "estwrite": if isinstance(self.inputs.in_files[0], list): first_image = self.inputs.in_files[0][0] @@ -237,10 +234,10 @@ def _list_outputs(self): first_image = self.inputs.in_files[0] if resliced_mean: - outputs['mean_image'] = fname_presuffix(first_image, prefix='mean') + self.outputs.mean_image = fname_presuffix(first_image, prefix='mean') if resliced_all: - outputs['realigned_files'] = [] + self.outputs.realigned_files = [] for idx, imgf in enumerate(filename_to_list(self.inputs.in_files)): realigned_run = [] if isinstance(imgf, list): @@ -251,8 +248,7 @@ def _list_outputs(self): else: realigned_run = fname_presuffix(imgf, prefix=self.inputs.out_prefix) - outputs['realigned_files'].append(realigned_run) - return outputs + self.outputs.realigned_files.append(realigned_run) class CoregisterInputSpec(SPMCommandInputSpec): @@ -314,8 +310,8 @@ class Coregister(SPMCommand): """ - input_spec = CoregisterInputSpec - output_spec = CoregisterOutputSpec + _input_spec = CoregisterInputSpec + _output_spec = CoregisterOutputSpec _jobtype = 'spatial' _jobname = 'coreg' @@ -334,34 +330,32 @@ def _format_arg(self, opt, spec, val): return scans_for_fnames(val) return super(Coregister, self)._format_arg(opt, spec, val) - def _parse_inputs(self): + def parse_args(self): """validate spm coregister options if set to None ignore """ if self.inputs.jobtype == "write": - einputs = super(Coregister, self)._parse_inputs(skip=('jobtype', 'apply_to_files')) + einputs = super(Coregister, self).parse_args(skip=('jobtype', 'apply_to_files')) else: - einputs = super(Coregister, self)._parse_inputs(skip=('jobtype')) + einputs = super(Coregister, self).parse_args(skip=('jobtype')) jobtype = self.inputs.jobtype return [{'%s' % (jobtype): einputs[0]}] - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): if self.inputs.jobtype == "estimate": if isdefined(self.inputs.apply_to_files): - outputs['coregistered_files'] = self.inputs.apply_to_files - outputs['coregistered_source'] = self.inputs.source + self.outputs.coregistered_files = self.inputs.apply_to_files + self.outputs.coregistered_source = self.inputs.source elif self.inputs.jobtype == "write" or self.inputs.jobtype == "estwrite": if isdefined(self.inputs.apply_to_files): - outputs['coregistered_files'] = [] + self.outputs.coregistered_files = [] for imgf in filename_to_list(self.inputs.apply_to_files): - outputs['coregistered_files'].append(fname_presuffix(imgf, prefix=self.inputs.out_prefix)) + self.outputs.coregistered_files.append(fname_presuffix(imgf, prefix=self.inputs.out_prefix)) - outputs['coregistered_source'] = [] + self.outputs.coregistered_source = [] for imgf in filename_to_list(self.inputs.source): - outputs['coregistered_source'].append(fname_presuffix(imgf, prefix=self.inputs.out_prefix)) + self.outputs.coregistered_source.append(fname_presuffix(imgf, prefix=self.inputs.out_prefix)) - return outputs class NormalizeInputSpec(SPMCommandInputSpec): @@ -441,8 +435,8 @@ class Normalize(SPMCommand): """ - input_spec = NormalizeInputSpec - output_spec = NormalizeOutputSpec + _input_spec = NormalizeInputSpec + _output_spec = NormalizeOutputSpec _jobtype = 'spatial' _jobname = 'normalise' @@ -462,10 +456,10 @@ def _format_arg(self, opt, spec, val): raise ValueError('%s must have 3 elements' % opt) return super(Normalize, self)._format_arg(opt, spec, val) - def _parse_inputs(self): + def parse_args(self): """validate spm normalize options if set to None ignore """ - einputs = super(Normalize, self)._parse_inputs(skip=('jobtype', + einputs = super(Normalize, self).parse_args(skip=('jobtype', 'apply_to_files')) if isdefined(self.inputs.apply_to_files): inputfiles = deepcopy(self.inputs.apply_to_files) @@ -479,28 +473,27 @@ def _parse_inputs(self): einputs[0]['subj']['resample'] = scans_for_fname(self.inputs.source) return [{'%s' % (jobtype): einputs[0]}] - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): jobtype = self.inputs.jobtype if jobtype.startswith('est'): - outputs['normalization_parameters'] = [] + self.outputs.normalization_parameters = [] for imgf in filename_to_list(self.inputs.source): - outputs['normalization_parameters'].append(fname_presuffix(imgf, + self.outputs.normalization_parameters.append(fname_presuffix(imgf, suffix='_sn.mat', use_ext=False)) - outputs['normalization_parameters'] = list_to_filename(outputs['normalization_parameters']) + self.outputs.normalization_parameters = list_to_filename(self.outputs.normalization_parameters) if self.inputs.jobtype == "estimate": if isdefined(self.inputs.apply_to_files): - outputs['normalized_files'] = self.inputs.apply_to_files - outputs['normalized_source'] = self.inputs.source + self.outputs.normalized_files = self.inputs.apply_to_files + self.outputs.normalized_source = self.inputs.source elif 'write' in self.inputs.jobtype: if isdefined(self.inputs.write_preserve) and self.inputs.write_preserve: prefixNorm = ''.join(['m', self.inputs.out_prefix]) else: prefixNorm = self.inputs.out_prefix - outputs['normalized_files'] = [] + self.outputs.normalized_files = [] if isdefined(self.inputs.apply_to_files): filelist = filename_to_list(self.inputs.apply_to_files) for f in filelist: @@ -508,14 +501,13 @@ def _list_outputs(self): run = [fname_presuffix(in_f, prefix=prefixNorm) for in_f in f] else: run = [fname_presuffix(f, prefix=prefixNorm)] - outputs['normalized_files'].extend(run) + self.outputs.normalized_files.extend(run) if isdefined(self.inputs.source): - outputs['normalized_source'] = [] + self.outputs.normalized_source = [] for imgf in filename_to_list(self.inputs.source): - outputs['normalized_source'].append(fname_presuffix(imgf, + self.outputs.normalized_source.append(fname_presuffix(imgf, prefix=prefixNorm)) - return outputs class Normalize12InputSpec(SPMCommandInputSpec): @@ -603,8 +595,8 @@ class Normalize12(SPMCommand): """ - input_spec = Normalize12InputSpec - output_spec = Normalize12OutputSpec + _input_spec = Normalize12InputSpec + _output_spec = Normalize12OutputSpec _jobtype = 'spatial' _jobname = 'normalise' @@ -624,10 +616,10 @@ def _format_arg(self, opt, spec, val): raise ValueError('%s must have 5 elements' % opt) return super(Normalize12, self)._format_arg(opt, spec, val) - def _parse_inputs(self, skip=()): + def parse_args(self, skip=()): """validate spm normalize options if set to None ignore """ - einputs = super(Normalize12, self)._parse_inputs(skip=('jobtype', + einputs = super(Normalize12, self).parse_args(skip=('jobtype', 'apply_to_files')) if isdefined(self.inputs.apply_to_files): inputfiles = deepcopy(self.inputs.apply_to_files) @@ -641,24 +633,23 @@ def _parse_inputs(self, skip=()): einputs[0]['subj']['resample'] = scans_for_fname(self.inputs.image_to_align) return [{'%s' % (jobtype): einputs[0]}] - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): jobtype = self.inputs.jobtype if jobtype.startswith('est'): - outputs['deformation_field'] = [] + self.outputs.deformation_field = [] for imgf in filename_to_list(self.inputs.image_to_align): - outputs['deformation_field'].append(fname_presuffix(imgf, + self.outputs.deformation_field.append(fname_presuffix(imgf, prefix='y_')) - outputs['deformation_field'] = list_to_filename(outputs['deformation_field']) + self.outputs.deformation_field = list_to_filename(self.outputs.deformation_field) if self.inputs.jobtype == "estimate": if isdefined(self.inputs.apply_to_files): - outputs['normalized_files'] = self.inputs.apply_to_files - outputs['normalized_image'] = fname_presuffix(self.inputs.image_to_align, + self.outputs.normalized_files = self.inputs.apply_to_files + self.outputs.normalized_image = fname_presuffix(self.inputs.image_to_align, prefix='w') elif 'write' in self.inputs.jobtype: - outputs['normalized_files'] = [] + self.outputs.normalized_files = [] if isdefined(self.inputs.apply_to_files): filelist = filename_to_list(self.inputs.apply_to_files) for f in filelist: @@ -666,12 +657,11 @@ def _list_outputs(self): run = [fname_presuffix(in_f, prefix='w') for in_f in f] else: run = [fname_presuffix(f, prefix='w')] - outputs['normalized_files'].extend(run) + self.outputs.normalized_files.extend(run) if isdefined(self.inputs.image_to_align): - outputs['normalized_image'] = fname_presuffix(self.inputs.image_to_align, + self.outputs.normalized_image = fname_presuffix(self.inputs.image_to_align, prefix='w') - return outputs class SegmentInputSpec(SPMCommandInputSpec): @@ -765,8 +755,8 @@ class Segment(SPMCommand): """ - input_spec = SegmentInputSpec - output_spec = SegmentOutputSpec + _input_spec = SegmentInputSpec + _output_spec = SegmentOutputSpec def __init__(self, **inputs): _local_version = SPMCommand().version @@ -797,8 +787,7 @@ def _format_arg(self, opt, spec, val): return clean_masks_dict[val] return super(Segment, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): f = self.inputs.data[0] for tidx, tissue in enumerate(['gm', 'wm', 'csf']): @@ -809,17 +798,16 @@ def _list_outputs(self): ('native', '')]): if getattr(self.inputs, outtype)[idx]: outfield = '%s_%s_image' % (image, tissue) - outputs[outfield] = fname_presuffix(f, + setattr(self.outputs, outfield, fname_presuffix(f, prefix='%sc%d' % (prefix, - tidx + 1)) + tidx + 1))) if isdefined(self.inputs.save_bias_corrected) and \ self.inputs.save_bias_corrected: - outputs['bias_corrected_image'] = fname_presuffix(f, prefix='m') + self.outputs.bias_corrected_image = fname_presuffix(f, prefix='m') t_mat = fname_presuffix(f, suffix='_seg_sn.mat', use_ext=False) - outputs['transformation_mat'] = t_mat + self.outputs.transformation_mat = t_mat invt_mat = fname_presuffix(f, suffix='_seg_inv_sn.mat', use_ext=False) - outputs['inverse_transformation_mat'] = invt_mat - return outputs + self.outputs.inverse_transformation_mat = invt_mat class NewSegmentInputSpec(SPMCommandInputSpec): @@ -894,8 +882,8 @@ class NewSegment(SPMCommand): """ - input_spec = NewSegmentInputSpec - output_spec = NewSegmentOutputSpec + _input_spec = NewSegmentInputSpec + _output_spec = NewSegmentOutputSpec def __init__(self, **inputs): _local_version = SPMCommand().version @@ -937,56 +925,54 @@ def _format_arg(self, opt, spec, val): else: return super(NewSegment, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['native_class_images'] = [] - outputs['dartel_input_images'] = [] - outputs['normalized_class_images'] = [] - outputs['modulated_class_images'] = [] - outputs['transformation_mat'] = [] - outputs['bias_corrected_images'] = [] - outputs['bias_field_images'] = [] - outputs['inverse_deformation_field'] = [] - outputs['forward_deformation_field'] = [] + def _post_run(self): + self.outputs.native_class_images = [] + self.outputs.dartel_input_images = [] + self.outputs.normalized_class_images = [] + self.outputs.modulated_class_images = [] + self.outputs.transformation_mat = [] + self.outputs.bias_corrected_images = [] + self.outputs.bias_field_images = [] + self.outputs.inverse_deformation_field = [] + self.outputs.forward_deformation_field = [] n_classes = 5 if isdefined(self.inputs.tissues): n_classes = len(self.inputs.tissues) for i in range(n_classes): - outputs['native_class_images'].append([]) - outputs['dartel_input_images'].append([]) - outputs['normalized_class_images'].append([]) - outputs['modulated_class_images'].append([]) + self.outputs.native_class_images.append([]) + self.outputs.dartel_input_images.append([]) + self.outputs.normalized_class_images.append([]) + self.outputs.modulated_class_images.append([]) for filename in self.inputs.channel_files: pth, base, ext = split_filename(filename) if isdefined(self.inputs.tissues): for i, tissue in enumerate(self.inputs.tissues): if tissue[2][0]: - outputs['native_class_images'][i].append(os.path.join(pth, "c%d%s.nii" % (i + 1, base))) + self.outputs.native_class_images[i].append(os.path.join(pth, "c%d%s.nii" % (i + 1, base))) if tissue[2][1]: - outputs['dartel_input_images'][i].append(os.path.join(pth, "rc%d%s.nii" % (i + 1, base))) + self.outputs.dartel_input_images[i].append(os.path.join(pth, "rc%d%s.nii" % (i + 1, base))) if tissue[3][0]: - outputs['normalized_class_images'][i].append(os.path.join(pth, "wc%d%s.nii" % (i + 1, base))) + self.outputs.normalized_class_images[i].append(os.path.join(pth, "wc%d%s.nii" % (i + 1, base))) if tissue[3][1]: - outputs['modulated_class_images'][i].append(os.path.join(pth, "mwc%d%s.nii" % (i + 1, base))) + self.outputs.modulated_class_images[i].append(os.path.join(pth, "mwc%d%s.nii" % (i + 1, base))) else: for i in range(n_classes): - outputs['native_class_images'][i].append(os.path.join(pth, "c%d%s.nii" % (i + 1, base))) - outputs['transformation_mat'].append(os.path.join(pth, "%s_seg8.mat" % base)) + self.outputs.native_class_images[i].append(os.path.join(pth, "c%d%s.nii" % (i + 1, base))) + self.outputs.transformation_mat.append(os.path.join(pth, "%s_seg8.mat" % base)) if isdefined(self.inputs.write_deformation_fields): if self.inputs.write_deformation_fields[0]: - outputs['inverse_deformation_field'].append(os.path.join(pth, "iy_%s.nii" % base)) + self.outputs.inverse_deformation_field.append(os.path.join(pth, "iy_%s.nii" % base)) if self.inputs.write_deformation_fields[1]: - outputs['forward_deformation_field'].append(os.path.join(pth, "y_%s.nii" % base)) + self.outputs.forward_deformation_field.append(os.path.join(pth, "y_%s.nii" % base)) if isdefined(self.inputs.channel_info): if self.inputs.channel_info[2][0]: - outputs['bias_corrected_images'].append(os.path.join(pth, "m%s.nii" % (base))) + self.outputs.bias_corrected_images.append(os.path.join(pth, "m%s.nii" % (base))) if self.inputs.channel_info[2][1]: - outputs['bias_field_images'].append(os.path.join(pth, "BiasField_%s.nii" % (base))) - return outputs + self.outputs.bias_field_images.append(os.path.join(pth, "BiasField_%s.nii" % (base))) class SmoothInputSpec(SPMCommandInputSpec): @@ -1023,8 +1009,8 @@ class Smooth(SPMCommand): >>> smooth.run() # doctest: +SKIP """ - input_spec = SmoothInputSpec - output_spec = SmoothOutputSpec + _input_spec = SmoothInputSpec + _output_spec = SmoothOutputSpec _jobtype = 'spatial' _jobname = 'smooth' @@ -1042,13 +1028,11 @@ def _format_arg(self, opt, spec, val): return super(Smooth, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['smoothed_files'] = [] + def _post_run(self): + self.outputs.smoothed_files = [] for imgf in filename_to_list(self.inputs.in_files): - outputs['smoothed_files'].append(fname_presuffix(imgf, prefix=self.inputs.out_prefix)) - return outputs + self.outputs.smoothed_files.append(fname_presuffix(imgf, prefix=self.inputs.out_prefix)) class DARTELInputSpec(SPMCommandInputSpec): @@ -1109,8 +1093,8 @@ class DARTEL(SPMCommand): """ - input_spec = DARTELInputSpec - output_spec = DARTELOutputSpec + _input_spec = DARTELInputSpec + _output_spec = DARTELOutputSpec _jobtype = 'tools' _jobname = 'dartel' @@ -1142,19 +1126,17 @@ def _format_arg(self, opt, spec, val): else: return super(DARTEL, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['template_files'] = [] + def _post_run(self): + self.outputs.template_files = [] for i in range(6): - outputs['template_files'].append(os.path.realpath('%s_%d.nii' % (self.inputs.template_prefix, i + 1))) - outputs['final_template_file'] = os.path.realpath('%s_6.nii' % self.inputs.template_prefix) - outputs['dartel_flow_fields'] = [] + self.outputs.template_files.append(os.path.realpath('%s_%d.nii' % (self.inputs.template_prefix, i + 1))) + self.outputs.final_template_file = os.path.realpath('%s_6.nii' % self.inputs.template_prefix) + self.outputs.dartel_flow_fields = [] for filename in self.inputs.image_files[0]: pth, base, ext = split_filename(filename) - outputs['dartel_flow_fields'].append(os.path.realpath('u_%s_%s%s' % (base, + self.outputs.dartel_flow_fields.append(os.path.realpath('u_%s_%s%s' % (base, self.inputs.template_prefix, ext))) - return outputs class DARTELNorm2MNIInputSpec(SPMCommandInputSpec): @@ -1205,8 +1187,8 @@ class DARTELNorm2MNI(SPMCommand): """ - input_spec = DARTELNorm2MNIInputSpec - output_spec = DARTELNorm2MNIOutputSpec + _input_spec = DARTELNorm2MNIInputSpec + _output_spec = DARTELNorm2MNIOutputSpec _jobtype = 'tools' _jobname = 'dartel' @@ -1231,11 +1213,10 @@ def _format_arg(self, opt, spec, val): else: return super(DARTELNorm2MNI, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): pth, base, ext = split_filename(self.inputs.template_file) - outputs['normalization_parameter_file'] = os.path.realpath(base + '_2mni.mat') - outputs['normalized_files'] = [] + self.outputs.normalization_parameter_file = os.path.realpath(base + '_2mni.mat') + self.outputs.normalized_files = [] prefix = "w" if isdefined(self.inputs.modulate) and self.inputs.modulate: prefix = 'm' + prefix @@ -1243,11 +1224,10 @@ def _list_outputs(self): prefix = 's' + prefix for filename in self.inputs.apply_to_files: pth, base, ext = split_filename(filename) - outputs['normalized_files'].append(os.path.realpath('%s%s%s' % (prefix, + self.outputs.normalized_files.append(os.path.realpath('%s%s%s' % (prefix, base, ext))) - return outputs class CreateWarpedInputSpec(SPMCommandInputSpec): @@ -1289,8 +1269,8 @@ class CreateWarped(SPMCommand): """ - input_spec = CreateWarpedInputSpec - output_spec = CreateWarpedOutputSpec + _input_spec = CreateWarpedInputSpec + _output_spec = CreateWarpedOutputSpec _jobtype = 'tools' _jobname = 'dartel' @@ -1306,18 +1286,16 @@ def _format_arg(self, opt, spec, val): else: return super(CreateWarped, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['warped_files'] = [] + def _post_run(self): + self.outputs.warped_files = [] for filename in self.inputs.image_files: pth, base, ext = split_filename(filename) if isdefined(self.inputs.modulate) and self.inputs.modulate: - outputs['warped_files'].append(os.path.realpath('mw%s%s' % (base, + self.outputs.warped_files.append(os.path.realpath('mw%s%s' % (base, ext))) else: - outputs['warped_files'].append(os.path.realpath('w%s%s' % (base, + self.outputs.warped_files.append(os.path.realpath('w%s%s' % (base, ext))) - return outputs class ApplyDeformationFieldInputSpec(SPMCommandInputSpec): @@ -1334,8 +1312,8 @@ class ApplyDeformationFieldOutputSpec(TraitedSpec): class ApplyDeformations(SPMCommand): - input_spec = ApplyDeformationFieldInputSpec - output_spec = ApplyDeformationFieldOutputSpec + _input_spec = ApplyDeformationFieldInputSpec + _output_spec = ApplyDeformationFieldOutputSpec _jobtype = 'util' _jobname = 'defs' @@ -1354,13 +1332,11 @@ def _format_arg(self, opt, spec, val): else: return super(ApplyDeformations, self)._format_arg(opt, spec, val) - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_files'] = [] + def _post_run(self): + self.outputs.out_files = [] for filename in self.inputs.in_files: _, fname = os.path.split(filename) - outputs['out_files'].append(os.path.realpath('w%s' % fname)) - return outputs + self.outputs.out_files.append(os.path.realpath('w%s' % fname)) class VBMSegmentInputSpec(SPMCommandInputSpec): @@ -1519,100 +1495,98 @@ class VBMSegment(SPMCommand): >>> seg.run() # doctest: +SKIP """ - input_spec = VBMSegmentInputSpec - output_spec = VBMSegmentOuputSpec + _input_spec = VBMSegmentInputSpec + _output_spec = VBMSegmentOuputSpec _jobtype = 'tools' _jobname = 'vbm8' - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): do_dartel = self.inputs.spatial_normalization dartel_px = '' if do_dartel: dartel_px = 'r' - outputs['native_class_images'] = [[], [], []] - outputs['dartel_input_images'] = [[], [], []] - outputs['normalized_class_images'] = [[], [], []] - outputs['modulated_class_images'] = [[], [], []] + self.outputs.native_class_images = [[], [], []] + self.outputs.dartel_input_images = [[], [], []] + self.outputs.normalized_class_images = [[], [], []] + self.outputs.modulated_class_images = [[], [], []] - outputs['transformation_mat'] = [] + self.outputs.transformation_mat = [] - outputs['bias_corrected_images'] = [] - outputs['normalized_bias_corrected_images'] = [] + self.outputs.bias_corrected_images = [] + self.outputs.normalized_bias_corrected_images = [] - outputs['inverse_deformation_field'] = [] - outputs['forward_deformation_field'] = [] - outputs['jacobian_determinant_images'] = [] + self.outputs.inverse_deformation_field = [] + self.outputs.forward_deformation_field = [] + self.outputs.jacobian_determinant_images = [] - outputs['pve_label_native_images'] = [] - outputs['pve_label_normalized_images'] = [] - outputs['pve_label_registered_images'] = [] + self.outputs.pve_label_native_images = [] + self.outputs.pve_label_normalized_images = [] + self.outputs.pve_label_registered_images = [] for filename in self.inputs.in_files: pth, base, ext = split_filename(filename) - outputs['transformation_mat'].append( + self.outputs.transformation_mat.append( os.path.join(pth, "%s_seg8.mat" % base)) for i, tis in enumerate(['gm', 'wm', 'csf']): # native space if getattr(self.inputs, '%s_native' % tis): - outputs['native_class_images'][i].append( + self.outputs.native_class_images[i].append( os.path.join(pth, "p%d%s.nii" % (i + 1, base))) if getattr(self.inputs, '%s_dartel' % tis) == 1: - outputs['dartel_input_images'][i].append( + self.outputs.dartel_input_images[i].append( os.path.join(pth, "rp%d%s.nii" % (i + 1, base))) elif getattr(self.inputs, '%s_dartel' % tis) == 2: - outputs['dartel_input_images'][i].append( + self.outputs.dartel_input_images[i].append( os.path.join(pth, "rp%d%s_affine.nii" % (i + 1, base))) # normalized space if getattr(self.inputs, '%s_normalized' % tis): - outputs['normalized_class_images'][i].append( + self.outputs.normalized_class_images[i].append( os.path.join(pth, "w%sp%d%s.nii" % (dartel_px, i + 1, base))) if getattr(self.inputs, '%s_modulated_normalized' % tis) == 1: - outputs['modulated_class_images'][i].append(os.path.join( + self.outputs.modulated_class_images[i].append(os.path.join( pth, "mw%sp%d%s.nii" % (dartel_px, i + 1, base))) elif getattr(self.inputs, '%s_modulated_normalized' % tis) == 2: - outputs['normalized_class_images'][i].append(os.path.join( + self.outputs.normalized_class_images[i].append(os.path.join( pth, "m0w%sp%d%s.nii" % (dartel_px, i + 1, base))) if self.inputs.pve_label_native: - outputs['pve_label_native_images'].append( + self.outputs.pve_label_native_images.append( os.path.join(pth, "p0%s.nii" % (base))) if self.inputs.pve_label_normalized: - outputs['pve_label_normalized_images'].append( + self.outputs.pve_label_normalized_images.append( os.path.join(pth, "w%sp0%s.nii" % (dartel_px, base))) if self.inputs.pve_label_dartel == 1: - outputs['pve_label_registered_images'].append( + self.outputs.pve_label_registered_images.append( os.path.join(pth, "rp0%s.nii" % (base))) elif self.inputs.pve_label_dartel == 2: - outputs['pve_label_registered_images'].append( + self.outputs.pve_label_registered_images.append( os.path.join(pth, "rp0%s_affine.nii" % (base))) if self.inputs.bias_corrected_native: - outputs['bias_corrected_images'].append( + self.outputs.bias_corrected_images.append( os.path.join(pth, "m%s.nii" % (base))) if self.inputs.bias_corrected_normalized: - outputs['normalized_bias_corrected_images'].append( + self.outputs.normalized_bias_corrected_images.append( os.path.join(pth, "wm%s%s.nii" % (dartel_px, base))) if self.inputs.deformation_field[0]: - outputs['forward_deformation_field'].append( + self.outputs.forward_deformation_field.append( os.path.join(pth, "y_%s%s.nii" % (dartel_px, base))) if self.inputs.deformation_field[1]: - outputs['inverse_deformation_field'].append( + self.outputs.inverse_deformation_field.append( os.path.join(pth, "iy_%s%s.nii" % (dartel_px, base))) if self.inputs.jacobian_determinant and do_dartel: - outputs['jacobian_determinant_images'].append( + self.outputs.jacobian_determinant_images.append( os.path.join(pth, "jac_wrp1%s.nii" % (base))) - return outputs def _format_arg(self, opt, spec, val): """Convert input to appropriate format for spm @@ -1629,11 +1603,11 @@ def _format_arg(self, opt, spec, val): else: return super(VBMSegment, self)._format_arg(opt, spec, val) - def _parse_inputs(self): + def parse_args(self): if self.inputs.spatial_normalization == 'low': - einputs = super(VBMSegment, self)._parse_inputs( + einputs = super(VBMSegment, self).parse_args( skip=('spatial_normalization', 'dartel_template')) einputs[0]['estwrite']['extopts']['dartelwarp'] = {'normlow': 1} return einputs else: - return super(VBMSegment, self)._parse_inputs(skip=('spatial_normalization')) + return super(VBMSegment, self).parse_args(skip=('spatial_normalization')) diff --git a/nipype/interfaces/spm/tests/test_auto_Analyze2nii.py b/nipype/interfaces/spm/tests/test_auto_Analyze2nii.py index 2f175f80f6..b319cbf62e 100644 --- a/nipype/interfaces/spm/tests/test_auto_Analyze2nii.py +++ b/nipype/interfaces/spm/tests/test_auto_Analyze2nii.py @@ -6,9 +6,6 @@ def test_Analyze2nii_inputs(): input_map = dict(analyze_file=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -18,7 +15,7 @@ def test_Analyze2nii_inputs(): usedefault=True, ), ) - inputs = Analyze2nii.input_spec() + inputs = Analyze2nii._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -26,10 +23,7 @@ def test_Analyze2nii_inputs(): def test_Analyze2nii_outputs(): - output_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - matlab_cmd=dict(), + output_map = dict(matlab_cmd=dict(), mfile=dict(usedefault=True, ), nifti_file=dict(), @@ -39,7 +33,7 @@ def test_Analyze2nii_outputs(): usedefault=True, ), ) - outputs = Analyze2nii.output_spec() + outputs = Analyze2nii._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_ApplyDeformations.py b/nipype/interfaces/spm/tests/test_auto_ApplyDeformations.py index a84d6e8246..11d0273df2 100644 --- a/nipype/interfaces/spm/tests/test_auto_ApplyDeformations.py +++ b/nipype/interfaces/spm/tests/test_auto_ApplyDeformations.py @@ -7,9 +7,6 @@ def test_ApplyDeformations_inputs(): input_map = dict(deformation_field=dict(field='comp{1}.def', mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(field='fnames', mandatory=True, ), @@ -27,7 +24,7 @@ def test_ApplyDeformations_inputs(): usedefault=True, ), ) - inputs = ApplyDeformations.input_spec() + inputs = ApplyDeformations._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +34,7 @@ def test_ApplyDeformations_inputs(): def test_ApplyDeformations_outputs(): output_map = dict(out_files=dict(), ) - outputs = ApplyDeformations.output_spec() + outputs = ApplyDeformations._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_ApplyInverseDeformation.py b/nipype/interfaces/spm/tests/test_auto_ApplyInverseDeformation.py index 8eca900dd9..9901677221 100644 --- a/nipype/interfaces/spm/tests/test_auto_ApplyInverseDeformation.py +++ b/nipype/interfaces/spm/tests/test_auto_ApplyInverseDeformation.py @@ -12,9 +12,6 @@ def test_ApplyInverseDeformation_inputs(): deformation_field=dict(field='comp{1}.inv.comp{1}.def', xor=['deformation'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(field='fnames', mandatory=True, ), @@ -33,7 +30,7 @@ def test_ApplyInverseDeformation_inputs(): voxel_sizes=dict(field='comp{1}.inv.comp{1}.sn2def.vox', ), ) - inputs = ApplyInverseDeformation.input_spec() + inputs = ApplyInverseDeformation._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +40,7 @@ def test_ApplyInverseDeformation_inputs(): def test_ApplyInverseDeformation_outputs(): output_map = dict(out_files=dict(), ) - outputs = ApplyInverseDeformation.output_spec() + outputs = ApplyInverseDeformation._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_ApplyTransform.py b/nipype/interfaces/spm/tests/test_auto_ApplyTransform.py index 090ae3e200..75a5c0406b 100644 --- a/nipype/interfaces/spm/tests/test_auto_ApplyTransform.py +++ b/nipype/interfaces/spm/tests/test_auto_ApplyTransform.py @@ -4,10 +4,7 @@ def test_ApplyTransform_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - in_file=dict(copyfile=True, + input_map = dict(in_file=dict(copyfile=True, mandatory=True, ), mat=dict(mandatory=True, @@ -23,7 +20,7 @@ def test_ApplyTransform_inputs(): usedefault=True, ), ) - inputs = ApplyTransform.input_spec() + inputs = ApplyTransform._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -33,7 +30,7 @@ def test_ApplyTransform_inputs(): def test_ApplyTransform_outputs(): output_map = dict(out_file=dict(), ) - outputs = ApplyTransform.output_spec() + outputs = ApplyTransform._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_CalcCoregAffine.py b/nipype/interfaces/spm/tests/test_auto_CalcCoregAffine.py index a058f57767..883234a93d 100644 --- a/nipype/interfaces/spm/tests/test_auto_CalcCoregAffine.py +++ b/nipype/interfaces/spm/tests/test_auto_CalcCoregAffine.py @@ -4,10 +4,7 @@ def test_CalcCoregAffine_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - invmat=dict(), + input_map = dict(invmat=dict(), mat=dict(), matlab_cmd=dict(), mfile=dict(usedefault=True, @@ -23,7 +20,7 @@ def test_CalcCoregAffine_inputs(): usedefault=True, ), ) - inputs = CalcCoregAffine.input_spec() + inputs = CalcCoregAffine._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -34,7 +31,7 @@ def test_CalcCoregAffine_outputs(): output_map = dict(invmat=dict(), mat=dict(), ) - outputs = CalcCoregAffine.output_spec() + outputs = CalcCoregAffine._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_Coregister.py b/nipype/interfaces/spm/tests/test_auto_Coregister.py index 5b8eb8f51f..0b33156bef 100644 --- a/nipype/interfaces/spm/tests/test_auto_Coregister.py +++ b/nipype/interfaces/spm/tests/test_auto_Coregister.py @@ -11,9 +11,6 @@ def test_Coregister_inputs(): ), fwhm=dict(field='eoptions.fwhm', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), jobtype=dict(usedefault=True, ), matlab_cmd=dict(), @@ -46,7 +43,7 @@ def test_Coregister_inputs(): write_wrap=dict(field='roptions.wrap', ), ) - inputs = Coregister.input_spec() + inputs = Coregister._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -57,7 +54,7 @@ def test_Coregister_outputs(): output_map = dict(coregistered_files=dict(), coregistered_source=dict(), ) - outputs = Coregister.output_spec() + outputs = Coregister._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_CreateWarped.py b/nipype/interfaces/spm/tests/test_auto_CreateWarped.py index 043847d15e..f77fb87903 100644 --- a/nipype/interfaces/spm/tests/test_auto_CreateWarped.py +++ b/nipype/interfaces/spm/tests/test_auto_CreateWarped.py @@ -8,9 +8,6 @@ def test_CreateWarped_inputs(): field='crt_warped.flowfields', mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_files=dict(copyfile=False, field='crt_warped.images', mandatory=True, @@ -30,7 +27,7 @@ def test_CreateWarped_inputs(): usedefault=True, ), ) - inputs = CreateWarped.input_spec() + inputs = CreateWarped._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -40,7 +37,7 @@ def test_CreateWarped_inputs(): def test_CreateWarped_outputs(): output_map = dict(warped_files=dict(), ) - outputs = CreateWarped.output_spec() + outputs = CreateWarped._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_DARTEL.py b/nipype/interfaces/spm/tests/test_auto_DARTEL.py index 0e3bb00668..388288b3bf 100644 --- a/nipype/interfaces/spm/tests/test_auto_DARTEL.py +++ b/nipype/interfaces/spm/tests/test_auto_DARTEL.py @@ -4,10 +4,7 @@ def test_DARTEL_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - image_files=dict(copyfile=False, + input_map = dict(image_files=dict(copyfile=False, field='warp.images', mandatory=True, ), @@ -29,7 +26,7 @@ def test_DARTEL_inputs(): usedefault=True, ), ) - inputs = DARTEL.input_spec() + inputs = DARTEL._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +38,7 @@ def test_DARTEL_outputs(): final_template_file=dict(), template_files=dict(), ) - outputs = DARTEL.output_spec() + outputs = DARTEL._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_DARTELNorm2MNI.py b/nipype/interfaces/spm/tests/test_auto_DARTELNorm2MNI.py index 8af7fc0285..2569076ef4 100644 --- a/nipype/interfaces/spm/tests/test_auto_DARTELNorm2MNI.py +++ b/nipype/interfaces/spm/tests/test_auto_DARTELNorm2MNI.py @@ -15,9 +15,6 @@ def test_DARTELNorm2MNI_inputs(): ), fwhm=dict(field='mni_norm.fwhm', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -35,7 +32,7 @@ def test_DARTELNorm2MNI_inputs(): voxel_size=dict(field='mni_norm.vox', ), ) - inputs = DARTELNorm2MNI.input_spec() + inputs = DARTELNorm2MNI._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +43,7 @@ def test_DARTELNorm2MNI_outputs(): output_map = dict(normalization_parameter_file=dict(), normalized_files=dict(), ) - outputs = DARTELNorm2MNI.output_spec() + outputs = DARTELNorm2MNI._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_DicomImport.py b/nipype/interfaces/spm/tests/test_auto_DicomImport.py index 9bc1c2762e..11b8e299a0 100644 --- a/nipype/interfaces/spm/tests/test_auto_DicomImport.py +++ b/nipype/interfaces/spm/tests/test_auto_DicomImport.py @@ -10,9 +10,6 @@ def test_DicomImport_inputs(): icedims=dict(field='convopts.icedims', usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(field='data', mandatory=True, ), @@ -31,7 +28,7 @@ def test_DicomImport_inputs(): usedefault=True, ), ) - inputs = DicomImport.input_spec() + inputs = DicomImport._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +38,7 @@ def test_DicomImport_inputs(): def test_DicomImport_outputs(): output_map = dict(out_files=dict(), ) - outputs = DicomImport.output_spec() + outputs = DicomImport._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_EstimateContrast.py b/nipype/interfaces/spm/tests/test_auto_EstimateContrast.py index 558790c20e..85c11a1123 100644 --- a/nipype/interfaces/spm/tests/test_auto_EstimateContrast.py +++ b/nipype/interfaces/spm/tests/test_auto_EstimateContrast.py @@ -11,9 +11,6 @@ def test_EstimateContrast_inputs(): ), group_contrast=dict(xor=['use_derivs'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -32,7 +29,7 @@ def test_EstimateContrast_inputs(): usedefault=True, ), ) - inputs = EstimateContrast.input_spec() + inputs = EstimateContrast._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -46,7 +43,7 @@ def test_EstimateContrast_outputs(): spmT_images=dict(), spm_mat_file=dict(), ) - outputs = EstimateContrast.output_spec() + outputs = EstimateContrast._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_EstimateModel.py b/nipype/interfaces/spm/tests/test_auto_EstimateModel.py index 44d269e89c..fe5ee1f894 100644 --- a/nipype/interfaces/spm/tests/test_auto_EstimateModel.py +++ b/nipype/interfaces/spm/tests/test_auto_EstimateModel.py @@ -8,9 +8,6 @@ def test_EstimateModel_inputs(): mandatory=True, ), flags=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -24,7 +21,7 @@ def test_EstimateModel_inputs(): usedefault=True, ), ) - inputs = EstimateModel.input_spec() + inputs = EstimateModel._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -38,7 +35,7 @@ def test_EstimateModel_outputs(): residual_image=dict(), spm_mat_file=dict(), ) - outputs = EstimateModel.output_spec() + outputs = EstimateModel._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_FactorialDesign.py b/nipype/interfaces/spm/tests/test_auto_FactorialDesign.py index c382ed3c8d..7fb31898b5 100644 --- a/nipype/interfaces/spm/tests/test_auto_FactorialDesign.py +++ b/nipype/interfaces/spm/tests/test_auto_FactorialDesign.py @@ -19,9 +19,6 @@ def test_FactorialDesign_inputs(): ), global_normalization=dict(field='globalm.glonorm', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -46,7 +43,7 @@ def test_FactorialDesign_inputs(): usedefault=True, ), ) - inputs = FactorialDesign.input_spec() + inputs = FactorialDesign._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -56,7 +53,7 @@ def test_FactorialDesign_inputs(): def test_FactorialDesign_outputs(): output_map = dict(spm_mat_file=dict(), ) - outputs = FactorialDesign.output_spec() + outputs = FactorialDesign._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_Level1Design.py b/nipype/interfaces/spm/tests/test_auto_Level1Design.py index de50c577c0..9369d00bb9 100644 --- a/nipype/interfaces/spm/tests/test_auto_Level1Design.py +++ b/nipype/interfaces/spm/tests/test_auto_Level1Design.py @@ -11,9 +11,6 @@ def test_Level1Design_inputs(): ), global_intensity_normalization=dict(field='global', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), interscan_interval=dict(field='timing.RT', mandatory=True, ), @@ -46,7 +43,7 @@ def test_Level1Design_inputs(): volterra_expansion_order=dict(field='volt', ), ) - inputs = Level1Design.input_spec() + inputs = Level1Design._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -56,7 +53,7 @@ def test_Level1Design_inputs(): def test_Level1Design_outputs(): output_map = dict(spm_mat_file=dict(), ) - outputs = Level1Design.output_spec() + outputs = Level1Design._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_MultipleRegressionDesign.py b/nipype/interfaces/spm/tests/test_auto_MultipleRegressionDesign.py index 5fa47fadf2..1c166741a7 100644 --- a/nipype/interfaces/spm/tests/test_auto_MultipleRegressionDesign.py +++ b/nipype/interfaces/spm/tests/test_auto_MultipleRegressionDesign.py @@ -19,9 +19,6 @@ def test_MultipleRegressionDesign_inputs(): ), global_normalization=dict(field='globalm.glonorm', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(field='des.mreg.scans', mandatory=True, ), @@ -54,7 +51,7 @@ def test_MultipleRegressionDesign_inputs(): user_covariates=dict(field='des.mreg.mcov', ), ) - inputs = MultipleRegressionDesign.input_spec() + inputs = MultipleRegressionDesign._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -64,7 +61,7 @@ def test_MultipleRegressionDesign_inputs(): def test_MultipleRegressionDesign_outputs(): output_map = dict(spm_mat_file=dict(), ) - outputs = MultipleRegressionDesign.output_spec() + outputs = MultipleRegressionDesign._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_NewSegment.py b/nipype/interfaces/spm/tests/test_auto_NewSegment.py index 89f6a5c18c..4c648b97d2 100644 --- a/nipype/interfaces/spm/tests/test_auto_NewSegment.py +++ b/nipype/interfaces/spm/tests/test_auto_NewSegment.py @@ -12,9 +12,6 @@ def test_NewSegment_inputs(): ), channel_info=dict(field='channel', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -32,7 +29,7 @@ def test_NewSegment_inputs(): write_deformation_fields=dict(field='warp.write', ), ) - inputs = NewSegment.input_spec() + inputs = NewSegment._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -50,7 +47,7 @@ def test_NewSegment_outputs(): normalized_class_images=dict(), transformation_mat=dict(), ) - outputs = NewSegment.output_spec() + outputs = NewSegment._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_Normalize.py b/nipype/interfaces/spm/tests/test_auto_Normalize.py index 96ce55975e..4d0cd8a0c1 100644 --- a/nipype/interfaces/spm/tests/test_auto_Normalize.py +++ b/nipype/interfaces/spm/tests/test_auto_Normalize.py @@ -11,9 +11,6 @@ def test_Normalize_inputs(): apply_to_files=dict(copyfile=True, field='subj.resample', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), jobtype=dict(usedefault=True, ), matlab_cmd=dict(), @@ -67,7 +64,7 @@ def test_Normalize_inputs(): write_wrap=dict(field='roptions.wrap', ), ) - inputs = Normalize.input_spec() + inputs = Normalize._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -79,7 +76,7 @@ def test_Normalize_outputs(): normalized_files=dict(), normalized_source=dict(), ) - outputs = Normalize.output_spec() + outputs = Normalize._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_Normalize12.py b/nipype/interfaces/spm/tests/test_auto_Normalize12.py index 7fedba9d86..0baa8c8e9d 100644 --- a/nipype/interfaces/spm/tests/test_auto_Normalize12.py +++ b/nipype/interfaces/spm/tests/test_auto_Normalize12.py @@ -18,9 +18,6 @@ def test_Normalize12_inputs(): mandatory=True, xor=['image_to_align', 'tpm'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), image_to_align=dict(copyfile=True, field='subj.vol', mandatory=True, @@ -53,7 +50,7 @@ def test_Normalize12_inputs(): write_voxel_sizes=dict(field='woptions.vox', ), ) - inputs = Normalize12.input_spec() + inputs = Normalize12._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -65,7 +62,7 @@ def test_Normalize12_outputs(): normalized_files=dict(), normalized_image=dict(), ) - outputs = Normalize12.output_spec() + outputs = Normalize12._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_OneSampleTTestDesign.py b/nipype/interfaces/spm/tests/test_auto_OneSampleTTestDesign.py index 51f4e9d4e2..486cc029cd 100644 --- a/nipype/interfaces/spm/tests/test_auto_OneSampleTTestDesign.py +++ b/nipype/interfaces/spm/tests/test_auto_OneSampleTTestDesign.py @@ -19,9 +19,6 @@ def test_OneSampleTTestDesign_inputs(): ), global_normalization=dict(field='globalm.glonorm', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(field='des.t1.scans', mandatory=True, ), @@ -49,7 +46,7 @@ def test_OneSampleTTestDesign_inputs(): usedefault=True, ), ) - inputs = OneSampleTTestDesign.input_spec() + inputs = OneSampleTTestDesign._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -59,7 +56,7 @@ def test_OneSampleTTestDesign_inputs(): def test_OneSampleTTestDesign_outputs(): output_map = dict(spm_mat_file=dict(), ) - outputs = OneSampleTTestDesign.output_spec() + outputs = OneSampleTTestDesign._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_PairedTTestDesign.py b/nipype/interfaces/spm/tests/test_auto_PairedTTestDesign.py index b053cb58d1..ca35c6e0a8 100644 --- a/nipype/interfaces/spm/tests/test_auto_PairedTTestDesign.py +++ b/nipype/interfaces/spm/tests/test_auto_PairedTTestDesign.py @@ -23,9 +23,6 @@ def test_PairedTTestDesign_inputs(): ), grand_mean_scaling=dict(field='des.pt.gmsca', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -53,7 +50,7 @@ def test_PairedTTestDesign_inputs(): usedefault=True, ), ) - inputs = PairedTTestDesign.input_spec() + inputs = PairedTTestDesign._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -63,7 +60,7 @@ def test_PairedTTestDesign_inputs(): def test_PairedTTestDesign_outputs(): output_map = dict(spm_mat_file=dict(), ) - outputs = PairedTTestDesign.output_spec() + outputs = PairedTTestDesign._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_Realign.py b/nipype/interfaces/spm/tests/test_auto_Realign.py index 6ee1c7a110..39082b5936 100644 --- a/nipype/interfaces/spm/tests/test_auto_Realign.py +++ b/nipype/interfaces/spm/tests/test_auto_Realign.py @@ -6,9 +6,6 @@ def test_Realign_inputs(): input_map = dict(fwhm=dict(field='eoptions.fwhm', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(copyfile=True, field='data', mandatory=True, @@ -50,7 +47,7 @@ def test_Realign_inputs(): write_wrap=dict(field='roptions.wrap', ), ) - inputs = Realign.input_spec() + inputs = Realign._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -63,7 +60,7 @@ def test_Realign_outputs(): realigned_files=dict(), realignment_parameters=dict(), ) - outputs = Realign.output_spec() + outputs = Realign._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_Reslice.py b/nipype/interfaces/spm/tests/test_auto_Reslice.py index 1687309bd7..814e5c15af 100644 --- a/nipype/interfaces/spm/tests/test_auto_Reslice.py +++ b/nipype/interfaces/spm/tests/test_auto_Reslice.py @@ -4,10 +4,7 @@ def test_Reslice_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - in_file=dict(mandatory=True, + input_map = dict(in_file=dict(mandatory=True, ), interp=dict(usedefault=True, ), @@ -23,7 +20,7 @@ def test_Reslice_inputs(): usedefault=True, ), ) - inputs = Reslice.input_spec() + inputs = Reslice._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -33,7 +30,7 @@ def test_Reslice_inputs(): def test_Reslice_outputs(): output_map = dict(out_file=dict(), ) - outputs = Reslice.output_spec() + outputs = Reslice._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_ResliceToReference.py b/nipype/interfaces/spm/tests/test_auto_ResliceToReference.py index d791b5965a..8012e6d425 100644 --- a/nipype/interfaces/spm/tests/test_auto_ResliceToReference.py +++ b/nipype/interfaces/spm/tests/test_auto_ResliceToReference.py @@ -6,9 +6,6 @@ def test_ResliceToReference_inputs(): input_map = dict(bounding_box=dict(field='comp{2}.idbbvox.bb', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(field='fnames', mandatory=True, ), @@ -27,7 +24,7 @@ def test_ResliceToReference_inputs(): voxel_sizes=dict(field='comp{2}.idbbvox.vox', ), ) - inputs = ResliceToReference.input_spec() + inputs = ResliceToReference._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -37,7 +34,7 @@ def test_ResliceToReference_inputs(): def test_ResliceToReference_outputs(): output_map = dict(out_files=dict(), ) - outputs = ResliceToReference.output_spec() + outputs = ResliceToReference._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_SPMCommand.py b/nipype/interfaces/spm/tests/test_auto_SPMCommand.py index 76676dd1ab..6f0fe180a1 100644 --- a/nipype/interfaces/spm/tests/test_auto_SPMCommand.py +++ b/nipype/interfaces/spm/tests/test_auto_SPMCommand.py @@ -4,10 +4,7 @@ def test_SPMCommand_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - matlab_cmd=dict(), + input_map = dict(matlab_cmd=dict(), mfile=dict(usedefault=True, ), paths=dict(), @@ -16,9 +13,17 @@ def test_SPMCommand_inputs(): usedefault=True, ), ) - inputs = SPMCommand.input_spec() + inputs = SPMCommand._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_SPMCommand_outputs(): + output_map = dict() + outputs = SPMCommand._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/spm/tests/test_auto_Segment.py b/nipype/interfaces/spm/tests/test_auto_Segment.py index c32284105c..b2257c2eaa 100644 --- a/nipype/interfaces/spm/tests/test_auto_Segment.py +++ b/nipype/interfaces/spm/tests/test_auto_Segment.py @@ -22,9 +22,6 @@ def test_Segment_inputs(): ), gm_output_type=dict(field='output.GM', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), mask_image=dict(field='opts.msk', ), matlab_cmd=dict(), @@ -48,7 +45,7 @@ def test_Segment_inputs(): wm_output_type=dict(field='output.WM', ), ) - inputs = Segment.input_spec() + inputs = Segment._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -72,7 +69,7 @@ def test_Segment_outputs(): normalized_wm_image=dict(), transformation_mat=dict(), ) - outputs = Segment.output_spec() + outputs = Segment._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_SliceTiming.py b/nipype/interfaces/spm/tests/test_auto_SliceTiming.py index c230c2909c..a9ffcaef6d 100644 --- a/nipype/interfaces/spm/tests/test_auto_SliceTiming.py +++ b/nipype/interfaces/spm/tests/test_auto_SliceTiming.py @@ -4,10 +4,7 @@ def test_SliceTiming_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - in_files=dict(copyfile=False, + input_map = dict(in_files=dict(copyfile=False, field='scans', mandatory=True, ), @@ -38,7 +35,7 @@ def test_SliceTiming_inputs(): usedefault=True, ), ) - inputs = SliceTiming.input_spec() + inputs = SliceTiming._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -48,7 +45,7 @@ def test_SliceTiming_inputs(): def test_SliceTiming_outputs(): output_map = dict(timecorrected_files=dict(), ) - outputs = SliceTiming.output_spec() + outputs = SliceTiming._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_Smooth.py b/nipype/interfaces/spm/tests/test_auto_Smooth.py index aa5708ba5f..e7c69bbdba 100644 --- a/nipype/interfaces/spm/tests/test_auto_Smooth.py +++ b/nipype/interfaces/spm/tests/test_auto_Smooth.py @@ -8,9 +8,6 @@ def test_Smooth_inputs(): ), fwhm=dict(field='fwhm', ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), implicit_masking=dict(field='im', ), in_files=dict(copyfile=False, @@ -29,7 +26,7 @@ def test_Smooth_inputs(): usedefault=True, ), ) - inputs = Smooth.input_spec() + inputs = Smooth._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +36,7 @@ def test_Smooth_inputs(): def test_Smooth_outputs(): output_map = dict(smoothed_files=dict(), ) - outputs = Smooth.output_spec() + outputs = Smooth._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_Threshold.py b/nipype/interfaces/spm/tests/test_auto_Threshold.py index e79460f980..6e865006e9 100644 --- a/nipype/interfaces/spm/tests/test_auto_Threshold.py +++ b/nipype/interfaces/spm/tests/test_auto_Threshold.py @@ -16,9 +16,6 @@ def test_Threshold_inputs(): ), height_threshold_type=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -38,7 +35,7 @@ def test_Threshold_inputs(): usedefault=True, ), ) - inputs = Threshold.input_spec() + inputs = Threshold._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -53,7 +50,7 @@ def test_Threshold_outputs(): pre_topo_n_clusters=dict(), thresholded_map=dict(), ) - outputs = Threshold.output_spec() + outputs = Threshold._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_ThresholdStatistics.py b/nipype/interfaces/spm/tests/test_auto_ThresholdStatistics.py index a5363ebccd..a19f3fbf95 100644 --- a/nipype/interfaces/spm/tests/test_auto_ThresholdStatistics.py +++ b/nipype/interfaces/spm/tests/test_auto_ThresholdStatistics.py @@ -10,9 +10,6 @@ def test_ThresholdStatistics_inputs(): ), height_threshold=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -28,7 +25,7 @@ def test_ThresholdStatistics_inputs(): usedefault=True, ), ) - inputs = ThresholdStatistics.input_spec() + inputs = ThresholdStatistics._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -43,7 +40,7 @@ def test_ThresholdStatistics_outputs(): voxelwise_P_RF=dict(), voxelwise_P_uncor=dict(), ) - outputs = ThresholdStatistics.output_spec() + outputs = ThresholdStatistics._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_TwoSampleTTestDesign.py b/nipype/interfaces/spm/tests/test_auto_TwoSampleTTestDesign.py index c27ae684dc..28d5f2513b 100644 --- a/nipype/interfaces/spm/tests/test_auto_TwoSampleTTestDesign.py +++ b/nipype/interfaces/spm/tests/test_auto_TwoSampleTTestDesign.py @@ -27,9 +27,6 @@ def test_TwoSampleTTestDesign_inputs(): group2_files=dict(field='des.t2.scans2', mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), matlab_cmd=dict(), mfile=dict(usedefault=True, ), @@ -56,7 +53,7 @@ def test_TwoSampleTTestDesign_inputs(): usedefault=True, ), ) - inputs = TwoSampleTTestDesign.input_spec() + inputs = TwoSampleTTestDesign._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -66,7 +63,7 @@ def test_TwoSampleTTestDesign_inputs(): def test_TwoSampleTTestDesign_outputs(): output_map = dict(spm_mat_file=dict(), ) - outputs = TwoSampleTTestDesign.output_spec() + outputs = TwoSampleTTestDesign._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_auto_VBMSegment.py b/nipype/interfaces/spm/tests/test_auto_VBMSegment.py index 1b330af007..9695fa7d20 100644 --- a/nipype/interfaces/spm/tests/test_auto_VBMSegment.py +++ b/nipype/interfaces/spm/tests/test_auto_VBMSegment.py @@ -56,9 +56,6 @@ def test_VBMSegment_inputs(): gm_normalized=dict(field='estwrite.output.GM.warped', usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_files=dict(copyfile=False, field='estwrite.data', mandatory=True, @@ -112,7 +109,7 @@ def test_VBMSegment_inputs(): usedefault=True, ), ) - inputs = VBMSegment.input_spec() + inputs = VBMSegment._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -134,7 +131,7 @@ def test_VBMSegment_outputs(): pve_label_registered_images=dict(), transformation_mat=dict(), ) - outputs = VBMSegment.output_spec() + outputs = VBMSegment._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/spm/tests/test_base.py b/nipype/interfaces/spm/tests/test_base.py index 73e8ad9c12..0d22befe32 100644 --- a/nipype/interfaces/spm/tests/test_base.py +++ b/nipype/interfaces/spm/tests/test_base.py @@ -63,7 +63,7 @@ def test_spm_path(): def test_use_mfile(): class TestClass(spm.SPMCommand): - input_spec = spm.SPMCommandInputSpec + _input_spec = spm.SPMCommandInputSpec dc = TestClass() # dc = derived_class yield assert_true, dc.inputs.mfile @@ -100,7 +100,7 @@ class TestClass(spm.SPMCommand): @skipif(no_spm, "SPM not found") def test_cmd_update(): class TestClass(spm.SPMCommand): - input_spec = spm.SPMCommandInputSpec + _input_spec = spm.SPMCommandInputSpec dc = TestClass() # dc = derived_class dc.inputs.matlab_cmd = 'foo' yield assert_equal, dc.mlab._cmd, 'foo' @@ -110,7 +110,7 @@ def test_cmd_update2(): class TestClass(spm.SPMCommand): _jobtype = 'jobtype' _jobname = 'jobname' - input_spec = spm.SPMCommandInputSpec + _input_spec = spm.SPMCommandInputSpec dc = TestClass() # dc = derived_class yield assert_equal, dc.jobtype, 'jobtype' yield assert_equal, dc.jobname, 'jobname' @@ -118,7 +118,7 @@ class TestClass(spm.SPMCommand): def test_reformat_dict_for_savemat(): class TestClass(spm.SPMCommand): - input_spec = spm.SPMCommandInputSpec + _input_spec = spm.SPMCommandInputSpec dc = TestClass() # dc = derived_class out = dc._reformat_dict_for_savemat({'a': {'b': {'c': []}}}) yield assert_equal, out, [{'a': [{'b': [{'c': []}]}]}] @@ -126,7 +126,7 @@ class TestClass(spm.SPMCommand): def test_generate_job(): class TestClass(spm.SPMCommand): - input_spec = spm.SPMCommandInputSpec + _input_spec = spm.SPMCommandInputSpec dc = TestClass() # dc = derived_class out = dc._generate_job() yield assert_equal, out, '' @@ -158,15 +158,15 @@ class TestClassInputSpec(SPMCommandInputSpec): test_in = include_intercept = traits.Bool(field='testfield') class TestClass(spm.SPMCommand): - input_spec = TestClassInputSpec + _input_spec = TestClassInputSpec _jobtype = 'jobtype' _jobname = 'jobname' dc = TestClass() # dc = derived_class dc.inputs.test_in = True - out = dc._make_matlab_command(dc._parse_inputs()) + out = dc._make_matlab_command(dc.parse_args()) yield assert_equal, out.find('jobs{1}.spm.jobtype.jobname.testfield = 1;') > 0, 1 dc.inputs.use_v8struct = False - out = dc._make_matlab_command(dc._parse_inputs()) + out = dc._make_matlab_command(dc.parse_args()) yield assert_equal, out.find('jobs{1}.jobtype{1}.jobname{1}.testfield = 1;') > 0, 1 @@ -174,7 +174,7 @@ def test_make_matlab_command(): class TestClass(spm.SPMCommand): _jobtype = 'jobtype' _jobname = 'jobname' - input_spec = spm.SPMCommandInputSpec + _input_spec = spm.SPMCommandInputSpec dc = TestClass() # dc = derived_class filelist, outdir, cwd = create_files_in_directory() contents = {'contents': [1, 2, 3, 4]} diff --git a/nipype/interfaces/spm/utils.py b/nipype/interfaces/spm/utils.py index 452727fa44..86d2d2bb01 100644 --- a/nipype/interfaces/spm/utils.py +++ b/nipype/interfaces/spm/utils.py @@ -6,7 +6,7 @@ from .base import SPMCommandInputSpec, SPMCommand, Info, scans_for_fnames, scans_for_fname from ..matlab import MatlabCommand from ..base import (TraitedSpec, BaseInterface, - BaseInterfaceInputSpec, isdefined, + BaseInputSpec, isdefined, OutputMultiPath, InputMultiPath) from ..base import File, traits from ...utils.filemanip import split_filename, fname_presuffix, filename_to_list, list_to_filename @@ -22,8 +22,8 @@ class Analyze2niiOutputSpec(SPMCommandInputSpec): class Analyze2nii(SPMCommand): - input_spec = Analyze2niiInputSpec - output_spec = Analyze2niiOutputSpec + _input_spec = Analyze2niiInputSpec + _output_spec = Analyze2niiOutputSpec def _make_matlab_command(self, _): script = "V = spm_vol('%s');\n" % self.inputs.analyze_file @@ -35,10 +35,8 @@ def _make_matlab_command(self, _): return script - def _list_outputs(self): - outputs = self._outputs().get() - outputs['nifti_file'] = self.output_name - return outputs + def _post_run(self): + self.outputs.nifti_file = self.output_name class CalcCoregAffineInputSpec(SPMCommandInputSpec): @@ -78,8 +76,8 @@ class CalcCoregAffine(SPMCommand): that can be used to move it """ - input_spec = CalcCoregAffineInputSpec - output_spec = CalcCoregAffineOutputSpec + _input_spec = CalcCoregAffineInputSpec + _output_spec = CalcCoregAffineOutputSpec def _make_inv_file(self): """ makes filename to hold inverse transform if not specified""" @@ -115,11 +113,9 @@ def _make_matlab_command(self, _): self.inputs.invmat) return script - def _list_outputs(self): - outputs = self._outputs().get() - outputs['mat'] = os.path.abspath(self.inputs.mat) - outputs['invmat'] = os.path.abspath(self.inputs.invmat) - return outputs + def _post_run(self): + self.outputs.mat = os.path.abspath(self.inputs.mat) + self.outputs.invmat = os.path.abspath(self.inputs.invmat) class ApplyTransformInputSpec(SPMCommandInputSpec): @@ -148,13 +144,13 @@ class ApplyTransform(SPMCommand): >>> applymat.run() # doctest: +SKIP """ - input_spec = ApplyTransformInputSpec - output_spec = ApplyTransformOutputSpec + _input_spec = ApplyTransformInputSpec + _output_spec = ApplyTransformOutputSpec def _make_matlab_command(self, _): """checks for SPM, generates script""" outputs = self._list_outputs() - self.inputs.out_file = outputs['out_file'] + self.inputs.out_file = self.outputs.out_file script = """ infile = '%s'; outfile = '%s' @@ -174,13 +170,12 @@ def _make_matlab_command(self, _): # spm_get_space(infile, transform.M * img_space); return script - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): + if not isdefined(self.inputs.out_file): - outputs['out_file'] = os.path.abspath(self._gen_outfilename()) + self.outputs.out_file = os.path.abspath(self._gen_outfilename()) else: - outputs['out_file'] = os.path.abspath(self.inputs.out_file) - return outputs + self.outputs.out_file = os.path.abspath(self.inputs.out_file) def _gen_outfilename(self): _, name, _ = split_filename(self.inputs.in_file) @@ -207,8 +202,8 @@ class ResliceOutputSpec(TraitedSpec): class Reslice(SPMCommand): """ uses spm_reslice to resample in_file into space of space_defining""" - input_spec = ResliceInputSpec - output_spec = ResliceOutputSpec + _input_spec = ResliceInputSpec + _output_spec = ResliceOutputSpec def _make_matlab_command(self, _): """ generates script""" @@ -228,10 +223,8 @@ def _make_matlab_command(self, _): self.inputs.in_file) return script - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_file'] = os.path.abspath(self.inputs.out_file) - return outputs + def _post_run(self): + self.outputs.out_file = os.path.abspath(self.inputs.out_file) class ApplyInverseDeformationInput(SPMCommandInputSpec): @@ -267,6 +260,19 @@ class ApplyInverseDeformationInput(SPMCommandInputSpec): minlen=3, maxlen=3, desc='3-element list (opt)') + def _format_arg(self, opt, spec, val): + """Convert input to appropriate format for spm + """ + if opt == 'in_files': + return scans_for_fnames(filename_to_list(val)) + if opt == 'target': + return scans_for_fname(filename_to_list(val)) + if opt == 'deformation': + return np.array([list_to_filename(val)], dtype=object) + if opt == 'deformation_field': + return np.array([list_to_filename(val)], dtype=object) + return val + class ApplyInverseDeformationOutput(TraitedSpec): out_files = OutputMultiPath(File(exists=True), @@ -288,32 +294,17 @@ class ApplyInverseDeformation(SPMCommand): >>> inv.run() # doctest: +SKIP """ - input_spec = ApplyInverseDeformationInput - output_spec = ApplyInverseDeformationOutput + _input_spec = ApplyInverseDeformationInput + _output_spec = ApplyInverseDeformationOutput _jobtype = 'util' _jobname = 'defs' - def _format_arg(self, opt, spec, val): - """Convert input to appropriate format for spm - """ - if opt == 'in_files': - return scans_for_fnames(filename_to_list(val)) - if opt == 'target': - return scans_for_fname(filename_to_list(val)) - if opt == 'deformation': - return np.array([list_to_filename(val)], dtype=object) - if opt == 'deformation_field': - return np.array([list_to_filename(val)], dtype=object) - return val - - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_files'] = [] + def _post_run(self): + self.outputs.out_files = [] for filename in self.inputs.in_files: _, fname = os.path.split(filename) - outputs['out_files'].append(os.path.realpath('w%s' % fname)) - return outputs + self.outputs.out_files.append(os.path.realpath('w%s' % fname)) class ResliceToReferenceInput(SPMCommandInputSpec): @@ -358,8 +349,8 @@ class ResliceToReference(SPMCommand): >>> r2ref.run() # doctest: +SKIP """ - input_spec = ResliceToReferenceInput - output_spec = ResliceToReferenceOutput + _input_spec = ResliceToReferenceInput + _output_spec = ResliceToReferenceOutput _jobtype = 'util' _jobname = 'defs' @@ -377,13 +368,11 @@ def _format_arg(self, opt, spec, val): return np.array([list_to_filename(val)], dtype=object) return val - def _list_outputs(self): - outputs = self._outputs().get() - outputs['out_files'] = [] + def _post_run(self): + self.outputs.out_files = [] for filename in self.inputs.in_files: _, fname = os.path.split(filename) - outputs['out_files'].append(os.path.realpath('w%s' % fname)) - return outputs + self.outputs.out_files.append(os.path.realpath('w%s' % fname)) class DicomImportInputSpec(SPMCommandInputSpec): @@ -415,6 +404,21 @@ class DicomImportInputSpec(SPMCommandInputSpec): exactly the same file names.') + def _format_arg(self, opt, spec, val): + """Convert input to appropriate format for spm + """ + if opt == 'in_files': + return np.array(val, dtype=object) + if opt == 'output_dir': + return np.array([val], dtype=object) + if opt == 'output_dir': + return os.path.abspath(val) + if opt == 'icedims': + if val: + return 1 + return 0 + return super(DicomImportInputSpec, self)._format_arg(opt, spec, val) + class DicomImportOutputSpec(TraitedSpec): out_files = OutputMultiPath(File(exists=True), desc='converted files') @@ -432,45 +436,28 @@ class DicomImport(SPMCommand): >>> di.run() # doctest: +SKIP """ - input_spec = DicomImportInputSpec - output_spec = DicomImportOutputSpec + _input_spec = DicomImportInputSpec + _output_spec = DicomImportOutputSpec _jobtype = 'util' _jobname = 'dicom' - def _format_arg(self, opt, spec, val): - """Convert input to appropriate format for spm - """ - if opt == 'in_files': - return np.array(val, dtype=object) - if opt == 'output_dir': - return np.array([val], dtype=object) - if opt == 'output_dir': - return os.path.abspath(val) - if opt == 'icedims': - if val: - return 1 - return 0 - return super(DicomImport, self)._format_arg(opt, spec, val) - def _run_interface(self, runtime): od = os.path.abspath(self.inputs.output_dir) if not os.path.isdir(od): os.mkdir(od) return super(DicomImport, self)._run_interface(runtime) - def _list_outputs(self): + def _post_run(self): from glob import glob - outputs = self._outputs().get() od = os.path.abspath(self.inputs.output_dir) - ext = self.inputs.format if self.inputs.output_dir_struct == "flat": - outputs['out_files'] = glob(os.path.join(od, '*.%s' % ext)) + self.outputs.out_files = glob(os.path.join(od, '*.%s' % ext)) elif self.inputs.output_dir_struct == 'series': - outputs['out_files'] = glob(os.path.join(od, os.path.join('*', '*.%s' % ext))) + self.outputs.out_files = glob(os.path.join(od, os.path.join('*', '*.%s' % ext))) elif self.inputs.output_dir_struct in ['patid', 'date_time', 'patname']: - outputs['out_files'] = glob(os.path.join(od, os.path.join('*', '*', '*.%s' % ext))) + self.outputs.out_files = glob(os.path.join(od, os.path.join('*', '*', '*.%s' % ext))) elif self.inputs.output_dir_struct == 'patid_date': - outputs['out_files'] = glob(os.path.join(od, os.path.join('*', '*', '*', '*.%s' % ext))) - return outputs + self.outputs.out_files = glob(os.path.join(od, os.path.join('*', '*', '*', '*.%s' % ext))) + diff --git a/nipype/interfaces/tests/test_auto_AssertEqual.py b/nipype/interfaces/tests/test_auto_AssertEqual.py index 4a1d763e43..54f02f6e02 100644 --- a/nipype/interfaces/tests/test_auto_AssertEqual.py +++ b/nipype/interfaces/tests/test_auto_AssertEqual.py @@ -4,17 +4,22 @@ def test_AssertEqual_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - volume1=dict(mandatory=True, + input_map = dict(volume1=dict(mandatory=True, ), volume2=dict(mandatory=True, ), ) - inputs = AssertEqual.input_spec() + inputs = AssertEqual._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_AssertEqual_outputs(): + output_map = dict() + outputs = AssertEqual._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/tests/test_auto_BaseInterface.py b/nipype/interfaces/tests/test_auto_BaseInterface.py index 5851add1da..dd13b1c7d1 100644 --- a/nipype/interfaces/tests/test_auto_BaseInterface.py +++ b/nipype/interfaces/tests/test_auto_BaseInterface.py @@ -8,9 +8,17 @@ def test_BaseInterface_inputs(): usedefault=True, ), ) - inputs = BaseInterface.input_spec() + inputs = BaseInterface._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_BaseInterface_outputs(): + output_map = dict() + outputs = BaseInterface._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/tests/test_auto_C3dAffineTool.py b/nipype/interfaces/tests/test_auto_C3dAffineTool.py index dc8cc37b8c..df37aa4472 100644 --- a/nipype/interfaces/tests/test_auto_C3dAffineTool.py +++ b/nipype/interfaces/tests/test_auto_C3dAffineTool.py @@ -6,15 +6,9 @@ def test_C3dAffineTool_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), fsl2ras=dict(argstr='-fsl2ras', position=4, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), itk_transform=dict(argstr='-oitk %s', hash_files=False, position=5, @@ -25,13 +19,11 @@ def test_C3dAffineTool_inputs(): source_file=dict(argstr='-src %s', position=2, ), - terminal_output=dict(nohash=True, - ), transform_file=dict(argstr='%s', position=3, ), ) - inputs = C3dAffineTool.input_spec() + inputs = C3dAffineTool._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -41,7 +33,7 @@ def test_C3dAffineTool_inputs(): def test_C3dAffineTool_outputs(): output_map = dict(itk_transform=dict(), ) - outputs = C3dAffineTool.output_spec() + outputs = C3dAffineTool._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_CSVReader.py b/nipype/interfaces/tests/test_auto_CSVReader.py index a6f42de676..e822b91a9a 100644 --- a/nipype/interfaces/tests/test_auto_CSVReader.py +++ b/nipype/interfaces/tests/test_auto_CSVReader.py @@ -9,7 +9,7 @@ def test_CSVReader_inputs(): in_file=dict(mandatory=True, ), ) - inputs = CSVReader.input_spec() + inputs = CSVReader._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -18,7 +18,7 @@ def test_CSVReader_inputs(): def test_CSVReader_outputs(): output_map = dict() - outputs = CSVReader.output_spec() + outputs = CSVReader._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_CommandLine.py b/nipype/interfaces/tests/test_auto_CommandLine.py index 9ea4f08937..f567263fac 100644 --- a/nipype/interfaces/tests/test_auto_CommandLine.py +++ b/nipype/interfaces/tests/test_auto_CommandLine.py @@ -15,9 +15,17 @@ def test_CommandLine_inputs(): terminal_output=dict(nohash=True, ), ) - inputs = CommandLine.input_spec() + inputs = CommandLine._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_CommandLine_outputs(): + output_map = dict() + outputs = CommandLine._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/tests/test_auto_CopyMeta.py b/nipype/interfaces/tests/test_auto_CopyMeta.py index 8b456d4e09..fc9698dcef 100644 --- a/nipype/interfaces/tests/test_auto_CopyMeta.py +++ b/nipype/interfaces/tests/test_auto_CopyMeta.py @@ -11,7 +11,7 @@ def test_CopyMeta_inputs(): src_file=dict(mandatory=True, ), ) - inputs = CopyMeta.input_spec() + inputs = CopyMeta._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -21,7 +21,7 @@ def test_CopyMeta_inputs(): def test_CopyMeta_outputs(): output_map = dict(dest_file=dict(), ) - outputs = CopyMeta.output_spec() + outputs = CopyMeta._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_DataFinder.py b/nipype/interfaces/tests/test_auto_DataFinder.py index 8eb5faa9ea..d126018481 100644 --- a/nipype/interfaces/tests/test_auto_DataFinder.py +++ b/nipype/interfaces/tests/test_auto_DataFinder.py @@ -4,10 +4,7 @@ def test_DataFinder_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - ignore_regexes=dict(), + input_map = dict(ignore_regexes=dict(), match_regex=dict(usedefault=True, ), max_depth=dict(), @@ -17,7 +14,7 @@ def test_DataFinder_inputs(): unpack_single=dict(usedefault=True, ), ) - inputs = DataFinder.input_spec() + inputs = DataFinder._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -26,7 +23,7 @@ def test_DataFinder_inputs(): def test_DataFinder_outputs(): output_map = dict() - outputs = DataFinder.output_spec() + outputs = DataFinder._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_DataGrabber.py b/nipype/interfaces/tests/test_auto_DataGrabber.py index f72eb2bdfe..b123f9991b 100644 --- a/nipype/interfaces/tests/test_auto_DataGrabber.py +++ b/nipype/interfaces/tests/test_auto_DataGrabber.py @@ -5,9 +5,6 @@ def test_DataGrabber_inputs(): input_map = dict(base_directory=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), raise_on_empty=dict(usedefault=True, ), sort_filelist=dict(mandatory=True, @@ -16,7 +13,7 @@ def test_DataGrabber_inputs(): ), template_args=dict(), ) - inputs = DataGrabber.input_spec() + inputs = DataGrabber._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -25,7 +22,7 @@ def test_DataGrabber_inputs(): def test_DataGrabber_outputs(): output_map = dict() - outputs = DataGrabber.output_spec() + outputs = DataGrabber._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_DataSink.py b/nipype/interfaces/tests/test_auto_DataSink.py index 38cb7c1915..f3a1d4d578 100644 --- a/nipype/interfaces/tests/test_auto_DataSink.py +++ b/nipype/interfaces/tests/test_auto_DataSink.py @@ -13,9 +13,6 @@ def test_DataSink_inputs(): container=dict(), creds_path=dict(), encrypt_bucket_keys=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), local_copy=dict(), parameterization=dict(usedefault=True, ), @@ -25,7 +22,7 @@ def test_DataSink_inputs(): strip_dir=dict(), substitutions=dict(), ) - inputs = DataSink.input_spec() + inputs = DataSink._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -35,7 +32,7 @@ def test_DataSink_inputs(): def test_DataSink_outputs(): output_map = dict(out_file=dict(), ) - outputs = DataSink.output_spec() + outputs = DataSink._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_Dcm2nii.py b/nipype/interfaces/tests/test_auto_Dcm2nii.py index c322f76149..b11f38d7bf 100644 --- a/nipype/interfaces/tests/test_auto_Dcm2nii.py +++ b/nipype/interfaces/tests/test_auto_Dcm2nii.py @@ -21,9 +21,6 @@ def test_Dcm2nii_inputs(): date_in_filename=dict(argstr='-d', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), events_in_filename=dict(argstr='-e', usedefault=True, ), @@ -33,14 +30,11 @@ def test_Dcm2nii_inputs(): id_in_filename=dict(argstr='-i', usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), nii_output=dict(argstr='-n', usedefault=True, ), output_dir=dict(argstr='-o %s', - genfile=True, + usedefault=True, ), protocol_in_filename=dict(argstr='-p', usedefault=True, @@ -67,10 +61,8 @@ def test_Dcm2nii_inputs(): spm_analyze=dict(argstr='-s', xor=['nii_output'], ), - terminal_output=dict(nohash=True, - ), ) - inputs = Dcm2nii.input_spec() + inputs = Dcm2nii._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -84,7 +76,7 @@ def test_Dcm2nii_outputs(): reoriented_and_cropped_files=dict(), reoriented_files=dict(), ) - outputs = Dcm2nii.output_spec() + outputs = Dcm2nii._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_DcmStack.py b/nipype/interfaces/tests/test_auto_DcmStack.py index c91379caa6..02ee1860fe 100644 --- a/nipype/interfaces/tests/test_auto_DcmStack.py +++ b/nipype/interfaces/tests/test_auto_DcmStack.py @@ -16,7 +16,7 @@ def test_DcmStack_inputs(): out_format=dict(), out_path=dict(), ) - inputs = DcmStack.input_spec() + inputs = DcmStack._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -26,7 +26,7 @@ def test_DcmStack_inputs(): def test_DcmStack_outputs(): output_map = dict(out_file=dict(), ) - outputs = DcmStack.output_spec() + outputs = DcmStack._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_FreeSurferSource.py b/nipype/interfaces/tests/test_auto_FreeSurferSource.py index 8b393bf0c4..384af5217d 100644 --- a/nipype/interfaces/tests/test_auto_FreeSurferSource.py +++ b/nipype/interfaces/tests/test_auto_FreeSurferSource.py @@ -6,15 +6,12 @@ def test_FreeSurferSource_inputs(): input_map = dict(hemi=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), subject_id=dict(mandatory=True, ), subjects_dir=dict(mandatory=True, ), ) - inputs = FreeSurferSource.input_spec() + inputs = FreeSurferSource._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -99,7 +96,7 @@ def test_FreeSurferSource_outputs(): loc='stats', ), ) - outputs = FreeSurferSource.output_spec() + outputs = FreeSurferSource._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_Function.py b/nipype/interfaces/tests/test_auto_Function.py index 65afafbe47..744668f79b 100644 --- a/nipype/interfaces/tests/test_auto_Function.py +++ b/nipype/interfaces/tests/test_auto_Function.py @@ -6,11 +6,8 @@ def test_Function_inputs(): input_map = dict(function_str=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), ) - inputs = Function.input_spec() + inputs = Function._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -19,7 +16,7 @@ def test_Function_inputs(): def test_Function_outputs(): output_map = dict() - outputs = Function.output_spec() + outputs = Function._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_GroupAndStack.py b/nipype/interfaces/tests/test_auto_GroupAndStack.py index 8523f76c32..ec9c33c7b4 100644 --- a/nipype/interfaces/tests/test_auto_GroupAndStack.py +++ b/nipype/interfaces/tests/test_auto_GroupAndStack.py @@ -16,7 +16,7 @@ def test_GroupAndStack_inputs(): out_format=dict(), out_path=dict(), ) - inputs = GroupAndStack.input_spec() + inputs = GroupAndStack._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -26,7 +26,7 @@ def test_GroupAndStack_inputs(): def test_GroupAndStack_outputs(): output_map = dict(out_list=dict(), ) - outputs = GroupAndStack.output_spec() + outputs = GroupAndStack._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_IOBase.py b/nipype/interfaces/tests/test_auto_IOBase.py index 548b613986..19af3112c6 100644 --- a/nipype/interfaces/tests/test_auto_IOBase.py +++ b/nipype/interfaces/tests/test_auto_IOBase.py @@ -4,13 +4,18 @@ def test_IOBase_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - ) - inputs = IOBase.input_spec() + input_map = dict() + inputs = IOBase._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_IOBase_outputs(): + output_map = dict() + outputs = IOBase._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/tests/test_auto_IdentityInterface.py b/nipype/interfaces/tests/test_auto_IdentityInterface.py index f5787df81c..3bb049933a 100644 --- a/nipype/interfaces/tests/test_auto_IdentityInterface.py +++ b/nipype/interfaces/tests/test_auto_IdentityInterface.py @@ -5,7 +5,7 @@ def test_IdentityInterface_inputs(): input_map = dict() - inputs = IdentityInterface.input_spec() + inputs = IdentityInterface._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -14,7 +14,7 @@ def test_IdentityInterface_inputs(): def test_IdentityInterface_outputs(): output_map = dict() - outputs = IdentityInterface.output_spec() + outputs = IdentityInterface._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_JSONFileGrabber.py b/nipype/interfaces/tests/test_auto_JSONFileGrabber.py index a99c4c6ba2..785479caf3 100644 --- a/nipype/interfaces/tests/test_auto_JSONFileGrabber.py +++ b/nipype/interfaces/tests/test_auto_JSONFileGrabber.py @@ -5,12 +5,9 @@ def test_JSONFileGrabber_inputs(): input_map = dict(defaults=dict(), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(), ) - inputs = JSONFileGrabber.input_spec() + inputs = JSONFileGrabber._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -19,7 +16,7 @@ def test_JSONFileGrabber_inputs(): def test_JSONFileGrabber_outputs(): output_map = dict() - outputs = JSONFileGrabber.output_spec() + outputs = JSONFileGrabber._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_JSONFileSink.py b/nipype/interfaces/tests/test_auto_JSONFileSink.py index 738166527f..18378ddf29 100644 --- a/nipype/interfaces/tests/test_auto_JSONFileSink.py +++ b/nipype/interfaces/tests/test_auto_JSONFileSink.py @@ -6,14 +6,11 @@ def test_JSONFileSink_inputs(): input_map = dict(_outputs=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_dict=dict(usedefault=True, ), out_file=dict(), ) - inputs = JSONFileSink.input_spec() + inputs = JSONFileSink._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -23,7 +20,7 @@ def test_JSONFileSink_inputs(): def test_JSONFileSink_outputs(): output_map = dict(out_file=dict(), ) - outputs = JSONFileSink.output_spec() + outputs = JSONFileSink._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_LookupMeta.py b/nipype/interfaces/tests/test_auto_LookupMeta.py index 7e89973931..603e00f266 100644 --- a/nipype/interfaces/tests/test_auto_LookupMeta.py +++ b/nipype/interfaces/tests/test_auto_LookupMeta.py @@ -9,7 +9,7 @@ def test_LookupMeta_inputs(): meta_keys=dict(mandatory=True, ), ) - inputs = LookupMeta.input_spec() + inputs = LookupMeta._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -18,7 +18,7 @@ def test_LookupMeta_inputs(): def test_LookupMeta_outputs(): output_map = dict() - outputs = LookupMeta.output_spec() + outputs = LookupMeta._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_MatlabCommand.py b/nipype/interfaces/tests/test_auto_MatlabCommand.py index bfc24cb064..5d8abc2c23 100644 --- a/nipype/interfaces/tests/test_auto_MatlabCommand.py +++ b/nipype/interfaces/tests/test_auto_MatlabCommand.py @@ -6,12 +6,6 @@ def test_MatlabCommand_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), logfile=dict(argstr='-logfile %s', ), mfile=dict(usedefault=True, @@ -38,15 +32,21 @@ def test_MatlabCommand_inputs(): single_comp_thread=dict(argstr='-singleCompThread', nohash=True, ), - terminal_output=dict(nohash=True, - ), uses_mcr=dict(nohash=True, xor=['nodesktop', 'nosplash', 'single_comp_thread'], ), ) - inputs = MatlabCommand.input_spec() + inputs = MatlabCommand._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_MatlabCommand_outputs(): + output_map = dict() + outputs = MatlabCommand._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/tests/test_auto_Merge.py b/nipype/interfaces/tests/test_auto_Merge.py index adddcdebd2..1d71ca7cc6 100644 --- a/nipype/interfaces/tests/test_auto_Merge.py +++ b/nipype/interfaces/tests/test_auto_Merge.py @@ -6,13 +6,10 @@ def test_Merge_inputs(): input_map = dict(axis=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), no_flatten=dict(usedefault=True, ), ) - inputs = Merge.input_spec() + inputs = Merge._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -22,7 +19,7 @@ def test_Merge_inputs(): def test_Merge_outputs(): output_map = dict(out=dict(), ) - outputs = Merge.output_spec() + outputs = Merge._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_MergeNifti.py b/nipype/interfaces/tests/test_auto_MergeNifti.py index 3a6e0fc5a1..b3d49ce3d0 100644 --- a/nipype/interfaces/tests/test_auto_MergeNifti.py +++ b/nipype/interfaces/tests/test_auto_MergeNifti.py @@ -13,7 +13,7 @@ def test_MergeNifti_inputs(): out_path=dict(), sort_order=dict(), ) - inputs = MergeNifti.input_spec() + inputs = MergeNifti._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -23,7 +23,7 @@ def test_MergeNifti_inputs(): def test_MergeNifti_outputs(): output_map = dict(out_file=dict(), ) - outputs = MergeNifti.output_spec() + outputs = MergeNifti._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_MeshFix.py b/nipype/interfaces/tests/test_auto_MeshFix.py index 4c0fd67596..1e07299994 100644 --- a/nipype/interfaces/tests/test_auto_MeshFix.py +++ b/nipype/interfaces/tests/test_auto_MeshFix.py @@ -20,9 +20,6 @@ def test_MeshFix_inputs(): ), dont_clean=dict(argstr='--no-clean', ), - environ=dict(nohash=True, - usedefault=True, - ), epsilon_angle=dict(argstr='-a %f', ), finetuning_distance=dict(argstr='%f', @@ -38,9 +35,6 @@ def test_MeshFix_inputs(): finetuning_substeps=dict(argstr='%d', requires=['finetuning_distance'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file1=dict(argstr='%s', mandatory=True, position=1, @@ -78,8 +72,6 @@ def test_MeshFix_inputs(): ), set_intersections_to_one=dict(argstr='--intersect', ), - terminal_output=dict(nohash=True, - ), uniform_remeshing_steps=dict(argstr='-u %d', requires=['uniform_remeshing_vertices'], ), @@ -89,7 +81,7 @@ def test_MeshFix_inputs(): x_shift=dict(argstr='--smooth %d', ), ) - inputs = MeshFix.input_spec() + inputs = MeshFix._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -99,7 +91,7 @@ def test_MeshFix_inputs(): def test_MeshFix_outputs(): output_map = dict(mesh_file=dict(), ) - outputs = MeshFix.output_spec() + outputs = MeshFix._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_MpiCommandLine.py b/nipype/interfaces/tests/test_auto_MpiCommandLine.py index 57d1611f4d..7fa5abe0a6 100644 --- a/nipype/interfaces/tests/test_auto_MpiCommandLine.py +++ b/nipype/interfaces/tests/test_auto_MpiCommandLine.py @@ -18,9 +18,17 @@ def test_MpiCommandLine_inputs(): use_mpi=dict(usedefault=True, ), ) - inputs = MpiCommandLine.input_spec() + inputs = MpiCommandLine._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_MpiCommandLine_outputs(): + output_map = dict() + outputs = MpiCommandLine._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/tests/test_auto_MySQLSink.py b/nipype/interfaces/tests/test_auto_MySQLSink.py index 7b4ff10c0c..402fddab73 100644 --- a/nipype/interfaces/tests/test_auto_MySQLSink.py +++ b/nipype/interfaces/tests/test_auto_MySQLSink.py @@ -14,17 +14,22 @@ def test_MySQLSink_inputs(): usedefault=True, xor=['config'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), password=dict(), table_name=dict(mandatory=True, ), username=dict(), ) - inputs = MySQLSink.input_spec() + inputs = MySQLSink._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_MySQLSink_outputs(): + output_map = dict() + outputs = MySQLSink._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/tests/test_auto_NiftiGeneratorBase.py b/nipype/interfaces/tests/test_auto_NiftiGeneratorBase.py index 762c862ed8..8ada1a3950 100644 --- a/nipype/interfaces/tests/test_auto_NiftiGeneratorBase.py +++ b/nipype/interfaces/tests/test_auto_NiftiGeneratorBase.py @@ -4,13 +4,18 @@ def test_NiftiGeneratorBase_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - ) - inputs = NiftiGeneratorBase.input_spec() + input_map = dict() + inputs = NiftiGeneratorBase._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_NiftiGeneratorBase_outputs(): + output_map = dict() + outputs = NiftiGeneratorBase._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/tests/test_auto_PETPVC.py b/nipype/interfaces/tests/test_auto_PETPVC.py index 67c02c72b0..b711069647 100644 --- a/nipype/interfaces/tests/test_auto_PETPVC.py +++ b/nipype/interfaces/tests/test_auto_PETPVC.py @@ -11,9 +11,6 @@ def test_PETPVC_inputs(): debug=dict(argstr='-d', usedefault=True, ), - environ=dict(nohash=True, - usedefault=True, - ), fwhm_x=dict(argstr='-x %.4f', mandatory=True, ), @@ -23,9 +20,6 @@ def test_PETPVC_inputs(): fwhm_z=dict(argstr='-z %.4f', mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-i %s', mandatory=True, ), @@ -45,10 +39,8 @@ def test_PETPVC_inputs(): ), stop_crit=dict(argstr='-a %.4f', ), - terminal_output=dict(nohash=True, - ), ) - inputs = PETPVC.input_spec() + inputs = PETPVC._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -58,7 +50,7 @@ def test_PETPVC_inputs(): def test_PETPVC_outputs(): output_map = dict(out_file=dict(), ) - outputs = PETPVC.output_spec() + outputs = PETPVC._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_Rename.py b/nipype/interfaces/tests/test_auto_Rename.py index 1cace232fe..39ee679b43 100644 --- a/nipype/interfaces/tests/test_auto_Rename.py +++ b/nipype/interfaces/tests/test_auto_Rename.py @@ -13,7 +13,7 @@ def test_Rename_inputs(): use_fullpath=dict(usedefault=True, ), ) - inputs = Rename.input_spec() + inputs = Rename._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -23,7 +23,7 @@ def test_Rename_inputs(): def test_Rename_outputs(): output_map = dict(out_file=dict(), ) - outputs = Rename.output_spec() + outputs = Rename._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_S3DataGrabber.py b/nipype/interfaces/tests/test_auto_S3DataGrabber.py index 584134ca8f..ff819e78e9 100644 --- a/nipype/interfaces/tests/test_auto_S3DataGrabber.py +++ b/nipype/interfaces/tests/test_auto_S3DataGrabber.py @@ -10,9 +10,6 @@ def test_S3DataGrabber_inputs(): ), bucket_path=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), local_directory=dict(), raise_on_empty=dict(usedefault=True, ), @@ -24,7 +21,7 @@ def test_S3DataGrabber_inputs(): ), template_args=dict(), ) - inputs = S3DataGrabber.input_spec() + inputs = S3DataGrabber._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -33,7 +30,7 @@ def test_S3DataGrabber_inputs(): def test_S3DataGrabber_outputs(): output_map = dict() - outputs = S3DataGrabber.output_spec() + outputs = S3DataGrabber._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_SEMLikeCommandLine.py b/nipype/interfaces/tests/test_auto_SEMLikeCommandLine.py index 8afc2cdec2..13850aeb9c 100644 --- a/nipype/interfaces/tests/test_auto_SEMLikeCommandLine.py +++ b/nipype/interfaces/tests/test_auto_SEMLikeCommandLine.py @@ -15,9 +15,17 @@ def test_SEMLikeCommandLine_inputs(): terminal_output=dict(nohash=True, ), ) - inputs = SEMLikeCommandLine.input_spec() + inputs = SEMLikeCommandLine._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_SEMLikeCommandLine_outputs(): + output_map = dict() + outputs = SEMLikeCommandLine._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/tests/test_auto_SQLiteSink.py b/nipype/interfaces/tests/test_auto_SQLiteSink.py index f215e3e424..db35d63123 100644 --- a/nipype/interfaces/tests/test_auto_SQLiteSink.py +++ b/nipype/interfaces/tests/test_auto_SQLiteSink.py @@ -6,15 +6,20 @@ def test_SQLiteSink_inputs(): input_map = dict(database_file=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), table_name=dict(mandatory=True, ), ) - inputs = SQLiteSink.input_spec() + inputs = SQLiteSink._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_SQLiteSink_outputs(): + output_map = dict() + outputs = SQLiteSink._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/tests/test_auto_SSHDataGrabber.py b/nipype/interfaces/tests/test_auto_SSHDataGrabber.py index cbec846af1..4c2e7dccc8 100644 --- a/nipype/interfaces/tests/test_auto_SSHDataGrabber.py +++ b/nipype/interfaces/tests/test_auto_SSHDataGrabber.py @@ -10,9 +10,6 @@ def test_SSHDataGrabber_inputs(): ), hostname=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), password=dict(), raise_on_empty=dict(usedefault=True, ), @@ -27,7 +24,7 @@ def test_SSHDataGrabber_inputs(): ), username=dict(), ) - inputs = SSHDataGrabber.input_spec() + inputs = SSHDataGrabber._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +33,7 @@ def test_SSHDataGrabber_inputs(): def test_SSHDataGrabber_outputs(): output_map = dict() - outputs = SSHDataGrabber.output_spec() + outputs = SSHDataGrabber._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_Select.py b/nipype/interfaces/tests/test_auto_Select.py index 26d629da4c..bda409ddfa 100644 --- a/nipype/interfaces/tests/test_auto_Select.py +++ b/nipype/interfaces/tests/test_auto_Select.py @@ -4,15 +4,12 @@ def test_Select_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - index=dict(mandatory=True, + input_map = dict(index=dict(mandatory=True, ), inlist=dict(mandatory=True, ), ) - inputs = Select.input_spec() + inputs = Select._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -22,7 +19,7 @@ def test_Select_inputs(): def test_Select_outputs(): output_map = dict(out=dict(), ) - outputs = Select.output_spec() + outputs = Select._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_SelectFiles.py b/nipype/interfaces/tests/test_auto_SelectFiles.py index 49cb40dcf6..89b3cdc468 100644 --- a/nipype/interfaces/tests/test_auto_SelectFiles.py +++ b/nipype/interfaces/tests/test_auto_SelectFiles.py @@ -7,15 +7,12 @@ def test_SelectFiles_inputs(): input_map = dict(base_directory=dict(), force_lists=dict(usedefault=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), raise_on_empty=dict(usedefault=True, ), sort_filelist=dict(usedefault=True, ), ) - inputs = SelectFiles.input_spec() + inputs = SelectFiles._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -24,7 +21,7 @@ def test_SelectFiles_inputs(): def test_SelectFiles_outputs(): output_map = dict() - outputs = SelectFiles.output_spec() + outputs = SelectFiles._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_SlicerCommandLine.py b/nipype/interfaces/tests/test_auto_SlicerCommandLine.py index 131c8f851c..d6c8a0a9cc 100644 --- a/nipype/interfaces/tests/test_auto_SlicerCommandLine.py +++ b/nipype/interfaces/tests/test_auto_SlicerCommandLine.py @@ -6,17 +6,9 @@ def test_SlicerCommandLine_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), module=dict(), - terminal_output=dict(nohash=True, - ), ) - inputs = SlicerCommandLine.input_spec() + inputs = SlicerCommandLine._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -25,7 +17,7 @@ def test_SlicerCommandLine_inputs(): def test_SlicerCommandLine_outputs(): output_map = dict() - outputs = SlicerCommandLine.output_spec() + outputs = SlicerCommandLine._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_Split.py b/nipype/interfaces/tests/test_auto_Split.py index 03da66dec6..38338fbf1e 100644 --- a/nipype/interfaces/tests/test_auto_Split.py +++ b/nipype/interfaces/tests/test_auto_Split.py @@ -4,17 +4,14 @@ def test_Split_inputs(): - input_map = dict(ignore_exception=dict(nohash=True, - usedefault=True, - ), - inlist=dict(mandatory=True, + input_map = dict(inlist=dict(mandatory=True, ), splits=dict(mandatory=True, ), squeeze=dict(usedefault=True, ), ) - inputs = Split.input_spec() + inputs = Split._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -23,7 +20,7 @@ def test_Split_inputs(): def test_Split_outputs(): output_map = dict() - outputs = Split.output_spec() + outputs = Split._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_SplitNifti.py b/nipype/interfaces/tests/test_auto_SplitNifti.py index 1a0ad4aa15..009a97fadd 100644 --- a/nipype/interfaces/tests/test_auto_SplitNifti.py +++ b/nipype/interfaces/tests/test_auto_SplitNifti.py @@ -12,7 +12,7 @@ def test_SplitNifti_inputs(): out_path=dict(), split_dim=dict(), ) - inputs = SplitNifti.input_spec() + inputs = SplitNifti._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -22,7 +22,7 @@ def test_SplitNifti_inputs(): def test_SplitNifti_outputs(): output_map = dict(out_list=dict(), ) - outputs = SplitNifti.output_spec() + outputs = SplitNifti._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_auto_StdOutCommandLine.py b/nipype/interfaces/tests/test_auto_StdOutCommandLine.py index 6c91c5de40..ac1daf7239 100644 --- a/nipype/interfaces/tests/test_auto_StdOutCommandLine.py +++ b/nipype/interfaces/tests/test_auto_StdOutCommandLine.py @@ -13,15 +13,24 @@ def test_StdOutCommandLine_inputs(): usedefault=True, ), out_file=dict(argstr='> %s', - genfile=True, position=-1, + usedefault=True, ), terminal_output=dict(nohash=True, ), ) - inputs = StdOutCommandLine.input_spec() + inputs = StdOutCommandLine._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_StdOutCommandLine_outputs(): + output_map = dict(out_file=dict(), + ) + outputs = StdOutCommandLine._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/tests/test_auto_XNATSink.py b/nipype/interfaces/tests/test_auto_XNATSink.py index dd681af29f..1bb2dd9f72 100644 --- a/nipype/interfaces/tests/test_auto_XNATSink.py +++ b/nipype/interfaces/tests/test_auto_XNATSink.py @@ -14,9 +14,6 @@ def test_XNATSink_inputs(): ), experiment_id=dict(mandatory=True, ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), project_id=dict(mandatory=True, ), pwd=dict(), @@ -32,9 +29,17 @@ def test_XNATSink_inputs(): ), user=dict(), ) - inputs = XNATSink.input_spec() + inputs = XNATSink._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_XNATSink_outputs(): + output_map = dict() + outputs = XNATSink._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/tests/test_auto_XNATSource.py b/nipype/interfaces/tests/test_auto_XNATSource.py index 297c050a22..5330aaa132 100644 --- a/nipype/interfaces/tests/test_auto_XNATSource.py +++ b/nipype/interfaces/tests/test_auto_XNATSource.py @@ -8,9 +8,6 @@ def test_XNATSource_inputs(): config=dict(mandatory=True, xor=['server'], ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), pwd=dict(), query_template=dict(mandatory=True, ), @@ -22,7 +19,7 @@ def test_XNATSource_inputs(): ), user=dict(), ) - inputs = XNATSource.input_spec() + inputs = XNATSource._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -31,7 +28,7 @@ def test_XNATSource_inputs(): def test_XNATSource_outputs(): output_map = dict() - outputs = XNATSource.output_spec() + outputs = XNATSource._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/tests/test_io.py b/nipype/interfaces/tests/test_io.py index c1f4ec35f5..0455b1b47f 100644 --- a/nipype/interfaces/tests/test_io.py +++ b/nipype/interfaces/tests/test_io.py @@ -187,9 +187,9 @@ def test_datasink(): # Make dummy input file def _make_dummy_input(): - ''' + """ Function to create a dummy file - ''' + """ # Import packages import tempfile @@ -210,10 +210,10 @@ def _make_dummy_input(): # Test datasink writes to s3 properly @skipif(noboto3 or not fakes3) def test_datasink_to_s3(): - ''' + """ This function tests to see if the S3 functionality of a DataSink works properly - ''' + """ # Import packages import hashlib @@ -272,10 +272,10 @@ def test_datasink_to_s3(): # Test AWS creds read from env vars @skipif(noboto3 or not fakes3) def test_aws_keys_from_env(): - ''' + """ Function to ensure the DataSink can successfully read in AWS credentials from the environment variables - ''' + """ # Import packages import os @@ -300,10 +300,10 @@ def test_aws_keys_from_env(): # Test the local copy attribute def test_datasink_localcopy(): - ''' + """ Function to validate DataSink will make local copy via local_copy attribute - ''' + """ # Import packages import hashlib diff --git a/nipype/interfaces/tests/test_matlab.py b/nipype/interfaces/tests/test_matlab.py index 874e0bddd8..05fa159629 100644 --- a/nipype/interfaces/tests/test_matlab.py +++ b/nipype/interfaces/tests/test_matlab.py @@ -62,7 +62,7 @@ def test_mlab_init(): default_script_file = clean_workspace_and_get_default_script_file() yield assert_equal, mlab.MatlabCommand._cmd, 'matlab' - yield assert_equal, mlab.MatlabCommand.input_spec, mlab.MatlabInputSpec + yield assert_equal, mlab.MatlabCommand._input_spec, mlab.MatlabInputSpec yield assert_equal, mlab.MatlabCommand().cmd, matlab_cmd mc = mlab.MatlabCommand(matlab_cmd='foo_m') diff --git a/nipype/interfaces/traits_extension.py b/nipype/interfaces/traits_extension.py deleted file mode 100644 index 49af1db164..0000000000 --- a/nipype/interfaces/traits_extension.py +++ /dev/null @@ -1,252 +0,0 @@ -# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- -# vi: set ft=python sts=4 ts=4 sw=4 et: -"""This module contains Trait classes that we've pulled from the -traits source and fixed due to various bugs. File and Directory are -redefined as the release version had dependencies on TraitsUI, which -we do not want Nipype to depend on. At least not yet. - -Undefined class was missing the __len__ operator, causing edit_traits -and configure_traits to fail on List objects. Even though we don't -require TraitsUI, this bug was the only thing preventing us from -popping up GUIs which users like. - -These bugs have been in Traits v3.3.0 and v3.2.1. We have reported -all of these bugs and they've been fixed in enthought svn repository -(usually by Robert Kern). - -""" -import os - -# perform all external trait imports here -import traits -if traits.__version__ < '3.7.0': - raise ImportError('Traits version 3.7.0 or higher must be installed') -import traits.api as traits -from traits.trait_handlers import TraitDictObject, TraitListObject -from traits.trait_errors import TraitError -from traits.trait_base import _Undefined - - -class BaseFile (traits.BaseStr): - """ Defines a trait whose value must be the name of a file. - """ - - # A description of the type of value this trait accepts: - info_text = 'a file name' - - def __init__(self, value='', filter=None, auto_set=False, - entries=0, exists=False, **metadata): - """ Creates a File trait. - - Parameters - ---------- - value : string - The default value for the trait - filter : string - A wildcard string to filter filenames in the file dialog box used by - the attribute trait editor. - auto_set : boolean - Indicates whether the file editor updates the trait value after - every key stroke. - exists : boolean - Indicates whether the trait value must be an existing file or - not. - - Default Value - ------------- - *value* or '' - """ - self.filter = filter - self.auto_set = auto_set - self.entries = entries - self.exists = exists - - if exists: - self.info_text = 'an existing file name' - - super(BaseFile, self).__init__(value, **metadata) - - def validate(self, object, name, value): - """ Validates that a specified value is valid for this trait. - - Note: The 'fast validator' version performs this check in C. - """ - validated_value = super(BaseFile, self).validate(object, name, value) - if not self.exists: - return validated_value - elif os.path.isfile(value): - return validated_value - - self.error(object, name, value) - - -class File (BaseFile): - """ Defines a trait whose value must be the name of a file using a C-level - fast validator. - """ - - def __init__(self, value='', filter=None, auto_set=False, - entries=0, exists=False, **metadata): - """ Creates a File trait. - - Parameters - ---------- - value : string - The default value for the trait - filter : string - A wildcard string to filter filenames in the file dialog box used by - the attribute trait editor. - auto_set : boolean - Indicates whether the file editor updates the trait value after - every key stroke. - exists : boolean - Indicates whether the trait value must be an existing file or - not. - - Default Value - ------------- - *value* or '' - """ - if not exists: - # Define the C-level fast validator to use: - fast_validate = (11, str) - - super(File, self).__init__(value, filter, auto_set, entries, exists, - **metadata) - -# ------------------------------------------------------------------------------- -# 'BaseDirectory' and 'Directory' traits: -# ------------------------------------------------------------------------------- - - -class BaseDirectory (traits.BaseStr): - """ Defines a trait whose value must be the name of a directory. - """ - - # A description of the type of value this trait accepts: - info_text = 'a directory name' - - def __init__(self, value='', auto_set=False, entries=0, - exists=False, **metadata): - """ Creates a BaseDirectory trait. - - Parameters - ---------- - value : string - The default value for the trait - auto_set : boolean - Indicates whether the directory editor updates the trait value - after every key stroke. - exists : boolean - Indicates whether the trait value must be an existing directory or - not. - - Default Value - ------------- - *value* or '' - """ - self.entries = entries - self.auto_set = auto_set - self.exists = exists - - if exists: - self.info_text = 'an existing directory name' - - super(BaseDirectory, self).__init__(value, **metadata) - - def validate(self, object, name, value): - """ Validates that a specified value is valid for this trait. - - Note: The 'fast validator' version performs this check in C. - """ - validated_value = super(BaseDirectory, self).validate(object, name, value) - if not self.exists: - return validated_value - - if os.path.isdir(value): - return validated_value - - self.error(object, name, value) - - -class Directory (BaseDirectory): - """ Defines a trait whose value must be the name of a directory using a - C-level fast validator. - """ - - def __init__(self, value='', auto_set=False, entries=0, - exists=False, **metadata): - """ Creates a Directory trait. - - Parameters - ---------- - value : string - The default value for the trait - auto_set : boolean - Indicates whether the directory editor updates the trait value - after every key stroke. - exists : boolean - Indicates whether the trait value must be an existing directory or - not. - - Default Value - ------------- - *value* or '' - """ - # Define the C-level fast validator to use if the directory existence - # test is not required: - if not exists: - self.fast_validate = (11, str) - - super(Directory, self).__init__(value, auto_set, entries, exists, - **metadata) - - -""" -The functions that pop-up the Traits GUIs, edit_traits and -configure_traits, were failing because all of our inputs default to -Undefined deep and down in traits/ui/wx/list_editor.py it checks for -the len() of the elements of the list. The _Undefined class in traits -does not define the __len__ method and would error. I tried defining -our own Undefined and even sublassing Undefined, but both of those -failed with a TraitError in our initializer when we assign the -Undefined to the inputs because of an incompatible type: - -TraitError: The 'vertical_gradient' trait of a BetInputSpec instance must be a float, but a value of was specified. - -So... in order to keep the same type but add the missing method, I -monkey patched. -""" - - -def length(self): - return 0 - -########################################################################## -# Apply monkeypatch here -_Undefined.__len__ = length -########################################################################## - -Undefined = _Undefined() - - -def isdefined(object): - return not isinstance(object, _Undefined) - - -def has_metadata(trait, metadata, value=None, recursive=True): - ''' - Checks if a given trait has a metadata (and optionally if it is set to particular value) - ''' - count = 0 - if hasattr(trait, "_metadata") and metadata in list(trait._metadata.keys()) and (trait._metadata[metadata] == value or value is None): - count += 1 - if recursive: - if hasattr(trait, 'inner_traits'): - for inner_trait in trait.inner_traits(): - count += has_metadata(inner_trait.trait_type, metadata, recursive) - if hasattr(trait, 'handlers') and trait.handlers is not None: - for handler in trait.handlers: - count += has_metadata(handler, metadata, recursive) - - return count > 0 diff --git a/nipype/interfaces/utility.py b/nipype/interfaces/utility.py index 37883d4e5c..a8ec4997ca 100644 --- a/nipype/interfaces/utility.py +++ b/nipype/interfaces/utility.py @@ -21,9 +21,9 @@ import numpy as np import nibabel as nb -from .base import (traits, TraitedSpec, DynamicTraitedSpec, File, - Undefined, isdefined, OutputMultiPath, - InputMultiPath, BaseInterface, BaseInterfaceInputSpec) +from .base import (traits, Undefined, File, isdefined, InputMultiPath, + OutputMultiPath, TraitedSpec, DynamicTraitedSpec, + BaseInputSpec, BaseInterface) from .io import IOBase, add_traits from ..external.six import string_types from ..testing import assert_equal @@ -56,8 +56,8 @@ class IdentityInterface(IOBase): >>> out = ii2.run() # doctest: +SKIP ValueError: IdentityInterface requires a value for input 'b' because it was listed in 'fields' Interface IdentityInterface failed to run. """ - input_spec = DynamicTraitedSpec - output_spec = DynamicTraitedSpec + _input_spec = DynamicTraitedSpec + _output_spec = DynamicTraitedSpec def __init__(self, fields=None, mandatory_inputs=True, **inputs): super(IdentityInterface, self).__init__(**inputs) @@ -83,7 +83,7 @@ def _add_output_traits(self, base): base.trait_set(trait_change_notify=False, **undefined_traits) return base - def _list_outputs(self): + def _post_run(self): # manual mandatory inputs check if self._fields and self._mandatory_inputs: for key in self._fields: @@ -94,15 +94,13 @@ def _list_outputs(self): (self.__class__.__name__, key) raise ValueError(msg) - outputs = self._outputs().get() for key in self._fields: val = getattr(self.inputs, key) if isdefined(val): - outputs[key] = val - return outputs + setattr(self.outputs, key, val) -class MergeInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class MergeInputSpec(DynamicTraitedSpec, BaseInputSpec): axis = traits.Enum('vstack', 'hstack', usedefault=True, desc='direction in which to merge, hstack requires same number of elements in each input') no_flatten = traits.Bool(False, usedefault=True, desc='append to outlist instead of extending in vstack mode') @@ -128,16 +126,15 @@ class Merge(IOBase): [1, 2, 5, 3] """ - input_spec = MergeInputSpec - output_spec = MergeOutputSpec + _input_spec = MergeInputSpec + _output_spec = MergeOutputSpec def __init__(self, numinputs=0, **inputs): super(Merge, self).__init__(**inputs) self._numinputs = numinputs add_traits(self.inputs, ['in%d' % (i + 1) for i in range(numinputs)]) - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): out = [] if self.inputs.axis == 'vstack': for idx in range(self._numinputs): @@ -153,8 +150,7 @@ def _list_outputs(self): for j in range(self._numinputs): out[i].append(filename_to_list(getattr(self.inputs, 'in%d' % (j + 1)))[i]) if out: - outputs['out'] = out - return outputs + self.outputs.out = out class RenameInputSpec(DynamicTraitedSpec): @@ -217,8 +213,8 @@ class Rename(IOBase): 'subj_201_epi_run02.nii' # doctest: +SKIP """ - input_spec = RenameInputSpec - output_spec = RenameOutputSpec + _input_spec = RenameInputSpec + _output_spec = RenameOutputSpec def __init__(self, format_string=None, **inputs): super(Rename, self).__init__(**inputs) @@ -257,13 +253,11 @@ def _run_interface(self, runtime): self._rename())) return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_file"] = os.path.join(os.getcwd(), self._rename()) - return outputs + def _post_run(self): + self.outputs.out_file = os.path.join(os.getcwd(), self._rename()) -class SplitInputSpec(BaseInterfaceInputSpec): +class SplitInputSpec(BaseInputSpec): inlist = traits.List(traits.Any, mandatory=True, desc='list of values to split') splits = traits.List(traits.Int, mandatory=True, @@ -287,8 +281,8 @@ class Split(IOBase): """ - input_spec = SplitInputSpec - output_spec = DynamicTraitedSpec + _input_spec = SplitInputSpec + _output_spec = DynamicTraitedSpec def _add_output_traits(self, base): undefined_traits = {} @@ -299,8 +293,7 @@ def _add_output_traits(self, base): base.trait_set(trait_change_notify=False, **undefined_traits) return base - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): if isdefined(self.inputs.splits): if sum(self.inputs.splits) != len(self.inputs.inlist): raise RuntimeError('sum of splits != num of list elements') @@ -311,11 +304,10 @@ def _list_outputs(self): val = np.array(self.inputs.inlist)[splits[i]:splits[i + 1]].tolist() if self.inputs.squeeze and len(val) == 1: val = val[0] - outputs['out%d' % (i + 1)] = val - return outputs + setattr(self.outputs, 'out%d' % (i + 1), val) -class SelectInputSpec(BaseInterfaceInputSpec): +class SelectInputSpec(BaseInputSpec): inlist = InputMultiPath(traits.Any, mandatory=True, desc='list of values to choose from') index = InputMultiPath(traits.Int, mandatory=True, @@ -346,17 +338,13 @@ class Select(IOBase): """ - input_spec = SelectInputSpec - output_spec = SelectOutputSpec + _input_spec = SelectInputSpec + _output_spec = SelectOutputSpec - def _list_outputs(self): - outputs = self._outputs().get() - out = np.array(self.inputs.inlist)[np.array(self.inputs.index)].tolist() - outputs['out'] = out - return outputs + def _post_run(self): + self.outputs.out = np.array(self.inputs.inlist)[np.array(self.inputs.index)].tolist() - -class FunctionInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec): +class FunctionInputSpec(DynamicTraitedSpec, BaseInputSpec): function_str = traits.Str(mandatory=True, desc='code for function') @@ -375,8 +363,8 @@ class Function(IOBase): """ - input_spec = FunctionInputSpec - output_spec = DynamicTraitedSpec + _input_spec = FunctionInputSpec + _output_spec = DynamicTraitedSpec def __init__(self, input_names, output_names, function=None, imports=None, **inputs): @@ -463,20 +451,18 @@ def _run_interface(self, runtime): return runtime - def _list_outputs(self): - outputs = self._outputs().get() + def _post_run(self): for key in self._output_names: - outputs[key] = self._out[key] - return outputs + setattr(self.outputs, key, self._out[key]) -class AssertEqualInputSpec(BaseInterfaceInputSpec): +class AssertEqualInputSpec(BaseInputSpec): volume1 = File(exists=True, mandatory=True) volume2 = File(exists=True, mandatory=True) class AssertEqual(BaseInterface): - input_spec = AssertEqualInputSpec + _input_spec = AssertEqualInputSpec def _run_interface(self, runtime): @@ -520,14 +506,13 @@ class CSVReader(BaseInterface): True """ - input_spec = CSVReaderInputSpec - output_spec = DynamicTraitedSpec + _input_spec = CSVReaderInputSpec + _output_spec = DynamicTraitedSpec _always_run = True def _append_entry(self, outputs, entry): for key, value in zip(self._outfields, entry): outputs[key].append(value) - return outputs def _parse_line(self, line): line = line.replace('\n', '') @@ -553,11 +538,10 @@ def _outputs(self): def _add_output_traits(self, base): return add_traits(base, self._get_outfields()) - def _list_outputs(self): - outputs = self.output_spec().get() + def _post_run(self): isHeader = True for key in self._outfields: - outputs[key] = [] # initialize outfields + setattr(self.outputs, key, []) # initialize outfields with open(self.inputs.in_file, 'r') as fid: for line in fid.readlines(): if self.inputs.header and isHeader: # skip header line @@ -565,4 +549,3 @@ def _list_outputs(self): continue entry = self._parse_line(line) outputs = self._append_entry(outputs, entry) - return outputs diff --git a/nipype/interfaces/vista/tests/test_auto_Vnifti2Image.py b/nipype/interfaces/vista/tests/test_auto_Vnifti2Image.py index 16abe83a0e..6ecafbf5af 100644 --- a/nipype/interfaces/vista/tests/test_auto_Vnifti2Image.py +++ b/nipype/interfaces/vista/tests/test_auto_Vnifti2Image.py @@ -9,12 +9,6 @@ def test_Vnifti2Image_inputs(): attributes=dict(argstr='-attr %s', position=2, ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-in %s', mandatory=True, position=1, @@ -26,10 +20,8 @@ def test_Vnifti2Image_inputs(): name_template='%s.v', position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = Vnifti2Image.input_spec() + inputs = Vnifti2Image._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -39,7 +31,7 @@ def test_Vnifti2Image_inputs(): def test_Vnifti2Image_outputs(): output_map = dict(out_file=dict(), ) - outputs = Vnifti2Image.output_spec() + outputs = Vnifti2Image._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/vista/tests/test_auto_VtoMat.py b/nipype/interfaces/vista/tests/test_auto_VtoMat.py index 77c814dab5..6d354e348b 100644 --- a/nipype/interfaces/vista/tests/test_auto_VtoMat.py +++ b/nipype/interfaces/vista/tests/test_auto_VtoMat.py @@ -6,12 +6,6 @@ def test_VtoMat_inputs(): input_map = dict(args=dict(argstr='%s', ), - environ=dict(nohash=True, - usedefault=True, - ), - ignore_exception=dict(nohash=True, - usedefault=True, - ), in_file=dict(argstr='-in %s', mandatory=True, position=1, @@ -23,10 +17,8 @@ def test_VtoMat_inputs(): name_template='%s.mat', position=-1, ), - terminal_output=dict(nohash=True, - ), ) - inputs = VtoMat.input_spec() + inputs = VtoMat._input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -36,7 +28,7 @@ def test_VtoMat_inputs(): def test_VtoMat_outputs(): output_map = dict(out_file=dict(), ) - outputs = VtoMat.output_spec() + outputs = VtoMat._output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/vista/vista.py b/nipype/interfaces/vista/vista.py index fdb054a5ad..9fd7e9a91f 100644 --- a/nipype/interfaces/vista/vista.py +++ b/nipype/interfaces/vista/vista.py @@ -42,8 +42,8 @@ class Vnifti2Image(CommandLine): """ _cmd = 'vnifti2image' - input_spec = Vnifti2ImageInputSpec - output_spec = Vnifti2ImageOutputSpec + _input_spec = Vnifti2ImageInputSpec + _output_spec = Vnifti2ImageOutputSpec class VtoMatInputSpec(CommandLineInputSpec): @@ -71,5 +71,5 @@ class VtoMat(CommandLine): """ _cmd = 'vtomat' - input_spec = VtoMatInputSpec - output_spec = VtoMatOutputSpec + _input_spec = VtoMatInputSpec + _output_spec = VtoMatOutputSpec diff --git a/nipype/pipeline/engine/base.py b/nipype/pipeline/engine/base.py index 148db2f271..e47bc360c5 100644 --- a/nipype/pipeline/engine/base.py +++ b/nipype/pipeline/engine/base.py @@ -27,7 +27,6 @@ from copy import deepcopy import re import numpy as np -from ...interfaces.traits_extension import traits, Undefined from ...interfaces.base import DynamicTraitedSpec from ...utils.filemanip import loadpkl, savepkl diff --git a/nipype/pipeline/engine/nodes.py b/nipype/pipeline/engine/nodes.py index 9f9165e3b2..e06ea9b92c 100644 --- a/nipype/pipeline/engine/nodes.py +++ b/nipype/pipeline/engine/nodes.py @@ -47,30 +47,27 @@ import numpy as np import networkx as nx +from ...external.six import string_types from ...utils.misc import package_check, str2bool -package_check('networkx', '1.3') - from ... import config, logging -logger = logging.getLogger('workflow') -from ...interfaces.base import (traits, InputMultiPath, CommandLine, - Undefined, TraitedSpec, DynamicTraitedSpec, - Bunch, InterfaceResult, md5, Interface, - TraitDictObject, TraitListObject, isdefined) -from ...utils.misc import (getsource, create_function_from_source, - flatten, unflatten) -from ...utils.filemanip import (save_json, FileNotFoundError, - filename_to_list, list_to_filename, - copyfiles, fnames_presuffix, loadpkl, - split_filename, load_json, savepkl, - write_rst_header, write_rst_dict, - write_rst_list) -from ...external.six import string_types -from .utils import (generate_expanded_graph, modify_paths, - export_graph, make_output_dir, write_workflow_prov, + +from ...utils.misc import flatten, unflatten +from ...utils.filemanip import md5, save_json, FileNotFoundError, filename_to_list, \ + list_to_filename, copyfiles, fnames_presuffix, loadpkl, split_filename, load_json, \ + savepkl, write_rst_header, write_rst_dict, write_rst_list + +from ...interfaces.base import (traits, Undefined, isdefined, + InputMultiPath, DynamicTraitedSpec, + CommandLine, Bunch, InterfaceResult, Interface) + +from .utils import (modify_paths, make_output_dir, write_workflow_prov, clean_working_directory, format_dot, topological_sort, get_print_name, merge_dict, evaluate_connect_function) from .base import EngineBase +package_check('networkx', '1.3') +logger = logging.getLogger('workflow') + class Node(EngineBase): """Wraps interface objects for use in pipeline @@ -210,7 +207,7 @@ def inputs(self): @property def outputs(self): """Return the output fields of the underlying interface""" - return self._interface._outputs() + return self._interface.outputs def output_dir(self): """Return the location of the output directory for the node""" @@ -661,14 +658,14 @@ def _strip_temp(self, files, wd): def _copyfiles_to_wd(self, outdir, execute, linksonly=False): """ copy files over and change the inputs""" - if hasattr(self._interface, '_get_filecopy_info'): + if hasattr(self.inputs, 'get_filecopy_info'): logger.debug('copying files to wd [execute=%s, linksonly=%s]' % (str(execute), str(linksonly))) if execute and linksonly: olddir = outdir outdir = op.join(outdir, '_tempinput') os.makedirs(outdir) - for info in self._interface._get_filecopy_info(): + for info in self.inputs.get_filecopy_info(): files = self.inputs.get().get(info['key']) if not isdefined(files): continue diff --git a/nipype/pipeline/engine/tests/test_engine.py b/nipype/pipeline/engine/tests/test_engine.py index 5eaaa81fbf..55a4b75a3f 100644 --- a/nipype/pipeline/engine/tests/test_engine.py +++ b/nipype/pipeline/engine/tests/test_engine.py @@ -17,29 +17,23 @@ from ....interfaces import base as nib -class InputSpec(nib.TraitedSpec): +class InputSpec(nib.BaseInputSpec): input1 = nib.traits.Int(desc='a random int') input2 = nib.traits.Int(desc='a random int') - class OutputSpec(nib.TraitedSpec): output1 = nib.traits.List(nib.traits.Int, desc='outputs') class TestInterface(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec + _input_spec = InputSpec + _output_spec = OutputSpec def _run_interface(self, runtime): runtime.returncode = 0 + self.outputs.output1 = [1, self.inputs.input1] return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = [1, self.inputs.input1] - return outputs - - def test_init(): yield assert_raises, Exception, pe.Workflow pipe = pe.Workflow(name='pipe') @@ -391,7 +385,7 @@ def test_doubleconnect(): yield assert_raises, Exception, x -''' +""" Test for order of iterables import nipype.pipeline.engine as pe @@ -421,19 +415,19 @@ def test_doubleconnect(): wf1.run(inseries=True, createdirsonly=True) wf1.write_graph(graph2use='exec') -''' +""" -''' +""" import nipype.pipeline.engine as pe import nipype.interfaces.spm as spm import os from nipype.external.six import StringIO from nipype.utils.config import config -config.readfp(StringIO(""" +config.readfp(StringIO(''' [execution] remove_unnecessary_outputs = true -""")) +''')) segment = pe.Node(interface=spm.Segment(), name="segment") @@ -459,7 +453,7 @@ def test_doubleconnect(): workflow.run() workflow.run() -''' +""" # Node diff --git a/nipype/pipeline/engine/tests/test_join.py b/nipype/pipeline/engine/tests/test_join.py index b0882de91e..6f75d5894f 100644 --- a/nipype/pipeline/engine/tests/test_join.py +++ b/nipype/pipeline/engine/tests/test_join.py @@ -24,17 +24,15 @@ class PickFirstOutSpec(nib.TraitedSpec): class PickFirst(nib.BaseInterface): - input_spec = PickFirstSpec - output_spec = PickFirstOutSpec + _input_spec = PickFirstSpec + _output_spec = PickFirstOutSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = self.inputs.in_files[0] - return outputs + def _post_run(self): + self.outputs.output1 = self.inputs.in_files[0] class IncrementInputSpec(nib.TraitedSpec): @@ -47,17 +45,15 @@ class IncrementOutputSpec(nib.TraitedSpec): class IncrementInterface(nib.BaseInterface): - input_spec = IncrementInputSpec - output_spec = IncrementOutputSpec + _input_spec = IncrementInputSpec + _output_spec = IncrementOutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = self.inputs.input1 + self.inputs.inc - return outputs + def _post_run(self): + self.outputs.output1 = self.inputs.input1 + self.inputs.inc _sums = [] @@ -74,22 +70,20 @@ class SumOutputSpec(nib.TraitedSpec): class SumInterface(nib.BaseInterface): - input_spec = SumInputSpec - output_spec = SumOutputSpec + _input_spec = SumInputSpec + _output_spec = SumOutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): + def _post_run(self): global _sum global _sum_operands - outputs = self._outputs().get() - outputs['operands'] = self.inputs.input1 - _sum_operands.append(outputs['operands']) - outputs['output1'] = sum(self.inputs.input1) - _sums.append(outputs['output1']) - return outputs + self.outputs.operands = self.inputs.input1 + _sum_operands.append(self.outputs.operands) + self.outputs.output1 = sum(self.inputs.input1) + _sums.append(self.outputs.output1) _set_len = None @@ -105,18 +99,16 @@ class SetOutputSpec(nib.TraitedSpec): class SetInterface(nib.BaseInterface): - input_spec = SetInputSpec - output_spec = SetOutputSpec + _input_spec = SetInputSpec + _output_spec = SetOutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): + def _post_run(self): global _set_len - outputs = self._outputs().get() - _set_len = outputs['output1'] = len(self.inputs.input1) - return outputs + _set_len = self.outputs.output1 = len(self.inputs.input1) _products = [] @@ -133,19 +125,17 @@ class ProductOutputSpec(nib.TraitedSpec): class ProductInterface(nib.BaseInterface): - input_spec = ProductInputSpec - output_spec = ProductOutputSpec + _input_spec = ProductInputSpec + _output_spec = ProductOutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): + def _post_run(self): global _products - outputs = self._outputs().get() - outputs['output1'] = self.inputs.input1 * self.inputs.input2 - _products.append(outputs['output1']) - return outputs + self.outputs.output1 = self.inputs.input1 * self.inputs.input2 + _products.append(self.outputs.output1) def test_join_expansion(): diff --git a/nipype/pipeline/engine/tests/test_utils.py b/nipype/pipeline/engine/tests/test_utils.py index 8420f587c2..74b7719e68 100644 --- a/nipype/pipeline/engine/tests/test_utils.py +++ b/nipype/pipeline/engine/tests/test_utils.py @@ -141,18 +141,16 @@ class OutputSpec(nib.TraitedSpec): class TestInterface(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec + _input_spec = InputSpec + _output_spec = OutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = [1] - return outputs - + def _post_run(self): + self.outputs.output1 = [1] + def test_inputs_removal(): out_dir = mkdtemp() diff --git a/nipype/pipeline/engine/utils.py b/nipype/pipeline/engine/utils.py index 440400c8e0..8b862dc209 100644 --- a/nipype/pipeline/engine/utils.py +++ b/nipype/pipeline/engine/utils.py @@ -36,8 +36,7 @@ from ...utils.filemanip import (fname_presuffix, FileNotFoundError, filename_to_list, get_related_files) from ...utils.misc import create_function_from_source, str2bool -from ...interfaces.base import (CommandLine, isdefined, Undefined, - InterfaceResult) +from ...interfaces.base import CommandLine, InterfaceResult, isdefined, Undefined from ...interfaces.utility import IdentityInterface from ...utils.provenance import ProvStore, pm, nipype_ns, get_id @@ -1159,7 +1158,6 @@ def clean_working_directory(outputs, cwd, inputs, needed_outputs, config, for key in outputs.copyable_trait_names(): if key not in outputs_to_keep: setattr(outputs, key, Undefined) - return outputs def merge_dict(d1, d2, merge=lambda x, y: y): diff --git a/nipype/pipeline/engine/workflows.py b/nipype/pipeline/engine/workflows.py index b14d73a307..ef8ef8d858 100644 --- a/nipype/pipeline/engine/workflows.py +++ b/nipype/pipeline/engine/workflows.py @@ -48,31 +48,22 @@ import networkx as nx from ...utils.misc import package_check, str2bool -package_check('networkx', '1.3') - from ... import config, logging -logger = logging.getLogger('workflow') -from ...interfaces.base import (traits, InputMultiPath, CommandLine, - Undefined, TraitedSpec, DynamicTraitedSpec, - Bunch, InterfaceResult, md5, Interface, - TraitDictObject, TraitListObject, isdefined) + +from ...interfaces.base.traits_extension import TraitListObject, TraitDictObject +from ...interfaces.base import traits, TraitedSpec from ...utils.misc import (getsource, create_function_from_source, flatten, unflatten) -from ...utils.filemanip import (save_json, FileNotFoundError, - filename_to_list, list_to_filename, - copyfiles, fnames_presuffix, loadpkl, - split_filename, load_json, savepkl, - write_rst_header, write_rst_dict, - write_rst_list) +from ...utils.filemanip import save_json from ...external.six import string_types -from .utils import (generate_expanded_graph, modify_paths, - export_graph, make_output_dir, write_workflow_prov, - clean_working_directory, format_dot, topological_sort, - get_print_name, merge_dict, evaluate_connect_function, - _write_inputs, format_node) - +from .utils import (generate_expanded_graph, export_graph, make_output_dir, + write_workflow_prov, format_dot, topological_sort, + get_print_name, merge_dict, format_node) from .base import EngineBase -from .nodes import Node, MapNode +from .nodes import MapNode + +logger = logging.getLogger('workflow') +package_check('networkx', '1.3') class Workflow(EngineBase): diff --git a/nipype/pipeline/plugins/slurm.py b/nipype/pipeline/plugins/slurm.py index 4b22f853bd..99c6366372 100644 --- a/nipype/pipeline/plugins/slurm.py +++ b/nipype/pipeline/plugins/slurm.py @@ -1,10 +1,10 @@ -''' +""" Created on Aug 2, 2013 @author: chadcumba Parallel workflow execution with SLURM -''' +""" import os import re @@ -17,7 +17,7 @@ class SLURMPlugin(SGELikeBatchManagerBase): - ''' + """ Execute using SLURM The plugin_args input to run can be used to control the SLURM execution. @@ -28,7 +28,7 @@ class SLURMPlugin(SGELikeBatchManagerBase): - sbatch_args: arguments to pass prepend to the sbatch call - ''' + """ def __init__(self, **kwargs): diff --git a/nipype/pipeline/plugins/tests/test_base.py b/nipype/pipeline/plugins/tests/test_base.py index 243ae195c2..6801d5bb01 100644 --- a/nipype/pipeline/plugins/tests/test_base.py +++ b/nipype/pipeline/plugins/tests/test_base.py @@ -16,7 +16,7 @@ def test_scipy_sparse(): goo[goo.nonzero()] = 0 yield assert_equal, foo[0, 1], 0 -''' +""" Can use the following code to test that a mapnode crash continues successfully Need to put this into a nose-test with a timeout @@ -39,4 +39,4 @@ def func(arg1): wf.base_dir = '/tmp' wf.run(plugin='MultiProc') -''' +""" diff --git a/nipype/pipeline/plugins/tests/test_debug.py b/nipype/pipeline/plugins/tests/test_debug.py index f15fc62939..5299b04b62 100644 --- a/nipype/pipeline/plugins/tests/test_debug.py +++ b/nipype/pipeline/plugins/tests/test_debug.py @@ -17,18 +17,16 @@ class OutputSpec(nib.TraitedSpec): class TestInterface(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec + _input_spec = InputSpec + _output_spec = OutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = [1, self.inputs.input1] - return outputs - + def _post_run(self): + self.outputs.output1 = [1, self.inputs.input1] + def callme(node, graph): pass diff --git a/nipype/pipeline/plugins/tests/test_linear.py b/nipype/pipeline/plugins/tests/test_linear.py index a59c7c1981..3cff6bb894 100644 --- a/nipype/pipeline/plugins/tests/test_linear.py +++ b/nipype/pipeline/plugins/tests/test_linear.py @@ -17,18 +17,16 @@ class OutputSpec(nib.TraitedSpec): class TestInterface(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec + _input_spec = InputSpec + _output_spec = OutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = [1, self.inputs.input1] - return outputs - + def _post_run(self): + self.outputs.output1 = [1, self.inputs.input1] + def test_run_in_series(): cur_dir = os.getcwd() diff --git a/nipype/pipeline/plugins/tests/test_multiproc.py b/nipype/pipeline/plugins/tests/test_multiproc.py index efa9ec4161..fb8c34fdb8 100644 --- a/nipype/pipeline/plugins/tests/test_multiproc.py +++ b/nipype/pipeline/plugins/tests/test_multiproc.py @@ -17,18 +17,16 @@ class OutputSpec(nib.TraitedSpec): class TestInterface(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec + _input_spec = InputSpec + _output_spec = OutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = [1, self.inputs.input1] - return outputs - + def _post_run(self): + self.outputs.output1 = [1, self.inputs.input1] + def test_run_multiproc(): cur_dir = os.getcwd() diff --git a/nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py b/nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py index 89336c2026..6b2c209c77 100644 --- a/nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py +++ b/nipype/pipeline/plugins/tests/test_multiproc_nondaemon.py @@ -9,9 +9,9 @@ def mytestFunction(insum=0): - ''' + """ Run a multiprocessing job and spawn child processes. - ''' + """ # need to import here since this is executed as an external process import multiprocessing @@ -31,9 +31,9 @@ def mytestFunction(insum=0): f = [None] * numberOfThreads def dummyFunction(filename): - ''' + """ This function writes the value 45 to the given filename. - ''' + """ j = 0 for i in range(0, 10): j += i @@ -83,9 +83,9 @@ def dummyFunction(filename): def run_multiproc_nondaemon_with_flag(nondaemon_flag): - ''' + """ Start a pipe with two nodes using the multiproc plugin and passing the nondaemon_flag. - ''' + """ cur_dir = os.getcwd() temp_dir = mkdtemp(prefix='test_engine_') @@ -124,13 +124,13 @@ def run_multiproc_nondaemon_with_flag(nondaemon_flag): def test_run_multiproc_nondaemon_false(): - ''' + """ This is the entry point for the test. Two times a pipe of several multiprocessing jobs gets executed. First, without the nondaemon flag. Second, with the nondaemon flag. Since the processes of the pipe start child processes, the execution only succeeds when the non_daemon flag is on. - ''' + """ shouldHaveFailed = False try: # with nondaemon_flag = False, the execution should fail diff --git a/nipype/pipeline/plugins/tests/test_oar.py b/nipype/pipeline/plugins/tests/test_oar.py index a5ef97fee3..9488370ccf 100644 --- a/nipype/pipeline/plugins/tests/test_oar.py +++ b/nipype/pipeline/plugins/tests/test_oar.py @@ -17,18 +17,16 @@ class OutputSpec(nib.TraitedSpec): class TestInterface(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec + _input_spec = InputSpec + _output_spec = OutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = [1, self.inputs.input1] - return outputs - + def _post_run(self): + self.outputs.output1 = [1, self.inputs.input1] + @skipif(True) def test_run_oar(): diff --git a/nipype/pipeline/plugins/tests/test_pbs.py b/nipype/pipeline/plugins/tests/test_pbs.py index 8aa52e1163..55d7efc20b 100644 --- a/nipype/pipeline/plugins/tests/test_pbs.py +++ b/nipype/pipeline/plugins/tests/test_pbs.py @@ -18,18 +18,16 @@ class OutputSpec(nib.TraitedSpec): class TestInterface(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec + _input_spec = InputSpec + _output_spec = OutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = [1, self.inputs.input1] - return outputs - + def _post_run(self): + self.outputs.output1 = [1, self.inputs.input1] + @skipif(True) def test_run_pbsgraph(): diff --git a/nipype/pipeline/plugins/tests/test_somaflow.py b/nipype/pipeline/plugins/tests/test_somaflow.py index 27b2e30a83..1cdc31d14d 100644 --- a/nipype/pipeline/plugins/tests/test_somaflow.py +++ b/nipype/pipeline/plugins/tests/test_somaflow.py @@ -20,18 +20,16 @@ class OutputSpec(nib.TraitedSpec): class TestInterface(nib.BaseInterface): - input_spec = InputSpec - output_spec = OutputSpec + _input_spec = InputSpec + _output_spec = OutputSpec def _run_interface(self, runtime): runtime.returncode = 0 return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs['output1'] = [1, self.inputs.input1] - return outputs - + def _post_run(self): + self.outputs.output1 = [1, self.inputs.input1] + @skipif(soma_not_loaded) def test_run_somaflow(): diff --git a/nipype/pkg_info.py b/nipype/pkg_info.py index 04ea874f7d..f32043ee61 100644 --- a/nipype/pkg_info.py +++ b/nipype/pkg_info.py @@ -14,7 +14,7 @@ def pkg_commit_hash(pkg_path): - ''' Get short form of commit hash given directory `pkg_path` + """ Get short form of commit hash given directory `pkg_path` There should be a file called 'COMMIT_INFO.txt' in `pkg_path`. This is a file in INI file format, with at least one section: ``commit hash``, and two @@ -42,7 +42,7 @@ def pkg_commit_hash(pkg_path): Where we got the hash from - description hash_str : str short form of hash - ''' + """ # Try and get commit from written commit text file pth = os.path.join(pkg_path, COMMIT_INFO_FNAME) if not os.path.isfile(pth): @@ -67,7 +67,7 @@ def pkg_commit_hash(pkg_path): def get_pkg_info(pkg_path): - ''' Return dict describing the context of this package + """ Return dict describing the context of this package Parameters ---------- @@ -78,7 +78,7 @@ def get_pkg_info(pkg_path): ------- context : dict with named parameters of interest - ''' + """ src, hsh = pkg_commit_hash(pkg_path) import networkx import nibabel diff --git a/nipype/interfaces/tests/realign_json.json b/nipype/testing/data/realign_json.json similarity index 100% rename from nipype/interfaces/tests/realign_json.json rename to nipype/testing/data/realign_json.json diff --git a/nipype/utils/config.py b/nipype/utils/config.py index bd7ab032ef..f54b5a8d81 100644 --- a/nipype/utils/config.py +++ b/nipype/utils/config.py @@ -1,13 +1,13 @@ # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- # vi: set ft=python sts=4 ts=4 sw=4 et: -''' +""" Created on 20 Apr 2010 logging options : INFO, DEBUG hash_method : content, timestamp @author: Chris Filo Gorgolewski -''' +""" from future import standard_library standard_library.install_aliases() from builtins import object @@ -121,8 +121,8 @@ def set_log_dir(self, log_dir): """ self._config.set('logging', 'log_directory', log_dir) - def get(self, section, option): - return self._config.get(section, option) + def get(self, section, option, default=None): + return self._config.get(section, option, default) def set(self, section, option, value): if isinstance(value, bool): diff --git a/nipype/utils/errors.py b/nipype/utils/errors.py new file mode 100644 index 0000000000..0026e84652 --- /dev/null +++ b/nipype/utils/errors.py @@ -0,0 +1,23 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +""" +Define custom errors +""" + +class InterfaceError(Exception): + """Error raised in nipype interfaces""" + def __init__(self, value): + self.value = value + super(InterfaceError, self).__init__(value) + + def __str__(self): + return repr(self.value) + +class InterfaceInputsError(InterfaceError): + """Error raised in nipype interfaces""" + def __init__(self, value): + self.value = value + super(InterfaceInputsError, self).__init__(value) + + def __str__(self): + return repr(self.value) diff --git a/nipype/utils/filemanip.py b/nipype/utils/filemanip.py index de6f6760f5..c5a83e86b7 100644 --- a/nipype/utils/filemanip.py +++ b/nipype/utils/filemanip.py @@ -3,25 +3,23 @@ """Miscellaneous file manipulation functions """ - -from future import standard_library -standard_library.install_aliases() - +import sys +import os +import re +import shutil import pickle import gzip import hashlib from hashlib import md5 + +from future import standard_library +standard_library.install_aliases() import simplejson -import os -import re -import shutil import numpy as np from .misc import is_container -from .config import mkdir_p from ..external.six import string_types -from ..interfaces.traits_extension import isdefined from .. import logging, config fmlogger = logging.getLogger("filemanip") @@ -86,22 +84,12 @@ def split_filename(fname): """ - special_extensions = [".nii.gz", ".tar.gz"] - pth = os.path.dirname(fname) fname = os.path.basename(fname) - - ext = None - for special_ext in special_extensions: - ext_len = len(special_ext) - if (len(fname) > ext_len) and \ - (fname[-ext_len:].lower() == special_ext.lower()): - ext = fname[-ext_len:] - fname = fname[:-ext_len] - break - if not ext: - fname, ext = os.path.splitext(fname) - + fname, ext = os.path.splitext(fname) + if ext == '.gz': + fname, ext2 = os.path.splitext(fname) + ext = ext2 + ext return pth, fname, ext @@ -135,7 +123,7 @@ def fname_presuffix(fname, prefix='', suffix='', newpath=None, use_ext=True): pth, fname, ext = split_filename(fname) if not use_ext: ext = '' - if newpath and isdefined(newpath): + if newpath is not None: pth = os.path.abspath(newpath) return os.path.join(pth, prefix + fname + suffix + ext) @@ -169,10 +157,19 @@ def check_forhash(filename): else: return False, None +def auto_hash(afile, hash_method=None, chunk_len=8192, crypto=hashlib.md5): + """Checks the hash method and calls the appropriate function""" + if hash_method is None: + hash_method = config.get('execution', 'hash_method').lower() -def hash_infile(afile, chunk_len=8192, crypto=hashlib.md5): + if hash_method not in ['content', 'timestamp']: + raise ValueError("Unknown hash method: %s" % hash_method) + func = getattr(sys.modules[__name__], 'hash_' + hash_method) + return func(afile, chunk_len, crypto) + +def hash_content(afile, chunk_len=8192, crypto=hashlib.md5): """ Computes hash of a file using 'crypto' module""" - hex = None + hashhex = None if os.path.isfile(afile): crypto_obj = crypto() with open(afile, 'rb') as fp: @@ -181,11 +178,10 @@ def hash_infile(afile, chunk_len=8192, crypto=hashlib.md5): if not data: break crypto_obj.update(data) - hex = crypto_obj.hexdigest() - return hex - + hashhex = crypto_obj.hexdigest() + return hashhex -def hash_timestamp(afile): +def hash_timestamp(afile, **kwargs): # pylint: disable=W0613 """ Computes md5 hash of the timestamp of a file """ md5hex = None if os.path.isfile(afile): @@ -198,7 +194,7 @@ def hash_timestamp(afile): def copyfile(originalfile, newfile, copy=False, create_new=False, - hashmethod=None, use_hardlink=False): + hash_method=None, use_hardlink=False): """Copy or symlink ``originalfile`` to ``newfile``. Parameters @@ -232,14 +228,14 @@ def copyfile(originalfile, newfile, copy=False, create_new=False, fname += "_c%04d" % i newfile = base + os.sep + fname + ext - if hashmethod is None: - hashmethod = config.get('execution', 'hash_method').lower() + if hash_method is None: + hash_method = config.get('execution', 'hash_method').lower() elif os.path.exists(newfile): - if hashmethod == 'timestamp': + if hash_method == 'timestamp': newhash = hash_timestamp(newfile) - elif hashmethod == 'content': - newhash = hash_infile(newfile) + elif hash_method == 'content': + newhash = hash_content(newfile) fmlogger.debug("File: %s already exists,%s, copy:%d" % (newfile, newhash, copy)) # the following seems unnecessary @@ -249,10 +245,10 @@ def copyfile(originalfile, newfile, copy=False, create_new=False, # newhash = None if os.name is 'posix' and not copy: if os.path.lexists(newfile): - if hashmethod == 'timestamp': + if hash_method == 'timestamp': orighash = hash_timestamp(originalfile) - elif hashmethod == 'content': - orighash = hash_infile(originalfile) + elif hash_method == 'content': + orighash = hash_content(originalfile) fmlogger.debug('Original hash: %s, %s' % (originalfile, orighash)) if newhash != orighash: os.unlink(newfile) @@ -260,10 +256,10 @@ def copyfile(originalfile, newfile, copy=False, create_new=False, os.symlink(originalfile, newfile) else: if newhash: - if hashmethod == 'timestamp': + if hash_method == 'timestamp': orighash = hash_timestamp(originalfile) - elif hashmethod == 'content': - orighash = hash_infile(originalfile) + elif hash_method == 'content': + orighash = hash_content(originalfile) if (newhash is None) or (newhash != orighash): try: fmlogger.debug("Copying File: %s->%s" % diff --git a/nipype/utils/matlabtools.py b/nipype/utils/matlabtools.py index e272288b75..b32a013f43 100644 --- a/nipype/utils/matlabtools.py +++ b/nipype/utils/matlabtools.py @@ -13,7 +13,7 @@ def fltcols(vals): - ''' Trivial little function to make 1xN float vector ''' + """ Trivial little function to make 1xN float vector """ return np.atleast_2d(np.array(vals, dtype=float)) diff --git a/nipype/utils/nipype2boutiques.py b/nipype/utils/nipype2boutiques.py index 49fc1d755d..728f10876f 100644 --- a/nipype/utils/nipype2boutiques.py +++ b/nipype/utils/nipype2boutiques.py @@ -51,14 +51,14 @@ def main(argv): def generate_boutiques_descriptor(module, interface_name, ignored_template_inputs, docker_image, docker_index, verbose, ignore_template_numbers): - ''' + """ Returns a JSON string containing a JSON Boutiques description of a Nipype interface. Arguments: * module: module where the Nipype interface is declared. * interface: Nipype interface. * ignored_template_inputs: a list of input names that should be ignored in the generation of output path templates. * ignore_template_numbers: True if numbers must be ignored in output path creations. - ''' + """ if not module: raise Exception("Undefined module.") @@ -66,8 +66,8 @@ def generate_boutiques_descriptor(module, interface_name, ignored_template_input # Retrieves Nipype interface __import__(module) interface = getattr(sys.modules[module], interface_name)() - inputs = interface.input_spec() - outputs = interface.output_spec() + inputs = interface._input_spec() + outputs = interface._output_spec() # Tool description tool_desc = {} @@ -206,10 +206,10 @@ def get_boutiques_output(name, interface, tool_inputs, verbose=False): def get_type_from_spec_info(spec_info): - ''' + """ Returns an input type from the spec info. There must be a better way to get an input type in Nipype than to parse the spec info. - ''' + """ if ("an existing file name" in spec_info) or ("input volumes" in spec_info): return "File" elif ("an integer" in spec_info or "a float" in spec_info): @@ -220,21 +220,21 @@ def get_type_from_spec_info(spec_info): def is_list(spec_info): - ''' + """ Returns True if the spec info looks like it describes a list parameter. There must be a better way in Nipype to check if an input is a list. - ''' + """ if "a list" in spec_info: return True return False def get_unique_value(type, id): - ''' + """ Returns a unique value of type 'type', for input with id 'id', assuming id is unique. - ''' + """ return { "File": os.path.abspath(create_tempfile()), "Boolean": True, @@ -244,9 +244,9 @@ def get_unique_value(type, id): def create_tempfile(): - ''' + """ Creates a temp file and returns its name. - ''' + """ fileTemp = tempfile.NamedTemporaryFile(delete=False) fileTemp.write("hello") fileTemp.close() @@ -254,7 +254,7 @@ def create_tempfile(): def must_generate_value(name, type, ignored_template_inputs, spec_info, spec, ignore_template_numbers): - ''' + """ Return True if a temporary value must be generated for this input. Arguments: * name: input name. @@ -262,7 +262,7 @@ def must_generate_value(name, type, ignored_template_inputs, spec_info, spec, ig * ignored_template_inputs: a list of inputs names for which no value must be generated. * spec_info: spec info of the Nipype input * ignore_template_numbers: True if numbers must be ignored. - ''' + """ # Return false when type is number and numbers must be ignored. if ignore_template_numbers and type == "Number": return False diff --git a/nipype/utils/nipype_cmd.py b/nipype/utils/nipype_cmd.py index 9bdfd7df91..c196d9cd47 100644 --- a/nipype/utils/nipype_cmd.py +++ b/nipype/utils/nipype_cmd.py @@ -23,7 +23,7 @@ def add_options(parser=None, module=None, function=None): __import__(module) interface = getattr(sys.modules[module], function)() - inputs = interface.input_spec() + inputs = interface._input_spec() for name, spec in sorted(interface.inputs.traits(transient=None).items()): desc = "\n".join(interface._get_trait_desc(inputs, name, spec))[len(name) + 2:] args = {} diff --git a/nipype/utils/provenance.py b/nipype/utils/provenance.py index 028200573e..6d461e15cf 100644 --- a/nipype/utils/provenance.py +++ b/nipype/utils/provenance.py @@ -20,7 +20,7 @@ from ..external.six import string_types, text_type from .. import get_info -from .filemanip import (md5, hashlib, hash_infile) +from .filemanip import (md5, hashlib, hash_content) from .. import logging iflogger = logging.getLogger('interface') @@ -102,7 +102,7 @@ def _get_sorteddict(object, dictwithhash=False): out = tuple(out) else: if isinstance(object, string_types) and os.path.isfile(object): - hash = hash_infile(object) + hash = hash_content(object) if dictwithhash: out = (object, hash) else: @@ -226,7 +226,7 @@ def prov_encode(graph, value, create_container=True): if isinstance(value, string_types) and os.path.exists(value): attr.update({pm.PROV['location']: encoded_literal}) if not os.path.isdir(value): - sha512 = hash_infile(value, crypto=hashlib.sha512) + sha512 = hash_content(value, crypto=hashlib.sha512) attr.update({crypto['sha512']: pm.Literal(sha512, pm.XSD['string'])}) id = get_attr_id(attr, skip=[pm.PROV['location'], diff --git a/setup.py b/setup.py index 2cae86461a..51ce7bb570 100755 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ from distutils.core import setup # Commit hash writing, and dependency checking -''' Distutils / setuptools helpers from nibabel.nisext''' +""" Distutils / setuptools helpers from nibabel.nisext""" import os from os.path import join as pjoin @@ -89,7 +89,7 @@ def get_comrec_build(pkg_dir, build_cmd=build_py): package for an example. """ class MyBuildPy(build_cmd): - ''' Subclass to write commit data into installation tree ''' + """ Subclass to write commit data into installation tree """ def run(self): build_cmd.run(self) import subprocess @@ -129,7 +129,7 @@ def package_check(pkg_name, version=None, messages=None, setuptools_args=None ): - ''' Check if package `pkg_name` is present and has good enough version + """ Check if package `pkg_name` is present and has good enough version Has two modes of operation. If `setuptools_args` is None (the default), raise an error for missing non-optional dependencies and log warnings for @@ -171,7 +171,7 @@ def package_check(pkg_name, version=None, If None, raise errors / warnings for missing non-optional / optional dependencies. If dict fill key values ``install_requires`` and ``extras_require`` for non-optional and optional dependencies. - ''' + """ setuptools_mode = setuptools_args is not None optional_tf = bool(optional) if version_getter is None: @@ -312,6 +312,8 @@ def main(**extra_args): 'nipype.interfaces.afni.tests', 'nipype.interfaces.ants', 'nipype.interfaces.ants.tests', + 'nipype.interfaces.base', + 'nipype.interfaces.base.tests', 'nipype.interfaces.camino', 'nipype.interfaces.camino.tests', 'nipype.interfaces.camino2trackvis', diff --git a/tools/apigen.py b/tools/apigen.py index dba2ce0a37..6e2f645377 100644 --- a/tools/apigen.py +++ b/tools/apigen.py @@ -28,8 +28,8 @@ # Functions and classes class ApiDocWriter(object): - ''' Class for automatic detection and parsing of API docs - to Sphinx-parsable reST format''' + """ Class for automatic detection and parsing of API docs + to Sphinx-parsable reST format""" # only separating first two levels rst_section_levels = ['*', '=', '-', '~', '^'] @@ -40,7 +40,7 @@ def __init__(self, package_skip_patterns=None, module_skip_patterns=None, ): - ''' Initialize package for parsing + """ Initialize package for parsing Parameters ---------- @@ -65,7 +65,7 @@ def __init__(self, ``.util.console`` If is None, gives default. Default is: ['\.setup$', '\._'] - ''' + """ if package_skip_patterns is None: package_skip_patterns = ['\\.tests$'] if module_skip_patterns is None: @@ -79,7 +79,7 @@ def get_package_name(self): return self._package_name def set_package_name(self, package_name): - ''' Set package_name + """ Set package_name >>> docwriter = ApiDocWriter('sphinx') >>> import sphinx @@ -89,7 +89,7 @@ def set_package_name(self, package_name): >>> import docutils >>> docwriter.root_path == docutils.__path__[0] True - ''' + """ # It's also possible to imagine caching the module parsing here self._package_name = package_name self.root_module = __import__(package_name) @@ -100,7 +100,7 @@ def set_package_name(self, package_name): 'get/set package_name') def _get_object_name(self, line): - ''' Get second token in line + """ Get second token in line >>> docwriter = ApiDocWriter('sphinx') >>> docwriter._get_object_name(" def func(): ") 'func' @@ -108,14 +108,14 @@ def _get_object_name(self, line): 'Klass' >>> docwriter._get_object_name(" class Klass: ") 'Klass' - ''' + """ name = line.split()[1].split('(')[0].strip() # in case we have classes which are not derived from object # ie. old style classes return name.rstrip(':') def _uri2path(self, uri): - ''' Convert uri to absolute filepath + """ Convert uri to absolute filepath Parameters ---------- @@ -141,7 +141,7 @@ def _uri2path(self, uri): True >>> docwriter._uri2path('sphinx.does_not_exist') - ''' + """ if uri == self.package_name: return os.path.join(self.root_path, '__init__.py') path = uri.replace('.', os.path.sep) @@ -157,14 +157,14 @@ def _uri2path(self, uri): return path def _path2uri(self, dirpath): - ''' Convert directory path to uri ''' + """ Convert directory path to uri """ relpath = dirpath.replace(self.root_path, self.package_name) if relpath.startswith(os.path.sep): relpath = relpath[1:] return relpath.replace(os.path.sep, '.') def _parse_module(self, uri): - ''' Parse module defined in *uri* ''' + """ Parse module defined in *uri* """ filename = self._uri2path(uri) if filename is None: # nothing that we could handle here. @@ -175,7 +175,7 @@ def _parse_module(self, uri): return functions, classes def _parse_lines(self, linesource): - ''' Parse lines of text for functions and classes ''' + """ Parse lines of text for functions and classes """ functions = [] classes = [] for line in linesource: @@ -196,7 +196,7 @@ def _parse_lines(self, linesource): return functions, classes def generate_api_doc(self, uri): - '''Make autodoc documentation template string for a module + """Make autodoc documentation template string for a module Parameters ---------- @@ -207,7 +207,7 @@ def generate_api_doc(self, uri): ------- S : string Contents of API doc - ''' + """ # get the names of all classes and functions functions, classes = self._parse_module(uri) if not len(functions) and not len(classes): @@ -271,7 +271,7 @@ def generate_api_doc(self, uri): return ad def _survives_exclude(self, matchstr, match_type): - ''' Returns True if *matchstr* does not match patterns + """ Returns True if *matchstr* does not match patterns ``self.package_name`` removed from front of string if present @@ -290,7 +290,7 @@ def _survives_exclude(self, matchstr, match_type): >>> dw.module_skip_patterns.append('^\\.badmod$') >>> dw._survives_exclude('sphinx.badmod', 'module') False - ''' + """ if match_type == 'module': patterns = self.module_skip_patterns elif match_type == 'package': @@ -314,7 +314,7 @@ def _survives_exclude(self, matchstr, match_type): return True def discover_modules(self): - ''' Return module sequence discovered from ``self.package_name`` + """ Return module sequence discovered from ``self.package_name`` Parameters @@ -336,7 +336,7 @@ def discover_modules(self): >>> 'sphinx.util' in dw.discover_modules() False >>> - ''' + """ modules = [] # raw directory parsing for dirpath, dirnames, filenames in os.walk(self.root_path): diff --git a/tools/checkspecs.py b/tools/checkspecs.py index 8974428780..6feca1bf90 100644 --- a/tools/checkspecs.py +++ b/tools/checkspecs.py @@ -28,7 +28,7 @@ def __init__(self, module_skip_patterns=None, class_skip_patterns=None ): - ''' Initialize package for parsing + """ Initialize package for parsing Parameters ---------- @@ -55,7 +55,7 @@ def __init__(self, Sequence of strings giving classes to be excluded Default is: None - ''' + """ if package_skip_patterns is None: package_skip_patterns = ['\\.tests$'] if module_skip_patterns is None: @@ -117,14 +117,14 @@ def _uri2path(self, uri): return path def _path2uri(self, dirpath): - ''' Convert directory path to uri ''' + """ Convert directory path to uri """ relpath = dirpath.replace(self.root_path, self.package_name) if relpath.startswith(os.path.sep): relpath = relpath[1:] return relpath.replace(os.path.sep, '.') def _parse_module(self, uri): - ''' Parse module defined in *uri* ''' + """ Parse module defined in *uri* """ filename = self._uri2path(uri) if filename is None: # nothing that we could handle here. @@ -135,7 +135,7 @@ def _parse_module(self, uri): return functions, classes def _parse_lines(self, linesource, module): - ''' Parse lines of text for functions and classes ''' + """ Parse lines of text for functions and classes """ functions = [] classes = [] for line in linesource: @@ -214,7 +214,7 @@ def test_specs(self, uri): ''] cmd.append('\ndef test_%s_inputs():' % c) input_fields = '' - for traitname, trait in sorted(classinst.input_spec().traits(transient=None).items()): + for traitname, trait in sorted(classinst._input_spec().traits(transient=None).items()): input_fields += '%s=dict(' % traitname for key, value in sorted(trait.__dict__.items()): if key in in_built or key == 'desc': @@ -229,7 +229,7 @@ def test_specs(self, uri): input_fields += "%s=%s,\n " % (key, value) input_fields += '),\n ' cmd += [' input_map = dict(%s)' % input_fields] - cmd += [' inputs = %s.input_spec()' % c] + cmd += [' inputs = %s._input_spec()' % c] cmd += [""" for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): @@ -238,7 +238,7 @@ def test_specs(self, uri): else: print('%s has nonautotest' % c) - for traitname, trait in sorted(classinst.input_spec().traits(transient=None).items()): + for traitname, trait in sorted(classinst._input_spec().traits(transient=None).items()): for key in sorted(trait.__dict__): if key in in_built: continue @@ -251,14 +251,14 @@ def test_specs(self, uri): if key == 'mandatory' and trait.mandatory is not None and not trait.mandatory: bad_specs.append([uri, c, 'Inputs', traitname, 'mandatory=False']) - if not classinst.output_spec: + if not classinst._output_spec: continue if not os.path.exists(nonautotest): with open(testfile, 'at') as fp: cmd = ['\ndef test_%s_outputs():' % c] input_fields = '' - for traitname, trait in sorted(classinst.output_spec().traits(transient=None).items()): + for traitname, trait in sorted(classinst._output_spec().traits(transient=None).items()): input_fields += '%s=dict(' % traitname for key, value in sorted(trait.__dict__.items()): if key in in_built or key == 'desc': @@ -273,14 +273,14 @@ def test_specs(self, uri): input_fields += "%s=%s,\n " % (key, value) input_fields += '),\n ' cmd += [' output_map = dict(%s)' % input_fields] - cmd += [' outputs = %s.output_spec()' % c] + cmd += [' outputs = %s._output_spec()' % c] cmd += [""" for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): yield assert_equal, getattr(outputs.traits()[key], metakey), value"""] fp.writelines('\n'.join(cmd) + '\n') - for traitname, trait in sorted(classinst.output_spec().traits(transient=None).items()): + for traitname, trait in sorted(classinst._output_spec().traits(transient=None).items()): for key in sorted(trait.__dict__): if key in in_built: continue @@ -293,7 +293,7 @@ def test_specs(self, uri): return bad_specs def _survives_exclude(self, matchstr, match_type): - ''' Returns True if *matchstr* does not match patterns + """ Returns True if *matchstr* does not match patterns ``self.package_name`` removed from front of string if present @@ -312,7 +312,7 @@ def _survives_exclude(self, matchstr, match_type): >>> dw.module_skip_patterns.append('^\\.badmod$') >>> dw._survives_exclude('sphinx.badmod', 'module') False - ''' + """ if match_type == 'module': patterns = self.module_skip_patterns elif match_type == 'package': @@ -336,7 +336,7 @@ def _survives_exclude(self, matchstr, match_type): return True def discover_modules(self): - ''' Return module sequence discovered from ``self.package_name`` + """ Return module sequence discovered from ``self.package_name`` Parameters @@ -350,7 +350,7 @@ def discover_modules(self): Examples -------- - ''' + """ modules = [self.package_name] # raw directory parsing for dirpath, dirnames, filenames in os.walk(self.root_path): diff --git a/tools/gitwash_dumper.py b/tools/gitwash_dumper.py index 8803786c8c..7e7e85d4b8 100755 --- a/tools/gitwash_dumper.py +++ b/tools/gitwash_dumper.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -''' Checkout gitwash repo into directory and do search replace on name ''' +""" Checkout gitwash repo into directory and do search replace on name """ from __future__ import print_function import os @@ -52,9 +52,9 @@ def cp_files(in_path, globs, out_path): def filename_search_replace(sr_pairs, filename, backup=False): - ''' Search and replace for expressions in files + """ Search and replace for expressions in files - ''' + """ in_txt = open(filename, 'rt').read(-1) out_txt = in_txt[:] for in_exp, out_exp in sr_pairs: @@ -153,13 +153,13 @@ def make_link_targets(proj_name, out_links.close() -USAGE = ''' +USAGE = """ If not set with options, the repository name is the same as the If not set with options, the main github user is the same as the -repository name.''' +repository name.""" GITWASH_CENTRAL = 'git://github.com/matthew-brett/gitwash.git' diff --git a/tools/interfacedocgen.py b/tools/interfacedocgen.py index eda0c6a8b5..745f7945e1 100644 --- a/tools/interfacedocgen.py +++ b/tools/interfacedocgen.py @@ -40,8 +40,8 @@ class InterfaceHelpWriter(object): - ''' Class for automatic detection and parsing of API docs - to Sphinx-parsable reST format''' + """ Class for automatic detection and parsing of API docs + to Sphinx-parsable reST format""" # only separating first two levels rst_section_levels = ['*', '=', '-', '~', '^'] @@ -53,7 +53,7 @@ def __init__(self, module_skip_patterns=None, class_skip_patterns=None ): - ''' Initialize package for parsing + """ Initialize package for parsing Parameters ---------- @@ -82,7 +82,7 @@ def __init__(self, Sequence of strings giving classes to be excluded Default is: None - ''' + """ if package_skip_patterns is None: package_skip_patterns = ['\\.tests$'] if module_skip_patterns is None: @@ -100,7 +100,7 @@ def get_package_name(self): return self._package_name def set_package_name(self, package_name): - ''' Set package_name + """ Set package_name >>> docwriter = ApiDocWriter('sphinx') >>> import sphinx @@ -110,7 +110,7 @@ def set_package_name(self, package_name): >>> import docutils >>> docwriter.root_path == docutils.__path__[0] True - ''' + """ # It's also possible to imagine caching the module parsing here self._package_name = package_name self.root_module = __import__(package_name) @@ -121,7 +121,7 @@ def set_package_name(self, package_name): 'get/set package_name') def _get_object_name(self, line): - ''' Get second token in line + """ Get second token in line >>> docwriter = ApiDocWriter('sphinx') >>> docwriter._get_object_name(" def func(): ") 'func' @@ -129,14 +129,14 @@ def _get_object_name(self, line): 'Klass' >>> docwriter._get_object_name(" class Klass: ") 'Klass' - ''' + """ name = line.split()[1].split('(')[0].strip() # in case we have classes which are not derived from object # ie. old style classes return name.rstrip(':') def _uri2path(self, uri): - ''' Convert uri to absolute filepath + """ Convert uri to absolute filepath Parameters ---------- @@ -162,7 +162,7 @@ def _uri2path(self, uri): True >>> docwriter._uri2path('sphinx.does_not_exist') - ''' + """ if uri == self.package_name: return os.path.join(self.root_path, '__init__.py') path = uri.replace('.', os.path.sep) @@ -178,14 +178,14 @@ def _uri2path(self, uri): return path def _path2uri(self, dirpath): - ''' Convert directory path to uri ''' + """ Convert directory path to uri """ relpath = dirpath.replace(self.root_path, self.package_name) if relpath.startswith(os.path.sep): relpath = relpath[1:] return relpath.replace(os.path.sep, '.') def _parse_module(self, uri): - ''' Parse module defined in *uri* ''' + """ Parse module defined in *uri* """ filename = self._uri2path(uri) if filename is None: # nothing that we could handle here. @@ -196,7 +196,7 @@ def _parse_module(self, uri): return functions, classes def _parse_lines(self, linesource, module): - ''' Parse lines of text for functions and classes ''' + """ Parse lines of text for functions and classes """ functions = [] classes = [] for line in linesource: @@ -231,7 +231,7 @@ def _write_graph_section(self, fname, title): return ad def generate_api_doc(self, uri): - '''Make autodoc documentation template string for a module + """Make autodoc documentation template string for a module Parameters ---------- @@ -242,7 +242,7 @@ def generate_api_doc(self, uri): ------- S : string Contents of API doc - ''' + """ # get the names of all classes and functions functions, classes = self._parse_module(uri) workflows = [] @@ -343,7 +343,7 @@ def generate_api_doc(self, uri): return ad def _survives_exclude(self, matchstr, match_type): - ''' Returns True if *matchstr* does not match patterns + """ Returns True if *matchstr* does not match patterns ``self.package_name`` removed from front of string if present @@ -362,7 +362,7 @@ def _survives_exclude(self, matchstr, match_type): >>> dw.module_skip_patterns.append('^\\.badmod$') >>> dw._survives_exclude('sphinx.badmod', 'module') False - ''' + """ if match_type == 'module': patterns = self.module_skip_patterns elif match_type == 'package': @@ -386,7 +386,7 @@ def _survives_exclude(self, matchstr, match_type): return True def discover_modules(self): - ''' Return module sequence discovered from ``self.package_name`` + """ Return module sequence discovered from ``self.package_name`` Parameters @@ -408,7 +408,7 @@ def discover_modules(self): >>> 'sphinx.util' in dw.discover_modules() False >>> - ''' + """ modules = [self.package_name] # raw directory parsing for dirpath, dirnames, filenames in os.walk(self.root_path):