Ptychography

Ptychographic phase retrieval is very similar to other iterative phase retrieval algorithms—alternate back and forth between real space and Fourier space, imposing constraints as you go. There is some nuance to it, however, because it involves separating the probe from the object.

= The PIE family =

The Ptychographic Iterative Engine (PIE) and its offshoots, such as the extended PIE (ePIE) and the regularized PIE (rPIE), are a family of similar algorithms that perform iterative phase retrieval for ptychographic data. The original PIE was published in 2004, with the ePIE coming in this 2009 paper and rPIE in this 2017 paper. My derivation/explanation borrows heavily from these two papers, and I cannot stress enough how important it is to read them if you plan to implement this method.

Each PIE iteration has many sub-iterations (one for each probe position). Let’s take a look at a single sub-iteration. All the variations of the PIE start the same way. We start with the current exit wave guess for that region, which is acquired by shifting the probe to the appropriate position over the object and multiplying the overlapping parts of the arrays together. This is transformed into the Fourier plane, and the amplitude is replaced with the measured diffraction pattern. The updated Fourier plane is then transformed back. These steps are represented by the following equations:

$$\begin{aligned} \psi &= O P \label{pie:psi}\\ \Psi &= \mathcal{F}(\psi) \label{pie:PSI}\\ \Psi' &= A_{\mathrm{meas}} \frac{\Psi}{|\Psi|} \label{pie:PSI1}\\ \psi' &= \mathcal{F}^{-1}(\Psi') \label{pie:psi1} \end{aligned}$$

If you’ve done any kind of phase retrieval, this process should look a little familiar—it’s no different from the Fourier constraint in the ER and HIO algorithms. Here, though, it gets a little more tricky, because the object and probe are still all mixed up together in $\psi$, preventing us from using the ER/HIO object constraints. It’s clear that $\psi'$ is a step in the right direction, but how we use it to update the object is where the PIE variants differ.

The original PIE uses the update function

$$ O' = O + \frac{|P|P^*(\psi'-\psi)}{|P|_\mathrm{max}(|P|^2+\alpha|P|^2_\mathrm{max})}, $$

which works fairly well, but only if the probe is known. More recent PIE algorithms are able to simultaneously update both the object and the probe, which is infinitely more useful. The ePIE uses the update functions

$$\begin{aligned} O' = O + \alpha\, \frac{P^*(\psi'-\psi)}{|P|^2_{\mathrm{max}}} \label{pie:epie_obj} \\ P' = P + \beta\, \frac{O^*(\psi'-\psi)}{|O|^2_{\mathrm{max}}}\label{pie:epie_pro},\end{aligned} $$

and the rPIE uses

$$\begin{aligned} O' = O + \frac{P^*(\psi'-\psi)}{(1-\alpha)|P|^2+\alpha|P|^2_\mathrm{max}} \label{pie:rpie_obj} \\ P' = P + \frac{O^*(\psi'-\psi)}{(1-\beta)|O|^2+\beta|O|^2_\mathrm{max}}\label{pie:rpie_pro}.\end{aligned} $$

Generally speaking, rPIE is fast and coarse and ePIE is slow and fine. The two can be used sequentially or alternately to get the best of both.