|
12 | 12 | import os
|
13 | 13 |
|
14 | 14 | from ...utils.filemanip import split_filename
|
15 |
| -from ..base import TraitedSpec, File, traits, isdefined, InputMultiPath |
| 15 | +from ..base import (TraitedSpec, File, traits, isdefined, InputMultiPath, |
| 16 | + CommandLine, CommandLineInputSpec) |
16 | 17 | from .base import ANTSCommand, ANTSCommandInputSpec
|
17 | 18 |
|
18 | 19 |
|
@@ -178,3 +179,49 @@ def _list_outputs(self):
|
178 | 179 | outputs['jacobian_image'] = os.path.abspath(
|
179 | 180 | self.inputs.outputImage)
|
180 | 181 | return outputs
|
| 182 | + |
| 183 | + |
| 184 | +class AffineInitializerInputSpec(CommandLineInputSpec): |
| 185 | + dimension = traits.Enum(3, 2, usedefault=True, position=0, argstr='%s', |
| 186 | + desc='dimension') |
| 187 | + fixed_image = File(exists=True, mandatory=True, position=1, argstr='%s', |
| 188 | + desc='reference image') |
| 189 | + moving_image = File(exists=True, mandatory=True, position=2, argstr='%s', |
| 190 | + desc='moving image') |
| 191 | + out_file = File('transform.mat', usedefault=True, position=3, argstr='%s', |
| 192 | + desc='output transform file') |
| 193 | + # Defaults in antsBrainExtraction.sh -> 15 0.1 0 10 |
| 194 | + search_factor = traits.Float(15.0, usedefault=True, position=4, argstr='%f', |
| 195 | + desc='increments (degrees) for affine search') |
| 196 | + radian_fraction = traits.Range(0.0, 1.0, value=0.1, usedefault=True, position=5, |
| 197 | + argstr='%f', desc='search this arc +/- principal axes') |
| 198 | + principal_axes = traits.Bool( |
| 199 | + False, usedefault=True, position=6, argstr='%d', |
| 200 | + desc='whether the rotation is searched around an initial principal axis alignment.') |
| 201 | + local_search = traits.Int( |
| 202 | + 10, usedefault=True, position=7, argstr='%d', |
| 203 | + desc=' determines if a local optimization is run at each search point for the set ' |
| 204 | + 'number of iterations') |
| 205 | + |
| 206 | +class AffineInitializerOutputSpec(TraitedSpec): |
| 207 | + out_file = File(desc='output transform file') |
| 208 | + |
| 209 | + |
| 210 | +class AffineInitializer(CommandLine): |
| 211 | + """ |
| 212 | + Initialize an affine transform (as in antsBrainExtraction.sh) |
| 213 | +
|
| 214 | + >>> from nipype.interfaces.ants import AffineInitializer |
| 215 | + >>> init = AffineInitializer() |
| 216 | + >>> init.inputs.fixed_image = 'fixed1.nii' |
| 217 | + >>> init.inputs.moving_image = 'moving1.nii' |
| 218 | + >>> init.cmdline # doctest: +ALLOW_UNICODE |
| 219 | + 'antsAffineInitializer 3 fixed1.nii moving1.nii transform.mat 15.000000 0.100000 0 10' |
| 220 | +
|
| 221 | + """ |
| 222 | + _cmd = 'antsAffineInitializer' |
| 223 | + input_spec = AffineInitializerInputSpec |
| 224 | + output_spec = AffineInitializerOutputSpec |
| 225 | + |
| 226 | + def _list_outputs(self): |
| 227 | + return {'out_file': os.path.abspath(self.inputs.out_file)} |
0 commit comments