Wavefront optics toolbox
Back to Psych221-Projects-2012
We worked with the WavefrontOpticsToolbox, located in a SVN repository at https://platypus.psych.upenn.edu/repos/toolboxes/WavefrontOpticsToolbox/trunk. This toolbox models the optics of the human eye using scalar diffraction theory from Fourier optics. In particular, the aberrations of the human cornea, pupil, and lens, as well as the Stiles-Crawford effect from retinal cone cells, are modeled by the amplitude and phase of the eye's pupil function. This pupil function is then Fourier transformed to compute the eye's point spread function (PSF).
The project is split into two sections: 1) code clean-up and commenting and 2) the creation of a MATLAB tutorial to demonstrate some of the features of the toolbox.
- Would be cool to have intro pics
-
Example pic 1
-
Example pic 2
Background
Ray optics, or geometric optics, is concerned with modeling how light rays travel through optical systems like that of our eyes. However, to fully consider the effects of small pupil size, as well as variations in the geometry and chromatic aberrations of the eye's lenses, wave optics and diffraction must be accounted for. Fourier optics, or scalar diffraction theory, cleanly handles effects such as wavefront aberrations, finite pupil size, and apodizing filtering, so we will first briefly give a background of Fourier optics. Next, we will discuss how wavefront aberrations are modeled, namely by the basis set of Zernike polynomials. Finally, we will describe the Stiles-Crawford effect, the physical cause of this effect, and how it is modeled.
Fourier optics

Fourier optics is built upon the idea that the wave nature of light is modeled by the Huygens-Fresnel principle -- that every point on a wavefront of light is the source of new spherical waves. The summed interaction of these spherical waves at some observation plane determines what is observed at that plane. Here, it is assumed that the polarization of the electromagnetic field can be neglected, and instead, light can simply be modeled by a wavefunction that obeys the standard wave equation and represents electric or magnetic field. Hence, this is called scalar diffraction theory.
A direct result of this theory is that the diffraction effects of any imaging system can be modeled very cleanly by Fourier transforms. In fact the point spread function of an imaging system is given by [1]
where is a constant amplitude, is the wavelength of monochromatic light, is the distance from the exit pupil to the image plane, is the pupil's complex transmittance function, are image coordinates, and are coordinates in the pupil plane. Thus, we can see that the PSF is just the Fraunhofer diffraction pattern, or Fourier transform, of the exit pupil. The intensity actually observed on the retina is .
The expression above has several consequences for modeling the PSF of the human eye. First, it handles monochromatic light, so in order to obtain the polychromatic PSF, the equation above must be computed for several (or many) wavelengths of light. Secondly, care must be taken to sample finely enough to avoid aliasing; the phase of this function must be slowly varying at the chosen sampling rate. In addition, care must be taken to pad with enough zero values to avoid "ringing" effects associated with the periodic boundary conditions of the discrete Fourier transform.
Diffraction-limited PSF and the eye
The pupil function of a diffraction-limited optical system is simply given by [1]
where is 1 for and 0 for , , and is the radius of the pupil.

The Fourier transform of a circular pupil is the so-called Airy disk, given by [1]
where , is the distance from the pupil to the retina, and is a Bessel function of the first kind.
Here, the diffraction-limited pupil function is a real function that has uniform amplitude. However, there are two effects in human eyes that make their PSFs non-ideal. The first is wavefront aberrations caused by distortions of the cornea, pupil, and lens of the eye. These are modeled by a complex phase function that modifies the pupil function. The second arises from the waveguide-like nature of the cone cells in the retina, which only capture light over a limited angular range. This is modeled by a amplitude variation in the pupil function. Thus, in general, we can model the complex pupil function as
Wavefront aberrations and Zernike polynomials

As stated above, wavefront aberrations are modeled by phase variations in the pupil function. In order to conveniently describe the different types of aberrations that occur, The Optical Society has developed a standard convention [2] based upon the complete basis set of Zernike polynomials. These polynomials are orthogonal over the unit circle . They are indexed either by a pair of numbers or by their overall mode number . The radial order specifies the power of the radial portion of the polynomial, while the angular frequency specifies the number of angular nodes. For each radial order , there are polynomials forming a pyramid structure. To make indexing more convenient, especially when computing these functions in software, the single index is widely used and adopted here.
Since the polynomials form a complete orthogonal basis set over the unit disk, the wavefront aberrations of any human eye can be decomposed into the basis of Zernike polynomials:
Thus, it is sufficient to express the wavefront aberrations of any pupil function with a series of Zernike coefficients .
Notable polynomials and their aberration names are given below.
Zernike polynomial Aberration name Piston tilt tilt Primary astigmatism at Defocus Primary astigmatism at Primary coma Primary coma Primary spherical
Stiles-Crawford effect
The Stiles-Crawford effect arises from the tall waveguide-like nature of cone cells. Reported in 1933 by W.S. Stiles and B.H. Crawford [3], light impinging on the retina invokes different responses in cone cells based upon the incident angle. In the pupil plane, this suggests that rays entering the center of the pupil more efficiently excite photoreceptors compared to rays entering the edges of the pupil. Although this effect is strictly retinal in nature, it is modeled by an attenuating filter on the pupil function. It is hypothesized that this effect improves vision by decreasing the cone's response to aberrated or scattered light, especially since phase aberrations are worse near the edges of the pupil.
The model of the Stiles-Crawford effect is an exponentially decaying amplitude function [4]
where is an apodization factor and the peak location of transmission is given by .
Toolbox code clean-up
One of the goals of the wavefront optics toolbox is to help students understand and explore the use of Zernike polynomial representations of pupil functions and PSFs. To this end, the toolbox had to undergo some changes in order to to expose its associated functions in a more transparent fashion. This included the addition of comments explaining the use of subfunctions or parameters where applicable, rewriting functions so that their computation and output is more obvious, and restructuring wavefront variable parameters in a more physically meaningful way.
Comments
Zernike coefficients vector
wvfCreate.m and wvfSet.m form a 65-element column vector of "Zernike coefficients." For clarity, these have been explained as the weights of the first 65 terms of the Zernike polynomials, representing up to 10 orders of these basis functions. These terms follow the "j" single-indexing scheme adopted by OSA. [2]
Nominal wavelength and Defocus
It was previously unclear what the purpose of the nominal (in-focus) wavelength was. We have made it clear that computing a pupil function for a wavelength other than the nominal wavelength under which the Zernike coefficients were measured must account for longitudinal chromatic aberration (LCA). This is the result of the optics of the eye focusing light at different points on-axis depending on wavelength. With the exception of the 4th coefficient, "defocus," aberrations do not vary much with wavelength. As a result, the toolbox adjusts for LCA by introducing it into the "defocus" coefficient.
wvfComputePSF.m uses wvfGet to provide a defocus value in microns (because Zernike coefficients are in units of microns). Within wvfGet, this is done by calling wvfGetDefocusFromWavelengthDifference.m, a utility function which first converts the difference between the nominal and calculated-for wavelengths into diopters. It then combines this with any user-preset defocus in diopters. Finally, it converts all contributions to defocus from diopters into microns using the referenced equation. [5] The defocus in microns is finally set as the 4th term of the vector of Zernike coefficients on a wavelength by wavelength loop to compute the pupil function and PSF.
Code edits
Wavelength Vector Inputs
wvfSet.m can now accept a vector of wavelengths over which the pupil function and PSF are computed, specified in the format: [start spacing Nsamples]. The PSF will change if not being calculated for the nominal wavelength due to longitudinal chromatic aberration (LCA) effects, so it is useful to store multiple PSFs for multiple wavelengths at once using this format.
Removal of unnecessary loops
Previously, the Stiles-Crawford Effect (SCE) and Zernike polynomial computations of pupil function amplitude and phase, respectively, were handled in double for loops for all x and y points in the specified field. This method was not only cumbersome, but also did not reflect the natural conversion between polar and rectangular coordinate systems, which is one of the benefits of using the Zernike polynomials as the set of basis functions in the first place.
We use the simple relations:
- (as in the Pythagorean theorem), and
- (where atan2 is a common variation on the arctangent function that takes into account the quadrant)
Parameter Restructuring
text
Subsubheading
Tutorial
text text text
Zernike polynomials
text text text
Modeling chromatic aberration
text text text
Stiles-Crawford effect
text text text
Human eye aberrations and correction using eyeglasses
text text text
Conclusions and future directions
Revisions to the Wavefront Optics Toolbox are still incomplete. One prominent issue that remains is how wvfComputePSF.m still attempts to scale the calculated PSF relative to the scaling that an arbitrary reference wavelength would produce (in this case, 550nm). This comes from taking the Fourier Transform of the pupil function and is not a feature of the Zernike polynomials. Rewriting this portion of the code is important not only because it is confusing and not intuitive, but because it affects the resulting plots. Since the toolbox functions and associated tutorial are meant to be explored by students in order to understand pupil function and PSF computations, it would be much better to have a clearly-defined scaling based on a physical parameter in the code. With more time, this would be a natural and key next-step for the project.
Another potential area of development is the exploration of human eye data in the tutorial. Currently, there are Zernike polynomial coefficients for nine subjects. Each set, however, is missing the 4th Zernike polynomial coefficient (representing defocus), meaning we do not have a complete picture of the eye aberrations. The tutorial would be clearer and deeper with the addition of more complete human data matching the inputs that the toolbox already uses, for example, nominal focus wavelengths in wavefront aberration measurements and defocus diopters of the refractive power of eyes. With these data and a larger set of subjects, teh tutorial could perhaps include some statistical analysis.
Finally, while the tutorial has explored the how pupil functions and PSFs can be changed by correcting certain aberrations, it would be beneficial to combine this with sample images to compare "before and after" vision correction. This would require scaling and sizing/distance computations in order to properly convolve different versions of the PSF with images for simulating their appearance.
References
- Goodman, J. W. (2005). Introduction to Fourier optics. 3rd ed. Englewood, Colo.: Roberts & Co.
- Porter, J. (2006). Adaptive optics for vision science: principles, practices, design, and applications (Appendix A: Optical Society of America's Standards for Reporting Optical Aberrations). Hoboken, NJ: Wiley-Interscience.
- Stiles W. S. and Crawford B. H. (1933). "The luminous efficiency of rays entering the eye pupil at different points," Proc. R. Soc. Lond B 112:428-450.
- Schwiegerling, J. (2004). Field guide to visual and ophthalmic optics. Bellingham, Wash.: SPIE.
- Tarrant, J. (2010). Determining the accommodative response from wavefront aberrations. Journal of Vision.
Appendix I
Code
WavefrontOpticsToolbox SVN repository
Data
Wavefront measurements of human eyes are part of the WavefrontOpticsToolbox SVN repository.
Presentation
File:2012LewPhong WaveOpticsToolbox.pptx
Appendix II - Work partition
Matthew Lew - Heavily edited wvfComputePupilFunction.m to remove unnecessary nested loops; removed sizeOfFieldPixels field of the wvf struct so that all parameters are defined in terms of physical dimensions, not pixels; constructed sections of tutorial dealing with SCE and vision correction with eyeglasses
Kevin Phuong - Constructed core of t_Zernike.m to demonstrate Zernike polynomials and their effect on PSFs; updated various functions of the toolbox to use wvfGet() and wvfSet().