Overview

BcdiStrain 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

BcdiStrain.StateType
State(intensities, gVecs, recSupport)
State(intensities, gVecs, recSupport, support)

Create a reconstruction object. intensities is a vector of fully measured diffraction peaks, gVecs is a vector of peak locations, and recSupport is a vector of masks over the intensities that removes those intenities from the reconstruction process.

The initialization process shifts each 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
BcdiStrain.ERType
ER()

Create an object that applies one iteration of Error Reduction (ER) to the currently Mounted peak. 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
BcdiStrain.HIOType
HIO(beta)

Create an object that applies an iteration of hybrid input-output (HIO) to the currently Mounted peak. 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
BcdiStrain.ShrinkType
Shrink(threshold, sigma, state::State)

Create an object that applies one iteration of the shrinkwrap algorithm to the current real space object. 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
BcdiStrain.CenterType
Center(state)

Create an object that centers the current real space object. 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
BcdiStrain.MountType
Mount(beta, state, primitiveRecipLattice)

Create an object that mounts a new peak. The current real space object is projected back to update the magnitude of the electron density and the displacement field. A new peak is selected at random and the current solution is projected out to this peak.

The paper that describes this algorithm is currently in submission.

source