# Jacobian determinant - 2D deformation field and pixel/voxel spacing?

**URL:** <https://discourse.itk.org/t/jacobian-determinant-2d-deformation-field-and-pixel-voxel-spacing/7145>\
**Category:** Beginner Questions\
**Tags:** simpleitk\
**Created:** [July 31, 2024, 8:41am UTC](https://discourse.itk.org/t/jacobian-determinant-2d-deformation-field-and-pixel-voxel-spacing/7145 "2024-07-31T08:41:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lbrandao](https://discourse.itk.org/letter_avatar_proxy/v4/letter/l/9de0a6/32.png) [@lbrandao](https://discourse.itk.org/u/lbrandao)\
**Post date:** [July 31, 2024, 8:41am UTC](https://discourse.itk.org/t/jacobian-determinant-2d-deformation-field-and-pixel-voxel-spacing/7145/1 "2024-07-31T08:41:39Z")

</div>

Dear all,  
I have a numpy array representing a deformation field with 2D shape (i.e., only x and y displacements), and I want to compute its Jacobian determinant.

Here’s how I’m doing it:  
def\_field\_np is a numpy array w/ shape (256,256,2) representing the x and y displacements

```auto
def_field_sitk = sitk.GetImageFromArray(def_field_np, isVector=True)
jacobian_det = sitk.DisplacementFieldJacobianDeterminant(def_field_sitk)
jacobian_det = sitk.GetArrayFromImage(jacobian_det)

```

My questions:

- Can sitk.DisplacementFieldJacobianDeterminant compute the determinant for a 2D deformation field? Or is it expecting a 3D deformation field?
- Should the pixel/voxel spacing be set before computing the determinant?def\_field\_sitk.SetSpacing(pixel/voxel\_spacing)

Thank you!

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [July 31, 2024, 11:59am UTC](https://discourse.itk.org/t/jacobian-determinant-2d-deformation-field-and-pixel-voxel-spacing/7145/2 "2024-07-31T11:59:32Z")

</div>

> [@lbrandao](#):
>
> Can sitk.DisplacementFieldJacobianDeterminant compute the determinant for a 2D deformation field? Or is it expecting a 3D deformation field?

Yes.

> [@lbrandao](#):
>
> - Should the pixel/voxel spacing be set before computing the determinant?def\_field\_sitk.SetSpacing(pixel/voxel\_spacing)

Yes, but why is really the important question. The ITK displacement field as vector displacements in physical (x,y) space. That is to say the space, origin and direction cosine matrix define the input physical space coordinates before the displacement vector is applied.
