Skip to content

Commit d3aed2b

Browse files
committed
fix: test fixes for spm and rename interface
1 parent af51820 commit d3aed2b

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

nipype/interfaces/ants/segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def _format_arg(self, opt, spec, val):
490490
if priors_directory is not '':
491491
retval = "-p %s/BrainSegmentationPrior%%02d" %(priors_directory)
492492
else:
493-
retval = "-p BrainSegmentationPrior%02d"
493+
retval = "-p BrainSegmentationPrior%02d"
494494
retval += ext
495495
return retval
496496
return super(ANTSCommand, self)._format_arg(opt, spec, val)

nipype/interfaces/spm/preprocess.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ class NormalizeInputSpec(SPMCommandInputSpec):
374374
desc='file to normalize to template',
375375
xor=['parameter_file'],
376376
mandatory=True, copyfile=True)
377-
jobtype = traits.Enum('estwrite', 'est', 'write',
378-
desc='one of: est, write, estwrite estwrite')
377+
jobtype = traits.Enum('estwrite', 'est', 'write', usedefault=True,
378+
desc='Estimate, Write or do both')
379379
apply_to_files = InputMultiPath(traits.Either(File(exists=True),
380380
traits.List(File(exists=True))),
381381
field='subj.resample',
@@ -527,11 +527,11 @@ class Normalize12InputSpec(SPMCommandInputSpec):
527527
copyfile=True)
528528
deformation_file = File(field='subj.def', mandatory=True,
529529
xor=['image_to_align', 'tpm'],
530-
desc=('file y_*.nii containing 3 deformation fields',
530+
desc=('file y_*.nii containing 3 deformation fields '
531531
'for the deformation in x, y and z dimension'),
532532
copyfile=False)
533-
jobtype = traits.Enum('estwrite', 'est', 'write',
534-
desc='one of: est, write, estwrite estwrite')
533+
jobtype = traits.Enum('estwrite', 'est', 'write', usedefault=True,
534+
desc='Estimate, Write or do Both')
535535
bias_regularization = traits.Enum(0, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1,
536536
10, field='eoptions.biasreg',
537537
desc='no(0) - extremely heavy (10)')
@@ -547,37 +547,37 @@ class Normalize12InputSpec(SPMCommandInputSpec):
547547
desc='mni, size, none')
548548
warping_regularization = traits.List(traits.Float(), field='eoptions.reg',
549549
minlen=5, maxlen=5,
550-
desc=('controls balance between',
550+
desc=('controls balance between '
551551
'parameters and data'))
552552
smoothness = traits.Float(field='eoptions.fwhm',
553-
desc=('value (in mm) to smooth the data before',
553+
desc=('value (in mm) to smooth the data before '
554554
'normalization'))
555555
sampling_distance = traits.Float(field='eoptions.samp',
556-
desc=('Sampling distance on data for',
556+
desc=('Sampling distance on data for '
557557
'parameter estimation'))
558558
write_bounding_box = traits.List(traits.List(traits.Float(),
559559
minlen=3, maxlen=3),
560560
field='woptions.bb', minlen=2, maxlen=2,
561-
desc=('3x2-element list of lists representing',
561+
desc=('3x2-element list of lists representing '
562562
'the bounding box (in mm) to be written'))
563563
write_voxel_sizes = traits.List(traits.Float(), field='woptions.vox',
564564
minlen=3, maxlen=3,
565-
desc=('3-element list representing the',
566-
'voxel sizes (in mm) of the written',
565+
desc=('3-element list representing the '
566+
'voxel sizes (in mm) of the written '
567567
'normalised images'))
568568
write_interp = traits.Range(low=0, high=7, field='woptions.interp',
569569
desc='degree of b-spline used for interpolation')
570570

571571

572572
class Normalize12OutputSpec(TraitedSpec):
573573
deformation_field = OutputMultiPath(File(exists=True),
574-
desc=('NIfTI file containing 3 deformation',
575-
'fields for the deformation in',
574+
desc=('NIfTI file containing 3 deformation '
575+
'fields for the deformation in '
576576
'x, y and z dimension'))
577577
normalized_image = OutputMultiPath(File(exists=True),
578-
desc=('Normalized file that needed to',
578+
desc=('Normalized file that needed to '
579579
'be aligned'))
580-
normalized_files = OutputMultiPath(File(exists=True),
580+
normalized_files = OutputMultiPath(File(exists=True),
581581
desc='Normalized other files')
582582

583583

@@ -621,7 +621,7 @@ def _format_arg(self, opt, spec, val):
621621
raise ValueError('%s must have 5 elements' % opt)
622622
return super(Normalize12, self)._format_arg(opt, spec, val)
623623

624-
def _parse_inputs(self):
624+
def _parse_inputs(self, skip=()):
625625
"""validate spm normalize options if set to None ignore
626626
"""
627627
einputs = super(Normalize12, self)._parse_inputs(skip=('jobtype',

nipype/interfaces/spm/tests/test_preprocess.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_normalize_list_outputs():
8585
filelist, outdir, cwd = create_files_in_directory()
8686
norm = spm.Normalize(source=filelist[0])
8787
yield assert_true, norm._list_outputs()['normalized_source'][0].startswith('w')
88-
norm = spm.Normalize(source=filelist[0],apply_to_files=filelist[1])
88+
norm = spm.Normalize(source=filelist[0], apply_to_files=filelist[1])
8989
yield assert_true, norm._list_outputs()['normalized_files'][0].startswith('w')
9090
clean_directory(outdir, cwd)
9191

@@ -98,7 +98,8 @@ def test_normalize12_list_outputs():
9898
filelist, outdir, cwd = create_files_in_directory()
9999
norm12 = spm.Normalize12(image_to_align=filelist[0])
100100
yield assert_true, norm12._list_outputs()['normalized_image'][0].startswith('w')
101-
norm12 = spm.Normalize12(image_to_align=filelist[0],apply_to_files=filelist[1])
101+
norm12 = spm.Normalize12(image_to_align=filelist[0],
102+
apply_to_files=filelist[1])
102103
yield assert_true, norm12._list_outputs()['normalized_files'][0].startswith('w')
103104
clean_directory(outdir, cwd)
104105

nipype/interfaces/utility.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
"""Various utilities
4+
5+
Change directory to provide relative paths for doctests
6+
>>> import os
7+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
8+
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
9+
>>> os.chdir(datadir)
10+
"""
11+
312
import os
413
import re
514
from cPickle import dumps, loads

0 commit comments

Comments
 (0)