@@ -220,32 +220,37 @@ class AllineateInputSpec(AFNICommandInputSpec):
220220 out_file = File (
221221 desc = 'output file from 3dAllineate' ,
222222 argstr = '-prefix %s' ,
223- name_source = 'in_file' ,
224- name_template = '%s_allineate' ,
225223 genfile = True ,
226224 xor = ['allcostx' ])
227225 out_param_file = File (
228226 argstr = '-1Dparam_save %s' ,
229- desc = 'Save the warp parameters in ASCII (.1D) format.' )
227+ desc = 'Save the warp parameters in ASCII (.1D) format.' ,
228+ xor = ['in_param_file' ,'allcostx' ])
230229 in_param_file = File (
231230 exists = True ,
232231 argstr = '-1Dparam_apply %s' ,
233232 desc = 'Read warp parameters from file and apply them to '
234- 'the source dataset, and produce a new dataset' )
233+ 'the source dataset, and produce a new dataset' ,
234+ xor = ['out_param_file' ])
235235 out_matrix = File (
236236 argstr = '-1Dmatrix_save %s' ,
237- desc = 'Save the transformation matrix for each volume.' )
237+ desc = 'Save the transformation matrix for each volume.' ,
238+ xor = ['in_matrix' ,'allcostx' ])
238239 in_matrix = File (
239240 desc = 'matrix to align input file' ,
240- argstr = '-1Dmatrix_apply %s' )
241- # TODO: implement sensible xors for allcostx and suppres prefix in command when allcosx is used
241+ argstr = '-1Dmatrix_apply %s' ,
242+ position = - 3 ,
243+ xor = ['out_matrix' ])
244+ overwrite = traits .Bool (
245+ desc = 'overwrite output file if it already exists' ,
246+ argstr = '-overwrite' )
247+
242248 allcostx = File (
243249 desc = 'Compute and print ALL available cost functionals for the un-warped inputs'
244250 'AND THEN QUIT. If you use this option none of the other expected outputs will be produced' ,
245251 argstr = '-allcostx |& tee %s' ,
246252 position = - 1 ,
247- xor = ['out_file' ])
248-
253+ xor = ['out_file' , 'out_matrix' , 'out_param_file' , 'out_weight_file' ])
249254 _cost_funcs = [
250255 'leastsq' , 'ls' ,
251256 'mutualinfo' , 'mi' ,
@@ -356,7 +361,8 @@ class AllineateInputSpec(AFNICommandInputSpec):
356361 'Must be defined on the same grid as the base dataset' )
357362 out_weight_file = traits .File (
358363 argstr = '-wtprefix %s' ,
359- desc = 'Write the weight volume to disk as a dataset' )
364+ desc = 'Write the weight volume to disk as a dataset' ,
365+ xor = ['allcostx' ])
360366 source_mask = File (
361367 exists = True ,
362368 argstr = '-source_mask %s' ,
@@ -414,8 +420,10 @@ class AllineateInputSpec(AFNICommandInputSpec):
414420
415421
416422class AllineateOutputSpec (TraitedSpec ):
417- out_file = File (desc = 'output image file name' )
418- matrix = File (desc = 'matrix to align input file' )
423+ out_file = File (exists = True , desc = 'output image file name' )
424+ out_matrix = File (exists = True , desc = 'matrix to align input file' )
425+ out_param_file = File (exists = True , desc = 'warp parameters' )
426+ out_weight_file = File (exists = True , desc = 'weight volume' )
419427 allcostx = File (desc = 'Compute and print ALL available cost functionals for the un-warped inputs' )
420428
421429
@@ -434,7 +442,7 @@ class Allineate(AFNICommand):
434442 >>> allineate.inputs.out_file = 'functional_allineate.nii'
435443 >>> allineate.inputs.in_matrix = 'cmatrix.mat'
436444 >>> allineate.cmdline # doctest: +ALLOW_UNICODE
437- '3dAllineate -source functional.nii -1Dmatrix_apply cmatrix.mat -prefix functional_allineate.nii '
445+ '3dAllineate -source functional.nii -prefix functional_allineate.nii -1Dmatrix_apply cmatrix.mat '
438446 >>> res = allineate.run() # doctest: +SKIP
439447
440448 >>> from nipype.interfaces import afni
@@ -443,7 +451,7 @@ class Allineate(AFNICommand):
443451 >>> allineate.inputs.reference = 'structural.nii'
444452 >>> allineate.inputs.allcostx = 'out.allcostX.txt'
445453 >>> allineate.cmdline # doctest: +ALLOW_UNICODE
446- '3dAllineate -source functional.nii -prefix functional_allineate - base structural.nii -allcostx |& tee out.allcostX.txt'
454+ '3dAllineate -source functional.nii -base structural.nii -allcostx |& tee out.allcostX.txt'
447455 >>> res = allineate.run() # doctest: +SKIP
448456 """
449457
@@ -459,24 +467,38 @@ def _format_arg(self, name, trait_spec, value):
459467
460468 def _list_outputs (self ):
461469 outputs = self .output_spec ().get ()
462- if not isdefined (self .inputs .out_file ):
463- outputs ['out_file' ] = self ._gen_filename (self .inputs .in_file ,
464- suffix = self .inputs .suffix )
465- else :
466- outputs ['out_file' ] = os .path .abspath (self .inputs .out_file )
467470
468- if isdefined (self .inputs .out_matrix ):
469- outputs ['matrix' ] = os .path .abspath (os .path .join (os .getcwd (),\
470- self .inputs .out_matrix + '.aff12.1D' ))
471+ if self .inputs .out_file :
472+ outputs ['out_file' ] = op .abspath (self .inputs .out_file )
473+
474+ if self .inputs .out_weight_file :
475+ outputs ['out_weight_file' ] = op .abspath (self .inputs .out_weight_file )
476+
477+ if self .inputs .out_matrix :
478+ path , base , ext = split_filename (self .inputs .out_matrix )
479+ if ext .lower () not in ['.1d' , '.1D' ]:
480+ outputs ['out_matrix' ] = self ._gen_fname (self .inputs .out_matrix ,
481+ suffix = '.aff12.1D' )
482+ else :
483+ outputs ['out_matrix' ] = op .abspath (self .inputs .out_matrix )
484+
485+ if self .inputs .out_param_file :
486+ path , base , ext = split_filename (self .inputs .out_param_file )
487+ if ext .lower () not in ['.1d' , '.1D' ]:
488+ outputs ['out_param_file' ] = self ._gen_fname (self .inputs .out_param_file ,
489+ suffix = '.param.1D' )
490+ else :
491+ outputs ['out_param_file' ] = op .abspath (self .inputs .out_param_file )
471492
472- if isdefined (self .inputs .allcostX ):
473- outputs ['allcostX' ] = os .path .abspath (os .path .join (os .getcwd (),\
493+ if isdefined (self .inputs .allcostx ):
494+ outputs ['allcostX' ] = os .path .abspath (os .path .join (os .getcwd (),
474495 self .inputs .allcostx ))
475496 return outputs
476497
477498 def _gen_filename (self , name ):
478499 if name == 'out_file' :
479500 return self ._list_outputs ()[name ]
501+ return None
480502
481503
482504class AutoTcorrelateInputSpec (AFNICommandInputSpec ):
@@ -535,6 +557,7 @@ class AutoTcorrelate(AFNICommand):
535557 '3dAutoTcorrelate -eta2 -mask mask.nii -mask_only_targets -prefix functional_similarity_matrix.1D -polort -1 functional.nii'
536558 >>> res = corr.run() # doctest: +SKIP
537559 """
560+
538561 input_spec = AutoTcorrelateInputSpec
539562 output_spec = AFNICommandOutputSpec
540563 _cmd = '3dAutoTcorrelate'
0 commit comments