Skip to content

Commit 53a900c

Browse files
author
bpinsard
committed
Merge branch 'master' into fsl_model
* master: (21 commits) fix: fsl tests sty: white space fix: automask bug when apply_mask is not specified fix: updated test writer with additional metadata fix: remove unnecessary print statement fix: trim http link for code fix: github url generation fix: return full hash Removed unnecessary usedefault. fixed typo in a file name fix: github authentication Going back to distinguishing affine transformations by names. Improved docs. fixed typo in randomize parameters Removed unnecessary copyfiles and added output_image option. BF: Pass plugin_args to child nodes of MapNode ENH: Don't require ordereddict for python < 2.7 BF: Fix for plugins when using python2.7 Fixed parenthesis. Fix fslreorient2std output collection Allow FNIRT to take standard names as reference. ...
2 parents 66539dc + 47cdfdb commit 53a900c

18 files changed

+88
-69
lines changed

nipype/interfaces/afni/preprocess.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@ class AutomaskInputSpec(AFNITraitedSpec):
562562
hash_files=False)
563563

564564
apply_mask = File(desc="output file from 3dAutomask",
565-
argstr='-apply_prefix %s')
565+
argstr='-apply_prefix %s',
566+
genfile=True,
567+
hash_files=False)
566568

567569
clfrac = traits.Float(desc='sets the clip level fraction' +
568570
' (must be 0.1-0.9). ' +
@@ -610,8 +612,10 @@ class Automask(AFNICommand):
610612
output_spec = AutomaskOutputSpec
611613

612614
def _gen_filename(self, name):
613-
if name == 'out_file' or name == 'brain_file':
615+
if name == 'out_file':
614616
return self._list_outputs()[name]
617+
if name == 'apply_mask':
618+
return self._list_outputs()['brain_file']
615619
return None
616620

617621
def _list_outputs(self):
@@ -623,8 +627,8 @@ def _list_outputs(self):
623627
outputs['out_file'] = os.path.abspath(self.inputs.out_file)
624628

625629
if not isdefined(self.inputs.apply_mask):
626-
outputs['brain_file'] = self._gen_fname(
627-
self.inputs.in_file, suffix=self.inputs.apply_suffix)
630+
outputs['brain_file'] = self._gen_fname(self.inputs.in_file,
631+
suffix=self.inputs.apply_suffix)
628632
else:
629633
outputs['brain_file'] = os.path.abspath(self.inputs.apply_mask)
630634
return outputs

nipype/interfaces/afni/tests/test_preprocess.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,20 @@ def test_maskave():
356356
yield assert_equal, getattr(instance.inputs.traits()[key], metakey), value
357357

358358
def test_automask():
359-
input_map = dict(apply_mask = dict(argstr='-apply_prefix %s',),
359+
input_map = dict(apply_mask = dict(argstr='-apply_prefix %s',
360+
hash_files=False,genfile=True,),
361+
apply_suffix = dict(usedefault=True,),
360362
args = dict(argstr='%s',),
361363
clfrac = dict(argstr='-dilate %s',),
362364
dilate = dict(argstr='-dilate %s',),
363365
environ = dict(usedefault=True,),
364366
erode = dict(argstr='-erode %s',),
365367
ignore_exception = dict(usedefault=True,),
366368
in_file = dict(argstr='%s',mandatory=True,),
367-
out_file = dict(argstr='-prefix %s',),
369+
mask_suffix = dict(usedefault=True,),
370+
out_file = dict(hash_files=False,genfile=True,
371+
argstr='-prefix %s',),
368372
outputtype = dict(),
369-
suffix = dict(),
370373
)
371374
instance = afni.Automask()
372375
for key, metadata in input_map.items():

nipype/interfaces/ants/registration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
192192
requires=['sampling_strategy'], desc='')
193193
use_estimate_learning_rate_once = traits.List(traits.Bool(), desc='')
194194
use_histogram_matching = traits.List(traits.Bool(argstr='%s'), default=True, usedefault=True)
195-
# Interpolation flag
195+
# Interpolation flag
196196
interpolation = traits.Enum('Linear',
197197
'NearestNeighbor',
198198
'CosineWindowedSinc',
@@ -339,9 +339,9 @@ def _format_arg(self, opt, spec, val):
339339
if self.inputs.invert_initial_moving_transform:
340340
return '--initial-moving-transform [ %s, 1 ]' % self.inputs.initial_moving_transform
341341
else:
342-
return '--initial-moving-transform [ %s, 0 ]' % self.inputs.initial_moving_transform
343-
elif opt == 'interpolation':
344-
# TODO: handle multilabel, gaussian, and bspline options
342+
return '--initial-moving-transform [ %s, 0 ]' % self.inputs.initial_moving_transform
343+
elif opt == 'interpolation':
344+
# TODO: handle multilabel, gaussian, and bspline options
345345
return '--interpolation %s' % self.inputs.interpolation
346346
elif opt == 'output_transform_prefix':
347347
if isdefined(self.inputs.output_inverse_warped_image) and self.inputs.output_inverse_warped_image:

nipype/interfaces/ants/resampling.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ def _list_outputs(self):
103103
class WarpImageMultiTransformInputSpec(ANTSCommandInputSpec):
104104
dimension = traits.Enum(3, 2, argstr='%d', usedefault=True,
105105
desc='image dimension (2 or 3)', position=1)
106-
input_image = File(argstr='%s', mandatory=True, copyfile=True,
106+
input_image = File(argstr='%s', mandatory=True,
107107
desc=('image to apply transformation to (generally a '
108-
'coregistered functional)') )
109-
out_postfix = traits.Str('_wimt', argstr='%s', usedefault=True,
110-
desc=('Postfix that is prepended to all output '
111-
'files (default = _wimt)'))
108+
'coregistered functional)'), position=2)
109+
output_image = File(genfile=True, hash_files=False, argstr='%s',
110+
desc=('name of the output warped image'), position = 3, xor=['out_postfix'])
111+
out_postfix = File("_wimt", usedefault=True, hash_files=False,
112+
desc=('Postfix that is prepended to all output '
113+
'files (default = _wimt)'), xor=['output_image'])
112114
reference_image = File(argstr='-R %s', xor=['tightest_box'],
113115
desc='reference image space that you wish to warp INTO')
114116
tightest_box = traits.Bool(argstr='--tightest-bounding-box',
@@ -123,13 +125,16 @@ class WarpImageMultiTransformInputSpec(ANTSCommandInputSpec):
123125
desc='Use nearest neighbor interpolation')
124126
use_bspline = traits.Bool(argstr='--use-Bspline',
125127
desc='Use 3rd order B-Spline interpolation')
126-
transformation_series = InputMultiPath(File(exists=True, copyfile=False), argstr='%s',
128+
transformation_series = InputMultiPath(File(exists=True), argstr='%s',
127129
desc='transformation file(s) to be applied',
128-
mandatory=True, copyfile=False)
130+
mandatory=True)
129131
invert_affine = traits.List(traits.Int,
130-
desc=('List of Affine transformations to invert. '
132+
desc=('List of Affine transformations to invert.'
131133
'E.g.: [1,4,5] inverts the 1st, 4th, and 5th Affines '
132-
'found in transformation_series'))
134+
'found in transformation_series. Note that indexing '
135+
'starts with 1 and does not include warp fields. Affine '
136+
'transformations are distinguished '
137+
'from warp fields by the word "affine" included in their filenames.'))
133138

134139
class WarpImageMultiTransformOutputSpec(TraitedSpec):
135140
output_image = File(exists=True, desc='Warped image')
@@ -162,15 +167,18 @@ class WarpImageMultiTransform(ANTSCommand):
162167
input_spec = WarpImageMultiTransformInputSpec
163168
output_spec = WarpImageMultiTransformOutputSpec
164169

165-
def _format_arg(self, opt, spec, val):
166-
if opt == 'out_postfix':
170+
def _gen_filename(self, name):
171+
if name == 'output_image':
167172
_, name, ext = split_filename(os.path.abspath(self.inputs.input_image))
168-
return name + val + ext
173+
return ''.join((name, self.inputs.out_postfix, ext))
174+
return None
175+
176+
def _format_arg(self, opt, spec, val):
169177
if opt == 'transformation_series':
170178
series = []
171179
affine_counter = 0
172180
for transformation in val:
173-
if 'Affine' in transformation and \
181+
if "affine" in transformation.lower() and \
174182
isdefined(self.inputs.invert_affine):
175183
affine_counter += 1
176184
if affine_counter in self.inputs.invert_affine:
@@ -181,11 +189,10 @@ def _format_arg(self, opt, spec, val):
181189

182190
def _list_outputs(self):
183191
outputs = self._outputs().get()
184-
_, name, ext = split_filename(os.path.abspath(self.inputs.input_image))
185-
outputs['output_image'] = os.path.join(os.getcwd(),
186-
''.join((name,
187-
self.inputs.out_postfix,
188-
ext)))
192+
if isdefined(self.inputs.output_image):
193+
outputs['output_image'] = os.path.abspath(self.inputs.output_image)
194+
else:
195+
outputs['output_image'] = os.path.abspath(self._gen_filename('output_image'))
189196
return outputs
190197

191198

nipype/interfaces/fsl/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,15 +1403,15 @@ def _format_arg(self, name, spec, value):
14031403
class RandomiseInputSpec(FSLCommandInputSpec):
14041404
in_file = File(exists=True, desc='4D input file', argstr='-i %s', position=0, mandatory=True)
14051405
base_name = traits.Str('tbss_', desc='the rootname that all generated files will have',
1406-
argstr='-o %s', position=1, usedefault=True)
1407-
design_mat = File(exists=True, desc='design matrix file', argstr='-d %s', position=2, mandatory=True)
1408-
tcon = File(exists=True, desc='t contrasts file', argstr='-t %s', position=3, mandatory=True)
1406+
argstr='-o "%s"', position=1, usedefault=True)
1407+
design_mat = File(exists=True, desc='design matrix file', argstr='-d %s', position=2)
1408+
tcon = File(exists=True, desc='t contrasts file', argstr='-t %s', position=3)
14091409
fcon = File(exists=True, desc='f contrasts file', argstr='-f %s')
14101410
mask = File(exists=True, desc='mask image', argstr='-m %s')
14111411
x_block_labels = File(exists=True, desc='exchangeability block labels file', argstr='-e %s')
14121412
demean = traits.Bool(desc='demean data temporally before model fitting', argstr='-D')
14131413
one_sample_group_mean = traits.Bool(desc='perform 1-sample group-mean test instead of generic permutation test',
1414-
argstr='-l')
1414+
argstr='-1')
14151415
show_total_perms = traits.Bool(desc='print out how many unique permutations would be generated and exit',
14161416
argstr='-q')
14171417
show_info_parallel_mode = traits.Bool(desc='print out information required for parallel mode and exit',

nipype/interfaces/fsl/preprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _gen_outfilename(self):
153153
def _list_outputs(self):
154154
outputs = self.output_spec().get()
155155
outputs['out_file'] = self._gen_outfilename()
156-
if ((isdefined(self.inputs.mesh) and self.inputs.mesh) or
156+
if ((isdefined(self.inputs.mesh) and self.inputs.mesh) or
157157
(isdefined(self.inputs.surfaces) and self.inputs.surfaces)):
158158
outputs['meshfile'] = self._gen_fname(outputs['out_file'],
159159
suffix='_mesh.vtk',
@@ -690,7 +690,7 @@ class FNIRTInputSpec(FSLCommandInputSpec):
690690
'to intensity mapping', hash_files=False)
691691
log_file = File(argstr='--logout=%s',
692692
desc='Name of log-file', genfile=True, hash_files=False)
693-
config_file = File(exists=True, argstr='--config=%s',
693+
config_file = traits.Either(traits.Enum("T1_2_MNI152_2mm", "FA_2_FMRIB58_1mm"), File(exists=True), argstr='--config=%s',
694694
desc='Name of config file specifying command line arguments')
695695
refmask_file = File(exists=True, argstr='--refmask=%s',
696696
desc='name of file with mask in reference space')

nipype/interfaces/fsl/tests/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_fslversion():
1515
if ver:
1616
# If ver is None, fsl is not installed
1717
ver = ver.split('.')
18-
yield assert_equal, ver[0], '4'
18+
yield assert_true, ver[0] in ['4', '5']
1919

2020
@skipif(no_fsl)#skip if fsl not installed)
2121
def test_fsloutputtype():

nipype/interfaces/fsl/tests/test_model.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,29 +299,30 @@ def test_cluster():
299299
yield assert_equal, getattr(instance.inputs.traits()[key], metakey), value
300300

301301
@skipif(no_fsl)
302-
def test_randomise1():
302+
def test_randomise():
303303
input_map = dict(args = dict(argstr='%s',),
304-
base_name = dict(argstr='-o %s',),
304+
base_name = dict(argstr='-o "%s"',usedefault=True,),
305305
c_thresh = dict(argstr='-c %.2f',),
306306
cm_thresh = dict(argstr='-C %.2f',),
307307
demean = dict(argstr='-D',),
308-
design_mat = dict(argstr='-d %s',mandatory=True,),
309-
environ = dict(),
308+
design_mat = dict(argstr='-d %s',),
309+
environ = dict(usedefault=True,),
310310
f_c_thresh = dict(argstr='-F %.2f',),
311311
f_cm_thresh = dict(argstr='-S %.2f',),
312312
f_only = dict(argstr='--f_only',),
313313
fcon = dict(argstr='-f %s',),
314+
ignore_exception = dict(usedefault=True,),
314315
in_file = dict(argstr='-i %s',mandatory=True,),
315316
mask = dict(argstr='-m %s',),
316317
num_perm = dict(argstr='-n %d',),
317-
one_sample_group_mean = dict(argstr='-l',),
318+
one_sample_group_mean = dict(argstr='-1',),
318319
output_type = dict(),
319320
p_vec_n_dist_files = dict(argstr='-P',),
320321
raw_stats_imgs = dict(argstr='-R',),
321322
seed = dict(argstr='--seed %d',),
322323
show_info_parallel_mode = dict(argstr='-Q',),
323324
show_total_perms = dict(argstr='-q',),
324-
tcon = dict(argstr='-t %s',mandatory=True,),
325+
tcon = dict(argstr='-t %s',),
325326
tfce = dict(argstr='-T',),
326327
tfce2D = dict(argstr='--T2',),
327328
tfce_C = dict(argstr='--tfce_C %.2f',),

nipype/interfaces/fsl/utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,14 +1151,14 @@ def _list_outputs(self):
11511151
outputs['exf_mask'] = self._gen_fname(cwd=self.inputs.tmpdir,
11521152
basename='maskexf')
11531153
return outputs
1154-
1154+
11551155
class Reorient2StdInputSpec(FSLCommandInputSpec):
11561156
in_file = File(exists=True, mandatory=True, argstr="%s")
11571157
out_file = File(genfile=True, hash_files=False, argstr="%s")
1158-
1158+
11591159
class Reorient2StdOutputSpec(TraitedSpec):
11601160
out_file = File(exists=True)
1161-
1161+
11621162
class Reorient2Std(FSLCommand):
11631163
"""fslreorient2std is a tool for reorienting the image to match the
11641164
approximate orientation of the standard template images (MNI152).
@@ -1180,10 +1180,11 @@ def _gen_filename(self, name):
11801180
return self._gen_fname(self.inputs.in_file,
11811181
suffix="_reoriented")
11821182
return None
1183-
1183+
11841184
def _list_outputs(self):
11851185
outputs = self.output_spec().get()
11861186
if not isdefined(self.inputs.out_file):
11871187
outputs['out_file'] = self._gen_filename('out_file')
11881188
else:
11891189
outputs['out_file'] = os.path.abspath(self.inputs.out_file)
1190+
return outputs

nipype/pipeline/engine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,7 @@ def _make_nodes(self, cwd=None):
15961596
node = Node(deepcopy(self._interface), name=nodename)
15971597
node.overwrite = self.overwrite
15981598
node.run_without_submitting = self.run_without_submitting
1599+
node.plugin_args = self.plugin_args
15991600
node._interface.inputs.set(**deepcopy(self._interface.inputs.get()))
16001601
for field in self.iterfield:
16011602
fieldvals = filename_to_list(getattr(self.inputs, field))

0 commit comments

Comments
 (0)