Skip to content

Commit 95b14e6

Browse files
committed
RF: Adopt traits_extension.Tuple throughout
1 parent b81192b commit 95b14e6

39 files changed

+304
-280
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
CommandLine,
1212
TraitedSpec,
1313
traits,
14+
Tuple,
1415
isdefined,
1516
File,
1617
InputMultiPath,
@@ -2439,7 +2440,7 @@ class TCorrMapInputSpec(AFNICommandInputSpec):
24392440
mask = File(exists=True, argstr="-mask %s")
24402441
automask = traits.Bool(argstr="-automask")
24412442
polort = traits.Int(argstr="-polort %d")
2442-
bandpass = traits.Tuple((traits.Float(), traits.Float()), argstr="-bpass %f %f")
2443+
bandpass = Tuple((traits.Float(), traits.Float()), argstr="-bpass %f %f")
24432444
regress_out_timeseries = File(exists=True, argstr="-ort %s")
24442445
blur_fwhm = traits.Float(argstr="-Gblur %f")
24452446
seeds_width = traits.Float(argstr="-Mseed %f", xor=("seeds"))
@@ -3011,13 +3012,13 @@ class TProjectInputSpec(AFNICommandInputSpec):
30113012
30123013
""",
30133014
)
3014-
bandpass = traits.Tuple(
3015+
bandpass = Tuple(
30153016
traits.Float,
30163017
traits.Float,
30173018
desc="""Remove all frequencies EXCEPT those in the range""",
30183019
argstr="-bandpass %g %g",
30193020
)
3020-
stopband = traits.Tuple(
3021+
stopband = Tuple(
30213022
traits.Float,
30223023
traits.Float,
30233024
desc="""Remove all frequencies in the range""",
@@ -3394,7 +3395,7 @@ class VolregInputSpec(AFNICommandInputSpec):
33943395
copyfile=False,
33953396
)
33963397
in_weight_volume = traits.Either(
3397-
traits.Tuple(File(exists=True), traits.Int),
3398+
Tuple(File(exists=True), traits.Int),
33983399
File(exists=True),
33993400
desc="weights for each voxel specified by a file with an "
34003401
"optional volume number (defaults to 0)",
@@ -3821,8 +3822,8 @@ class QwarpInputSpec(AFNICommandInputSpec):
38213822
maxlen=5,
38223823
xor=["wmask"],
38233824
)
3824-
traits.Tuple((traits.Float(), traits.Float()), argstr="-bpass %f %f")
3825-
wmask = traits.Tuple(
3825+
bandpass = Tuple((traits.Float(), traits.Float()), argstr="-bpass %f %f")
3826+
wmask = Tuple(
38263827
(File(exists=True), traits.Float()),
38273828
desc="""\
38283829
Similar to '-wball', but here, you provide a dataset 'ws'

nipype/interfaces/afni/utils.py

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Directory,
1414
TraitedSpec,
1515
traits,
16+
Tuple,
1617
isdefined,
1718
File,
1819
InputMultiObject,
@@ -261,7 +262,7 @@ class BrickStatInputSpec(CommandLineInputSpec):
261262
mean = traits.Bool(desc="print the mean value in the dataset", argstr="-mean")
262263
sum = traits.Bool(desc="print the sum of values in the dataset", argstr="-sum")
263264
var = traits.Bool(desc="print the variance in the dataset", argstr="-var")
264-
percentile = traits.Tuple(
265+
percentile = Tuple(
265266
traits.Float,
266267
traits.Float,
267268
traits.Float,
@@ -330,7 +331,7 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
330331

331332
class BucketInputSpec(AFNICommandInputSpec):
332333
in_file = traits.List(
333-
traits.Tuple(
334+
Tuple(
334335
(File(exists=True, copyfile=False), traits.Str(argstr="'%s'")),
335336
artstr="%s%s",
336337
),
@@ -590,7 +591,7 @@ class Cat(AFNICommand):
590591

591592
class CatMatvecInputSpec(AFNICommandInputSpec):
592593
in_file = traits.List(
593-
traits.Tuple(traits.Str(), traits.Str()),
594+
Tuple(traits.Str(), traits.Str()),
594595
desc="list of tuples of mfiles and associated opkeys",
595596
mandatory=True,
596597
argstr="%s",
@@ -683,7 +684,7 @@ class CenterMassInputSpec(CommandLineInputSpec):
683684
exists=True,
684685
)
685686
automask = traits.Bool(desc="Generate the mask automatically", argstr="-automask")
686-
set_cm = traits.Tuple(
687+
set_cm = Tuple(
687688
(traits.Float(), traits.Float(), traits.Float()),
688689
desc="After computing the center of mass, set the origin fields in "
689690
"the header so that the center of mass will be at (x,y,z) in "
@@ -711,7 +712,7 @@ class CenterMassOutputSpec(TraitedSpec):
711712
out_file = File(exists=True, desc="output file")
712713
cm_file = File(desc="file with the center of mass coordinates")
713714
cm = traits.List(
714-
traits.Tuple(traits.Float(), traits.Float(), traits.Float()),
715+
Tuple(traits.Float(), traits.Float(), traits.Float()),
715716
desc="center of mass",
716717
)
717718

@@ -889,7 +890,7 @@ class DotInputSpec(AFNICommandInputSpec):
889890
)
890891
out_file = File(desc="collect output to a file", argstr=" |& tee %s", position=-1)
891892
mask = File(desc="Use this dataset as a mask", argstr="-mask %s")
892-
mrange = traits.Tuple(
893+
mrange = Tuple(
893894
(traits.Float(), traits.Float()),
894895
desc="Means to further restrict the voxels from 'mset' so that"
895896
"only those mask values within this range (inclusive) willbe used.",
@@ -1214,7 +1215,7 @@ class FWHMxInputSpec(CommandLineInputSpec):
12141215
acf = traits.Either(
12151216
traits.Bool(),
12161217
File(),
1217-
traits.Tuple(File(exists=True), traits.Float()),
1218+
Tuple(File(exists=True), traits.Float()),
12181219
default=False,
12191220
usedefault=True,
12201221
argstr="-acf",
@@ -1227,13 +1228,13 @@ class FWHMxOutputSpec(TraitedSpec):
12271228
out_subbricks = File(exists=True, desc="output file (subbricks)")
12281229
out_detrend = File(desc="output file, detrended")
12291230
fwhm = traits.Either(
1230-
traits.Tuple(traits.Float(), traits.Float(), traits.Float()),
1231-
traits.Tuple(traits.Float(), traits.Float(), traits.Float(), traits.Float()),
1231+
Tuple(traits.Float(), traits.Float(), traits.Float()),
1232+
Tuple(traits.Float(), traits.Float(), traits.Float(), traits.Float()),
12321233
desc="FWHM along each axis",
12331234
)
12341235
acf_param = traits.Either(
1235-
traits.Tuple(traits.Float(), traits.Float(), traits.Float()),
1236-
traits.Tuple(traits.Float(), traits.Float(), traits.Float(), traits.Float()),
1236+
Tuple(traits.Float(), traits.Float(), traits.Float()),
1237+
Tuple(traits.Float(), traits.Float(), traits.Float(), traits.Float()),
12371238
desc="fitted ACF model parameters",
12381239
)
12391240
out_acf = File(exists=True, desc="output acf file")
@@ -1429,10 +1430,10 @@ class LocalBistatInputSpec(AFNICommandInputSpec):
14291430
desc="Filename of the second image",
14301431
)
14311432
neighborhood = traits.Either(
1432-
traits.Tuple(traits.Enum("SPHERE", "RHDD", "TOHD"), traits.Float()),
1433-
traits.Tuple(
1433+
Tuple(traits.Enum("SPHERE", "RHDD", "TOHD"), traits.Float()),
1434+
Tuple(
14341435
traits.Enum("RECT"),
1435-
traits.Tuple(traits.Float(), traits.Float(), traits.Float()),
1436+
Tuple(traits.Float(), traits.Float(), traits.Float()),
14361437
),
14371438
mandatory=True,
14381439
desc="The region around each voxel that will be extracted for "
@@ -1557,10 +1558,10 @@ class LocalstatInputSpec(AFNICommandInputSpec):
15571558
exists=True, mandatory=True, argstr="%s", position=-1, desc="input dataset"
15581559
)
15591560
neighborhood = traits.Either(
1560-
traits.Tuple(traits.Enum("SPHERE", "RHDD", "TOHD"), traits.Float()),
1561-
traits.Tuple(
1561+
Tuple(traits.Enum("SPHERE", "RHDD", "TOHD"), traits.Float()),
1562+
Tuple(
15621563
traits.Enum("RECT"),
1563-
traits.Tuple(traits.Float(), traits.Float(), traits.Float()),
1564+
Tuple(traits.Float(), traits.Float(), traits.Float()),
15641565
),
15651566
mandatory=True,
15661567
desc="The region around each voxel that will be extracted for "
@@ -1594,9 +1595,9 @@ class LocalstatInputSpec(AFNICommandInputSpec):
15941595
stat = InputMultiObject(
15951596
traits.Either(
15961597
traits.Enum(_stat_names),
1597-
traits.Tuple(
1598+
Tuple(
15981599
traits.Enum("perc"),
1599-
traits.Tuple(traits.Float, traits.Float, traits.Float),
1600+
Tuple(traits.Float, traits.Float, traits.Float),
16001601
),
16011602
),
16021603
mandatory=True,
@@ -1669,7 +1670,7 @@ class LocalstatInputSpec(AFNICommandInputSpec):
16691670
)
16701671
reduce_grid = traits.Either(
16711672
traits.Float,
1672-
traits.Tuple(traits.Float, traits.Float, traits.Float),
1673+
Tuple(traits.Float, traits.Float, traits.Float),
16731674
argstr="-reduce_grid %s",
16741675
xor=["reduce_restore_grid", "reduce_max_vox"],
16751676
desc="Compute output on a grid that is reduced by the specified "
@@ -1683,7 +1684,7 @@ class LocalstatInputSpec(AFNICommandInputSpec):
16831684
)
16841685
reduce_restore_grid = traits.Either(
16851686
traits.Float,
1686-
traits.Tuple(traits.Float, traits.Float, traits.Float),
1687+
Tuple(traits.Float, traits.Float, traits.Float),
16871688
argstr="-reduce_restore_grid %s",
16881689
xor=["reduce_max_vox", "reduce_grid"],
16891690
desc="Like reduce_grid, but also resample output back to input grid.",
@@ -2127,7 +2128,7 @@ class NwarpApply(AFNICommandBase):
21272128
class NwarpCatInputSpec(AFNICommandInputSpec):
21282129
in_files = traits.List(
21292130
traits.Either(
2130-
File(), traits.Tuple(traits.Enum("IDENT", "INV", "SQRT", "SQRTINV"), File())
2131+
File(), Tuple(traits.Enum("IDENT", "INV", "SQRT", "SQRTINV"), File())
21312132
),
21322133
desc="list of tuples of 3D warps and associated functions",
21332134
mandatory=True,
@@ -2273,7 +2274,7 @@ class OneDToolPyInputSpec(AFNIPythonCommandInputSpec):
22732274
"file, and zeros are simply counted.",
22742275
argstr="-show_censor_count",
22752276
)
2276-
censor_motion = traits.Tuple(
2277+
censor_motion = Tuple(
22772278
(traits.Float(), File()),
22782279
desc="Tuple of motion limit and outfile prefix. need to also set set_nruns -r set_run_lengths",
22792280
argstr="-censor_motion %f %s",
@@ -2381,7 +2382,7 @@ class RefitInputSpec(CommandLineInputSpec):
23812382
desc="Associates the dataset with a specific template type, e.g. "
23822383
"TLRC, MNI, ORIG",
23832384
)
2384-
atrcopy = traits.Tuple(
2385+
atrcopy = Tuple(
23852386
File(exists=True),
23862387
traits.Str(),
23872388
argstr="-atrcopy %s %s",
@@ -2392,15 +2393,15 @@ class RefitInputSpec(CommandLineInputSpec):
23922393
"advanced users only. Do NOT use -atrcopy or -atrstring with "
23932394
"other modification options. See also -copyaux.",
23942395
)
2395-
atrstring = traits.Tuple(
2396+
atrstring = Tuple(
23962397
traits.Str(),
23972398
traits.Str(),
23982399
argstr="-atrstring %s %s",
23992400
desc="Copy the last given string into the dataset(s) being modified, "
24002401
"giving it the attribute name given by the last string."
24012402
"To be safe, the last string should be in quotes.",
24022403
)
2403-
atrfloat = traits.Tuple(
2404+
atrfloat = Tuple(
24042405
traits.Str(),
24052406
traits.Str(),
24062407
argstr="-atrfloat %s %s",
@@ -2410,7 +2411,7 @@ class RefitInputSpec(CommandLineInputSpec):
24102411
"'1 0.2 0 0 -0.2 1 0 0 0 0 1 0' or "
24112412
"flipZ.1D or '1D:1,0.2,2@0,-0.2,1,2@0,2@0,1,0'",
24122413
)
2413-
atrint = traits.Tuple(
2414+
atrint = Tuple(
24142415
traits.Str(),
24152416
traits.Str(),
24162417
argstr="-atrint %s %s",
@@ -2524,7 +2525,7 @@ class ReHoInputSpec(CommandLineInputSpec):
25242525
25252526
but you can choose most any value.""",
25262527
)
2527-
ellipsoid = traits.Tuple(
2528+
ellipsoid = Tuple(
25282529
traits.Float,
25292530
traits.Float,
25302531
traits.Float,
@@ -2618,7 +2619,7 @@ class ResampleInputSpec(AFNICommandInputSpec):
26182619
'for "Nearest Neighbor", "Linear", "Cubic" and "Blocky"'
26192620
"interpolation, respectively. Default is NN.",
26202621
)
2621-
voxel_size = traits.Tuple(
2622+
voxel_size = Tuple(
26222623
*[traits.Float()] * 3,
26232624
argstr="-dxyz %f %f %f",
26242625
desc="resample to new dx, dy and dz",
@@ -2711,7 +2712,7 @@ class TCat(AFNICommand):
27112712

27122713
class TCatSBInputSpec(AFNICommandInputSpec):
27132714
in_files = traits.List(
2714-
traits.Tuple(File(exists=True), Str()),
2715+
Tuple(File(exists=True), Str()),
27152716
desc="List of tuples of file names and subbrick selectors as strings."
27162717
"Don't forget to protect the single quotes in the subbrick selector"
27172718
"so the contents are protected from the command line interpreter.",
@@ -2933,7 +2934,7 @@ class UndumpInputSpec(AFNICommandInputSpec):
29332934
"then each input data line sets the value in only one voxel.",
29342935
argstr="-srad %f",
29352936
)
2936-
orient = traits.Tuple(
2937+
orient = Tuple(
29372938
traits.Enum("R", "L"),
29382939
traits.Enum("A", "P"),
29392940
traits.Enum("I", "S"),
@@ -3057,7 +3058,7 @@ class UnifizeInputSpec(AFNICommandInputSpec):
30573058
requires=["no_duplo", "t2"],
30583059
xor=["gm"],
30593060
)
3060-
rbt = traits.Tuple(
3061+
rbt = Tuple(
30613062
traits.Float(),
30623063
traits.Float(),
30633064
traits.Float(),

nipype/interfaces/ants/resampling.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55

66
from .base import ANTSCommand, ANTSCommandInputSpec
7-
from ..base import TraitedSpec, File, traits, isdefined, InputMultiObject
7+
from ..base import TraitedSpec, File, traits, Tuple, isdefined, InputMultiObject
88
from ...utils.filemanip import split_filename
99

1010

@@ -355,11 +355,9 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
355355
usedefault=True,
356356
)
357357
interpolation_parameters = traits.Either(
358-
traits.Tuple(traits.Int()), # BSpline (order)
359-
traits.Tuple(
360-
traits.Float(), traits.Float() # Gaussian/MultiLabel (sigma, alpha)
361-
),
362-
traits.Tuple(traits.Str()), # GenericLabel
358+
Tuple(traits.Int()), # BSpline (order)
359+
Tuple(traits.Float(), traits.Float()), # Gaussian/MultiLabel (sigma, alpha)
360+
Tuple(traits.Str()), # GenericLabel
363361
)
364362
transforms = InputMultiObject(
365363
traits.Either(File(exists=True), "identity"),

nipype/interfaces/ants/segmentation.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44
from glob import glob
55
from ...external.due import BibTeX
66
from ...utils.filemanip import split_filename, copyfile, which, fname_presuffix
7-
from ..base import TraitedSpec, File, traits, InputMultiPath, OutputMultiPath, isdefined
7+
from ..base import (
8+
TraitedSpec,
9+
File,
10+
traits,
11+
Tuple,
12+
InputMultiPath,
13+
OutputMultiPath,
14+
isdefined,
15+
)
816
from ..mixins import CopyHeaderInterface
917
from .base import ANTSCommand, ANTSCommandInputSpec
1018

@@ -401,7 +409,7 @@ class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec):
401409
This option rescales to the [min,max] range of the original image intensities
402410
within the user-specified mask.""",
403411
)
404-
histogram_sharpening = traits.Tuple(
412+
histogram_sharpening = Tuple(
405413
(0.15, 0.01, 200),
406414
traits.Float,
407415
traits.Float,

0 commit comments

Comments
 (0)