1
+ """
2
+ Change directory to provide relative paths for doctests
3
+ >>> import os
4
+ >>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
5
+ >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
6
+ >>> os.chdir(datadir)
7
+
8
+ """
1
9
# Standard library imports
2
10
import os
3
11
4
12
# Local imports
5
- from ..base import (TraitedSpec , File , traits , InputMultiPath , OutputMultiPath , isdefined )
6
- from ...utils .filemanip import split_filename
13
+ from ..base import TraitedSpec , File , traits , InputMultiPath
7
14
from .base import ANTSCommand , ANTSCommandInputSpec
8
15
9
16
class AverageAffineTransformInputSpec (ANTSCommandInputSpec ):
@@ -18,7 +25,13 @@ class AverageAffineTransform(ANTSCommand):
18
25
"""
19
26
Examples
20
27
--------
21
- >>>
28
+ >>> from nipype.interfaces.ants.AverageAffineTransform import AverageAffineTransform
29
+ >>> avg = AverageAffineTransform()
30
+ >>> avg.inputs.dimension = 3
31
+ >>> avg.inputs.transforms = ['trans.mat', 'func_to_struct.mat']
32
+ >>> avg.inputs.output_affine_transform = 'MYtemplatewarp.mat'
33
+ >>> avg.cmdline
34
+ 'AverageAffineTransform 3 MYtemplatewarp.mat trans.mat func_to_struct.mat'
22
35
"""
23
36
_cmd = 'AverageAffineTransform'
24
37
input_spec = AverageAffineTransformInputSpec
@@ -31,32 +44,3 @@ def _list_outputs(self):
31
44
outputs = self ._outputs ().get ()
32
45
outputs ['affine_transform' ] = os .path .abspath (self .inputs .output_affine_transform )
33
46
return outputs
34
-
35
- """
36
- Usage:
37
-
38
- AverageAffineTransform ImageDimension output_affine_transform [-R reference_affine_transform] {[-i] affine_transform_txt [weight(=1)] ]}
39
-
40
- Compute weighted average of input affine transforms.
41
- For 2D and 3D transform, the affine transform is first decomposed into scale x shearing
42
- x rotation. Then these parameters are averaged, using the weights if they provided. For
43
- 3D transform, the rotation component is the quaternion. After averaging, the quaternion
44
- will also be normalized to have unit norm. For 2D transform, the rotation component is
45
- the rotation angle. The weight for each transform is a non-negative number. The sum of
46
- all weights will be normalized to 1 before averaging. The default value for each weight
47
- is 1.0.
48
-
49
- All affine transforms is a "centerd" transform, following ITK convention. A
50
- reference_affine_transform defines the center for the output transform. The first provided
51
- transform is the default reference transform
52
-
53
- Output affine transform is a MatrixOffsetBaseTransform.
54
-
55
- -i option takes the inverse of the affine mapping.
56
-
57
- For example:
58
-
59
- 2 output_affine.txt -R A.txt A1.txt 1.0 -i A2.txt 2.0 A3.txt A4.txt 6.0 A5.txt
60
-
61
- This computes: (1*A1 + 2*(A2)^-1 + A3 + A4*6 + A5 ) / (1+2+1+6+5)
62
- """
0 commit comments