Skip to content

Commit

Permalink
ENH: deformation gradient
Browse files Browse the repository at this point in the history
STYLE: should fix use of mktemp which is not recommended
  • Loading branch information
stnava committed Aug 8, 2023
1 parent ac2b72f commit d639ab7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ants/registration/create_jacobian_determinant_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,21 @@ def deformation_gradient( warp_image ):
"""
if isinstance(warp_image, iio.ANTsImage):
txuse = mktemp(suffix='.nii.gz')
iio2.image_write(tx, txuse)
iio2.image_write(warp_image, txuse)
else:
txuse = warp_image
warp_image=ants.image_read(txuse)
if not isinstance(warp_image, iio.ANTsImage):
raise RuntimeError("antsimage is required")
writtenimage = mktemp(suffix='.nrrd')
dimage = warp_image.split_channels()[0].clone('double')
dim = dimage.dim
args2 = [dim, txuse, dimage, int(0), int(0), int(1)]
dim = dimage.dimension
args2 = [dim, txuse, writtenimage, int(0), int(0), int(1)]
# print(args2)
processed_args = utils._int_antsProcessArguments(args2)
libfn = utils.get_lib_fn('CreateJacobianDeterminantImage')
libfn(processed_args)
jimage = args2[2].clone('float')
jimage = iio2.image_read(writtenimage)
return jimage
import numpy as np
if not isinstance(warp_image, iio.ANTsImage):
Expand Down Expand Up @@ -132,4 +134,3 @@ def create_jacobian_determinant_image(domain_image, tx, do_log=False, geom=False

return jimage


0 comments on commit d639ab7

Please sign in to comment.