Evaluation

Evaluation functions for registration quality assessment

core.evaluation.evaluation.apply_displacement_field_to_points(points, displacement_field, pixel_scale=1.0)[source]

Apply displacement field to a set of points

Parameters:
  • points – Input points (N, 2)

  • displacement_field – Displacement field (H, W, 2)

  • pixel_scale – Scale factor to convert points to pixel coordinates

Returns:

(transformed_points, valid_mask)

Return type:

tuple

core.evaluation.evaluation.evaluate_nonrigid_registration(fixed_points, moving_points, rigid_transform, displacement_field, pixel_scale=16)[source]

Evaluate non-rigid registration with displacement field

Parameters:
  • fixed_points – Fixed landmark points

  • moving_points – Moving landmark points

  • rigid_transform – Rigid transformation matrix

  • displacement_field – Non-rigid displacement field

  • pixel_scale – Scale factor for pixel conversion

Returns:

Evaluation metrics

Return type:

dict

core.evaluation.evaluation.evaluate_registration_tre(fixed_points, moving_points, transform_matrix, target_shape, scale_factor=None)[source]

Evaluate registration using TRE metrics

Parameters:
  • fixed_points – Fixed landmark points

  • moving_points – Moving landmark points

  • transform_matrix – Transformation matrix to apply

  • target_shape – Shape of target image for rTRE calculation

  • scale_factor – Optional scaling factor for transform

Returns:

Dictionary with TRE metrics

Return type:

dict

core.evaluation.evaluation.load_evaluation_landmarks(fixed_path, moving_path, scale_factor=1000)[source]

Load evaluation landmark points (alternative format)

Parameters:
  • fixed_path – Path to fixed landmarks CSV

  • moving_path – Path to moving landmarks CSV

  • scale_factor – Scaling factor for coordinates

Returns:

(fixed_points, moving_points)

Return type:

tuple

core.evaluation.evaluation.load_landmark_points(fixed_path, moving_path, scale_factor=1.0)[source]

Load landmark points from CSV files

Parameters:
  • fixed_path – Path to fixed landmarks CSV

  • moving_path – Path to moving landmarks CSV

  • scale_factor – Scaling factor for coordinates

Returns:

(fixed_points, moving_points)

Return type:

tuple

core.evaluation.evaluation.ngf_metric(fixed_image, moving_image, epsilon=0.01)[source]

Calculate Normalized Gradient Field (NGF) metric. Works well for multi-stain registration as it focuses on edge alignment.

Parameters:
  • fixed_image – Fixed image array (H, W, C)

  • moving_image – Moving image array (H, W, C)

  • epsilon – Small constant to avoid division by zero

Returns:

NGF metric (float)

core.evaluation.evaluation.rtre(landmarks_1, landmarks_2, x_size, y_size)[source]

Calculate relative Target Registration Error (rTRE)

Parameters:
  • landmarks_1 – First set of landmarks (N, 2)

  • landmarks_2 – Second set of landmarks (N, 2)

  • x_size – Image width

  • y_size – Image height

Returns:

Relative TRE values

core.evaluation.evaluation.transform_points_homogeneous(points, transform_matrix)[source]

Transform points using homogeneous coordinates

Parameters:
  • points – Input points (N, 2)

  • transform_matrix – 3x3 transformation matrix

Returns:

Transformed points (N, 2)

core.evaluation.evaluation.tre(landmarks_1, landmarks_2)[source]

Calculate Target Registration Error (TRE)

Parameters:
  • landmarks_1 – First set of landmarks (N, 2)

  • landmarks_2 – Second set of landmarks (N, 2)

Returns:

TRE values for each landmark pair