visisipy.models.geometry#
Models for the ocular geometry.
Classes#
Base class for optical surfaces. |
|
Standard conic surface. |
|
Stop surface. |
|
Standard biconic surface. |
|
Zernike standard coefficients surface with surface deformations. |
|
Zernike standard coefficients surface with wavefront aberrations. |
|
A surface that does not exist. |
|
Geometric parameters of an eye. |
Module Contents#
- class visisipy.models.geometry.Surface#
Bases:
abc.ABCBase class for optical surfaces.
- Attributes:
- thicknessfloat
The thickness of the surface. Default is 0.
- to_dict() dict[str, Any]#
Convert the surface to a dictionary.
- Returns:
- dict[str, Any]
A dictionary representation of the surface, including a
"type"key with the class name.
- classmethod from_dict(data: dict[str, Any]) Surface#
Create a surface from a dictionary.
- Parameters:
- datadict[str, Any]
A dictionary with the surface parameters. Must contain a
"type"key with the class name.
- Returns:
- Surface
A surface instance of the class specified by
data["type"].
- Raises:
- ValueError
If the
"type"value indatadoes not correspond to a known surface class.
- class visisipy.models.geometry.StandardSurface#
Bases:
SurfaceStandard conic surface.
Represents surfaces as conic sections (spheres, ellipsoids, paraboloids, hyperboloids), defined in terms of their radius of curvature and asphericity. For the asphericity, the following definition is used:
\[k = - \varepsilon^2 = - \left( 1 - \frac{b^2}{a^2} \right)\]with \(k\) the asphericity, \(\varepsilon\) the eccentricity, \(a\) the ellipsoid axis parallel to the optical axis and \(b\) the ellipsoid axis perpendicular to the optical axis. This is the definition used in OpticStudio. Note that the meaning of \(a\) and \(b\) differs from the standard definition of an ellipse, where they are the semi-major and semi-minor axes.
- Attributes:
- radiusfloat
The radius of the surface. Default is infinity.
- asphericityfloat
The asphericity of the surface. Default is 0.
- thicknessfloat
The thickness of the surface. Default is 0.
- semi_diameterfloat | None
The semi-diameter of the surface aperture. Default is None.
- is_stopbool
If True, the surface is a stop surface. Default is False.
Methods
ellipsoid_radii(self) -> tuple[float, float, float]:
Calculate and return the ellipsoid x, y and z radii (semi-axes) of the surface.
- property ellipsoid_radii: _EllipsoidRadii#
Calculate and return the ellipsoid radii (semi-axes) of the surface.
This works only if the surface is an ellipsoid (asphericity > -1), otherwise a NotImplementedError is raised. A tuple of the radii along the z, y and x axes is returned, where the z axis is the optical axis. These axes correspond to the following anatomical directions:
z: anterior-posterior
y: inferior-superior
x: left-right
- Returns:
- tuple[float, float, float]
The ellipsoid radii (semi-axes) of the surface.
- Raises:
- NotImplementedError
If the surface is not an ellipsoid (asphericity <= -1).
- class visisipy.models.geometry.Stop#
Bases:
StandardSurfaceStop surface.
This surface represents the aperture stop of an optical system.
- Attributes:
- semi_diameterfloat
The semi-diameter of the aperture stop. Default is 1.
- thicknessfloat
The thickness of the stop. Default is 0.
- class visisipy.models.geometry.BiconicSurface#
Bases:
StandardSurfaceStandard biconic surface.
Inherits from the StandardSurface class and represents a surface with different radii of curvature and asphericities in the x (left-right) and y (inferior-superior) directions. This is useful for modeling astigmatic surfaces. For the left eye, the x (left-right) direction corresponds to the temporal-nasal direction, while for the right eye, it corresponds to the nasal-temporal direction.
- Attributes:
- radiusfloat
The radius of the surface in the y (inferior-superior) direction. Default is infinity.
- radius_xfloat
The radius of the surface in the x (left-right) direction. Default is infinity.
- asphericityfloat
The asphericity of the surface in the y (inferior-superior) direction. Default is 0.
- asphericity_xfloat
The asphericity of the surface in the x (left-right) direction. Default is 0.
- thicknessfloat
The thickness of the surface. Default is 0.
- semi_diameterfloat | None
The semi-diameter of the surface aperture. Default is None.
- is_stopbool
If True, the surface is a stop surface. Default is False.
Methods
ellipsoid_radii(self) -> tuple[float, float, float]:
Calculate and return the ellipsoid x, y and z radii of the surface.
- property ellipsoid_radii: _EllipsoidRadii#
Calculate and return the ellipsoid radii (semi-axes) of the surface.
This works only if the surface is an ellipsoid (asphericity > -1), otherwise a NotImplementedError is raised. A tuple of the radii along the z, y and x axes is returned, where the z axis is the optical axis. These axes correspond to the following anatomical directions:
z: anterior-posterior
y: inferior-superior
x: left-right
- Returns:
- tuple[float, float, float]
The ellipsoid radii (semi-axes) of the surface.
- Raises:
- NotImplementedError
If the surface is not an ellipsoid (asphericity <= -1).
- class visisipy.models.geometry.ZernikeStandardSagSurface#
Bases:
BaseZernikeStandardSurfaceZernike standard coefficients surface with surface deformations.
Represents a surface with surface deformations described by Zernike polynomials.
- Attributes:
- zernike_coefficientsZernikeCoefficients | dict[int, float]
The Zernike coefficients of the surface. Default is an empty dictionary.
- extrapolatebool
If True, the Zernike coefficients will be considered even if the ray lands beyond the normalization radius. Default is True.
- zernike_decenter_xfloat
Decentration of the Zernike terms with respect to the conical and aspherical terms in the x-direction. Default is 0.
- zernike_decenter_yfloat
Decentration of the Zernike terms with respect to the conical and aspherical terms in the y-direction. Default is 0.
- maximum_termint | None
The maximum Zernike term to consider. If None is passed, this will be set to the maximum term in zernike_coefficients.
- norm_radiusfloat
The normalization radius for the Zernike coefficients, in lens units (usually mm). Default is 100.
- Raises:
- ValueError
If the Zernike coefficients contain terms that are greater than the maximum term.
- class visisipy.models.geometry.ZernikeStandardPhaseSurface#
Bases:
BaseZernikeStandardSurfaceZernike standard coefficients surface with wavefront aberrations.
Represents a surface with wavefront aberrations described by Zernike polynomials.
- Attributes:
- zernike_coefficientsZernikeCoefficients | dict[int, float]
The Zernike coefficients of the surface. Default is an empty dictionary.
- extrapolatebool
If True, the Zernike coefficients will be considered even if the ray lands beyond the normalization radius. Default is True.
- diffraction_orderfloat
The diffraction order of the surface. Default is 0.
- maximum_termint | None
The maximum Zernike term to consider. If None is passed, this will be set to the maximum term in zernike_coefficients.
- norm_radiusfloat
The normalization radius for the Zernike coefficients, in lens units (usually mm). Default is 100.
- Raises:
- ValueError
If the Zernike coefficients contain terms that are greater than the maximum term.
- class visisipy.models.geometry.NoSurface#
Bases:
SurfaceA surface that does not exist.
This surface is used to indicate that a surface is not present in the optical system. It can be used to define three-surface schematic eyes and reduced eye models.
Note
This surface does not modify the optical system, i.e. surfaces of the NoSurface type are not built when calling EyeModel.build. This means the properties of the preceding surface, e.g. the refractive index, will propagate to the next surface.
- class visisipy.models.geometry.EyeGeometry(cornea_front: _CorneaFront | None = None, cornea_back: _CorneaBack | None = None, pupil: _Pupil | None = None, lens_front: _LensFront | None = None, lens_back: _LensBack | None = None, retina: _Retina | None = None)#
Bases:
Generic[_CorneaFront,_CorneaBack,_Pupil,_LensFront,_LensBack,_Retina]Geometric parameters of an eye.
Sizes are specified in mm. This class is mainly intended as a base class for more specific eye models. When used directly, all surfaces need to be specified manually.
- Attributes:
- cornea_frontSurface
The front surface of the cornea.
- cornea_backSurface
The back surface of the cornea.
- pupilSurface
The pupil of the eye.
- lens_frontSurface
The front surface of the lens.
- lens_backSurface
The back surface of the lens.
- retinaSurface
The retina of the eye.
Methods
axial_length(self) -> float:
Calculates and returns the axial length of the eye.
cornea_thickness(self) -> float:
Returns the thickness of the cornea.
anterior_chamber_depth(self) -> float:
Returns the depth of the anterior chamber.
lens_thickness(self) -> float:
Returns the thickness of the lens.
vitreous_thickness(self) -> float:
Returns the thickness of the vitreous.
- property cornea_front: _CorneaFront#
Cornea front geometry.
- property cornea_back: _CorneaBack#
Cornea back geometry.
- property pupil: _Pupil#
Pupil geometry.
- property lens_front: _LensFront#
Lens front geometry.
- property lens_back: _LensBack#
Lens back geometry.
- property retina: _Retina#
Retina geometry.
- property axial_length: float#
Axial length of the eye, in mm.
- property cornea_thickness: float#
Central thickness of the cornea, in mm.
The corneal thickness is defined as the distance between the anterior and posterior cornea surfaces.
- property anterior_chamber_depth: float#
Depth of the anterior chamber, in mm.
The anterior chamber depth is defined as the distance between the posterior cornea surface and the anterior lens surface.
- property aqueous_depth: float#
Depth of the aqueous humor, in mm.
The aqueous depth is defined as the distance between the posterior cornea surface and the anterior lens surface.
See also
anterior_chamber_depthEquivalent to the anterior chamber depth.
- property pupil_lens_distance: float#
Distance between the pupil and the anterior lens surface, in mm.
- property lens_thickness: float#
Thickness of the crystalline lens, in mm.
The lens thickness is defined as the distance between the anterior and posterior lens surfaces.
- property vitreous_thickness: float#
Thickness of the vitreous body, in mm.
The vitreous thickness is defined as the distance between the posterior lens surface and the retina.
- abstractmethod reverse()#
Return a reversed geometry representation.
- to_dict() dict[str, Any]#
Convert the eye geometry to a dictionary.
- Returns:
- dict[str, Any]
A dictionary representation of the eye geometry, including a
"type"key with the class name and the serialized surfaces.
- classmethod from_dict(data: dict[str, Any]) EyeGeometry[Surface, Surface, Surface, Surface, Surface, StandardSurface]#
Create an eye geometry from a dictionary.
- Parameters:
- datadict[str, Any]
A dictionary with the eye geometry parameters, as produced by
to_dict().
- Returns:
- EyeGeometry
An
EyeGeometryinstance with surfaces reconstructed fromdata.
- Raises:
- ValueError
If the
"type"value indatadoes not correspond to a known eye geometry class.