Skip to content

Commit

Permalink
ENH: enable return of deformation gradient; for testing purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
stnava committed Aug 8, 2023
1 parent 8285c6d commit 5b392f5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Examples/CreateJacobianDeterminantImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ CreateJacobianDeterminantImage(int argc, char * argv[])
calculateGeometricJacobian = static_cast<bool>(std::stoi(argv[5]));
}

bool returnDeformationGradient = false;
if (argc > 6)
{
returnDeformationGradient = static_cast<bool>(std::stoi(argv[6]));
}

if (calculateGeometricJacobian)
{
using JacobianFilterType = itk::GeometricJacobianDeterminantImageFilter<VectorImageType, RealType, ImageType>;
Expand All @@ -66,6 +72,12 @@ CreateJacobianDeterminantImage(int argc, char * argv[])
jacobianFilter->SetOrder(2);
jacobianFilter->SetUseCenteredDifference(true);

if ( returnDeformationGradient ) {
jacobianFilter->Update();
ANTs::WriteImage<typename JacobianFilterType::OutputImageType>(jacobianFilter->GetOutput(), argv[3]);
return EXIT_SUCCESS;
}

using DeterminantFilterType =
itk::DeterminantTensorImageFilter<typename JacobianFilterType::OutputImageType, RealType>;
typename DeterminantFilterType::Pointer determinantFilter = DeterminantFilterType::New();
Expand Down Expand Up @@ -158,7 +170,8 @@ CreateJacobianDeterminantImage(std::vector<std::string> args, std::ostream * itk
if (argc < 3)
{
std::cout << "Usage: " << argv[0]
<< " imageDimension deformationField outputImage [doLogJacobian=0] [useGeometric=0]" << std::endl;
<< " imageDimension deformationField outputImage [doLogJacobian=0] [useGeometric=0] [deformationGradient=0]" << std::endl;
std::cout << "deformationGradient cannot be written to nifti: try mhd or nrrd."
return EXIT_FAILURE;
}

Expand Down

0 comments on commit 5b392f5

Please sign in to comment.