A semi-implicit relaxed Douglas-Rachford algorithm (sir-DR) for Ptychograhpy

Alternating projection based methods, such as ePIE and rPIE, have been used widely in ptychography. However, they only work well if there are adequate measurements (diffraction patterns); in the case of sparse data (i.e. fewer measurements) alternating projection underperforms and might not even converge. In this paper, we propose semi-implicit relaxed Douglas Rachford (sir-DR), an accelerated iterative method, to solve the classical ptychography problem. Using both simulated and experimental data, we show that sir-DR improves the convergence speed and the reconstruction quality relative to ePIE and rPIE. Furthermore, in certain cases when sparsity is high, sir-DR converges while ePIE and rPIE fail. To facilitate others to use the algorithm, we post the Matlab source code of sir-DR on a public website (www.physics.ucla.edu/research/imaging/sir-DR). We anticipate that this algorithm can be generally applied to the ptychographic reconstruction of a wide range of samples in the physical and biological sciences.


Introduction
Since the first experimental demonstration in 1999 [1], coherent diffraction imaging (CDI) through directly inverting far-field diffraction patterns to high-resolution images has been a rapidly growing field due to its broad potential applications in the physical and biological sciences [2][3][4][5]. A fundamental problem of CDI is the phase problem, that is, the diffraction pattern measured only contains the magnitude, but the phase information is lost. In the original demonstration of CDI, phase retrieval was performed by measuring the diffraction pattern from a finite object. If the diffraction intensity is sufficiently oversampled [6], the phase information can be directly retrieved by using iterative algorithms [7][8][9][10][11]. Ptychography, a powerful scanning CDI method, relieves the finite object requirement by performing 2D scanning of an extended relative to an illumination probe and measuring multiple diffraction patterns with each illumination probe overlapped with its neighboring ones [12,13]. The overlap of the illumination probes not only reduces the oversampling requirement, but also improves the convergence speed of the iterative process. By taking advantage of ever-improving computational power and advanced detectors, ptychography has been applied to study a wide range of samples using both coherent x-rays and electrons [2,5,[14][15][16][17][18][19][20][21][22][23]. More recently, a time-domain ptychography method was developed by introducing a time-invariant overlapping region as a constraint, allowing the reconstruction of a time series of complex exit wave of dynamic processes with robust and fast convergence [24].
These iterative algorithm can be generally divided into three classes: i) the conjugate gradient (CG) [30,34], ii) extended ptychography iterative engine (ePIE) [31], and iii) difference map (DM) [13], whereas the last two have a close relationship. ePIE is an alternating projection algorithm, while DM is built on both projection and reflection which is believed to provide a momentum to speed up the convergence. The relaxed average alternating reflection (RAAR) [8] is a relaxation of DM and has been shown to be effective in phase retrieval [39]. All algorithms except ePIE take a global approach, i.e. using the entire collection of diffraction patterns to perform an update of the probe and object in each iteration. In contrast, ePIE goes through the measured data sequentially to refine the probe and object. However, ePIE has a slow convergence due to the step size restriction which may cause divergence if violated. To fix this issue, rPIE was proposed, in which regularization is used for stability [40]. The significant results also show that rPIE obtains a larger field of view (FOV) than ePIE.
In this paper, we show that DM and RAAR can also be implemented locally, similarly to ePIE. We then apply non-convex optimization tools to improve the robustness, convergence and FOV of the ptychography reconstruction. The proposed algorithm incorporates two techniques. The first modifies the update of the probe and object as the algorithm iterates via semi-implicit method or Proximal Mapping. The second technique is the implementation of relaxed Douglas Rachford, a generalized version of DM and RAAR, on the local scale.

The proposed algorithm
Given N measured diffraction patterns at N positions, the ptychographic algorithm aims to find a 2D object O and probe P that satisfy the overlap constraint and the Fourier magnitude constraint |F (PO n )| = I n for n = 1, .., N. (1) Where O n is the object at the n th scan position. Here, we omit the spatial variables for a simple notation and use the notations P, O n and I n for both continuous and discrete cases. The absolute value, multiplication, division, conjugate, and square root operators are applied element-wise on P, O n and I n which represent 2D complex matrices of the same size in the discrete case. We can argue that O n is the object restricted to a sub-domain Ω n . The overlap constraint can be mathematically interpreted as where {r n } N n=1 are displacement vectors. In short notation, we write O n = O| Ω n to imply the object is restricted to sub domain Ω n . The equivalent constraint in the discrete case is the agreement between the sub-matrix of O and O n . We find a better representation of the problem by introducing the exit wave variable Ψ = PO. By denoting the Fourier measurement constraint set T and the overlap object constraint set S, we have Then we write the ptychography problem in a minimization fashion where i S (Ψ) and i T (Ψ) are the indicator functions of sets S and T respectively, defined as To solve Eq. (3), an alternating projection method is proposed. At each iteration, we select a random position n and update Ψ n The Frobenius norm is used in this minimization problem and entire paper unless a different norm is specified. The minimization of Eq. (6) is difficult due to instability. One way to solve this non-convex problem is to minimize each variable while fixing the other ones.
This approach is unstable because of the division. A cut-off method is used to avoid the divergence and zero-division. A modification is recommended by adding a penalizing least square error term (i.e. regularizer) The idea of regularization appears throughout the literature such as proximal algorithms [41,42]. Eq. (9) is more reliable to solve than Eq. (6) but is still very expensive since the variables are coupled. P k+1 and O k+1 n can be solved via a Backward-Euler system derived from Eq. (9).
ePIE proposes a simple approximation by linearizing the system so that it can be solved sequentially.
The system is solved by alternating direction methods (ADM) [43]. The remaining part is to choose appropriate step sizes t and s to ensure stability. ePIE suggests t = β O / P k 2 max and s = β P / O k+1 2 max where β O , β P ∈ (0, 1] are normalized step sizes. The max matrix norm is the element-wise norm, taking the maximum in absolute values of all elements in the matrix. The final version of ePIE is given by We will exploit the structure of Eq. (10) to give a better approximation.

A semi-implicit algorithm
We replace the minimization of Eq. (9) by two steps Step Step 2: P k+1 = argmin This results in a better approximation to the linearized system of Eq. (11) and simpler than the Backward-Euler Eq. (10) In this uncoupled system, we can derive a closed form solution for each sub-problem.
By choosing the step sizes s and t as in the ePIE algorithm and normalizing the parameters β O and β P , we obtain This formula can be explained as a weighted average between the previous update O k n and Ψ k n P k . The object update is similar to the rPIE algorithm when rewriting it as The difference is rPIE does not have the parameter β O in front of the fraction. i.e. rPIE has a larger step size than sir-DR. This helps converge faster but might also get trapped in local minima. The regularization (weighted average) in sir-DR is more mathematically correct and enhances the algorithm's stability.
In the next section, we apply the Douglas-Rachford algorithm to solve for the exit wave Ψ.

The relaxed Douglas-Rachford algorithm
The Douglas-Rachford algorithm was originally proposed to solve the heat conduction problem [44], which represents a composite minimization problem The iteration consists of Over the past decades, this accelerated convex optimization algorithm has been exhaustively studied in both theory and practice with many applications [45][46][47][48][49][50].Here we apply the algorithm to the ptychographic phase retrieval. Note that the Douglas-Rachford algorithm reduces to Difference Map (DM) when f = i T and g = i S are characteristic functions of constraint sets T and S, respectively We realize that the reflection operator 2Π S − I helps to accelerate the convergence in the convex case and escape local minima in the non-convex case. However this momentum, caused by reflection, might be too large and can lead to over-fitting. Therefore, we relax the reflection by introducing the relaxation parameter σ ∈ [0, 1] Since the experimental measurements are contaminated by noise, a direct projection of measurement constraint is not an appropriate approach. We thus relax the Fourier magnitude constraint by a least square penalty Recall that prox t f (Ψ) has a closed form solution where τ = t/(1 + t) ∈ (0, 1) exclusively is the normalized step size. Combining this result with DM, we obtain When we let β = 1 − τ and σ = 1, the update reduces to RAAR. Therefore, we show that relaxed Douglas-Rachford is a generalized version of RAAR. We now move to our main algorithm.

The sir-DR algorithm
In combination of the semi-implicit algorithm and relaxed Douglas Rachford algorithm, we propose the sir-DR algorithm, shown in Fig. 1.
In this algorithm, we only apply the semi-implicit method on O k n while P k can be integrated with the Forward Euler (gradient descent) method. τ ∈ [0, 1] is chosen to be small. In most of our experiments, we select τ ≈ 0.1, while the choice of σ depends on the specific problem. In many cases, σ = 1 works very well (full reflection). But in some specific cases, large σ might cause divergence or small recovered FOV. We decrease σ in these cases, for example σ = 0.5. We choose β O = 0.9 in most cases. β P is chosen to be large at the beginning (β P = 1) and decreases as a function of iteration. This adaptive step-size has been introduced as a strategy for noise-robust Fourier ptychography [51].

Reconstruction from simulated data
To examine the sir-DR algorithm, we simulate a complex object of 128 × 128 pixels with a cameraman and a pepper images representing the amplitude and the phase, respectively (Fig.  2).The circular aperture is chosen as probe with a radius of 50 pixels. We raster scan the aperture over the object with a step size of 35 pixels, resulting in 4x4 scan positions. The overlap is therefore 56.4%, the approximate lower limit for ePIE to work. Poisson noise is added to the diffraction patterns with a flux of 10 8 photons per scan position. We use R noise to quantify the relative error with respect to the noise-free diffraction patterns where P 0 and O 0 is the noise-free model and the L 1,1 matrix norm represents the sum of all elements in absolute value of the matrix. The above flux results in R noise = 3.73%. Fig. 3 shows that three algorithms (ePIE, rPIE and sir-DR) all successfully reconstruct the object in the case where the overlap between adjacent positions is high and the noise level is low. As a baseline comparison, Fig. 3 shows that all three algorithms correctly reconstruct the object in the ideal case when the overlap between adjacent positions is high and the noise level is low.
Next, we apply the three algorithms to the reconstruction of sparse data, which is centrally important to reducing computation time, data storage requirements and incident dose to the sample. We increase the scan step size to 50 pixels while keeping the same field of view, which reduces the number of diffraction patterns to 3 × 3. Consequently, the overlap is reduced to 39.1%. Not only is the overlap between adjacent positions low, but the total number of measurements is also small, creating a challenging data set for conventional ptychographic algorithms. Fig. 4 show that sir-DR can work well with sparse data, while ePIE and rPIE fail to reconstruct the object faithfully.

Optical laser data
As an initial test of sir-DR with experimental data, we collect diffraction patterns from an USAF resolution pattern using a green laser with a wavelength of 543 nm. The incident illumination is created by a 15 µm diameter pinhole. The pinhole is placed approximately 6 mm in front of the sample, creating a illumination wavefront on the sample plane that can be approximated by Fresnel propagation. The detector is positioned 26 cm downstream of the sample to collect far-field diffraction patterns. We raster scan across the sample with a step size of 50 µm and acquire 169 diffraction patterns. We perform a sparsity test by randomly choosing 85 diffraction patterns (50% density) and run ePIE, rPIE, and sir-DR on this subset with 300 iterations. If we assume the probe diameter is to where the intensity falls to 10% of the maximum, then the the overlaps are 73% and 46.4% for the full and sparsity sets respectively. Fig. 5 shows that rPIE and sir-DR obtain a larger FOV than ePIE as both use regularization. Furthermore, sir-DR removes noise more effectively and obtains a flatter background than ePIE and rPIE. We monitor the R-factor (relative error) to quantify the reconstruction, defined as R F is 16.94%, 13.95% and 13.28% for the ePIE, rPIE and sir-DR reconstructions, respectively.

Synchrotron radiation data
To demonstrate the applicability of sir-DR to synchrotron radiation data, we reconstruct a ptychographic data set collected from the Advanced Light Sources [16]. In this experiment, 710 eV soft x-rays are focused onto a sample using a zone plate and the far-field diffraction patterns are collected by a detector. A 2D scan consists of 7,500 positions, which span approximately 10 × 4 µm. The sample is a portion of a HeLa cell labeled with nanoparticles, which is supported on a graphene-oxide layer. Fig. 6 shows the ePIE reconstruction of the whole FOV of the sample.
To compare the three algorithms, we choose a subdomain of a 4 × 4 µm region, consisting of 2,450 diffraction patterns. With the same assumption, the overlap is computed to be 79.5%. where sir-DR obtains a better quality reconstruction than ePIE and rPIE. Both sir-DR and rPIE produce a larger FOV than ePIE. Scale bar 200µm Fig. 7 show the ePIE, rPIE, and sir-DR reconstructions, respectively. With 300 iterations, all three algorithms converge to images with good quality. When reducing the number of iterations to 100, we observe that sir-DR converges faster and reconstruct a larger FOV than ePIE. The individual nanoparticles, which serve as a resolution benchmark, are better resolved in the sir-DR reconstruction than the ePIE and rPIE ones. Furthermore, the reconstruction by ePIE contains artifacts as a faint square grid, which is removed by rPIE and sir-DR. We next perform a sparsity test by randomly picking 980 out of 2,450 diffraction patterns, i.e. a reduction of data by 60%. The corresponding overlap of the sparsity set is 50.8%. Fig.  8 shows the reconstructions by ePIE, rPIE, and sir-DR with 300 iterations. Both the ePIE and rPIE reconstructions exhibit noticeable degradation. In particular, the nanoparticles are not well resolved. But the sir-DR reconstruction has no noticeable artifacts noise and the individual nanoparticles are clearly visible. The quality of sir-DR reconstruction with 60% data reduction is still comparable to that of ePIE using all the diffraction patterns

Conclusion
In this work, we have developed a fast and robust ptychographic algorithm, termed sir-DR. The algorithm relaxes Douglas-Rachford to improve robustness and applies a semi-implicit scheme (semi-Backward Euler) to solve for the object and to expand the reconstructed FOV. Using both simulated and experimental data, we have demonstrated that sir-DR outperforms ePIE and rPIE with sparse data. Being able to obtain good ptychographic reconstructions from sparse measurements, sir-DR can reduce the computation time, data storage requirement and radiation dose to the sample.