Overview

Similar to pynx and others?, BcdiTrad implements projection-based algorithms in operator-style format. This means that the multiplication (*) and power (^) operators are used to apply operators to some current state. This may look like the following:

er = BcdiTrad.ER()
hio = BcdiTrad.HIO(0.9)
state = BcdiTrad.State(intensities, trues(size(intensities)))

(er * hio^20)^5 * state

This short script applies 20 HIO iterations and one ER iterations for a total of 5 times. This makes it easy to implement very complex recipes for phase retrieval algorithms.

API

BcdiTrad.StateType
State(intensities, recSupport)
State(intensities, recSupport, support)

Create a reconstruction object. intensities is one fully measured diffraction peak and recSupport is a mask over the intensities that remove those intensities from the reconstruction process.

The initialization process shifts the peak to be centered in the Fourier sense (i.e. the center of mass of the peak is moved to the edge of the image, or the zero frequency). If the support is not passed in, an initial guess of the support is created by taking an IFFT of the intensities and including everything above 0.1 times the maximum value.

source
BcdiTrad.ERType
ER()

Create an object that applies one iteration of Error Reduction (ER). ER is an iterative projection algorithm that enforces two constraints, (1) the modulus constraint and (2) the support constraint:

  1. When moved to reciprocal space, the reconstructed object must match the diffraction pattern.
  2. The reconstructed object must fully lie within the support.

One iteration of ER first applies the modulus constraint, then the support constraint to the object, then returnns.

Gradient descent is an alternate way to view the ER algorithm becausee ER is equivalent to gradient descent with a step size of 0.5.

More information about the ER algorithm can be found in [1, 2].

source
BcdiTrad.HIOType
HIO(beta)

Create an object that applies an iteration of hybrid input-output (HIO). On the interior of the support, HIO is equivalent to applying the modulus constraint as described in the ER algorithm, and on the exterior of the support, HIO is equal to the current reconstruction minus a fraction of the output after applying the modulus constraint, that is,

\[\rho_{i+1} = \begin{cases} ER(\rho_i) & \rho \in support \\ \rho_i - \beta * ER(\rho_i) & \rho \notin support \end{cases}\]

Marchesini [2] has shown that the HIO algorithm is equivalent to a mini-max problem.

More information about the HIO algorithm can be found in [1, 2].

source
BcdiTrad.ShrinkType
Shrink(threshold, sigma, state::State)

Create an object that applies one iteration of the shrinkwrap algorithm. Shrinkwrap first applies a Gaussian blur to the current reconstruction using sigma as the width of the Gaussian. The support is then created from everything above the threshold times maximum value of the blurred object.

Further information about the shrinkwrap algorithm can be found in [3].

source
BcdiTrad.CenterType
Center(state)

Create an object that centers the current state. The center of mass of the support is calculated and the object is moved so the center of mass is centered in the Fourier transform sense. In other words, the center of mass is moved to the zeroth frequency, or the bottom left corner of the image.

source