Skip to content

changing arguments names to default values for traits (closes #2532) #2533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
feea3ed
changing the name of the argument to set default values for traits
djarecka Apr 10, 2018
456a516
fixing changes in minc
djarecka Apr 10, 2018
c55fdfd
removing usedefault=True if xor is defined
djarecka Apr 11, 2018
7aa6fc1
restoring previous version with default (either trait)
djarecka Apr 11, 2018
2e27fa2
typo
djarecka Apr 11, 2018
cc0c0c6
removing the second wsinc5
djarecka Apr 11, 2018
5b73787
changing tests (to be able to pass the after changes...)
djarecka Apr 11, 2018
d7917fe
changing doctesr in BEDPOSTX5
djarecka Apr 11, 2018
57d09ea
adding check for default values
djarecka Apr 15, 2018
388009f
removing tuples from checks
djarecka Apr 15, 2018
952a034
checking if for Range the default is not equal low (this is default s…
djarecka Apr 15, 2018
ef3688a
Merge branch 'master' into default_value_2532
djarecka Apr 16, 2018
f490108
excluding TraitCompound and checking ir trait has requires or or
djarecka Apr 16, 2018
7871798
correcting traits to remove warnings
djarecka Apr 16, 2018
83844ad
changing hash in test_core
djarecka Apr 16, 2018
a01d4b4
suggestions from chris
djarecka Apr 18, 2018
7b17b4e
warnings for usedefault=False
djarecka Apr 18, 2018
f2d39a2
removing usedefault=False from traits (for traits were default was se…
djarecka Apr 18, 2018
f82baf2
changinf freesurfer test_preprocess (default number of iterat)
djarecka Apr 18, 2018
534a6a0
changinf freesurfer test_preprocess (default number of iterat)
djarecka Apr 18, 2018
5cebe22
fixing the test
djarecka Apr 18, 2018
365d9c5
resolving conflicts
djarecka Apr 18, 2018
618e5a2
removing gen_file and using a default value in ICA_AROMA
djarecka Apr 25, 2018
59083d5
removing default value from out_intensity_fusion_name_format
djarecka Apr 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions nipype/algorithms/confounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,12 @@ class CompCorInputSpec(BaseInterfaceInputSpec):
desc='Detrend time series prior to component '
'extraction')
use_regress_poly = traits.Bool(
True,
deprecated='0.15.0',
new_name='pre_filter',
desc=('use polynomial regression '
'pre-component extraction'))
regress_poly_degree = traits.Range(
low=1, default=1, usedefault=True, desc='the degree polynomial to use')
low=1, value=1, usedefault=True, desc='the degree polynomial to use')
header_prefix = traits.Str(
desc=('the desired header for the output tsv '
'file (one column). If undefined, will '
Expand Down
1 change: 1 addition & 0 deletions nipype/algorithms/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ class MeshWarpMathsInputSpec(BaseInterfaceInputSpec):
float_trait,
File(exists=True),
default=1.0,
usedefault=True,
mandatory=True,
desc='image, float or tuple of floats to act as operator')

Expand Down
5 changes: 3 additions & 2 deletions nipype/algorithms/rapidart.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ class ArtifactDetectInputSpec(BaseInterfaceInputSpec):
desc=("Mask threshold to be used if mask_type"
" is 'thresh'."))
intersect_mask = traits.Bool(
True, desc=("Intersect the masks when computed from "
"spm_global."))
True, usedefault=True,
desc=("Intersect the masks when computed from "
"spm_global."))
save_plot = traits.Bool(
True, desc="save plots containing outliers", usedefault=True)
plot_type = traits.Enum(
Expand Down
2 changes: 1 addition & 1 deletion nipype/algorithms/tests/test_auto_ArtifactDetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_ArtifactDetect_inputs():
nohash=True,
usedefault=True,
),
intersect_mask=dict(),
intersect_mask=dict(usedefault=True, ),
mask_file=dict(),
mask_threshold=dict(),
mask_type=dict(mandatory=True, ),
Expand Down
5 changes: 4 additions & 1 deletion nipype/algorithms/tests/test_auto_MeshWarpMaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def test_MeshWarpMaths_inputs():
),
in_surf=dict(mandatory=True, ),
operation=dict(usedefault=True, ),
operator=dict(mandatory=True, ),
operator=dict(
mandatory=True,
usedefault=True,
),
out_file=dict(usedefault=True, ),
out_warp=dict(usedefault=True, ),
)
Expand Down
3 changes: 2 additions & 1 deletion nipype/interfaces/afni/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,7 @@ class OutlierCountInputSpec(CommandLineInputSpec):
value=1e-3,
low=0.0,
high=1.0,
usedefault=True,
argstr='-qthr %.5f',
desc='indicate a value for q to compute alpha')
autoclip = traits.Bool(
Expand Down Expand Up @@ -1681,7 +1682,7 @@ class OutlierCount(CommandLine):
>>> toutcount = afni.OutlierCount()
>>> toutcount.inputs.in_file = 'functional.nii'
>>> toutcount.cmdline # doctest: +ELLIPSIS
'3dToutcount functional.nii'
'3dToutcount -qthr 0.00100 functional.nii'
>>> res = toutcount.run() # doctest: +SKIP

"""
Expand Down
1 change: 1 addition & 0 deletions nipype/interfaces/afni/tests/test_auto_Cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_Cat_inputs():
argstr='> %s',
mandatory=True,
position=-1,
usedefault=True,
),
out_fint=dict(
argstr='-f',
Expand Down
5 changes: 4 additions & 1 deletion nipype/interfaces/afni/tests/test_auto_NwarpApply.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def test_NwarpApply_inputs():
argstr='-source %s',
mandatory=True,
),
interp=dict(argstr='-interp %s', ),
interp=dict(
argstr='-interp %s',
usedefault=True,
),
inv_warp=dict(argstr='-iwarp', ),
master=dict(argstr='-master %s', ),
out_file=dict(
Expand Down
5 changes: 4 additions & 1 deletion nipype/interfaces/afni/tests/test_auto_NwarpCat.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def test_NwarpCat_inputs():
mandatory=True,
position=-1,
),
interp=dict(argstr='-interp %s', ),
interp=dict(
argstr='-interp %s',
usedefault=True,
),
inv_warp=dict(argstr='-iwarp', ),
num_threads=dict(
nohash=True,
Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/afni/tests/test_auto_OneDToolPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def test_OneDToolPy_inputs():
show_cormat_warnings=dict(
argstr='-show_cormat_warnings |& tee %s',
position=-1,
usedefault=False,
xor=['out_file'],
),
show_indices_interest=dict(argstr='-show_indices_interest', ),
Expand Down
5 changes: 4 additions & 1 deletion nipype/interfaces/afni/tests/test_auto_OutlierCount.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def test_OutlierCount_inputs():
output_name='out_outliers',
),
polort=dict(argstr='-polort %d', ),
qthr=dict(argstr='-qthr %.5f', ),
qthr=dict(
argstr='-qthr %.5f',
usedefault=True,
),
save_outliers=dict(usedefault=True, ),
terminal_output=dict(
deprecated='1.0.0',
Expand Down
20 changes: 9 additions & 11 deletions nipype/interfaces/afni/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ class CatInputSpec(AFNICommandInputSpec):
File(exists=True), argstr="%s", mandatory=True, position=-2)
out_file = File(
argstr='> %s',
default='catout.1d',
value='catout.1d',
usedefault=True,
desc='output (concatenated) file name',
position=-1,
mandatory=True)
Expand Down Expand Up @@ -1610,6 +1611,7 @@ class NwarpApplyInputSpec(CommandLineInputSpec):
desc='the name of the master dataset, which defines the output grid',
argstr='-master %s')
interp = traits.Enum(
'wsinc5',
'NN',
'nearestneighbour',
'nearestneighbor',
Expand All @@ -1619,10 +1621,9 @@ class NwarpApplyInputSpec(CommandLineInputSpec):
'tricubic',
'quintic',
'triquintic',
'wsinc5',
desc='defines interpolation method to use during warp',
argstr='-interp %s',
default='wsinc5')
usedefault=True)
ainterp = traits.Enum(
'NN',
'nearestneighbour',
Expand All @@ -1636,8 +1637,7 @@ class NwarpApplyInputSpec(CommandLineInputSpec):
'wsinc5',
desc='specify a different interpolation method than might '
'be used for the warp',
argstr='-ainterp %s',
default='wsinc5')
argstr='-ainterp %s')
out_file = File(
name_template='%s_Nwarp',
desc='output image file name',
Expand Down Expand Up @@ -1670,7 +1670,7 @@ class NwarpApply(AFNICommandBase):
>>> nwarp.inputs.master = 'NWARP'
>>> nwarp.inputs.warp = "'Fred_WARP+tlrc Fred.Xaff12.1D'"
>>> nwarp.cmdline
"3dNwarpApply -source Fred+orig -master NWARP -prefix Fred+orig_Nwarp -nwarp \'Fred_WARP+tlrc Fred.Xaff12.1D\'"
"3dNwarpApply -source Fred+orig -interp wsinc5 -master NWARP -prefix Fred+orig_Nwarp -nwarp \'Fred_WARP+tlrc Fred.Xaff12.1D\'"
>>> res = nwarp.run() # doctest: +SKIP

"""
Expand All @@ -1696,13 +1696,13 @@ class NwarpCatInputSpec(AFNICommandInputSpec):
inv_warp = traits.Bool(
desc='invert the final warp before output', argstr='-iwarp')
interp = traits.Enum(
'wsinc5',
'linear',
'quintic',
'wsinc5',
desc='specify a different interpolation method than might '
'be used for the warp',
argstr='-interp %s',
default='wsinc5')
usedefault=True)
expad = traits.Int(
desc='Pad the nonlinear warps by the given number of voxels voxels in '
'all directions. The warp displacements are extended by linear '
Expand Down Expand Up @@ -1764,7 +1764,7 @@ class NwarpCat(AFNICommand):
>>> nwarpcat.inputs.in_files = ['Q25_warp+tlrc.HEAD', ('IDENT', 'structural.nii')]
>>> nwarpcat.inputs.out_file = 'Fred_total_WARP'
>>> nwarpcat.cmdline
"3dNwarpCat -prefix Fred_total_WARP Q25_warp+tlrc.HEAD 'IDENT(structural.nii)'"
"3dNwarpCat -interp wsinc5 -prefix Fred_total_WARP Q25_warp+tlrc.HEAD 'IDENT(structural.nii)'"
>>> res = nwarpcat.run() # doctest: +SKIP

"""
Expand Down Expand Up @@ -1841,8 +1841,6 @@ class OneDToolPyInputSpec(AFNIPythonCommandInputSpec):
show_cormat_warnings = traits.File(
desc='Write cormat warnings to a file',
argstr="-show_cormat_warnings |& tee %s",
default="out.cormat_warn.txt",
usedefault=False,
position=-1,
xor=['out_file'])
show_indices_interest = traits.Bool(
Expand Down
30 changes: 14 additions & 16 deletions nipype/interfaces/ants/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class ANTSInputSpec(ANTSCommandInputSpec):
3,
2,
argstr='%d',
usedefault=False,
position=1,
desc='image dimension (2 or 3)')
fixed_image = InputMultiPath(
Expand Down Expand Up @@ -98,7 +97,7 @@ class ANTSInputSpec(ANTSCommandInputSpec):
symmetry_type = traits.Float(requires=['delta_time'], desc='')

use_histogram_matching = traits.Bool(
argstr='%s', default=True, usedefault=True)
argstr='%s', default_value=True, usedefault=True)
number_of_iterations = traits.List(
traits.Int(), argstr='--number-of-iterations %s', sep='x')
smoothing_sigmas = traits.List(
Expand Down Expand Up @@ -324,7 +323,6 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
1,
2,
argstr='%s',
default=0,
xor=['initial_moving_transform'],
desc="Align the moving_image nad fixed_image befor registration using"
"the geometric center of the images (=0), the image intensities (=1),"
Expand All @@ -339,7 +337,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
desc='the metric(s) to use for each stage. '
'Note that multiple metrics per stage are not supported '
'in ANTS 1.9.1 and earlier.')
metric_weight_item_trait = traits.Float(1.0)
metric_weight_item_trait = traits.Float(1.0, usedefault=True)
metric_weight_stage_trait = traits.Either(
metric_weight_item_trait, traits.List(metric_weight_item_trait))
metric_weight = traits.List(
Expand All @@ -350,7 +348,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
mandatory=True,
desc='the metric weight(s) for each stage. '
'The weights must sum to 1 per stage.')
radius_bins_item_trait = traits.Int(5)
radius_bins_item_trait = traits.Int(5, usedefault=True)
radius_bins_stage_trait = traits.Either(
radius_bins_item_trait, traits.List(radius_bins_item_trait))
radius_or_number_of_bins = traits.List(
Expand Down Expand Up @@ -405,20 +403,20 @@ class RegistrationInputSpec(ANTSCommandInputSpec):

write_composite_transform = traits.Bool(
argstr='--write-composite-transform %d',
default=False,
default_value=False,
usedefault=True,
desc='')
collapse_output_transforms = traits.Bool(
argstr='--collapse-output-transforms %d',
default=True,
default_value=True,
usedefault=True, # This should be true for explicit completeness
desc=('Collapse output transforms. Specifically, enabling this option '
'combines all adjacent linear transforms and composes all '
'adjacent displacement field transforms before writing the '
'results to disk.'))
initialize_transforms_per_stage = traits.Bool(
argstr='--initialize-transforms-per-stage %d',
default=False,
default_value=False,
usedefault=True, # This should be true for explicit completeness
desc=
('Initialize linear transforms from the previous stage. By enabling this option, '
Expand All @@ -430,7 +428,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
# values instead of booleans
float = traits.Bool(
argstr='--float %d',
default=False,
default_value=False,
desc='Use float instead of double for computations.')

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

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


class RegistrationOutputSpec(TraitedSpec):
Expand Down Expand Up @@ -1386,7 +1384,7 @@ class MeasureImageSimilarityInputSpec(ANTSCommandInputSpec):
)
metric_weight = traits.Float(
requires=['metric'],
default=1.0,
default_value=1.0,
usedefault=True,
desc='The "metricWeight" variable is not used.',
)
Expand All @@ -1401,7 +1399,6 @@ class MeasureImageSimilarityInputSpec(ANTSCommandInputSpec):
"Regular",
"Random",
requires=['metric'],
default="None",
usedefault=True,
desc='Manner of choosing point set over which to optimize the metric. '
'Defaults to "None" (i.e. a dense sampling of one sample per voxel).')
Expand Down Expand Up @@ -1523,10 +1520,10 @@ class RegistrationSynQuickInputSpec(ANTSCommandInputSpec):

use_histogram_matching = traits.Bool(False, argstr='-j %d',
desc='use histogram matching')
histogram_bins = traits.Int(default_value=32, argstr='-r %d',
histogram_bins = traits.Int(default_value=32, usedefault=True, argstr='-r %d',
desc='histogram bins for mutual information in SyN stage \
(default = 32)')
spline_distance = traits.Int(default_value=26, argstr='-s %d',
spline_distance = traits.Int(default_value=26, usedefault=True, argstr='-s %d',
desc='spline distance for deformable B-spline SyN transform \
(default = 26)')
precision_type = traits.Enum('double', 'float', argstr='-p %s',
Expand Down Expand Up @@ -1556,7 +1553,7 @@ class RegistrationSynQuick(ANTSCommand):
>>> reg.inputs.moving_image = 'moving1.nii'
>>> reg.inputs.num_threads = 2
>>> reg.cmdline
'antsRegistrationSyNQuick.sh -d 3 -f fixed1.nii -m moving1.nii -n 2 -o transform -p d -t s'
'antsRegistrationSyNQuick.sh -d 3 -f fixed1.nii -r 32 -m moving1.nii -n 2 -o transform -p d -s 26 -t s'
>>> reg.run() # doctest: +SKIP

example for multiple images
Expand All @@ -1567,7 +1564,8 @@ class RegistrationSynQuick(ANTSCommand):
>>> reg.inputs.moving_image = ['moving1.nii', 'moving2.nii']
>>> reg.inputs.num_threads = 2
>>> reg.cmdline
'antsRegistrationSyNQuick.sh -d 3 -f fixed1.nii -f fixed2.nii -m moving1.nii -m moving2.nii -n 2 -o transform -p d -t s'
'antsRegistrationSyNQuick.sh -d 3 -f fixed1.nii -f fixed2.nii -r 32 -m moving1.nii -m moving2.nii \
-n 2 -o transform -p d -s 26 -t s'
>>> reg.run() # doctest: +SKIP
"""

Expand Down
17 changes: 9 additions & 8 deletions nipype/interfaces/ants/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
desc='output a composite warp file instead of a transformed image')
float = traits.Bool(
argstr='--float %d',
default=False,
default_value=False,
usedefault=True,
desc='Use float instead of double for computations.')


Expand All @@ -380,7 +381,7 @@ class ApplyTransforms(ANTSCommand):
>>> at.inputs.reference_image = 'fixed1.nii'
>>> at.inputs.transforms = 'identity'
>>> at.cmdline
'antsApplyTransforms --default-value 0 --input moving1.nii \
'antsApplyTransforms --default-value 0 --float 0 --input moving1.nii \
--interpolation Linear --output moving1_trans.nii \
--reference-image fixed1.nii -t identity'

Expand All @@ -394,9 +395,9 @@ class ApplyTransforms(ANTSCommand):
>>> at.inputs.transforms = ['ants_Warp.nii.gz', 'trans.mat']
>>> at.inputs.invert_transform_flags = [False, False]
>>> at.cmdline
'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation Linear \
--output deformed_moving1.nii --reference-image fixed1.nii --transform [ ants_Warp.nii.gz, 0 ] \
--transform [ trans.mat, 0 ]'
'antsApplyTransforms --default-value 0 --dimensionality 3 --float 0 --input moving1.nii \
--interpolation Linear --output deformed_moving1.nii --reference-image fixed1.nii \
--transform [ ants_Warp.nii.gz, 0 ] --transform [ trans.mat, 0 ]'

>>> at1 = ApplyTransforms()
>>> at1.inputs.dimension = 3
Expand All @@ -409,9 +410,9 @@ class ApplyTransforms(ANTSCommand):
>>> at1.inputs.transforms = ['ants_Warp.nii.gz', 'trans.mat']
>>> at1.inputs.invert_transform_flags = [False, False]
>>> at1.cmdline
'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation BSpline[ 5 ] \
--output deformed_moving1.nii --reference-image fixed1.nii --transform [ ants_Warp.nii.gz, 0 ] \
--transform [ trans.mat, 0 ]'
'antsApplyTransforms --default-value 0 --dimensionality 3 --float 0 --input moving1.nii \
--interpolation BSpline[ 5 ] --output deformed_moving1.nii --reference-image fixed1.nii \
--transform [ ants_Warp.nii.gz, 0 ] --transform [ trans.mat, 0 ]'
"""
_cmd = 'antsApplyTransforms'
input_spec = ApplyTransformsInputSpec
Expand Down
Loading