1111
1212import os
1313
14- from ..base import ( TraitedSpec , File , traits , isdefined , InputMultiPath )
14+ from ..base import TraitedSpec , File , traits , InputMultiPath
1515from .base import ANTSCommand , ANTSCommandInputSpec
1616
1717
@@ -57,12 +57,16 @@ def _list_outputs(self):
5757class AverageImagesInputSpec (ANTSCommandInputSpec ):
5858 dimension = traits .Enum (3 , 2 , argstr = '%d' , mandatory = True ,
5959 position = 0 , desc = 'image dimension (2 or 3)' )
60- output_average_image = File ("average.nii" , argstr = '%s' , position = 1 , desc = 'the name of the resulting image.' ,
61- usedefault = True , hash_files = False )
62- normalize = traits .Bool (argstr = "%d" , mandatory = True , position = 2 , desc = 'Normalize: if true, the 2nd image' +
63- 'is divided by its mean. This will select the largest image to average into.' )
64- images = InputMultiPath (File (exists = True ), argstr = '%s' , mandatory = True , position = 3 ,
65- desc = 'image to apply transformation to (generally a coregistered functional)' )
60+ output_average_image = File (
61+ "average.nii" , argstr = '%s' , position = 1 , usedefault = True , hash_files = False ,
62+ desc = 'the name of the resulting image.' )
63+ normalize = traits .Bool (
64+ argstr = "%d" , mandatory = True , position = 2 ,
65+ desc = 'Normalize: if true, the 2nd image is divided by its mean. '
66+ 'This will select the largest image to average into.' )
67+ images = InputMultiPath (
68+ File (exists = True ), argstr = '%s' , mandatory = True , position = 3 ,
69+ desc = 'image to apply transformation to (generally a coregistered functional)' )
6670
6771
6872class AverageImagesOutputSpec (TraitedSpec ):
@@ -101,8 +105,9 @@ class MultiplyImagesInputSpec(ANTSCommandInputSpec):
101105 desc = 'image dimension (2 or 3)' )
102106 first_input = File (argstr = '%s' , exists = True ,
103107 mandatory = True , position = 1 , desc = 'image 1' )
104- second_input = traits .Either (File (exists = True ), traits .Float , argstr = '%s' , mandatory = True , position = 2 ,
105- desc = 'image 2 or multiplication weight' )
108+ second_input = traits .Either (
109+ File (exists = True ), traits .Float , argstr = '%s' , mandatory = True , position = 2 ,
110+ desc = 'image 2 or multiplication weight' )
106111 output_product_image = File (argstr = '%s' , mandatory = True , position = 3 ,
107112 desc = 'Outputfname.nii.gz: the name of the resulting image.' )
108113
@@ -231,12 +236,12 @@ def _list_outputs(self):
231236
232237
233238class ComposeMultiTransformInputSpec (ANTSCommandInputSpec ):
234- dimension = traits .Enum (3 , 2 , argstr = '%d' , usedefault = True , mandatory = True ,
235- position = 0 , desc = 'image dimension (2 or 3)' )
236- output_transform = File (argstr = '%s' , mandatory = True , position = 1 ,
237- name_source = [ 'transforms' ], name_template = '%s_composed' ,
239+ dimension = traits .Enum (3 , 2 , argstr = '%d' , usedefault = True , position = 0 ,
240+ desc = 'image dimension (2 or 3)' )
241+ output_transform = File (argstr = '%s' , position = 1 , name_source = [ 'transforms' ] ,
242+ name_template = '%s_composed' , keep_ext = True ,
238243 desc = 'the name of the resulting transform.' )
239- reference_image = File (argstr = '%s' , mandatory = False , position = 2 ,
244+ reference_image = File (argstr = '%s' , position = 2 ,
240245 desc = 'Reference image (only necessary when output is warpfield)' )
241246 transforms = InputMultiPath (File (exists = True ), argstr = '%s' , mandatory = True ,
242247 position = 3 , desc = 'transforms to average' )
@@ -245,6 +250,7 @@ class ComposeMultiTransformInputSpec(ANTSCommandInputSpec):
245250class ComposeMultiTransformOutputSpec (TraitedSpec ):
246251 output_transform = File (exists = True , desc = 'Composed transform file' )
247252
253+
248254class ComposeMultiTransform (ANTSCommand ):
249255 """
250256 Take a set of transformations and convert them to a single transformation matrix/warpfield.
@@ -255,13 +261,10 @@ class ComposeMultiTransform(ANTSCommand):
255261 >>> compose_transform = ComposeMultiTransform()
256262 >>> compose_transform.inputs.dimension = 3
257263 >>> compose_transform.inputs.transforms = ['struct_to_template.mat', 'func_to_struct.mat']
258- >>> compose_transform.inputs.output_transform = 'func_to_template.mat'
259264 >>> compose_transform.cmdline # doctest: +ALLOW_UNICODE
260- 'ComposeMultiTransform 3 func_to_template.mat struct_to_template.mat func_to_struct.mat'
265+ 'ComposeMultiTransform 3 struct_to_template_composed struct_to_template.mat func_to_struct.mat'
266+
261267 """
262268 _cmd = 'ComposeMultiTransform'
263269 input_spec = ComposeMultiTransformInputSpec
264270 output_spec = ComposeMultiTransformOutputSpec
265-
266- def _format_arg (self , opt , spec , val ):
267- return super (ComposeMultiTransform , self )._format_arg (opt , spec , val )
0 commit comments