Skip to content

Commit

Permalink
Threshold before computing sqrt for kappa
Browse files Browse the repository at this point in the history
For noisy data, the numerical errors can lead to tiny positive
values in the Hessian, then giving NaN in the sqrt. So, we threshold.
  • Loading branch information
KrisThielemans committed Sep 20, 2024
1 parent 1a16838 commit aae6ed3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions SIRF_data_preparation/create_initial_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ def compute_kappa_image(obj_fun, initial_image):
WARNING: Assumes the objective function has been set-up already
"""
# This needs SIRF 3.7. If you don't have that yet, you should probably upgrade anyway!
Hessian_row_sum = obj_fun.multiply_with_Hessian(initial_image, initial_image.allocate(1))
return (-1 * Hessian_row_sum).power(.5)
minus_Hessian_row_sum = -1 * obj_fun.multiply_with_Hessian(initial_image, initial_image.allocate(1))
return minus_Hessian_row_sum.maximum(0).power(.5)


def main(argv=None):
Expand Down

0 comments on commit aae6ed3

Please sign in to comment.