@@ -220,32 +220,37 @@ class AllineateInputSpec(AFNICommandInputSpec):
220
220
out_file = File (
221
221
desc = 'output file from 3dAllineate' ,
222
222
argstr = '-prefix %s' ,
223
- name_source = 'in_file' ,
224
- name_template = '%s_allineate' ,
225
223
genfile = True ,
226
224
xor = ['allcostx' ])
227
225
out_param_file = File (
228
226
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' ])
230
229
in_param_file = File (
231
230
exists = True ,
232
231
argstr = '-1Dparam_apply %s' ,
233
232
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' ])
235
235
out_matrix = File (
236
236
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' ])
238
239
in_matrix = File (
239
240
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
+
242
248
allcostx = File (
243
249
desc = 'Compute and print ALL available cost functionals for the un-warped inputs'
244
250
'AND THEN QUIT. If you use this option none of the other expected outputs will be produced' ,
245
251
argstr = '-allcostx |& tee %s' ,
246
252
position = - 1 ,
247
- xor = ['out_file' ])
248
-
253
+ xor = ['out_file' , 'out_matrix' , 'out_param_file' , 'out_weight_file' ])
249
254
_cost_funcs = [
250
255
'leastsq' , 'ls' ,
251
256
'mutualinfo' , 'mi' ,
@@ -356,7 +361,8 @@ class AllineateInputSpec(AFNICommandInputSpec):
356
361
'Must be defined on the same grid as the base dataset' )
357
362
out_weight_file = traits .File (
358
363
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' ])
360
366
source_mask = File (
361
367
exists = True ,
362
368
argstr = '-source_mask %s' ,
@@ -414,8 +420,10 @@ class AllineateInputSpec(AFNICommandInputSpec):
414
420
415
421
416
422
class 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' )
419
427
allcostx = File (desc = 'Compute and print ALL available cost functionals for the un-warped inputs' )
420
428
421
429
@@ -434,7 +442,7 @@ class Allineate(AFNICommand):
434
442
>>> allineate.inputs.out_file = 'functional_allineate.nii'
435
443
>>> allineate.inputs.in_matrix = 'cmatrix.mat'
436
444
>>> 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 '
438
446
>>> res = allineate.run() # doctest: +SKIP
439
447
440
448
>>> from nipype.interfaces import afni
@@ -443,7 +451,7 @@ class Allineate(AFNICommand):
443
451
>>> allineate.inputs.reference = 'structural.nii'
444
452
>>> allineate.inputs.allcostx = 'out.allcostX.txt'
445
453
>>> 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'
447
455
>>> res = allineate.run() # doctest: +SKIP
448
456
"""
449
457
@@ -459,24 +467,38 @@ def _format_arg(self, name, trait_spec, value):
459
467
460
468
def _list_outputs (self ):
461
469
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 )
467
470
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 )
471
492
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 (),
474
495
self .inputs .allcostx ))
475
496
return outputs
476
497
477
498
def _gen_filename (self , name ):
478
499
if name == 'out_file' :
479
500
return self ._list_outputs ()[name ]
501
+ return None
480
502
481
503
482
504
class AutoTcorrelateInputSpec (AFNICommandInputSpec ):
@@ -535,6 +557,7 @@ class AutoTcorrelate(AFNICommand):
535
557
'3dAutoTcorrelate -eta2 -mask mask.nii -mask_only_targets -prefix functional_similarity_matrix.1D -polort -1 functional.nii'
536
558
>>> res = corr.run() # doctest: +SKIP
537
559
"""
560
+
538
561
input_spec = AutoTcorrelateInputSpec
539
562
output_spec = AFNICommandOutputSpec
540
563
_cmd = '3dAutoTcorrelate'
0 commit comments