pyrot.eye_modelling.datamodels.models ===================================== .. py:module:: pyrot.eye_modelling.datamodels.models .. autoapi-nested-parse:: Data structures for interacting with RayOcular eye models. Classes ------- .. autoapisummary:: pyrot.eye_modelling.datamodels.models.BaseModel pyrot.eye_modelling.datamodels.models.EyeModelMeasurements pyrot.eye_modelling.datamodels.models.AnteriorChamber pyrot.eye_modelling.datamodels.models.CiliaryBody pyrot.eye_modelling.datamodels.models.Cornea pyrot.eye_modelling.datamodels.models.Eye pyrot.eye_modelling.datamodels.models.Iris pyrot.eye_modelling.datamodels.models.Lens pyrot.eye_modelling.datamodels.models.Macula pyrot.eye_modelling.datamodels.models.OpticalDisc pyrot.eye_modelling.datamodels.models.OpticalNerve pyrot.eye_modelling.datamodels.models.Retina pyrot.eye_modelling.datamodels.models.Sclera pyrot.eye_modelling.datamodels.models.VitreousBody pyrot.eye_modelling.datamodels.models.EyeModelParameters pyrot.eye_modelling.datamodels.models.EyeModel Module Contents --------------- .. py:class:: BaseModel Abstract base class for RayOcular data models. For full functionality, all subclasses must be dataclasses and use the `RayOcularField` descriptor to define fields that correspond to RayOcular properties. Methods ------- from_rayocular(cls, rayocular_object) Converts a RayOcular object to an instance of the data model. to_rayocular(self) Converts the data model instance to a RayOcular object. to_dict(self) Converts the data model instance to a dictionary. from_dict(cls, data) Creates an instance of the data model from a dictionary. .. py:method:: from_rayocular(rayocular_object) -> _Self :classmethod: Convert a RayOcular object to an instance of the data model. Parameters ---------- rayocular_object : Any The RayOcular object to convert. Returns ------- BaseModel An instance of the data model. Raises ------ ValueError If any field in the data model does not have a corresponding RayOcular name. .. py:method:: to_rayocular() -> dict[str, Any] Convert the data model instance to a RayOcular dictionary. Returns ------- dict[str, Any] A dictionary that can be used to update the model in RayOcular. .. py:method:: to_dict() -> dict[str, Any] Convert the data model instance to a dictionary. This method is only implemented for dataclasses. Returns ------- dict[str, Any] A dictionary representation of the data model instance. Raises ------ NotImplementedError If the data model instance is not a dataclass. .. py:method:: from_dict(data: dict[str, Any]) -> _Self :classmethod: Create an instance of the data model from a dictionary. This method is only implemented for dataclasses. Parameters ---------- data : dict[str, Any] A dictionary representation of the data model instance. Returns ------- BaseModel An instance of the data model. Raises ------ NotImplementedError If the data model class is not a dataclass. TypeError If the type of any field cannot be resolved. ValueError If any required field is missing from the data. .. py:class:: EyeModelMeasurements Bases: :py:obj:`BaseModel` Store measurements for an eye model. Attributes ---------- cornea_lens_distance : float Distance from cornea to lens. eye_length : float Total length of the eye. eye_width : float Width of the eye. lens_thickness : float Thickness of the lens. limbus_diameter : float Diameter of the limbus. .. py:class:: AnteriorChamber Bases: :py:obj:`BaseModel` Store anterior chamber parameters for an eye model. Attributes ---------- local_rotation : Vector3[float] Local rotation of the anterior chamber. local_scale : Vector3[float] Local scale of the anterior chamber. local_translation : Vector3[float] Local translation of the anterior chamber. .. py:class:: CiliaryBody Bases: :py:obj:`BaseModel` Store ciliary body parameters for an eye model. Attributes ---------- base_curvature : float Base curvature of the ciliary body. height : float Height of the ciliary body. local_rotation : Vector3[float] Local rotation of the ciliary body. local_scale : Vector3[float] Local scale of the ciliary body. local_translation : Vector3[float] Local translation of the ciliary body. .. py:class:: Cornea Bases: :py:obj:`BaseModel` Store cornea parameters for an eye model. Attributes ---------- local_rotation : Vector3[float] Local rotation of the cornea. local_scale : Vector3[float] Local scale of the cornea. local_translation : Vector3[float] Local translation of the cornea. semi_axis : Vector3[float] Semi-axes of the cornea. thickness : float Thickness of the cornea. .. py:class:: Eye Bases: :py:obj:`BaseModel` Store eye positioning and scale parameters. Attributes ---------- pivot : Vector3[float] Pivot point of the eye. rotation : Vector3[float] Rotation of the eye. scale : Vector3[float] Scale of the eye. translation : Vector3[float] Translation of the eye. .. py:class:: Iris Bases: :py:obj:`BaseModel` Store iris parameters for an eye model. Attributes ---------- inner_semi_axis : RayOcularField[Vector3[float]] Inner semi-axes of the iris. outer_semi_axis : RayOcularField[Vector3[float]] Outer semi-axes of the iris. local_rotation : RayOcularField[Vector3[float]] Local rotation of the iris. local_scale : RayOcularField[Vector3[float]] Local scale of the iris. local_translation : RayOcularField[Vector3[float]] Local translation of the iris. thickness : RayOcularField[float] Thickness of the iris. .. py:class:: Lens Bases: :py:obj:`BaseModel` Store lens parameters for an eye model. Attributes ---------- curvature : RayOcularField[float] Curvature of the lens. local_rotation : RayOcularField[Vector3[float]] Local rotation of the lens. local_scale : RayOcularField[Vector3[float]] Local scale of the lens. local_translation : RayOcularField[Vector3[float]] Local translation of the lens. semi_axis : RayOcularField[Vector3[float]] Semi-axes of the lens. .. py:class:: Macula Bases: :py:obj:`BaseModel` Store macula parameters for an eye model. Attributes ---------- height : RayOcularField[float] Height of the macula. local_rotation : RayOcularField[Vector3[float]] Local rotation of the macula. local_scale : RayOcularField[Vector3[float]] Local scale of the macula. local_translation : RayOcularField[Vector3[float]] Local translation of the macula. rotation : RayOcularField[Vector3[float]] Rotation of the macula. semi_axis : RayOcularField[Vector3[float]] Semi-axes of the macula. .. py:class:: OpticalDisc Bases: :py:obj:`BaseModel` Store optical disc parameters for an eye model. Attributes ---------- height : RayOcularField[float] Height of the optical disc. local_rotation : RayOcularField[Vector3[float]] Local rotation of the optical disc. local_scale : RayOcularField[Vector3[float]] Local scale of the optical disc. local_translation : RayOcularField[Vector3[float]] Local translation of the optical disc. semi_axis : RayOcularField[Vector3[float]] Semi-axes of the optical disc. .. py:class:: OpticalNerve Bases: :py:obj:`BaseModel` Store optical nerve parameters for an eye model. Attributes ---------- height : RayOcularField[float] Height of the optical nerve. local_rotation : RayOcularField[Vector3[float]] Local rotation of the optical nerve. local_scale : RayOcularField[Vector3[float]] Local scale of the optical nerve. local_translation : RayOcularField[Vector3[float]] Local translation of the optical nerve. rotation : RayOcularField[Vector3[float]] Rotation of the optical nerve. semi_axis : RayOcularField[Vector3[float]] Semi-axes of the optical nerve. .. py:class:: Retina Bases: :py:obj:`BaseModel` Store retina parameters for an eye model. Attributes ---------- thickness : RayOcularField[float] Thickness of the retina. local_rotation : RayOcularField[Vector3[float]] Local rotation of the retina. local_scale : RayOcularField[Vector3[float]] Local scale of the retina. local_translation : RayOcularField[Vector3[float]] Local translation of the retina. .. py:class:: Sclera Bases: :py:obj:`BaseModel` Store sclera parameters for an eye model. Attributes ---------- thickness : RayOcularField[float] Thickness of the sclera. local_rotation : RayOcularField[Vector3[float]] Local rotation of the sclera. local_scale : RayOcularField[Vector3[float]] Local scale of the sclera. local_translation : RayOcularField[Vector3[float]] Local translation of the sclera. semi_axis : RayOcularField[Vector3[float]] Semi-axes of the sclera. .. py:class:: VitreousBody Bases: :py:obj:`BaseModel` Store vitreous body parameters for an eye model. Attributes ---------- local_rotation : RayOcularField[Vector3[float]] Local rotation of the vitreous body. local_scale : RayOcularField[Vector3[float]] Local scale of the vitreous body. local_translation : RayOcularField[Vector3[float]] Local translation of the vitreous body. .. py:class:: EyeModelParameters Bases: :py:obj:`BaseModel` Store all parameters that define an eye model. Attributes ---------- eye : ValidatedField[Eye] Eye positioning and scale parameters. anterior_chamber : ValidatedField[AnteriorChamber] Anterior chamber parameters. ciliary_body : ValidatedField[CiliaryBody] Ciliary body parameters. cornea : ValidatedField[Cornea] Cornea parameters. iris : ValidatedField[Iris] Iris parameters. lens : ValidatedField[Lens] Lens parameters. macula : ValidatedField[Macula] Macula parameters. optical_disc : ValidatedField[OpticalDisc] Optical disc parameters. optical_nerve : ValidatedField[OpticalNerve] Optical nerve parameters. retina : ValidatedField[Retina] Retina parameters. sclera : ValidatedField[Sclera] Sclera parameters. vitreous_body : ValidatedField[VitreousBody] Vitreous body parameters. lens_cornea_distance : ValidatedField[float] Distance from lens to cornea. level_of_detail : ValidatedField[int] Level of detail for geometry rendering. .. py:method:: from_rayocular(parameters) -> EyeModelParameters :classmethod: Create eye model parameters from a RayOcular object. Parameters ---------- parameters : object The RayOcular eye model parameters object. Returns ------- EyeModelParameters The created eye model parameters. .. py:method:: to_rayocular() -> dict[str, Any] Convert eye model parameters to a RayOcular dictionary. Returns ------- dict[str, Any] A dictionary that can be used to update the model in RayOcular. .. py:class:: EyeModel Bases: :py:obj:`BaseModel` Store a complete eye model with measurements and parameters. Attributes ---------- measurements : ValidatedField[EyeModelMeasurements] Eye model measurements. parameters : ValidatedField[EyeModelParameters] Eye model parameters. laterality : RayOcularField[EyeLaterality] Eye laterality (Left or Right). description : RayOcularField[str] Description of the eye model. inter_pupillary_distance : RayOcularField[Optional[float]] Inter-pupillary distance. name : RayOcularField[str] Name of the eye model. .. py:method:: from_rayocular(geometry_generator) -> EyeModel :classmethod: Create an eye model from a RayOcular geometry generator. Parameters ---------- geometry_generator : object The RayOcular geometry generator object. Returns ------- EyeModel The created eye model. .. py:method:: to_rayocular() -> dict[str, Any] :abstractmethod: Convert the eye model to a RayOcular dictionary. Raises ------ NotImplementedError This method is not implemented for EyeModel. .. py:method:: load_json(file_path: os.PathLike | str) -> EyeModel :classmethod: Load an eye model from a JSON file. Parameters ---------- file_path : PathLike | str Path to the JSON file. Returns ------- EyeModel The loaded eye model. .. py:method:: save_json(file_path: os.PathLike | str) -> None Save the eye model to a JSON file. Parameters ---------- file_path : PathLike | str Path where the JSON file will be saved.