# Adaptive Optics Shack-Hartmann Sensor and Deformable Mirror

I have a technical question regarding the Shack-Hartmann sensor in deformable mirrors. What algorithm is used to take the Shack-Hartmann measurements of local tilt and turn them into a full phase estimate that can be passed to the deformable mirror?

(Source: Wikipedia1)

I see that the the sensor itself can generate an estimate of the derivative of the wavefront $w(x,y)$ by observing the offset of the centroid of the guidestar. If the delta in from center of the guidestar is $\delta_x$ and $\delta_y$ then the derivative of the wavefront in that region is proportional $\delta$:

$\frac{dw}{dx} \propto \delta_x$ and $\frac{dw}{dy} \propto \delta_y$

Geary's Introduction to wavefront sensors2 has the following diagram:

with the comment: "To reconstruct the wavefront, the local tilts must be stitched together".

Is it enough to connect them end-to-end, perhaps make them non-negative, and pass them on? The values transmitted are usually Zernike Polynomial modes, so do we we desire to make them positive or zero mean? What algorithm is actually used to take the Shack-Hartmann measurements of local tilt and turn them into a full phase estimate that can be passed to the deformable mirror?

1 By 2pem - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=15279624

2 Geary, Joseph M.. (1995). Introduction to Wavefront Sensors.

Say your wavefront is $$w(x,y)$$, based on the diagram above you have sub-aperture local slope movements $$\delta(x,y)$$, and

$$\nabla w = \delta(x,y) / f$$

Since for Shack-Hartmann the spatial resolution is usually low, so people fit wavefront $$w$$ to a Zernike polynomial. Denote the Zernike basis be matrix $$Z$$ and coefficients be $$a$$, then

$$w = Za$$

In principle you solve a least-squares to estimate $$a$$ first

$$a = \arg\min_a \| \nabla Za - \delta/f \|^2 = \left((\nabla Z)^T\nabla Z\right)^{-1} (\nabla Z)^{T}\delta/f$$

Now you got the Zernike coefficients. And you would like to pass it to the deformable mirrors, which as @Carl mentioned contains many actuators. Say the commands to each actuator is a vector $$c$$, there is a command matrix $$C$$ that maps the commands to actual shape on the deformable mirror. In math

$$d = Cc$$

where $$d$$ the shape of the deformable mirror. Also since Shack-Hartmann and deformable mirror are in conjugate, there is another matrix describing this linear relationship, denoted as $$M$$. And

$$w = M d$$

One way to interpret matrix $$M$$ is, say your Zernike-fitted wavefront (i.e. $$w = Za$$) covers a square Shack-Hartmann sensor size of $$\sqrt{n} \times \sqrt{n}$$ $$\text{mm}^2$$. Your deformable mirror, at the conjugate plane, covers another square area of $$\sqrt{m} \times \sqrt{m}$$ $$\text{mm}^2$$. Assuming same sampling rate (e.g. 1 discretized pixel per $$\text{mm}^2$$), then:

$$w \in \mathbb{R}^n \quad d \in \mathbb{R}^m \quad \text{and} \quad M \in \mathbb{R}^{n \times m}$$

Of course the actual number of $$n$$ and $$m$$ depends on your manual specification on the resolution.

Another way to interpret $$M$$ is, $$M$$ models aperture occlusion as well. For simplicity say $$n = m$$, then $$M$$ is a square matrix. If you wavefront sensor covers area outside of the deformable mirror, you can just let those areas be zeros in corresponding position of $$M$$. Now $$M$$ is a diagonal matrix whose elements are either 1 or 0 (in ideal case). Diffraction or any setup misalignment will make $$M$$ not diagonal anymore.

Now go back to the formulation. Put it together

$$w = M d = MC c$$

Since you got $$w$$ but want $$c$$, so you need to invert the above system matrix $$MC$$, that is

$$c = (MC)^{-1} w = (MC)^{-1} Z a$$

where $$a$$ is the coefficients you solved from the least squares above. Usually $$(MC)^{-1}$$ is calibrated before the whole adaptive optics loop. So in real time correction you need only to solve $$a$$ and then pass it to the calibrated system to yield the reversal mirror shape.

• I appreciate this detail. Would you be willing to expound on the usage of M? – Steve Sep 30 '18 at 20:50
• @Steve Sure. Please see my edited answer. – WDC Sep 30 '18 at 21:09

Speaking as one who has dealt with those equations (and those problems) since 1984.

Yes, the simplest approach is to use matrix methods to force the phases at the edges of every subaperture to be the same. The assumption is that there is no phase tearing , and if there were, adaptive optics pretty much would be unable to handle such disruptions. Once the full "map" is constructed, the mean value is removed (aka the "piston" term, zeroth Zernike) to reduce the overall stroke requirement on the deformable mirror (DM). In most systems, the mean tip & tilt values (first Zernike terms) are removed as well and passed off to a full aperture tip/tilt correction mirror. Again, that reduces overall stroke requirements on the DM.

There's lots more in practice, because the subaperture actuators on the DM (other that segmented ones, which have a host of other problems) have what's known as the "influence function". That is, moving an actuator essentially creates a "hill" or "valley" over a decent region of the mirror. These influence functions may or may not overlap neighboring actuators, depending on the mirror design, but in any case the final correction matrix has to take into account the difference between an idealized subaperture tip/tilt correction and what the mirror actually can do.

Follow that up with spatial and temporal (history) noise reduction filters, and off you go.

Now, back to the start: the constant of proportionality between Hartmann spot motion and phase tilt (or tip) is a simple function of the lens focal length. Draw the triangle consisting of the optic axis distance from lenslet to image plane (i.e. lens focal length), the distance from the origin to the centroid of the spot image, and the hypotenuse from the center of the lens to the centroid of the spot. You can thus easily see that the tilt is the difference between the length of the hypotenuse and the focal length. Convert that from meters (or microns) to wavelengths of the sensing light, and there you are.