Free Matlab Source Codes for the OverSampling Smoothness Algorithm

I. Overview :

This page describes an iterative phase retrieval algorithm, termed oversampling smoothness (OSS), which has been developed to reconstruct fine features in weakly scattered objects. The OSS algorithm, freely available here, applies a general constraint to the region outside the support of an object. OSS forces a smooth density profile onto the region outside the support by means of a convolution with a proper filter at different stages of the iterative process. By properly choosing spatial frequency filters at different stages of the iteration process, OSS finds a balance between the hybrid input-output (HIO) and error reduction (ER) to search for a global minimum, while reducing oscillations in the reconstruction. Because the smoothness constraint is applied only to a region outside the support, the spatial resolution and fine features are retained in the reconstruction [see J. A. Rodriguez, R. Xu, C.-C. Chen, Y. Zou and J. Miao, J. Appl. Cryst. 46, 312-318 (2013). in detail].

In order to search for a global minimum in solution space, we typically perform OSS starting with 100 independent runs; each of these with different phase sets as initial input. The code posted here performs only a single run and is therefore subject to variable performance (a typical result is shown below). Each run iterates back and forth between real and reciprocal space a total of 2000 times. The greater the number of independent runs performed, the greater the likelihood that a better solution can be found.

II. Implementation :

a.The Filter Function
We implement the use of , a normalized Gaussian function in Fourier space, defined as as our spatial frequency filter in Fourier space. By modifying parameter , the width of the Gaussian filter can be tuned to reduce the influence of high frequency information in the region outside the support. Note that a Gaussian function is used here, but other filter functions can be implemented to suit the needs of particular data. In the code posted here, OSS employs a 10-step function for , which is changed linearly starting on the order of N (step 1) to 1/N (step 10), where N is the array size in that dimension (shown below).

Each step consists of 200 iterations and the best set of phases with the smallest Fourier Space Error is passed on as the initial input for the next step. The smoothness is evident in the final reconstructed image (illustrated below).

In the sample data used for this simulation, Poisson noise is added to the diffraction intensity with Noise Level at 5%, defined as

Here, represents the noise free Fourier magnitudes and means the Fourier magnitudes with Poisson noise.

b. Error Measurements
Error plots are generated to show Fourier Space Error (plot shown below), calculated by,

where is a scaling factor and is the Fourier transform of , and the difference between the reconstruction and the model using Real Space Error (plot shown below), defined as,

where represents the final reconstruction by each algorithm and the model structure (shown below).

The effect of OSS is observed best in a sequence of images (shown below) showing the best reconstruction at each step (1-10) for the trial whose error plots are shown above.

III. The Matlab Source Codes of the OSS Algorithm :

The OSS Matlab source codes are freely available. Please click here to download the Matlab code and Code Instruction.

If you use these codes for your publications and/or presentations, we request you cite our paper: J. A. Rodriguez, R. Xu, C.-C. Chen, Y. Zou and J. Miao, "Oversampling smoothness (OSS): an effective algorithm for phase retrieval of noisy diffraction intensities", J. Appl. Cryst. 46, 312-318 (2013).

For any further questions, comments and/or suggestions, please contact Jose A. Rodriguez ( or Rui Xu (