# Overview of the Iterative Algorithm for Phase Retrieval

In the previous post, the reason that only oversampled patterns can be reconstructed was introduced.

The next question is then–how do we construct these patterns and how can we retrieve the phase quantitatively? Here’s a overview of the iterative algorithm that is popular in the “Phase Retrieval world”, especially for nonperiodic objects.

First, let’s list out a few possible constraints, including the one we introduced in the last post, that we usually apply to the retrieval process to make sure that the phase we get back is what we originally have:

1) Creating known-valued pixels. For example, we could create an object with some non-scattering density (zero-valued pixels) inside it, such as the center of the object. In this method, a concept similar to the oversampling ratio comes about, which is a ratio calculated by “total pixel number/unknown-valued pixel number”. This has to be larger than 2 for the reconstruction, just as the oversampling ratio has to be larger than 2.

2) The previous introduced Oversampling method. Basically, with an oversampling ratio larger than 2, we can create a finite support for the object where the pixels outside this support are all zero, creating zero-pixels constraints again.

3) Apart from the external constraints of 1) and 2), we also have an internal constraint which is the positivity constraint. A complex valued object density can be expressed using complex atomic scattering factor, f1+if2. f1 is the effective number of electrons that diffract the photons in phase, which is usually positive. f2 is the attenuation and is also positive for ordinary matter. So the fact that these two values should usually be positive could serve as positivity constraints for the phase retrieval process.

Now that we’ve learned all the constraints, we should look at how the retrieval method is actually carried out through the iterative algorithm:

1) The measured magnitude of the Fourier transform is obtained through the diffraction pattern. We will combine it with a randomly created phase set and generate a new Fourier transform.

2) This Fourier transform is then inversely fast Fourier Transformed to create a new “image density”.

3) Through the oversampling ratio, a finite support is defined in real space for the separation of the density and no density region. For density outside the support, we enforce it to be 0, and for the density inside, we enforce the positivity constraints. These are usually enforced by the following equations, where f ‘ is the object density before applying the constraints and f is object density after conforming to constraints (which is also the S set).  The second line is to set pixels outside the support gradually to zero, and the “f1” “f2” increase at every iteration until both positive. After these are constraints enforced, we can obtain a new image density f that belongs to S.

4) With the new image density after the enforced constraints, we obtain a new Fourier transform of the image and adopt its phase set while restoring its central pixels to zero (the center of a diffraction pattern can not be experimentally measured). We have a new phase set which we can combine with the magnitude of the Fourier Transform again.

Usually after a few hundreds to thousands of iterations like this, convergence would be complete and we will be able to reconstruct the original image through retrieved phases.