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

<p>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 &amp; 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.  </p>

<p>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.  </p>

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

<p>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. </p>

CC BY-SA 4.0
2018-09-19T18:18:21.427Z
2018-09-19T18:18:21.427Z
Carl Witthoft
<p>Just adding some math.</p>

<p><a href="https://i.sstatic.net/dKnAw.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dKnAw.jpg" alt="Shack-Hartmann wavefront sensor"></a></p>

<p>Say your wavefront is <span class="math-container">$w(x,y)$</span>, based on the diagram above you have sub-aperture local slope movements <span class="math-container">$\delta(x,y)$</span>, and</p>

<p><span class="math-container">$$\nabla w = \delta(x,y) / f$$</span></p>

<p>Since for Shack-Hartmann the spatial resolution is usually low, so people fit wavefront <span class="math-container">$w$</span> to a Zernike polynomial. Denote the Zernike basis be matrix <span class="math-container">$Z$</span> and coefficients be <span class="math-container">$a$</span>, then</p>

<p><span class="math-container">$$w = Za$$</span></p>

<p>In principle you solve a least-squares to estimate <span class="math-container">$a$</span> first</p>

<p><span class="math-container">$$ a = \arg\min_a \| \nabla Za - \delta/f \|^2 = \left((\nabla Z)^T\nabla Z\right)^{-1} (\nabla Z)^{T}\delta/f$$</span></p>

<p>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 <span class="math-container">$c$</span>, there is a command matrix <span class="math-container">$C$</span> that maps the commands to actual shape on the deformable mirror. In math</p>

<p><span class="math-container">$$d = Cc$$</span></p>

<p>where <span class="math-container">$d$</span> 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 <span class="math-container">$M$</span>. And</p>

<p><span class="math-container">$$ w = M d $$</span></p>

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

<p><span class="math-container">$$ w \in \mathbb{R}^n \quad d \in \mathbb{R}^m \quad  \text{and} \quad M \in \mathbb{R}^{n \times m}$$</span></p>

<p>Of course the actual number of <span class="math-container">$n$</span> and <span class="math-container">$m$</span> depends on your manual specification on the resolution.</p>

<p>Another way to interpret <span class="math-container">$M$</span> is, <span class="math-container">$M$</span> models aperture occlusion as well. For simplicity say <span class="math-container">$n = m$</span>, then <span class="math-container">$M$</span> 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 <span class="math-container">$M$</span>. Now <span class="math-container">$M$</span> is a diagonal matrix whose elements are either 1 or 0 (in ideal case). Diffraction or any setup misalignment will make <span class="math-container">$M$</span> not diagonal anymore. </p>

<p>Now go back to the formulation. Put it together</p>

<p><span class="math-container">$$w = M d = MC c$$</span></p>

<p>Since you got <span class="math-container">$w$</span> but want <span class="math-container">$c$</span>, so you need to invert the above system matrix <span class="math-container">$MC$</span>, that is</p>

<p><span class="math-container">$$c = (MC)^{-1} w = (MC)^{-1} Z a$$</span></p>

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

CC BY-SA 4.0
2018-09-30T20:50:38.923Z
I appreciate this detail. Would you be willing to expound on the usage of M?
Steve
CC BY-SA 4.0
2018-09-30T21:09:44.080Z
@Steve Sure. Please see my edited answer.
WDC
CC BY-SA 4.0
2018-09-20T02:36:44.127Z
2018-09-30T21:09:28.607Z
2018-09-30T21:09:28.607Z
WDC
<p>I have a technical question regarding the Shack-Hartmann sensor in deformable mirrors.  <strong>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?</strong></p>

<p><a href="https://i.sstatic.net/g1g48.png" rel="noreferrer"><img src="https://i.sstatic.net/g1g48.png" alt="Adaptive Optics Diagram"></a></p>

<p>(Source: Wikipedia<sup>1</sup>)</p>

<p>I see that the the sensor itself can generate an estimate of the <em>derivative</em> 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$:</p>

<p>$\frac{dw}{dx} \propto \delta_x $ and $\frac{dw}{dy} \propto \delta_y $</p>

<p>Geary's Introduction to wavefront sensors<sup>2</sup> has the following diagram:</p>

<p><a href="https://i.sstatic.net/zGLbe.png" rel="noreferrer"><img src="https://i.sstatic.net/zGLbe.png" alt="Geary Diagram"></a></p>

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

<p>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?</p>

<p><sup>1</sup> By 2pem - Own work, CC BY-SA 3.0, <a href="https://commons.wikimedia.org/w/index.php?curid=15279624" rel="noreferrer">https://commons.wikimedia.org/w/index.php?curid=15279624</a></p>

<p><sup>2</sup> Geary, Joseph M.. (1995). Introduction to Wavefront Sensors.</p>

<adaptive-optics>
Adaptive Optics Shack-Hartmann Sensor and Deformable Mirror
Steve
# Adaptive Optics Shack-Hartmann Sensor and Deformable Mirror

(Asked by: username_0 on 2018-09-18)

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?**

[![Adaptive Optics Diagram](https://i.sstatic.net/g1g48.png)](https://i.sstatic.net/g1g48.png)

(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:

[![Geary Diagram](https://i.sstatic.net/zGLbe.png)](https://i.sstatic.net/zGLbe.png)

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.

**Tags:** adaptive-optics


---

## 2 answers

### Answer by username_2 on 2018-09-20. Score: 4 | Accepted answer

Just adding some math.

[![Shack-Hartmann wavefront sensor](https://i.sstatic.net/dKnAw.jpg)](https://i.sstatic.net/dKnAw.jpg)

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 @username_1 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.

> **Comments:**
> **username_0**: I appreciate this detail. Would you be willing to expound on the usage of M?  
> **username_2**: @username_0 Sure. Please see my edited answer.  

---

### Answer by username_1 on 2018-09-19. Score: 4

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.


---

