Skip to content

Commit 155ae52

Browse files
committed
miscellaneous fixes from code review
1 parent 4cedad9 commit 155ae52

11 files changed

+98
-116
lines changed

nipype/interfaces/dtitk/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# from .base import ()
99
from .registration import (Rigid, Affine, Diffeo,
10-
ComposeXfm, diffeoSymTensor3DVol, affSymTensor3DVol,
11-
affScalarVol,diffeoScalarVol)
10+
ComposeXfm, DiffeoSymTensor3DVol, AffSymTensor3DVol,
11+
AffScalarVol, DiffeoScalarVol)
1212
from .utils import (TVAdjustVoxSp, SVAdjustVoxSp, TVResample, SVResample,
1313
TVtool, BinThresh)

nipype/interfaces/dtitk/registration.py

Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ class RigidInputSpec(CommandLineInputSpec):
3939
similarity_metric = traits.Enum('EDS', 'GDS', 'DDS', 'NMI',
4040
mandatory=True, position=2, argstr="%s",
4141
desc="similarity metric", usedefault=True)
42-
samplingXYZ = traits.Tuple((4, 4, 4), mandatory=True, position=3,
43-
argstr="%g %g %g", usedefault=True,
44-
desc="dist between samp points (mm) (x,y,z)")
42+
sampling_xyz = traits.Tuple((4, 4, 4), mandatory=True, position=3,
43+
argstr="%g %g %g", usedefault=True,
44+
desc="dist between samp points (mm) (x,y,z)")
4545
ftol = traits.Float(mandatory=True, position=4, argstr="%g",
4646
desc="cost function tolerance", default_value=0.01,
4747
usedefault=True)
48-
useInTrans = traits.Bool(position=5, argstr="1",
49-
desc="to initialize with existing xfm set as 1")
48+
use_in_trans = traits.Bool(position=5, argstr="1",
49+
desc="initialize with existing transform")
5050

5151

5252
class RigidOutputSpec(TraitedSpec):
@@ -65,9 +65,9 @@ class Rigid(CommandLineDtitk):
6565
>>> node.inputs.fixed_file = 'im1.nii'
6666
>>> node.inputs.moving_file = 'im2.nii'
6767
>>> node.inputs.similarity_metric = 'EDS'
68-
>>> node.inputs.samplingXYZ = (4,4,4)
68+
>>> node.inputs.sampling_xyz = (4,4,4)
6969
>>> node.inputs.ftol = 0.01
70-
>>> node.inputs.useInTrans = True
70+
>>> node.inputs.use_in_trans = True
7171
>>> node.cmdline
7272
'dti_rigid_reg im1.nii im2.nii EDS 4 4 4 0.01 1'
7373
>>> node.run() # doctest: +SKIP
@@ -96,9 +96,9 @@ class Affine(Rigid):
9696
>>> node.inputs.fixed_file = 'im1.nii'
9797
>>> node.inputs.moving_file = 'im2.nii'
9898
>>> node.inputs.similarity_metric = 'EDS'
99-
>>> node.inputs.samplingXYZ = (4,4,4)
99+
>>> node.inputs.sampling_xyz = (4,4,4)
100100
>>> node.inputs.ftol = 0.01
101-
>>> node.inputs.useInTrans = True
101+
>>> node.inputs.use_in_trans = True
102102
>>> node.cmdline
103103
'dti_affine_reg im1.nii im2.nii EDS 4 4 4 0.01 1'
104104
>>> node.run() # doctest: +SKIP
@@ -116,10 +116,10 @@ class DiffeoInputSpec(CommandLineInputSpec):
116116
usedefault=True, mandatory=True,
117117
position=3, argstr="%d")
118118
n_iters = traits.Int(6, desc="number of iterations",
119-
exists=True, mandatory=True,
119+
mandatory=True,
120120
position=4, argstr="%d", usedefault=True)
121121
ftol = traits.Float(0.002, desc="iteration for the optimization to stop",
122-
exists=True, mandatory=True, position=5, argstr="%g",
122+
mandatory=True, position=5, argstr="%g",
123123
usedefault=True)
124124

125125

@@ -152,7 +152,7 @@ class Diffeo(CommandLineDtitk):
152152

153153
def _list_outputs(self):
154154
outputs = self.output_spec().get()
155-
moving = self.inputs.moving_file()
155+
moving = self.inputs.moving_file
156156
outputs['out_file_xfm'] = fname_presuffix(moving, suffix='_diffeo.df')
157157
outputs['out_file'] = fname_presuffix(moving, suffix='_diffeo')
158158
return outputs
@@ -184,8 +184,8 @@ class ComposeXfm(CommandLineDtitk):
184184
>>> node = dtitk.ComposeXfm()
185185
>>> node.inputs.in_df = 'im_warp.df.nii'
186186
>>> node.inputs.in_aff= 'im_affine.aff'
187-
>>> node.cmdline #doctest:
188-
'dfRightComposeAffine -aff im_affine.aff -df im_warp.df.nii -out\
187+
>>> node.cmdline
188+
'dfRightComposeAffine -aff im_affine.aff -df im_warp.df.nii -out
189189
im_warp.df_affdf.nii'
190190
>>> node.run() # doctest: +SKIP
191191
"""
@@ -194,7 +194,7 @@ class ComposeXfm(CommandLineDtitk):
194194
_cmd = 'dfRightComposeAffine'
195195

196196

197-
class affSymTensor3DVolInputSpec(CommandLineInputSpec):
197+
class AffSymTensor3DVolInputSpec(CommandLineInputSpec):
198198
in_file = File(desc='moving tensor volume', exists=True,
199199
argstr="-in %s", mandatory=True)
200200
out_file = File(desc='output filename',
@@ -215,7 +215,7 @@ class affSymTensor3DVolInputSpec(CommandLineInputSpec):
215215
desc='output volume specification read from the target '
216216
'volume if specified')
217217
translation = traits.Tuple((traits.Float(), traits.Float(),
218-
traits.Float()),
218+
traits.Float()),
219219
desc='translation (x,y,z) in mm',
220220
argstr='-translation %g %g %g',
221221
xor=['transform'])
@@ -227,32 +227,32 @@ class affSymTensor3DVolInputSpec(CommandLineInputSpec):
227227
argstr='-deformation %g %g %g %g %g %g')
228228

229229

230-
class affSymTensor3DVolOutputSpec(TraitedSpec):
230+
class AffSymTensor3DVolOutputSpec(TraitedSpec):
231231
out_file = File(exists=True)
232232

233233

234-
class affSymTensor3DVol(CommandLineDtitk):
234+
class AffSymTensor3DVol(CommandLineDtitk):
235235
"""
236236
Applies affine transform to a tensor volume
237237
238238
Example
239239
-------
240240
241241
>>> from nipype.interfaces import dtitk
242-
>>> node = dtitk.affSymTensor3DVol()
242+
>>> node = dtitk.AffSymTensor3DVol()
243243
>>> node.inputs.in_file = 'im1.nii'
244244
>>> node.inputs.transform = 'im_affine.aff'
245-
>>> node.cmdline #doctest:
246-
'affineSymTensor3DVolume -in im1.nii -interp LEI -out im1_affxfmd.nii\
245+
>>> node.cmdline
246+
'affineSymTensor3DVolume -in im1.nii -interp LEI -out im1_affxfmd.nii
247247
-reorient PPD -trans im_affine.aff'
248248
>>> node.run() # doctest: +SKIP
249249
"""
250-
input_spec = affSymTensor3DVolInputSpec
251-
output_spec = affSymTensor3DVolOutputSpec
250+
input_spec = AffSymTensor3DVolInputSpec
251+
output_spec = AffSymTensor3DVolOutputSpec
252252
_cmd = 'affineSymTensor3DVolume'
253253

254254

255-
class affScalarVolInputSpec(CommandLineInputSpec):
255+
class AffScalarVolInputSpec(CommandLineInputSpec):
256256
in_file = File(desc='moving scalar volume', exists=True,
257257
argstr="-in %s", mandatory=True)
258258
out_file = File(desc='output filename',
@@ -270,7 +270,7 @@ class affScalarVolInputSpec(CommandLineInputSpec):
270270
desc='output volume specification read from the target '
271271
'volume if specified')
272272
translation = traits.Tuple((traits.Float(), traits.Float(),
273-
traits.Float()),
273+
traits.Float()),
274274
desc='translation (x,y,z) in mm',
275275
argstr='-translation %g %g %g',
276276
xor=['transform'])
@@ -282,37 +282,37 @@ class affScalarVolInputSpec(CommandLineInputSpec):
282282
argstr='-deformation %g %g %g %g %g %g')
283283

284284

285-
class affScalarVolOutputSpec(TraitedSpec):
285+
class AffScalarVolOutputSpec(TraitedSpec):
286286
out_file = File(desc='moved volume', exists=True)
287287

288288

289-
class affScalarVol(CommandLineDtitk):
289+
class AffScalarVol(CommandLineDtitk):
290290
"""
291291
Applies affine transform to a scalar volume
292292
293293
Example
294294
-------
295295
296296
>>> from nipype.interfaces import dtitk
297-
>>> node = dtitk.affScalarVol()
297+
>>> node = dtitk.AffScalarVol()
298298
>>> node.inputs.in_file = 'im1.nii'
299299
>>> node.inputs.transform = 'im_affine.aff'
300-
>>> node.cmdline #doctest:
301-
'affineScalarVolume -in im1.nii -interp 0 -out im1_affxfmd.nii -trans\
300+
>>> node.cmdline
301+
'affineScalarVolume -in im1.nii -interp 0 -out im1_affxfmd.nii -trans
302302
im_affine.aff'
303303
>>> node.run() # doctest: +SKIP
304304
"""
305-
input_spec = affScalarVolInputSpec
306-
output_spec = affScalarVolOutputSpec
305+
input_spec = AffScalarVolInputSpec
306+
output_spec = AffScalarVolOutputSpec
307307
_cmd = 'affineScalarVolume'
308308

309309
def _format_arg(self, name, spec, value):
310310
if name == 'interpolation':
311311
value = {'trilinear': 0, 'NN': 1}[value]
312-
return super(affScalarVol, self)._format_arg(name, spec, value)
312+
return super(AffScalarVol, self)._format_arg(name, spec, value)
313313

314314

315-
class diffeoSymTensor3DVolInputSpec(CommandLineInputSpec):
315+
class DiffeoSymTensor3DVolInputSpec(CommandLineInputSpec):
316316
in_file = File(desc='moving tensor volume', exists=True,
317317
argstr="-in %s", mandatory=True)
318318
out_file = File(desc='output filename',
@@ -335,44 +335,44 @@ class diffeoSymTensor3DVolInputSpec(CommandLineInputSpec):
335335
desc='xyz voxel size (superseded by target)',
336336
argstr="-vsize %g %g %g", xor=['target'])
337337
flip = traits.Tuple((traits.Int(), traits.Int(), traits.Int()),
338-
exists=True, argstr="-flip %d %d %d")
338+
argstr="-flip %d %d %d")
339339
resampling_type = traits.Enum('backward', 'forward',
340340
desc='use backward or forward resampling',
341-
exists=True, argstr="-type %s")
341+
argstr="-type %s")
342342

343343

344-
class diffeoSymTensor3DVolOutputSpec(TraitedSpec):
344+
class DiffeoSymTensor3DVolOutputSpec(TraitedSpec):
345345
out_file = File(exists=True)
346346

347347

348-
class diffeoSymTensor3DVol(CommandLineDtitk):
348+
class DiffeoSymTensor3DVol(CommandLineDtitk):
349349
"""
350350
Applies diffeomorphic transform to a tensor volume
351351
352352
Example
353353
-------
354354
355355
>>> from nipype.interfaces import dtitk
356-
>>> node = dtitk.diffeoSymTensor3DVol()
356+
>>> node = dtitk.DiffeoSymTensor3DVol()
357357
>>> node.inputs.in_file = 'im1.nii'
358358
>>> node.inputs.transform = 'im_warp.df.nii'
359-
>>> node.cmdline #doctest:
360-
'deformationSymTensor3DVolume -df FD -in im1.nii -interp LEI -out\
359+
>>> node.cmdline
360+
'deformationSymTensor3DVolume -df FD -in im1.nii -interp LEI -out
361361
im1_diffeoxfmd.nii -reorient PPD -trans im_warp.df.nii'
362362
>>> node.run() # doctest: +SKIP
363363
"""
364364

365-
input_spec = diffeoSymTensor3DVolInputSpec
366-
output_spec = diffeoSymTensor3DVolOutputSpec
365+
input_spec = DiffeoSymTensor3DVolInputSpec
366+
output_spec = DiffeoSymTensor3DVolOutputSpec
367367
_cmd = 'deformationSymTensor3DVolume'
368368

369369
def _format_arg(self, name, spec, value):
370370
if name == 'resampling_type':
371371
value = {'forward': 0, 'backward': 1}[value]
372-
return super(diffeoSymTensor3DVol, self)._format_arg(name, spec, value)
372+
return super(DiffeoSymTensor3DVol, self)._format_arg(name, spec, value)
373373

374374

375-
class diffeoScalarVolInputSpec(CommandLineInputSpec):
375+
class DiffeoScalarVolInputSpec(CommandLineInputSpec):
376376
in_file = File(desc='moving scalar volume', exists=True,
377377
argstr="-in %s", mandatory=True)
378378
out_file = File(desc='output filename',
@@ -387,45 +387,44 @@ class diffeoScalarVolInputSpec(CommandLineInputSpec):
387387
desc='xyz voxel size (superseded by target)',
388388
argstr="-vsize %g %g %g", xor=['target'])
389389
flip = traits.Tuple((traits.Int(), traits.Int(), traits.Int()),
390-
exists=True, argstr="-flip %d %d %d")
390+
argstr="-flip %d %d %d")
391391
resampling_type = traits.Enum('backward', 'forward',
392392
desc='use backward or forward resampling',
393-
exists=True, argstr="-type %s")
393+
argstr="-type %s")
394394
interpolation = traits.Enum('trilinear', 'NN',
395395
desc='trilinear, or nearest neighbor',
396-
exists=True, argstr="-interp %s",
396+
argstr="-interp %s",
397397
usedefault=True)
398398

399399

400-
class diffeoScalarVolOutputSpec(TraitedSpec):
400+
class DiffeoScalarVolOutputSpec(TraitedSpec):
401401
out_file = File(desc='moved volume', exists=True)
402402

403403

404-
class diffeoScalarVol(CommandLineDtitk):
404+
class DiffeoScalarVol(CommandLineDtitk):
405405
"""
406406
Applies diffeomorphic transform to a scalar volume
407407
408408
Example
409409
-------
410410
411411
>>> from nipype.interfaces import dtitk
412-
>>> node = dtitk.diffeoScalarVol()
412+
>>> node = dtitk.DiffeoScalarVol()
413413
>>> node.inputs.in_file = 'im1.nii'
414414
>>> node.inputs.transform = 'im_warp.df.nii'
415415
>>> node.cmdline
416-
'deformationScalarVolume -in im1.nii -interp 0 -out im1_diffeoxfmd.nii\
416+
'deformationScalarVolume -in im1.nii -interp 0 -out im1_diffeoxfmd.nii
417417
-trans im_warp.df.nii'
418418
>>> node.run() # doctest: +SKIP
419419
"""
420420

421-
input_spec = diffeoScalarVolInputSpec
422-
output_spec = diffeoScalarVolOutputSpec
421+
input_spec = DiffeoScalarVolInputSpec
422+
output_spec = DiffeoScalarVolOutputSpec
423423
_cmd = 'deformationScalarVolume'
424424

425425
def _format_arg(self, name, spec, value):
426426
if name == 'resampling_type':
427427
value = {'forward': 0, 'backward': 1}[value]
428-
super(diffeoScalarVol, self)._format_arg(name, spec, value)
429-
if name == 'interpolation':
428+
elif name == 'interpolation':
430429
value = {'trilinear': 0, 'NN': 1}[value]
431-
return super(diffeoScalarVol, self)._format_arg(name, spec, value)
430+
return super(DiffeoScalarVol, self)._format_arg(name, spec, value)

nipype/interfaces/dtitk/tests/test_auto_Affine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_Affine_inputs():
3232
mandatory=True,
3333
position=1,
3434
),
35-
samplingXYZ=dict(
35+
sampling_xyz=dict(
3636
argstr='%g %g %g',
3737
mandatory=True,
3838
position=3,
@@ -48,7 +48,7 @@ def test_Affine_inputs():
4848
deprecated='1.0.0',
4949
nohash=True,
5050
),
51-
useInTrans=dict(
51+
use_in_trans=dict(
5252
argstr='1',
5353
position=5,
5454
),

nipype/interfaces/dtitk/tests/test_auto_Diffeo.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def test_Diffeo_inputs():
1616
),
1717
ftol=dict(
1818
argstr='%g',
19-
exists=True,
2019
mandatory=True,
2120
position=5,
2221
usedefault=True,
@@ -43,7 +42,6 @@ def test_Diffeo_inputs():
4342
),
4443
n_iters=dict(
4544
argstr='%d',
46-
exists=True,
4745
mandatory=True,
4846
position=4,
4947
usedefault=True,

nipype/interfaces/dtitk/tests/test_auto_Rigid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_Rigid_inputs():
3232
mandatory=True,
3333
position=1,
3434
),
35-
samplingXYZ=dict(
35+
sampling_xyz=dict(
3636
argstr='%g %g %g',
3737
mandatory=True,
3838
position=3,
@@ -48,7 +48,7 @@ def test_Rigid_inputs():
4848
deprecated='1.0.0',
4949
nohash=True,
5050
),
51-
useInTrans=dict(
51+
use_in_trans=dict(
5252
argstr='1',
5353
position=5,
5454
),

nipype/interfaces/dtitk/tests/test_auto_TVtool.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ def test_TVtool_inputs():
1919
argstr='-in %s',
2020
mandatory=True,
2121
),
22-
in_flag=dict(
23-
argstr='-%s',
24-
exists=True,
25-
),
22+
in_flag=dict(argstr='-%s', ),
2623
out_file=dict(
2724
argstr='-out %s',
2825
genfile=True,

0 commit comments

Comments
 (0)