pyrot.eye_modelling.clipbased_model#

Attributes#

Functions#

match_ellipse_with_pois(eye_model_generators, ...)

Aligns the eye model's translation and rotation to best fit known clip locations (POIs) and the optic disk location.

calc_on_model_loc_patient(geometry_generators, ...)

Calculates the location of the optic nerve ROI on the unity circle for a given eye model.

registration_residuals(params, clip_data, ...)

Compute the residuals for ellipsoid registration and optic nerve location alignment.

calc_ellipsoid_registration(clip_data, on_model_loc, ...)

Perform ellipsoid registration to align clip data and optic nerve locations.

Module Contents#

pyrot.eye_modelling.clipbased_model.logger#
pyrot.eye_modelling.clipbased_model.match_ellipse_with_pois(eye_model_generators, eye_model_parameters, structure_set, input_ellipse, poi_type_clips, poi_type_on)#

Aligns the eye model’s translation and rotation to best fit known clip locations (POIs) and the optic disk location. This function updates the eye model center and rotation so that the model’s sclera surface matches the positions of physical markers (clips) and the optic disk.

Parameters#

eye_model_generatorsobject

An object responsible for generating or updating the eye model.

eye_model_parametersobject

An object containing the current parameters of the eye model, such as translation and sclera radii.

structure_setobject

The structure set containing the POIs (points of interest) for the patient.

input_ellipsestr

The type of ellipse to fit to the POIs. Currently, only “sclera_radii” is supported.

poi_type_clipsstr

The POI type corresponding to the physical markers (clips) on the sclera.

poi_type_onstr

The POI type corresponding to the optic disk (OD) location.

Raises#

ValueError

If there are multiple or no POIs of the specified optic disk type.

NotImplementedError

If the specified input_ellipse type is not supported.

Notes#

  • The function assumes that the POIs for the clips are located at the center of the clips, and adjusts the sclera radii accordingly.

  • The function updates the eye model parameters in-place using the provided eye_model_generators object.

pyrot.eye_modelling.clipbased_model.calc_on_model_loc_patient(geometry_generators, eye_model_parameters, on_model_loc_method)#

Calculates the location of the optic nerve ROI on the unity circle for a given eye model.

This function determines the standardized location of the optic disk as if the eye model were positioned at the origin ([0, 0, 0]) with input angles [0, 0, 0] and sclera radii [1, 1, 1]. This is necessary for fitting procedures that standardize axes and points of interest (POI) locations to the unity circle.

Currently, only the “unity_circle_standard_model” method is implemented, which assumes the optic disk location within the eye model has not been manually changed.

Parameters#

geometry_generatorsobject

An object containing geometry generation parameters, including eye laterality.

eye_model_parametersobject

An object containing parameters of the eye model, including optic nerve rotation.

on_model_loc_methodstr

The method used to calculate the ON model location. Currently, only “unity_circle_standard_model” is supported.

Returns#

on_model_loc_patientnp.ndarray

The standardized location of the optic nerve in the eye model, mapped to the unity circle.

Raises#

AssertionError

If the optic nerve (and thus disk) has been rotated manually within the eye model, violating fit assumptions.

NotImplementedError

If the specified on_model_loc_method is not implemented.

Notes#

  • The function assumes the optic disk location has not been manually changed within the eye model.

  • The method should be validated with different types of eye models.

  • Unit testing for this methodology should be added.

pyrot.eye_modelling.clipbased_model.registration_residuals(params, clip_data, optic_nerve_data, axes)#

Compute the residuals for ellipsoid registration and optic nerve location alignment.

This function calculates the residuals between a set of 3D points (clip_data) and an ellipsoid model, as well as the normalized distance between the transformed optic nerve location and its model POI. The transformation includes translation and rotation (with the y-axis rotation fixed to zero).

Parameters#

paramsarray-like, shape (6,)

Model parameters. The first three elements are the center coordinates (x0, y0, z0), and the next three are Euler angles (degrees) for rotation. The y-axis angle is fixed to zero.

clip_datandarray, shape (N, 3)

Array of 3D points representing the data to be registered to the ellipsoid.

optic_nerve_datatuple of ndarray
Tuple containing:
  • on_model_loc: ndarray, shape (3,)

    The model location of the optic nerve (should be on the unit ellipsoid).

  • on_image_loc: ndarray, shape (3,)

    The observed location of the optic nerve in the image.

axesarray-like, shape (3,)

The semi-axes lengths (a, b, c) of the ellipsoid.

Returns#

residualsndarray, shape (N+1,)
Array containing:
  • The residuals for each point in clip_data (distance from the ellipsoid surface).

  • The normalized squared distance between the transformed optic nerve location and its model POI.

Notes#

The function applies translation and rotation to the input data, computes the ellipsoid equation residuals, and normalizes the optic nerve location to compare with the model location.

pyrot.eye_modelling.clipbased_model.calc_ellipsoid_registration(clip_data, on_model_loc, on_image_loc, axes, initial_guess=None)#

Perform ellipsoid registration to align clip data and optic nerve locations.

This function calculates the optimal translation and rotation parameters to align a set of 3D points (clip_data) with an ellipsoid defined by the given axes, while also aligning the optic nerve location in the model with its observed location.

Parameters#

clip_datandarray, shape (N, 3)

Array of 3D points representing the clip data to be registered to the ellipsoid.

on_model_locndarray, shape (3,)

The model location of the optic nerve (on the unit ellipsoid).

on_image_locndarray, shape (3,)

The observed location of the optic nerve in the image.

axesarray-like, shape (3,)

The semi-axes lengths (a, b, c) of the ellipsoid.

initial_guessarray-like, shape (6,), optional

Initial guess for the optimization. The first three elements are the center coordinates (x, y, z), and the next three are Euler angles (degrees) for rotation. If None, the center is initialized to the mean of clip_data, and angles are set to zero.

Returns#

fitted_centerndarray, shape (3,)

The optimized center coordinates of the ellipsoid.

fitted_anglesndarray, shape (3,)

The optimized Euler angles (degrees) for rotation.

Notes#

The optimization minimizes the residuals between the clip data and the ellipsoid surface, as well as the alignment error for the optic nerve location.