diff --git a/CHANGES b/CHANGES index 23345c155d..2f989d1b7b 100644 --- a/CHANGES +++ b/CHANGES @@ -26,7 +26,8 @@ Upcoming release 0.13 * ENH: Implement missing inputs/outputs in FSL AvScale (https://github.com/nipy/nipype/pull/1563) * FIX: Fix symlink test in copyfile (https://github.com/nipy/nipype/pull/1570, https://github.com/nipy/nipype/pull/1586) * ENH: Added support for custom job submission check in SLURM (https://github.com/nipy/nipype/pull/1582) - +* ENH: Added ANTs interface CreateJacobianDeterminantImage; replaces deprecated JacobianDeterminant + (https://github.com/nipy/nipype/pull/1654) Release 0.12.1 (August 3, 2016) =============================== diff --git a/nipype/interfaces/ants/__init__.py b/nipype/interfaces/ants/__init__.py index 039fb2d706..3bb83b3df9 100644 --- a/nipype/interfaces/ants/__init__.py +++ b/nipype/interfaces/ants/__init__.py @@ -19,4 +19,4 @@ from .visualization import ConvertScalarImageToRGB, CreateTiledMosaic # Utility Programs -from .utils import AverageAffineTransform, AverageImages, MultiplyImages, JacobianDeterminant +from .utils import AverageAffineTransform, AverageImages, MultiplyImages, CreateJacobianDeterminantImage diff --git a/nipype/interfaces/ants/tests/test_auto_JacobianDeterminant.py b/nipype/interfaces/ants/tests/test_auto_CreateJacobianDeterminantImage.py similarity index 63% rename from nipype/interfaces/ants/tests/test_auto_JacobianDeterminant.py rename to nipype/interfaces/ants/tests/test_auto_CreateJacobianDeterminantImage.py index c83a95a5f9..ccb92db57d 100644 --- a/nipype/interfaces/ants/tests/test_auto_JacobianDeterminant.py +++ b/nipype/interfaces/ants/tests/test_auto_CreateJacobianDeterminantImage.py @@ -1,15 +1,18 @@ # AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT from ....testing import assert_equal -from ..utils import JacobianDeterminant +from ..utils import CreateJacobianDeterminantImage -def test_JacobianDeterminant_inputs(): +def test_CreateJacobianDeterminantImage_inputs(): input_map = dict(args=dict(argstr='%s', ), - dimension=dict(argstr='%d', + deformationField=dict(argstr='%s', mandatory=True, - position=0, - usedefault=False, + position=1, + ), + doLogJacobian=dict(argstr='%d', + mandatory=False, + position=3, ), environ=dict(nohash=True, usedefault=True, @@ -17,45 +20,36 @@ def test_JacobianDeterminant_inputs(): ignore_exception=dict(nohash=True, usedefault=True, ), - norm_by_total=dict(argstr='%d', - position=5, + imageDimension=dict(argstr='%d', + mandatory=True, + position=0, + usedefault=False, ), num_threads=dict(nohash=True, usedefault=True, ), - output_prefix=dict(argstr='%s', - genfile=True, - hash_files=False, + outputImage=dict(argstr='%s', + mandatory=True, position=2, ), - projection_vector=dict(argstr='%s', - position=6, - sep='x', - ), - template_mask=dict(argstr='%s', - position=4, - ), terminal_output=dict(nohash=True, ), - use_log=dict(argstr='%d', - position=3, - ), - warp_file=dict(argstr='%s', - mandatory=True, - position=1, + useGeometric=dict(argstr='%d', + mandatory=False, + position=4, ), ) - inputs = JacobianDeterminant.input_spec() + inputs = CreateJacobianDeterminantImage.input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): yield assert_equal, getattr(inputs.traits()[key], metakey), value -def test_JacobianDeterminant_outputs(): +def test_CreateJacobianDeterminantImage_outputs(): output_map = dict(jacobian_image=dict(), ) - outputs = JacobianDeterminant.output_spec() + outputs = CreateJacobianDeterminantImage.output_spec() for key, metadata in list(output_map.items()): for metakey, value in list(metadata.items()): diff --git a/nipype/interfaces/ants/utils.py b/nipype/interfaces/ants/utils.py index 499dc7b17f..9c9d05fbd1 100644 --- a/nipype/interfaces/ants/utils.py +++ b/nipype/interfaces/ants/utils.py @@ -137,65 +137,44 @@ def _list_outputs(self): self.inputs.output_product_image) return outputs - -class JacobianDeterminantInputSpec(ANTSCommandInputSpec): - dimension = traits.Enum(3, 2, argstr='%d', usedefault=False, mandatory=True, +class CreateJacobianDeterminantImageInputSpec(ANTSCommandInputSpec): + imageDimension = traits.Enum(3, 2, argstr='%d', usedefault=False, mandatory=True, position=0, desc='image dimension (2 or 3)') - warp_file = File(argstr='%s', exists=True, mandatory=True, - position=1, desc='input warp file') - output_prefix = File(argstr='%s', genfile=True, hash_files=False, + deformationField = File(argstr='%s', exists=True, mandatory=True, + position=1, desc='deformation transformation file') + outputImage = File(argstr='%s', mandatory=True, position=2, - desc=('prefix of the output image filename: ' - 'PREFIX(log)jacobian.nii.gz')) - use_log = traits.Enum(0, 1, argstr='%d', position=3, - desc='log transform the jacobian determinant') - template_mask = File(argstr='%s', exists=True, position=4, - desc='template mask to adjust for head size') - norm_by_total = traits.Enum(0, 1, argstr='%d', position=5, - desc=('normalize jacobian by total in mask to ' - 'adjust for head size')) - projection_vector = traits.List(traits.Float(), argstr='%s', sep='x', - position=6, - desc='vector to project warp against') - + desc='output filename') + doLogJacobian = traits.Enum(0, 1, argstr='%d', mandatory=False, position=3, + desc='return the log jacobian') + useGeometric = traits.Enum(0, 1, argstr='%d', mandatory=False, position=4, + desc='return the geometric jacobian') -class JacobianDeterminantOutputSpec(TraitedSpec): - jacobian_image = File(exists=True, desc='(log transformed) jacobian image') +class CreateJacobianDeterminantImageOutputSpec(TraitedSpec): + jacobian_image = File(exists=True, desc='jacobian image') - -class JacobianDeterminant(ANTSCommand): +class CreateJacobianDeterminantImage(ANTSCommand): """ Examples -------- - >>> from nipype.interfaces.ants import JacobianDeterminant - >>> jacobian = JacobianDeterminant() - >>> jacobian.inputs.dimension = 3 - >>> jacobian.inputs.warp_file = 'ants_Warp.nii.gz' - >>> jacobian.inputs.output_prefix = 'Sub001_' - >>> jacobian.inputs.use_log = 1 + >>> from nipype.interfaces.ants import CreateJacobianDeterminantImage + >>> jacobian = CreateJacobianDeterminantImage() + >>> jacobian.inputs.imageDimension = 3 + >>> jacobian.inputs.deformationField = 'ants_Warp.nii.gz' + >>> jacobian.inputs.outputImage = 'out_name.nii.gz' >>> jacobian.cmdline # doctest: +IGNORE_UNICODE - 'ANTSJacobian 3 ants_Warp.nii.gz Sub001_ 1' + 'CreateJacobianDeterminantImage 3 ants_Warp.nii.gz out_name.nii.gz' """ - _cmd = 'ANTSJacobian' - input_spec = JacobianDeterminantInputSpec - output_spec = JacobianDeterminantOutputSpec + _cmd = 'CreateJacobianDeterminantImage' + input_spec = CreateJacobianDeterminantImageInputSpec + output_spec = CreateJacobianDeterminantImageOutputSpec - def _gen_filename(self, name): - if name == 'output_prefix': - output = self.inputs.output_prefix - if not isdefined(output): - _, name, ext = split_filename(self.inputs.warp_file) - output = name + '_' - return output - return None + def _format_arg(self, opt, spec, val): + return super(CreateJacobianDeterminantImage, self)._format_arg(opt, spec, val) def _list_outputs(self): outputs = self._outputs().get() - if self.inputs.use_log == 1: - outputs['jacobian_image'] = os.path.abspath( - self._gen_filename('output_prefix') + 'logjacobian.nii.gz') - else: - outputs['jacobian_image'] = os.path.abspath( - self._gen_filename('output_prefix') + 'jacobian.nii.gz') + outputs['jacobian_image'] = os.path.abspath( + self.inputs.outputImage) return outputs