Skip to content

uniGradICON Howto

Lin Tian edited this page Oct 28, 2024 · 3 revisions

Welcome to the uniGradICON Howto. On this page, we will show some code snippets using uniGradICON.

How to compute the Jacobian determinant map from the transformation

import itk
transform_file = ""
fixed_img_file = ""
transform = itk.transformread(transform_file)[0]
jacob = itk.displacement_field_jacobian_determinant_filter(
    itk.transform_to_displacement_field_filter(
        transform,
        reference_image=itk.imread(fixed_img_file),
        use_reference_image=True
    )
)
itk.imwrite(jacob, "transform_jacob.nii.gz")

How to compute the log of Jacobian determinant map from the transformation

import itk
transform_file = ""
fixed_img_file = ""
transform = itk.transformread(transform_file)[0]
jacob = itk.displacement_field_jacobian_determinant_filter(
    itk.transform_to_displacement_field_filter(
        transform,
        reference_image=itk.imread(fixed_img_file),
        use_reference_image=True
    )
)
log_jacob = itk.LogImageFilter.New(jacob)
log_jacob.Update()
log_jacob = log_jacob.GetOutput()

itk.imwrite(jacob, "transform_jacob.nii.gz")
itk.imwrite(jacob, "transform_log_jacob.nii.gz")