Wavefront Retrieval from Through-Focus Point Spread Functions with Machine Learning

From Psych 221 Image Systems Engineering
Revision as of 22:19, 8 December 2023 by Craigto (talk | contribs) (→‎Methods)
Jump to navigation Jump to search

Introduction

This project is about estimating wavefront error based on point spread function at different focus locations (at and around focus along optical path). Point spread function can be calculated from wavefront error, but there is no theoretical method to calculate wavefront error from point spread function. This is because the transformation from wavefront error to point spread function is not one-to-one. We overcome this challenge by using machine learning. First, we generated multiple samples of random wavefront error. Second, we calculated the point spread function at a range of focus locations based on each sample of wavefront error. Third, we used regression to relate the wavefront error to point spread function at different focus locations. Lastly, we compared the wavefront error estimated by our regression model to the real wave front error.

Background

Point Spread Function

Point spread function can represent optical quality. It is a measure of intensity (or relative intensity) as a function of x and y location (where optical path is along z-axis). Ideally, when a beam pass through a convex lens, the point spread function at focus location should be sharp, where the peak is the location that the beam focuses on.

However, with error such as aberration, the point spread function will be flatter.

Wavefront Error

Wavefront error is the difference between the reference wavefront phase and the detected wavefront phase of an optical system.

In simulation, we model the wavefront error using Zernike polynomials. Each Zernike polynomial represents the wavefront deviation in shape, and it is orthogonal to other Zernike polynomials. The overall wavefront error can be represented by the sum of a constant multiplying each Zernike polynomial.

Failed to parse (syntax error): {\displaystyle ϕ(u,v)= ∑_1^N c_i Z_i (u,v) } (Zi is a Zernike polynomial)

In this project, we use the first 36 Zernike polynomials only.

Methods

Set Up

The set up in this project is a beam passing through a lens.

𝑁𝐴=𝑛 sin⁡𝜃 The wavelength of the beam is 550nm. The numerical aperture is 0.65. We used Python to generate wavefront error samples, calculate the point spread function based on the wavefront error samples and focus locations, model wavefront error in terms of point spread function, and analyze the results.

Generating Wavefront Error Samples

We used the first 36 Zernike polynomials in this project. We created 500 randomly generated samples of wavefront errors. The wavefront error is represented by an array of 36 Zernike coefficients (c_i). ϕ(u,v)= ∑_1^36▒〖c_i Z_i (u,v) 〗 For each wavefront error, we calculated the point spread function at a range of focus location. Defocus can be expressed by c4*Z4. We experimented on 2 focus location ranges, the first one is -50mWave to +50mWave with 5mWave step, the second one is -500 to +500mWave with 50mWave step. For the range -50mWave to +50mWave, we created several sets of sample based on the total wavefront error magnitude, which are 20, 40, 70 mWave, and 0 – 70 mWave (varying). For the range -500 to +500mWave, we created a set of samples with 0 – 70 mWave (varying) wave front error magnitude. The total wavefront error magnitude is defined by the following equation. Total wavefront error (RMS) = √(∑_1^N▒c_i^2 ) 70mWave is selected, for the reason that the image quality is not sensibly degraded when the total wavefront error is less than or equal to 70mWave RMS.

=== Calculating Point Spread Function from Wavefront Error The wavefront error can be expressed in the following form. ϕ(u,v)= ∑_1^N▒〖c_i Z_i (u,v) 〗 The point spread function is the modulus square of the Fourier transform of the complex pupil function. It can be calculated from wavefront error with the following method. PSF=|F{A(u,v) exp⁡iϕ(u,v) " " }|^2 The implementation is done in Python, and you may refer to the source code for more details.

Generate Training Set

First, an n by n PSF image was calculated at focus F1. Then the image was flattened to n^2 by 1 and normalized by the peak value of PSF w/o aberration. We repeated the steps for all focal positions F1 to FN and got an n^2*N by 1 matrix. Last, we did the same thing for all 500 samples and generated an n^2*N by 500 matrix as the training data.

Regression

The machine learning model we used to estimate wavefront error from point spread function is linear regression. The library “sklearn” from Python was used to execute linear regression. The model was trained with the training data above. We then applied the trained model to predict the wavefront error from the point spread function. The input are the flattened point spread functions through focus. The output are the coefficients of the Zernike polynomials (c_i). You may refer to the source code for more details.

Analysis

After training our regression model, we computed its accuracy. We used our trained regression model to estimate the wavefront error from the point spread function that we generated earlier for training. We compared the wavefront error estimated by our regression model with the “real” wavefront error that leads to the point spread function. We computed the maximum error among the coefficients of the 36 Zernike polynomial, and the root sum square of the error in those coefficients. Our analysis goal is to verify how close our regression model is in estimating the wavefront error from point spread function.

Results

Conclusions

Appendix