Skip to content

Commit cbd5181

Browse files
committed
Merge pull request #680 from satra/enh/metakeys
MRG: to automate checking of metadata and to write automatic tests for interface change checks
2 parents 24b87f3 + 6cff659 commit cbd5181

34 files changed

+618
-190
lines changed

nipype/algorithms/misc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PickAtlasInputSpec(BaseInterfaceInputSpec):
4242
traits.Int, traits.List(traits.Int),
4343
desc=("Labels of regions that will be included in the mask. Must be\
4444
compatible with the atlas used."),
45-
compulsory=True
45+
mandatory=True
4646
)
4747
hemi = traits.Enum(
4848
'both', 'left', 'right',
@@ -614,7 +614,7 @@ class CreateNiftiInputSpec(BaseInterfaceInputSpec):
614614
data_file = File(exists=True, mandatory=True, desc="ANALYZE img file")
615615
header_file = File(
616616
exists=True, mandatory=True, desc="corresponding ANALYZE hdr file")
617-
affine = traits.Array(exists=True, desc="affine transformation array")
617+
affine = traits.Array(desc="affine transformation array")
618618

619619

620620
class CreateNiftiOutputSpec(TraitedSpec):
@@ -653,7 +653,7 @@ def _list_outputs(self):
653653
class TSNRInputSpec(BaseInterfaceInputSpec):
654654
in_file = InputMultiPath(File(exists=True), mandatory=True,
655655
desc='realigned 4D file or a list of 3D files')
656-
regress_poly = traits.Int(min=1, desc='Remove polynomials')
656+
regress_poly = traits.Range(low=1, desc='Remove polynomials')
657657

658658

659659
class TSNROutputSpec(TraitedSpec):

nipype/algorithms/modelgen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,16 @@ class SpecifyModelInputSpec(BaseInterfaceInputSpec):
173173
'corresponding to onsets, durations and amplitudes'))
174174
realignment_parameters = InputMultiPath(File(exists=True),
175175
desc = "Realignment parameters returned by motion correction algorithm",
176-
filecopy=False)
176+
copyfile=False)
177177
outlier_files = InputMultiPath(File(exists=True),
178178
desc="Files containing scan outlier indices that should be tossed",
179-
filecopy=False)
179+
copyfile=False)
180180
functional_runs = InputMultiPath(traits.Either(traits.List(File(exists=True)),
181181
File(exists=True)),
182182
mandatory=True,
183183
desc="Data files for model. List of 4D files or list of" \
184184
"list of 3D files per session",
185-
filecopy=False)
185+
copyfile=False)
186186
input_units = traits.Enum('secs', 'scans', mandatory=True,
187187
desc = "Units of event onsets and durations (secs or scans)" \
188188
"Output units are always in secs")

nipype/interfaces/afni/preprocess.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
class To3DInputSpec(AFNICommandInputSpec):
2828
out_file = File("%s", desc='output image file name',
29-
argstr='-prefix %s', name_source=["in_folder", "infolder"], usedefault=True)
29+
argstr='-prefix %s', name_source=["in_folder", "infolder"],
30+
usedefault=True)
3031
in_xor = ["infolder", "in_folder"]
3132
in_folder = Directory(desc='folder with DICOM images to convert',
3233
argstr='%s/*.dcm',
@@ -776,7 +777,7 @@ class BandpassInputSpec(AFNICommandInputSpec):
776777
++ You would only want to do this if the dataset
777778
had been detrended already in some other program.""")
778779
tr = traits.Float(
779-
arsgtr="-dt %f",
780+
argstr="-dt %f",
780781
desc="set time step (TR) in sec [default=from dataset header]")
781782
nfft = traits.Int(
782783
argstr='-nfft %d',
@@ -1113,7 +1114,8 @@ class MaskaveInputSpec(AFNICommandInputSpec):
11131114
exists=True)
11141115
out_file = File("%s_maskave.1D", desc='output image file name',
11151116
keep_extension=True,
1116-
argstr="> %s", name_source="in_file", usedefault=True, position=-1)
1117+
argstr="> %s", name_source="in_file", usedefault=True,
1118+
position=-1)
11171119
mask = File(desc='matrix to align input file',
11181120
argstr='-mask %s',
11191121
position=1,
@@ -1685,6 +1687,7 @@ class TCorrMap(AFNICommand):
16851687
_cmd = '3dTcorrMap'
16861688
input_spec = TCorrMapInputSpec
16871689
output_spec = TCorrMapOutputSpec
1690+
_additional_metadata = ['suffix']
16881691

16891692
def _format_arg(self, name, trait_spec, value):
16901693
if name in self.inputs._thresh_opts:

nipype/interfaces/ants/resampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
224224
exists=True)
225225
output_image = traits.Str(argstr='--output %s',
226226
desc=('output file name'), genfile=True,
227-
hash_file=False)
227+
hash_files=False)
228228
out_postfix = traits.Str("_trans", usedefault=True,
229229
desc=('Postfix that is appended to all output '
230230
'files (default = _trans)'))

nipype/interfaces/ants/segmentation.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818

1919
class AtroposInputSpec(ANTSCommandInputSpec):
20-
dimension = traits.Enum(3, 2, 4, argstr='--image-dimensionality %d', usedefault=True,
20+
dimension = traits.Enum(3, 2, 4, argstr='--image-dimensionality %d',
21+
usedefault=True,
2122
desc='image dimension (2, 3, or 4)')
22-
intensity_images = InputMultiPath(File(exists=True), argstr="--intensity-image %s...", madatory=True)
23+
intensity_images = InputMultiPath(File(exists=True),
24+
argstr="--intensity-image %s...",
25+
mandatory=True)
2326
mask_image = File(exists=True, argstr='--mask-image %s', mandatory=True)
2427
initialization = traits.Enum('Random', 'Otsu', 'KMeans',
2528
'PriorProbabilityImages', 'PriorLabelImage',
@@ -40,9 +43,10 @@ class AtroposInputSpec(ANTSCommandInputSpec):
4043
posterior_formulation = traits.Str(argstr="%s")
4144
use_mixture_model_proportions = traits.Bool(requires=['posterior_formulation'])
4245
out_classified_image_name = File(argstr="%s", genfile=True,
43-
hash_file=False)
46+
hash_files=False)
4447
save_posteriors = traits.Bool()
45-
output_posteriors_name_template = traits.Str('POSTERIOR_%02d.nii.gz', usedefault=True)
48+
output_posteriors_name_template = traits.Str('POSTERIOR_%02d.nii.gz',
49+
usedefault=True)
4650

4751

4852
class AtroposOutputSpec(TraitedSpec):
@@ -157,19 +161,24 @@ def _list_outputs(self):
157161
return outputs
158162

159163
class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec):
160-
dimension = traits.Enum(3, 2, argstr='--image-dimension %d', usedefault=True,
164+
dimension = traits.Enum(3, 2, argstr='--image-dimension %d',
165+
usedefault=True,
161166
desc='image dimension (2 or 3)')
162167
input_image = File(argstr='--input-image %s', mandatory=True,
163168
desc=('image to apply transformation to (generally a '
164169
'coregistered functional)'))
165170
mask_image = File(argstr='--mask-image %s')
166171
output_image = traits.Str(argstr='--output %s',
167172
desc=('output file name'), genfile=True,
168-
hash_file=False)
173+
hash_files=False)
169174
bspline_fitting_distance = traits.Float(argstr="--bsline-fitting [%g]")
170175
shrink_factor = traits.Int(argstr="--shrink-factor %d")
171-
n_iterations = traits.List(traits.Int(), argstr="--convergence [ %s", sep="x", requires=['convergence_threshold'], position=1)
172-
convergence_threshold = traits.Float(argstr=",%g]", requires=['n_iterations'], position=2)
176+
n_iterations = traits.List(traits.Int(), argstr="--convergence [ %s",
177+
sep="x", requires=['convergence_threshold'],
178+
position=1)
179+
convergence_threshold = traits.Float(argstr=",%g]",
180+
requires=['n_iterations'],
181+
position=2)
173182

174183

175184
class N4BiasFieldCorrectionOutputSpec(TraitedSpec):

nipype/interfaces/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ class BaseInterface(Interface):
699699
"""
700700
input_spec = BaseInterfaceInputSpec
701701
_version = None
702+
_additional_metadata = []
702703

703704
def __init__(self, **inputs):
704705
if not self.input_spec:

nipype/interfaces/camino/dti.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,13 @@ def __init__(self, command=None, **inputs):
411411
return super(TrackPICo, self).__init__(command, **inputs)
412412

413413
class TrackBayesDiracInputSpec(TrackInputSpec):
414-
scheme_file = File(argstr='-schemefile %s', mandatory=True, exist=True, desc='The scheme file corresponding to the data being processed.')
414+
scheme_file = File(argstr='-schemefile %s', mandatory=True, exists=True,
415+
desc=('The scheme file corresponding to the data being '
416+
'processed.'))
415417

416-
iterations = traits.Int(argstr='-iterations %d', units='NA', desc="Number of streamlines to generate at each seed point. The default is 5000.")
418+
iterations = traits.Int(argstr='-iterations %d', units='NA',
419+
desc=("Number of streamlines to generate at each "
420+
"seed point. The default is 5000."))
417421

418422
pdf = traits.Enum('bingham', 'watson', 'acg', argstr='-pdf %s', desc='Specifies the model for PICo priors (not the curvature priors). The default is "bingham".')
419423

@@ -469,13 +473,13 @@ def __init__(self, command=None, **inputs):
469473
return super(TrackBallStick, self).__init__(command, **inputs)
470474

471475
class TrackBootstrapInputSpec(TrackInputSpec):
472-
scheme_file = File(argstr='-schemefile %s', mandatory=True, exist=True, desc='The scheme file corresponding to the data being processed.')
476+
scheme_file = File(argstr='-schemefile %s', mandatory=True, exists=True, desc='The scheme file corresponding to the data being processed.')
473477

474478
iterations = traits.Int(argstr='-iterations %d', units='NA', desc="Number of streamlines to generate at each seed point.")
475479

476480
inversion = traits.Int(argstr='-inversion %s', desc = 'Tensor reconstruction algorithm for repetition bootstrapping. Default is 1 (linear reconstruction, single tensor).')
477481

478-
bsdatafiles = traits.List(File, mandatory=True, exists=True, argstr='-bsdatafile %s', desc='Specifies files containing raw data for repetition bootstrapping. Use -inputfile for wild bootstrap data.')
482+
bsdatafiles = traits.List(File(exists=True), mandatory=True, argstr='-bsdatafile %s', desc='Specifies files containing raw data for repetition bootstrapping. Use -inputfile for wild bootstrap data.')
479483

480484
bgmask = File(argstr='-bgmask %s', exists=True, desc = 'Provides the name of a file containing a background mask computed using, for example, FSL\'s bet2 program. The mask file contains zero in background voxels and non-zero in foreground.')
481485

nipype/interfaces/cmtk/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def _list_outputs(self):
204204
return outputs
205205

206206
class MergeCNetworksInputSpec(BaseInterfaceInputSpec):
207-
in_files = InputMultiPath(File, exists=True, mandatory=True, desc='List of CFF files to extract networks from')
207+
in_files = InputMultiPath(File(exists=True), mandatory=True, desc='List of CFF files to extract networks from')
208208
out_file = File('merged_network_connectome.cff', usedefault = True, desc='Output CFF file with all the networks added')
209209

210210
class MergeCNetworksOutputSpec(TraitedSpec):

nipype/interfaces/dcmstack.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class DcmStackInputSpec(NiftiGeneratorBaseInputSpec):
8585
"exclude filters")
8686

8787
class DcmStackOutputSpec(TraitedSpec):
88-
out_file = traits.File(exists=True)
88+
out_file = File(exists=True)
8989

9090
class DcmStack(NiftiGeneratorBase):
9191
'''Create one Nifti file from a set of DICOM files. Can optionally embed
@@ -240,19 +240,16 @@ def _list_outputs(self):
240240
return outputs
241241

242242
class CopyMetaInputSpec(TraitedSpec):
243-
src_file = traits.File(mandatory=True,
244-
exists=True,
245-
)
246-
dest_file = traits.File(mandatory=True,
247-
exists=True)
243+
src_file = File(mandatory=True, exists=True)
244+
dest_file = File(mandatory=True, exists=True)
248245
include_classes = traits.List(desc="List of specific meta data "
249246
"classifications to include. If not "
250247
"specified include everything.")
251248
exclude_classes = traits.List(desc="List of meta data "
252249
"classifications to exclude")
253250

254251
class CopyMetaOutputSpec(TraitedSpec):
255-
dest_file = traits.File(exists=True)
252+
dest_file = File(exists=True)
256253

257254
class CopyMeta(BaseInterface):
258255
'''Copy meta data from one Nifti file to another. Useful for preserving
@@ -308,8 +305,7 @@ class MergeNiftiInputSpec(NiftiGeneratorBaseInputSpec):
308305
"non-existant dimension is used.")
309306

310307
class MergeNiftiOutputSpec(TraitedSpec):
311-
out_file = traits.File(exists=True,
312-
desc="Merged Nifti file")
308+
out_file = File(exists=True, desc="Merged Nifti file")
313309

314310
def make_key_func(meta_keys, index=None):
315311
def key_func(src_nii):
@@ -352,14 +348,12 @@ def _list_outputs(self):
352348
return outputs
353349

354350
class SplitNiftiInputSpec(NiftiGeneratorBaseInputSpec):
355-
in_file = traits.File(exists=True,
356-
mandatory=True,
357-
desc="Nifti file to split")
351+
in_file = File(exists=True, mandatory=True, desc="Nifti file to split")
358352
split_dim = traits.Int(desc="Dimension to split along. If not "
359353
"specified, the last dimension is used.")
360354

361355
class SplitNiftiOutputSpec(TraitedSpec):
362-
out_list = traits.List(exists=True,
356+
out_list = traits.List(File(exists=True),
363357
desc="Split Nifti files")
364358

365359
class SplitNifti(NiftiGeneratorBase):

nipype/interfaces/diffusion_toolkit/odf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class HARDIMatInputSpec(CommandLineInputSpec):
2222
argstr='%s', position=1, mandatory=True)
2323
bvals = File(exists=True,desc = 'b values file', mandatory=True)
2424
out_file = File("recon_mat.dat", desc = 'output matrix file', argstr='%s', usedefault=True, position=2)
25-
order = traits.Int(argsstr='-order %s', desc="""maximum order of spherical harmonics. must be even number. default
25+
order = traits.Int(argstr='-order %s', desc="""maximum order of spherical harmonics. must be even number. default
2626
is 4""")
2727
odf_file = File(exists=True, argstr='-odf %s', desc="""filename that contains the reconstruction points on a HEMI-sphere.
2828
use the pre-set 181 points by default""")

0 commit comments

Comments
 (0)