Open Mikerov opened 2 years ago
import SimpleITK as sitk
def jacobian_determinant_from_displacement(displacement: np.ndarray) -> np.ndarray:
displacement = displacement.squeeze()
assert displacement.ndim == 4, "Displacement field should have shape (h, w, d, 3)"
# transpose if necessary
if displacement.shape[-1] != 3 and displacement.shape[0] == 3:
displacement = displacement.transpose(1, 2, 3, 0)
displacement_image = sitk.GetImageFromArray(displacement, isVector=True)
jacobian_determinant_image = sitk.DisplacementFieldJacobianDeterminant(
displacement_image)
return sitk.GetArrayFromImage(jacobian_determinant_image)
Is there a way to calculate the determinant of the Jacobian to see whether the used B-spline transformation is volume preserving? What alternative methods can I use to ensure that there is no shrinkage?