Skip to content

Commit bf4cc49

Browse files
committed
fix: do not monkeypatch Tuple and Either
1 parent 682c73c commit bf4cc49

File tree

97 files changed

+787
-777
lines changed

Some content is hidden

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

97 files changed

+787
-777
lines changed

nipype/algorithms/confounds.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from ..interfaces.base import (traits, TraitedSpec, BaseInterface,
2323
BaseInterfaceInputSpec, File, isdefined,
2424
InputMultiPath, OutputMultiPath,
25-
SimpleInterface)
25+
SimpleInterface, Either, Tuple)
2626
from ..utils import NUMPY_MMAP
2727
from ..utils.misc import normalize_mc_params
2828

@@ -56,7 +56,7 @@ class ComputeDVARSInputSpec(BaseInterfaceInputSpec):
5656
series_tr = traits.Float(desc='repetition time in sec.')
5757
save_plot = traits.Bool(False, usedefault=True, desc='write DVARS plot')
5858
figdpi = traits.Int(100, usedefault=True, desc='output dpi for the plot')
59-
figsize = traits.Tuple(
59+
figsize = Tuple(
6060
traits.Float(11.7),
6161
traits.Float(2.3),
6262
usedefault=True,
@@ -263,7 +263,7 @@ class FramewiseDisplacementInputSpec(BaseInterfaceInputSpec):
263263
False, usedefault=True, desc='calculate FD in mm/s')
264264
figdpi = traits.Int(
265265
100, usedefault=True, desc='output dpi for the FD plot')
266-
figsize = traits.Tuple(
266+
figsize = Tuple(
267267
traits.Float(11.7),
268268
traits.Float(2.3),
269269
usedefault=True,
@@ -398,7 +398,7 @@ class CompCorInputSpec(BaseInterfaceInputSpec):
398398
'components_file.txt',
399399
usedefault=True,
400400
desc='Filename to store physiological components')
401-
num_components = traits.Either(
401+
num_components = Either(
402402
'all', traits.Range(low=1), xor=['variance_threshold'],
403403
desc='Number of components to return from the decomposition. If '
404404
'`num_components` is `all`, then all components will be '
@@ -440,10 +440,10 @@ class CompCorInputSpec(BaseInterfaceInputSpec):
440440
repetition_time = traits.Float(
441441
desc='Repetition time (TR) of series - derived from image header if '
442442
'unspecified')
443-
save_pre_filter = traits.Either(
443+
save_pre_filter = Either(
444444
traits.Bool, File, default=False, usedefault=True,
445445
desc='Save pre-filter basis as text file')
446-
save_metadata = traits.Either(
446+
save_metadata = Either(
447447
traits.Bool, File, default=False, usedefault=True,
448448
desc='Save component metadata as text file')
449449
ignore_initial_volumes = traits.Range(

nipype/algorithms/mesh.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from .. import logging
1616
from ..interfaces.base import (BaseInterface, traits, TraitedSpec, File,
17-
BaseInterfaceInputSpec)
17+
BaseInterfaceInputSpec, Either, Tuple)
1818
from ..interfaces.vtkbase import tvtk
1919
from ..interfaces import vtkbase as VTKInfo
2020
IFLOGGER = logging.getLogger('nipype.interface')
@@ -281,11 +281,11 @@ class MeshWarpMathsInputSpec(BaseInterfaceInputSpec):
281281
mandatory=True,
282282
desc=('Input surface in vtk format, with associated warp '
283283
'field as point data (ie. from ComputeMeshWarp'))
284-
float_trait = traits.Either(
284+
float_trait = Either(
285285
traits.Float(1.0),
286-
traits.Tuple(traits.Float(1.0), traits.Float(1.0), traits.Float(1.0)))
286+
Tuple(traits.Float(1.0), traits.Float(1.0), traits.Float(1.0)))
287287

288-
operator = traits.Either(
288+
operator = Either(
289289
float_trait,
290290
File(exists=True),
291291
default=1.0,

nipype/algorithms/metrics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from ..interfaces.base import (
2121
SimpleInterface, BaseInterface, traits, TraitedSpec, File,
22-
InputMultiPath, BaseInterfaceInputSpec,
22+
Either, InputMultiPath, BaseInterfaceInputSpec,
2323
isdefined)
2424
from ..interfaces.nipy.base import NipyBaseInterface
2525

@@ -631,7 +631,7 @@ class SimilarityInputSpec(BaseInterfaceInputSpec):
631631
volume2 = File(exists=True, desc="3D/4D volume", mandatory=True)
632632
mask1 = File(exists=True, desc="3D volume")
633633
mask2 = File(exists=True, desc="3D volume")
634-
metric = traits.Either(
634+
metric = Either(
635635
traits.Enum('cc', 'cr', 'crl1', 'mi', 'nmi', 'slr'),
636636
traits.Callable(),
637637
desc="""str or callable

nipype/algorithms/misc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from . import metrics as nam
2323
from ..interfaces.base import (
2424
BaseInterface, traits, TraitedSpec, File, InputMultiPath, OutputMultiPath,
25-
BaseInterfaceInputSpec, isdefined, DynamicTraitedSpec, Undefined)
25+
BaseInterfaceInputSpec, isdefined, DynamicTraitedSpec, Undefined, Either, Tuple)
2626
from ..utils.filemanip import fname_presuffix, split_filename, ensure_list
2727
from ..utils import NUMPY_MMAP
2828

@@ -36,7 +36,7 @@ class PickAtlasInputSpec(BaseInterfaceInputSpec):
3636
exists=True,
3737
desc="Location of the atlas that will be used.",
3838
mandatory=True)
39-
labels = traits.Either(
39+
labels = Either(
4040
traits.Int,
4141
traits.List(traits.Int),
4242
desc=("Labels of regions that will be included in the mask. Must be\
@@ -1099,7 +1099,7 @@ def _list_outputs(self):
10991099
class SplitROIsInputSpec(TraitedSpec):
11001100
in_file = File(exists=True, mandatory=True, desc='file to be splitted')
11011101
in_mask = File(exists=True, desc='only process files inside mask')
1102-
roi_size = traits.Tuple(
1102+
roi_size = Tuple(
11031103
traits.Int, traits.Int, traits.Int, desc='desired ROI size')
11041104

11051105

nipype/algorithms/modelgen.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
from ..utils import NUMPY_MMAP
2727
from ..interfaces.base import (BaseInterface, TraitedSpec, InputMultiPath,
28-
traits, File, Bunch, BaseInterfaceInputSpec,
28+
traits, File, Bunch, Either, BaseInterfaceInputSpec,
2929
isdefined)
3030
from ..utils.filemanip import ensure_list
3131
from ..utils.misc import normalize_mc_params
@@ -284,7 +284,7 @@ class SpecifyModelInputSpec(BaseInterfaceInputSpec):
284284
'that should be tossed',
285285
copyfile=False)
286286
functional_runs = InputMultiPath(
287-
traits.Either(traits.List(File(exists=True)), File(exists=True)),
287+
Either(traits.List(File(exists=True)), File(exists=True)),
288288
mandatory=True,
289289
desc='Data files for model. List of 4D '
290290
'files or list of list of 3D '

nipype/interfaces/afni/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ... import logging, LooseVersion
1414
from ...utils.filemanip import split_filename
1515
from ..base import (CommandLine, traits, CommandLineInputSpec, isdefined, File,
16-
TraitedSpec, PackageInfo)
16+
TraitedSpec, PackageInfo, Either)
1717
from ...external.due import BibTeX
1818

1919
# Use nipype's logging system
@@ -248,7 +248,7 @@ def no_afni():
248248
class AFNIPythonCommandInputSpec(CommandLineInputSpec):
249249
outputtype = traits.Enum(
250250
'AFNI', list(Info.ftypes.keys()), desc='AFNI output filetype')
251-
py27_path = traits.Either(
251+
py27_path = Either(
252252
'python2', File(exists=True), usedefault=True, default='python2')
253253

254254

nipype/interfaces/afni/model.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import os
1616

1717
from ..base import (CommandLineInputSpec, CommandLine, Directory, TraitedSpec,
18-
traits, isdefined, File, InputMultiPath, Undefined, Str)
18+
traits, isdefined, File, InputMultiPath, Undefined, Str,
19+
Either, Tuple)
1920
from ...external.due import BibTeX
2021

2122
from .base import (AFNICommandBase, AFNICommand, AFNICommandInputSpec,
@@ -101,7 +102,7 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
101102
desc='don\'t consider all zero matrix columns to be the type of error '
102103
'that \'gotforit\' is needed to ignore.',
103104
argstr='-allzero_OK')
104-
dname = traits.Tuple(
105+
dname = Tuple(
105106
Str,
106107
Str,
107108
desc='set environmental variable to provided value',
@@ -133,7 +134,7 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
133134
desc='degree of polynomial corresponding to the null hypothesis '
134135
'[default: 1]',
135136
argstr='-polort %d')
136-
ortvec = traits.Tuple(
137+
ortvec = Tuple(
137138
File(desc='filename', exists=True),
138139
Str(desc='label'),
139140
desc='this option lets you input a rectangular array of 1 or more '
@@ -180,7 +181,7 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
180181
argstr='-num_stimts %d',
181182
position=-6)
182183
stim_times = traits.List(
183-
traits.Tuple(
184+
Tuple(
184185
traits.Int(desc='k-th response model'),
185186
File(desc='stimulus timing file', exists=True),
186187
Str(desc='model')),
@@ -189,7 +190,7 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
189190
argstr='-stim_times %d %s \'%s\'...',
190191
position=-5)
191192
stim_label = traits.List(
192-
traits.Tuple(
193+
Tuple(
193194
traits.Int(desc='k-th input stimulus'),
194195
Str(desc='stimulus label')),
195196
desc='label for kth input stimulus (e.g., Label1)',
@@ -213,7 +214,7 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
213214
argstr='-gltsym \'SYM: %s\'...',
214215
position=-2)
215216
glt_label = traits.List(
216-
traits.Tuple(
217+
Tuple(
217218
traits.Int(desc='k-th general linear test'),
218219
Str(desc='GLT label')),
219220
desc='general linear test (i.e., contrast) labels',
@@ -492,8 +493,8 @@ class RemlfitInputSpec(AFNICommandInputSpec):
492493
'to the \'rbeta_file\' and/or \'obeta_file\' output datasets.',
493494
argstr='-nobout')
494495
gltsym = traits.List(
495-
traits.Either(
496-
traits.Tuple(File(exists=True), Str()), traits.Tuple(Str(),
496+
Either(
497+
Tuple(File(exists=True), Str()), Tuple(Str(),
497498
Str())),
498499
desc='read a symbolic GLT from input file and associate it with a '
499500
'label. As in Deconvolve, you can also use the \'SYM:\' method '

nipype/interfaces/afni/preprocess.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
fname_presuffix)
1414
from ..base import (CommandLineInputSpec, CommandLine, TraitedSpec, traits,
1515
isdefined, File, InputMultiPath, Undefined, Str,
16-
InputMultiObject)
16+
InputMultiObject, Either, Tuple)
1717

1818
from .base import (AFNICommandBase, AFNICommand, AFNICommandInputSpec,
1919
AFNICommandOutputSpec, AFNIPythonCommandInputSpec,
@@ -54,7 +54,7 @@ class AlignEpiAnatPyInputSpec(AFNIPythonCommandInputSpec):
5454
mandatory=True,
5555
exists=True,
5656
copyfile=False)
57-
epi_base = traits.Either(
57+
epi_base = Either(
5858
traits.Range(low=0),
5959
traits.Enum('mean', 'median', 'max'),
6060
desc='the epi base used in alignment'
@@ -361,7 +361,7 @@ class AllineateInputSpec(AFNICommandInputSpec):
361361
desc='Set the weighting for each voxel in the base dataset; '
362362
'larger weights mean that voxel count more in the cost function. '
363363
'Must be defined on the same grid as the base dataset')
364-
weight = traits.Either(
364+
weight = Either(
365365
File(exists=True),
366366
traits.Float(),
367367
argstr='-weight %s',
@@ -2047,7 +2047,7 @@ class SegInputSpec(CommandLineInputSpec):
20472047
mandatory=True,
20482048
exists=True,
20492049
copyfile=True)
2050-
mask = traits.Either(
2050+
mask = Either(
20512051
traits.Enum('AUTO'),
20522052
File(exists=True),
20532053
desc='only non-zero voxels in mask are analyzed. mask can either be a '
@@ -2258,7 +2258,7 @@ class TCorrMapInputSpec(AFNICommandInputSpec):
22582258
mask = File(exists=True, argstr='-mask %s')
22592259
automask = traits.Bool(argstr='-automask')
22602260
polort = traits.Int(argstr='-polort %d')
2261-
bandpass = traits.Tuple(
2261+
bandpass = Tuple(
22622262
(traits.Float(), traits.Float()), argstr='-bpass %f %f')
22632263
regress_out_timeseries = File(exists=True, argstr='-ort %s')
22642264
blur_fwhm = traits.Float(argstr='-Gblur %f')
@@ -2591,11 +2591,11 @@ class TProjectInputSpec(AFNICommandInputSpec):
25912591
++ That is, 'fset' contains a different nuisance time
25922592
series for each voxel (e.g., from AnatICOR).
25932593
++ Multiple -dsort options are allowed.""")
2594-
bandpass = traits.Tuple(
2594+
bandpass = Tuple(
25952595
traits.Float, traits.Float,
25962596
desc="""Remove all frequencies EXCEPT those in the range""",
25972597
argstr='-bandpass %g %g')
2598-
stopband = traits.Tuple(
2598+
stopband = Tuple(
25992599
traits.Float, traits.Float,
26002600
desc="""Remove all frequencies in the range""",
26012601
argstr='-stopband %g %g')
@@ -2693,7 +2693,7 @@ class TShiftInputSpec(AFNICommandInputSpec):
26932693
desc='different interpolation methods (see 3dTshift for details) '
26942694
'default = Fourier',
26952695
argstr='-%s')
2696-
tpattern = traits.Either(
2696+
tpattern = Either(
26972697
traits.Enum('alt+z', 'altplus', # Synonyms
26982698
'alt+z2',
26992699
'alt-z', 'altminus', # Synonyms
@@ -2704,7 +2704,7 @@ class TShiftInputSpec(AFNICommandInputSpec):
27042704
desc='use specified slice time pattern rather than one in header',
27052705
argstr='-tpattern %s',
27062706
xor=['slice_timing'])
2707-
slice_timing = traits.Either(
2707+
slice_timing = Either(
27082708
File(exists=True),
27092709
traits.List(traits.Float),
27102710
desc='time offsets from the volume acquisition onset for each slice',
@@ -2861,8 +2861,8 @@ class VolregInputSpec(AFNICommandInputSpec):
28612861
mandatory=True,
28622862
exists=True,
28632863
copyfile=False)
2864-
in_weight_volume = traits.Either(
2865-
traits.Tuple(File(exists=True), traits.Int),
2864+
in_weight_volume = Either(
2865+
Tuple(File(exists=True), traits.Int),
28662866
File(exists=True),
28672867
desc='weights for each voxel specified by a file with an '
28682868
'optional volume number (defaults to 0)',
@@ -3234,8 +3234,8 @@ class QwarpInputSpec(AFNICommandInputSpec):
32343234
argstr='-wball %s',
32353235
minlen=5,
32363236
maxlen=5)
3237-
traits.Tuple((traits.Float(), traits.Float()), argstr='-bpass %f %f')
3238-
wmask = traits.Tuple(
3237+
Tuple((traits.Float(), traits.Float()), argstr='-bpass %f %f')
3238+
wmask = Tuple(
32393239
(File(exists=True), traits.Float()),
32403240
desc='-wmask ws f'
32413241
'Similar to \'-wball\', but here, you provide a dataset \'ws\''

0 commit comments

Comments
 (0)