Skip to content

Commit 615964c

Browse files
authored
Merge pull request #2533 from djarecka/default_value_2532
changing arguments names to default values for traits (closes #2532)
2 parents fde07fa + 59083d5 commit 615964c

File tree

87 files changed

+512
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+512
-295
lines changed

nipype/algorithms/confounds.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,12 @@ class CompCorInputSpec(BaseInterfaceInputSpec):
390390
desc='Detrend time series prior to component '
391391
'extraction')
392392
use_regress_poly = traits.Bool(
393-
True,
394393
deprecated='0.15.0',
395394
new_name='pre_filter',
396395
desc=('use polynomial regression '
397396
'pre-component extraction'))
398397
regress_poly_degree = traits.Range(
399-
low=1, default=1, usedefault=True, desc='the degree polynomial to use')
398+
low=1, value=1, usedefault=True, desc='the degree polynomial to use')
400399
header_prefix = traits.Str(
401400
desc=('the desired header for the output tsv '
402401
'file (one column). If undefined, will '

nipype/algorithms/mesh.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ class MeshWarpMathsInputSpec(BaseInterfaceInputSpec):
289289
float_trait,
290290
File(exists=True),
291291
default=1.0,
292+
usedefault=True,
292293
mandatory=True,
293294
desc='image, float or tuple of floats to act as operator')
294295

nipype/algorithms/rapidart.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@ class ArtifactDetectInputSpec(BaseInterfaceInputSpec):
234234
desc=("Mask threshold to be used if mask_type"
235235
" is 'thresh'."))
236236
intersect_mask = traits.Bool(
237-
True, desc=("Intersect the masks when computed from "
238-
"spm_global."))
237+
True, usedefault=True,
238+
desc=("Intersect the masks when computed from "
239+
"spm_global."))
239240
save_plot = traits.Bool(
240241
True, desc="save plots containing outliers", usedefault=True)
241242
plot_type = traits.Enum(

nipype/algorithms/tests/test_auto_ArtifactDetect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_ArtifactDetect_inputs():
1212
nohash=True,
1313
usedefault=True,
1414
),
15-
intersect_mask=dict(),
15+
intersect_mask=dict(usedefault=True, ),
1616
mask_file=dict(),
1717
mask_threshold=dict(),
1818
mask_type=dict(mandatory=True, ),

nipype/algorithms/tests/test_auto_MeshWarpMaths.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ def test_MeshWarpMaths_inputs():
1313
),
1414
in_surf=dict(mandatory=True, ),
1515
operation=dict(usedefault=True, ),
16-
operator=dict(mandatory=True, ),
16+
operator=dict(
17+
mandatory=True,
18+
usedefault=True,
19+
),
1720
out_file=dict(usedefault=True, ),
1821
out_warp=dict(usedefault=True, ),
1922
)

nipype/interfaces/afni/preprocess.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,7 @@ class OutlierCountInputSpec(CommandLineInputSpec):
16061606
value=1e-3,
16071607
low=0.0,
16081608
high=1.0,
1609+
usedefault=True,
16091610
argstr='-qthr %.5f',
16101611
desc='indicate a value for q to compute alpha')
16111612
autoclip = traits.Bool(
@@ -1675,7 +1676,7 @@ class OutlierCount(CommandLine):
16751676
>>> toutcount = afni.OutlierCount()
16761677
>>> toutcount.inputs.in_file = 'functional.nii'
16771678
>>> toutcount.cmdline # doctest: +ELLIPSIS
1678-
'3dToutcount functional.nii'
1679+
'3dToutcount -qthr 0.00100 functional.nii'
16791680
>>> res = toutcount.run() # doctest: +SKIP
16801681
16811682
"""

nipype/interfaces/afni/tests/test_auto_Cat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_Cat_inputs():
3838
argstr='> %s',
3939
mandatory=True,
4040
position=-1,
41+
usedefault=True,
4142
),
4243
out_fint=dict(
4344
argstr='-f',

nipype/interfaces/afni/tests/test_auto_NwarpApply.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def test_NwarpApply_inputs():
2020
argstr='-source %s',
2121
mandatory=True,
2222
),
23-
interp=dict(argstr='-interp %s', ),
23+
interp=dict(
24+
argstr='-interp %s',
25+
usedefault=True,
26+
),
2427
inv_warp=dict(argstr='-iwarp', ),
2528
master=dict(argstr='-master %s', ),
2629
out_file=dict(

nipype/interfaces/afni/tests/test_auto_NwarpCat.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ def test_NwarpCat_inputs():
2121
mandatory=True,
2222
position=-1,
2323
),
24-
interp=dict(argstr='-interp %s', ),
24+
interp=dict(
25+
argstr='-interp %s',
26+
usedefault=True,
27+
),
2528
inv_warp=dict(argstr='-iwarp', ),
2629
num_threads=dict(
2730
nohash=True,

nipype/interfaces/afni/tests/test_auto_OneDToolPy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def test_OneDToolPy_inputs():
3434
show_cormat_warnings=dict(
3535
argstr='-show_cormat_warnings |& tee %s',
3636
position=-1,
37-
usedefault=False,
3837
xor=['out_file'],
3938
),
4039
show_indices_interest=dict(argstr='-show_indices_interest', ),

nipype/interfaces/afni/tests/test_auto_OutlierCount.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ def test_OutlierCount_inputs():
5959
output_name='out_outliers',
6060
),
6161
polort=dict(argstr='-polort %d', ),
62-
qthr=dict(argstr='-qthr %.5f', ),
62+
qthr=dict(
63+
argstr='-qthr %.5f',
64+
usedefault=True,
65+
),
6366
save_outliers=dict(usedefault=True, ),
6467
terminal_output=dict(
6568
deprecated='1.0.0',

nipype/interfaces/afni/utils.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ class CatInputSpec(AFNICommandInputSpec):
479479
File(exists=True), argstr="%s", mandatory=True, position=-2)
480480
out_file = File(
481481
argstr='> %s',
482-
default='catout.1d',
482+
value='catout.1d',
483+
usedefault=True,
483484
desc='output (concatenated) file name',
484485
position=-1,
485486
mandatory=True)
@@ -1610,6 +1611,7 @@ class NwarpApplyInputSpec(CommandLineInputSpec):
16101611
desc='the name of the master dataset, which defines the output grid',
16111612
argstr='-master %s')
16121613
interp = traits.Enum(
1614+
'wsinc5',
16131615
'NN',
16141616
'nearestneighbour',
16151617
'nearestneighbor',
@@ -1619,10 +1621,9 @@ class NwarpApplyInputSpec(CommandLineInputSpec):
16191621
'tricubic',
16201622
'quintic',
16211623
'triquintic',
1622-
'wsinc5',
16231624
desc='defines interpolation method to use during warp',
16241625
argstr='-interp %s',
1625-
default='wsinc5')
1626+
usedefault=True)
16261627
ainterp = traits.Enum(
16271628
'NN',
16281629
'nearestneighbour',
@@ -1636,8 +1637,7 @@ class NwarpApplyInputSpec(CommandLineInputSpec):
16361637
'wsinc5',
16371638
desc='specify a different interpolation method than might '
16381639
'be used for the warp',
1639-
argstr='-ainterp %s',
1640-
default='wsinc5')
1640+
argstr='-ainterp %s')
16411641
out_file = File(
16421642
name_template='%s_Nwarp',
16431643
desc='output image file name',
@@ -1670,7 +1670,7 @@ class NwarpApply(AFNICommandBase):
16701670
>>> nwarp.inputs.master = 'NWARP'
16711671
>>> nwarp.inputs.warp = "'Fred_WARP+tlrc Fred.Xaff12.1D'"
16721672
>>> nwarp.cmdline
1673-
"3dNwarpApply -source Fred+orig -master NWARP -prefix Fred+orig_Nwarp -nwarp \'Fred_WARP+tlrc Fred.Xaff12.1D\'"
1673+
"3dNwarpApply -source Fred+orig -interp wsinc5 -master NWARP -prefix Fred+orig_Nwarp -nwarp \'Fred_WARP+tlrc Fred.Xaff12.1D\'"
16741674
>>> res = nwarp.run() # doctest: +SKIP
16751675
16761676
"""
@@ -1696,13 +1696,13 @@ class NwarpCatInputSpec(AFNICommandInputSpec):
16961696
inv_warp = traits.Bool(
16971697
desc='invert the final warp before output', argstr='-iwarp')
16981698
interp = traits.Enum(
1699+
'wsinc5',
16991700
'linear',
17001701
'quintic',
1701-
'wsinc5',
17021702
desc='specify a different interpolation method than might '
17031703
'be used for the warp',
17041704
argstr='-interp %s',
1705-
default='wsinc5')
1705+
usedefault=True)
17061706
expad = traits.Int(
17071707
desc='Pad the nonlinear warps by the given number of voxels voxels in '
17081708
'all directions. The warp displacements are extended by linear '
@@ -1764,7 +1764,7 @@ class NwarpCat(AFNICommand):
17641764
>>> nwarpcat.inputs.in_files = ['Q25_warp+tlrc.HEAD', ('IDENT', 'structural.nii')]
17651765
>>> nwarpcat.inputs.out_file = 'Fred_total_WARP'
17661766
>>> nwarpcat.cmdline
1767-
"3dNwarpCat -prefix Fred_total_WARP Q25_warp+tlrc.HEAD 'IDENT(structural.nii)'"
1767+
"3dNwarpCat -interp wsinc5 -prefix Fred_total_WARP Q25_warp+tlrc.HEAD 'IDENT(structural.nii)'"
17681768
>>> res = nwarpcat.run() # doctest: +SKIP
17691769
17701770
"""
@@ -1841,8 +1841,6 @@ class OneDToolPyInputSpec(AFNIPythonCommandInputSpec):
18411841
show_cormat_warnings = traits.File(
18421842
desc='Write cormat warnings to a file',
18431843
argstr="-show_cormat_warnings |& tee %s",
1844-
default="out.cormat_warn.txt",
1845-
usedefault=False,
18461844
position=-1,
18471845
xor=['out_file'])
18481846
show_indices_interest = traits.Bool(

nipype/interfaces/ants/registration.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class ANTSInputSpec(ANTSCommandInputSpec):
1717
3,
1818
2,
1919
argstr='%d',
20-
usedefault=False,
2120
position=1,
2221
desc='image dimension (2 or 3)')
2322
fixed_image = InputMultiPath(
@@ -98,7 +97,7 @@ class ANTSInputSpec(ANTSCommandInputSpec):
9897
symmetry_type = traits.Float(requires=['delta_time'], desc='')
9998

10099
use_histogram_matching = traits.Bool(
101-
argstr='%s', default=True, usedefault=True)
100+
argstr='%s', default_value=True, usedefault=True)
102101
number_of_iterations = traits.List(
103102
traits.Int(), argstr='--number-of-iterations %s', sep='x')
104103
smoothing_sigmas = traits.List(
@@ -324,7 +323,6 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
324323
1,
325324
2,
326325
argstr='%s',
327-
default=0,
328326
xor=['initial_moving_transform'],
329327
desc="Align the moving_image nad fixed_image befor registration using"
330328
"the geometric center of the images (=0), the image intensities (=1),"
@@ -339,7 +337,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
339337
desc='the metric(s) to use for each stage. '
340338
'Note that multiple metrics per stage are not supported '
341339
'in ANTS 1.9.1 and earlier.')
342-
metric_weight_item_trait = traits.Float(1.0)
340+
metric_weight_item_trait = traits.Float(1.0, usedefault=True)
343341
metric_weight_stage_trait = traits.Either(
344342
metric_weight_item_trait, traits.List(metric_weight_item_trait))
345343
metric_weight = traits.List(
@@ -350,7 +348,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
350348
mandatory=True,
351349
desc='the metric weight(s) for each stage. '
352350
'The weights must sum to 1 per stage.')
353-
radius_bins_item_trait = traits.Int(5)
351+
radius_bins_item_trait = traits.Int(5, usedefault=True)
354352
radius_bins_stage_trait = traits.Either(
355353
radius_bins_item_trait, traits.List(radius_bins_item_trait))
356354
radius_or_number_of_bins = traits.List(
@@ -405,20 +403,20 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
405403

406404
write_composite_transform = traits.Bool(
407405
argstr='--write-composite-transform %d',
408-
default=False,
406+
default_value=False,
409407
usedefault=True,
410408
desc='')
411409
collapse_output_transforms = traits.Bool(
412410
argstr='--collapse-output-transforms %d',
413-
default=True,
411+
default_value=True,
414412
usedefault=True, # This should be true for explicit completeness
415413
desc=('Collapse output transforms. Specifically, enabling this option '
416414
'combines all adjacent linear transforms and composes all '
417415
'adjacent displacement field transforms before writing the '
418416
'results to disk.'))
419417
initialize_transforms_per_stage = traits.Bool(
420418
argstr='--initialize-transforms-per-stage %d',
421-
default=False,
419+
default_value=False,
422420
usedefault=True, # This should be true for explicit completeness
423421
desc=
424422
('Initialize linear transforms from the previous stage. By enabling this option, '
@@ -430,7 +428,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
430428
# values instead of booleans
431429
float = traits.Bool(
432430
argstr='--float %d',
433-
default=False,
431+
default_value=False,
434432
desc='Use float instead of double for computations.')
435433

436434
transforms = traits.List(
@@ -532,7 +530,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
532530
usedefault=True,
533531
desc="The Lower quantile to clip image ranges")
534532

535-
verbose = traits.Bool(argstr='-v', default=False)
533+
verbose = traits.Bool(argstr='-v', default_value=False, usedefault=True)
536534

537535

538536
class RegistrationOutputSpec(TraitedSpec):
@@ -1386,7 +1384,7 @@ class MeasureImageSimilarityInputSpec(ANTSCommandInputSpec):
13861384
)
13871385
metric_weight = traits.Float(
13881386
requires=['metric'],
1389-
default=1.0,
1387+
default_value=1.0,
13901388
usedefault=True,
13911389
desc='The "metricWeight" variable is not used.',
13921390
)
@@ -1401,7 +1399,6 @@ class MeasureImageSimilarityInputSpec(ANTSCommandInputSpec):
14011399
"Regular",
14021400
"Random",
14031401
requires=['metric'],
1404-
default="None",
14051402
usedefault=True,
14061403
desc='Manner of choosing point set over which to optimize the metric. '
14071404
'Defaults to "None" (i.e. a dense sampling of one sample per voxel).')
@@ -1523,10 +1520,10 @@ class RegistrationSynQuickInputSpec(ANTSCommandInputSpec):
15231520

15241521
use_histogram_matching = traits.Bool(False, argstr='-j %d',
15251522
desc='use histogram matching')
1526-
histogram_bins = traits.Int(default_value=32, argstr='-r %d',
1523+
histogram_bins = traits.Int(default_value=32, usedefault=True, argstr='-r %d',
15271524
desc='histogram bins for mutual information in SyN stage \
15281525
(default = 32)')
1529-
spline_distance = traits.Int(default_value=26, argstr='-s %d',
1526+
spline_distance = traits.Int(default_value=26, usedefault=True, argstr='-s %d',
15301527
desc='spline distance for deformable B-spline SyN transform \
15311528
(default = 26)')
15321529
precision_type = traits.Enum('double', 'float', argstr='-p %s',
@@ -1556,7 +1553,7 @@ class RegistrationSynQuick(ANTSCommand):
15561553
>>> reg.inputs.moving_image = 'moving1.nii'
15571554
>>> reg.inputs.num_threads = 2
15581555
>>> reg.cmdline
1559-
'antsRegistrationSyNQuick.sh -d 3 -f fixed1.nii -m moving1.nii -n 2 -o transform -p d -t s'
1556+
'antsRegistrationSyNQuick.sh -d 3 -f fixed1.nii -r 32 -m moving1.nii -n 2 -o transform -p d -s 26 -t s'
15601557
>>> reg.run() # doctest: +SKIP
15611558
15621559
example for multiple images
@@ -1567,7 +1564,8 @@ class RegistrationSynQuick(ANTSCommand):
15671564
>>> reg.inputs.moving_image = ['moving1.nii', 'moving2.nii']
15681565
>>> reg.inputs.num_threads = 2
15691566
>>> reg.cmdline
1570-
'antsRegistrationSyNQuick.sh -d 3 -f fixed1.nii -f fixed2.nii -m moving1.nii -m moving2.nii -n 2 -o transform -p d -t s'
1567+
'antsRegistrationSyNQuick.sh -d 3 -f fixed1.nii -f fixed2.nii -r 32 -m moving1.nii -m moving2.nii \
1568+
-n 2 -o transform -p d -s 26 -t s'
15711569
>>> reg.run() # doctest: +SKIP
15721570
"""
15731571

nipype/interfaces/ants/resampling.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
359359
desc='output a composite warp file instead of a transformed image')
360360
float = traits.Bool(
361361
argstr='--float %d',
362-
default=False,
362+
default_value=False,
363+
usedefault=True,
363364
desc='Use float instead of double for computations.')
364365

365366

@@ -380,7 +381,7 @@ class ApplyTransforms(ANTSCommand):
380381
>>> at.inputs.reference_image = 'fixed1.nii'
381382
>>> at.inputs.transforms = 'identity'
382383
>>> at.cmdline
383-
'antsApplyTransforms --default-value 0 --input moving1.nii \
384+
'antsApplyTransforms --default-value 0 --float 0 --input moving1.nii \
384385
--interpolation Linear --output moving1_trans.nii \
385386
--reference-image fixed1.nii -t identity'
386387
@@ -394,9 +395,9 @@ class ApplyTransforms(ANTSCommand):
394395
>>> at.inputs.transforms = ['ants_Warp.nii.gz', 'trans.mat']
395396
>>> at.inputs.invert_transform_flags = [False, False]
396397
>>> at.cmdline
397-
'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation Linear \
398-
--output deformed_moving1.nii --reference-image fixed1.nii --transform [ ants_Warp.nii.gz, 0 ] \
399-
--transform [ trans.mat, 0 ]'
398+
'antsApplyTransforms --default-value 0 --dimensionality 3 --float 0 --input moving1.nii \
399+
--interpolation Linear --output deformed_moving1.nii --reference-image fixed1.nii \
400+
--transform [ ants_Warp.nii.gz, 0 ] --transform [ trans.mat, 0 ]'
400401
401402
>>> at1 = ApplyTransforms()
402403
>>> at1.inputs.dimension = 3
@@ -409,9 +410,9 @@ class ApplyTransforms(ANTSCommand):
409410
>>> at1.inputs.transforms = ['ants_Warp.nii.gz', 'trans.mat']
410411
>>> at1.inputs.invert_transform_flags = [False, False]
411412
>>> at1.cmdline
412-
'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation BSpline[ 5 ] \
413-
--output deformed_moving1.nii --reference-image fixed1.nii --transform [ ants_Warp.nii.gz, 0 ] \
414-
--transform [ trans.mat, 0 ]'
413+
'antsApplyTransforms --default-value 0 --dimensionality 3 --float 0 --input moving1.nii \
414+
--interpolation BSpline[ 5 ] --output deformed_moving1.nii --reference-image fixed1.nii \
415+
--transform [ ants_Warp.nii.gz, 0 ] --transform [ trans.mat, 0 ]'
415416
"""
416417
_cmd = 'antsApplyTransforms'
417418
input_spec = ApplyTransformsInputSpec

0 commit comments

Comments
 (0)