Data preparation and evaluation techniques for x-ray diffraction microscopy

The post-experiment processing of X-ray Diffraction Microscopy data is often time-consuming and difficult. This is mostly due to the fact that even if a preliminary result has been reconstructed, there is no definitive answer as to whether or not a better result with more consistently retrieved phases can still be obtained. We show here that the first step in data analysis, the assembly of two-dimensional diffraction patterns from a large set of raw diffraction data, is crucial to obtaining reconstructions of highest possible consistency. We have developed software that automates this process and results in consistently accurate diffraction patterns. We have furthermore derived some criteria of validity for a tool commonly used to assess the consistency of reconstructions, the phase retrieval transfer function, and suggest a modified version that has improved utility for judging reconstruction quality. © 2010 Optical Society of America OCIS codes: (110.7440) X-ray imaging; (050.1940) Diffraction; (110.3010) Image reconstruction techniques; (110.4280) Noise in imaging systems References and links 1. X. Huang,H. Miao, J. Steinbrener, J. Nelson, D. Shapiro, A. Stewart, J. Turner, and C. Jacobsen, “Signal-tonoise and radiation exposure considerations in conventional and diffraction x-ray microscopy”, Opt. Express 17, 13541–13553 (2009). 2. M. Howells, T. Beetz, H. Chapman, C. Cui, J. Holton, C. Jacobsen, J. Kirz, E. Lima, S. Marchesini, H. Miao, D. Sayre, D. Shapiro, J. Spence, and D. Starodub, “An assessment of the resolution limitation due to radiationdamage in x-ray diffraction microscopy”, J. Elec. Spectroscopy and Related Phenom. 170, 4–12 (2009). 3. D. Sayre, “Some implications of a theorem due to Shannon”, Acta Cryst. 5, 843 (1952). 4. J. Miao, P. Charalambous, J. Kirz, and D. Sayre, “An extension of the methods of x-ray crystallography to allow imaging of micron-size non-crystalline specimens”, Nature (London) 400, 342–344 (1999). 5. J. Miao, K. Hodgson, T. Ishikawa, C. Larabell, M. LeGros, and Y. Nishino, “Imaging whole escherichia coli bacteria by using single-particle x-ray diffraction”, Proc. Nat. Acad. Sci. 100, 110–112 (2003). 6. D. Shapiro, P. Thibault, T. Beetz, V. Elser, M. Howells, C. Jacobsen, J. Kirz, E. Lima, H. Miao, A. M. Neiman, and D. Sayre, “Biological imaging by soft x-ray diffraction microscopy”, Proc. Nat. Acad. Sci. 102, 15343–15346 (2005). 7. X. Huang, J. Nelson, J. Kirz, E. Lima, S. Marchesini, H. Miao, A. Neiman, D. Shapiro, J. Steinbrener, A. Stewart, J. Turner, and C. Jacobsen, “Soft x-ray diffraction microscopy of a frozen hydrated yeast cell”, Phys. Rev. Lett. 103, 198101 (2009). #130677 $15.00 USD Received 25 Jun 2010; revised 7 Aug 2010; accepted 10 Aug 2010; published 16 Aug 2010 (C) 2010 OSA 30 August 2010 / Vol. 18, No. 18 / OPTICS EXPRESS 18598 8. I. Robinson, I. Vartanyants, G. Williams, M. Pfeifer, and J. Pitney, “Reconstruction of the shapes of gold nanocrystalsusing coherent x-ray diffraction”, Phys. Rev. Lett. 87, 195505 (2001). 9. H. Chapman, A. Barty, S. Marchesini, A. Noy, S. P. Hau-Riege, C. Cui, M. Howells, R. Rosen, H. He, J. Spence, U. Weierstall, T. Beetz, C. Jacobsen, and D. Shapiro, “High resolution ab i itio three-dimensional x-ray diffraction microscopy”, J. Opt. Soc. Am. A23, 1179–1200 (2006). 10. J. Miao, C.-C. Chen, C. Song, Y. Nishino, Y. Kohmura, T. Ishikawa, D. Ramunno-Johnson, T.-K. Lee, and S. H. Risbud, “Three-dimensional GaN-Ga 2O3 core shell structure revealed by x-ray diffraction microscopy”, Phys. Rev. Lett.97, 215503 (2006). 11. A. Barty, S. Marchesini, H. N. Chapman, C. Cui, M. R. Howells, D. A. Shapiro, A. M. Minor, J. C. H. Spence, U. Weierstall, J. Ilavsky, A. Noy, S. P. Hau-Riege, A. B. Artyukhin, T. Baumann, T. Willey, J. Stolken, T. van Buuren, and J. H. Kinney, “Three-dimensional coherent x-ray diffraction imaging of a ceramic nanofoam: Determination of structural deformation mechanisms”, Phys. Rev. Lett. 101, 055501 (2008). 12. Y. Nishino, Y. Takahashi, N. Imamoto, T. Ishikawa, and K. Maeshima, “Three-dimensional visualization of a human chromosome using coherent x-ray diffraction”, Phys. Rev. Lett. 102, 018101 (2009). 13. J. Fienup, “Reconstruction of an object from the modulus of its Fourier transform”, Opt. Lett. 3, 27–29 (1978). 14. J. Fienup, “Phase retrieval algorithms: a comparison”, Appl. Opt. 21, 2758–2769 (1982). 15. V. Elser, “Phase retrieval by iterated projections”, J. Opt. Soc. Am. A 20, 40–55 (2003). 16. S. Marchesini, H. He, H. Chapman, S. Hau-Riege, A. Noy, M. Howells, U. Weierstall, and J. Spence, “X-ray image reconstruction from a diffraction pattern alone”, Phys. Rev. B 68, 140101 (2003). 17. K. A. Nugent, A. G. Peele, H. M. Quiney, and H. N. Chapman, “Diffraction with wavefront curvature: a path to unique phase recovery”, Acta Cryst. A 61, 373–381 (2005). 18. G. J. Williams, H. M. Quiney, B. B. Dhal, C. Q. Tran, K. A. Nugent, A. G. Peele, D. Paterson, and M. D. de Jonge, “Fresnel coherent diffractive imaging”, Phys. Rev. Lett. 97, 025506 (2006). 19. J. Rodenburg and R. Bates, “The theory of super-resolution electron microscopy via wigner-distribution deconvolution”, Phil. Trans. Roy. Soc. (London) 339, 521–553 (1992). 20. J. Rodenburg, A. Hurst, A. Cullis, B. Dobson, F. Pfeiffer, O. Bunk, C. David, K. Jefimovs, and I. Johnson, “Hard-x-ray lensless imaging of extended objects”, Phys. Rev. Lett. 98, 034801 (2007). 21. P. Thibault, M. Dierolf, A. Menzel, O. Bunk, C. David, and F. Pfeiffer, “High-resolution scanning x-ray diffraction microscopy”, Science 321, 379–382 (2008). 22. A. M. Maiden and J. M. Rodenburg, “An improved ptychographical phase retrieval algorithm for diffractive imaging”, Ultramicroscopy109, 1256–1262 (2009). 23. B. Abbey, K. Nugent, G. Williams, J. Clark, A. Peele, M. Pfeifer, M. de Jonge, and I. McNulty, “Keyhole coherent diffractive imaging”, Nature Physics 4, 394–398 (2008). 24. P. Thibault, V. Elser, C. Jacobsen, D. Shapiro, and D. Sayre, “Reconstruction of a yeast cell from x-ray diffraction data”, Acta Cryst. A62, 248–261 (2006). 25. J. Nelson, X. Huang, J. Steinbrener, D. Shapiro, J. Kirz, S. Marchesini, A. M. Neiman, J. J. Turner, and C. Jacobsen, “High-resolution x-ray diffraction microscopy of specifically labeled yeast cells”, Proc. Nat. Acad. Sci. 107, 7235–7239 (2010). 26. J. Miao, T. Ishikawa, B. Johnson, E. Anderson, B. Lai, and K. Hodgson, “High resolution 3D x-ray diffraction microscopy”, Phys. Rev. Lett. 89, 088303 (2002). 27. C.-C. Chen, J. Miao, C. W. Wang, and T. K. Lee, “Application of optimization technique to noncrystalline x-ray diffraction microscopy: Guided hybrid input-output method”, Phys. Rev. B 76, 064113 (2007). 28. C. G. Schroer, R. Boye, J. M. Feldkamp, J. Patommel, A. Schropp, A. Schwab, S. Stephan, M. Burghammer, S. Schoeder, and C. Riekel, “Coherent x-ray diffraction imaging with nanofocused illumination”, Phys. Rev. Lett. 101, 090801 (2008). 29. K. Giewekemeyer, P. Thibault, S. Kalbfleisch, A. Beerlink, C. M. Kewish, M. Dierolf, F. Pfeiffer, and T. Salditt, “Quantitative biological imaging by ptychographic x-ray diffraction microscopy”, Proc. Nat. Acad. Sci. 107, 529–534 (2010). 30. N. Wiener,Extrapolation, Interpolation, and Smoothing of Stationary Time Series (The MIT Press, 1964). 31. C. Jacobsen, S. Williams, E. Anderson, M. T. Browne, C. J. Buckley, D. Kern, J. Kirz, M. Rivers, and X. Zhang, “Diffraction-limited imaging in a scanning transmission x-ray microscope”, Opt. Commun. 86, 351–364 (1991). 32. B. Hornberger, M. Feser, and C. Jacobsen, “Quantitative amplitude and phase contrast imaging in a scanning transmission X-ray microscope”, Ultramicroscopy 107, 644–655 (2007). 33. B. L. Henke, E. M. Gullikson, and J. C. Davis, “X-ray interactions: Photoabsorption, scattering, transmission, and reflection at E=50–30,000 eV, Z=1–92”, Atomic Data and Nuclear Data Tables 54, 181–342 (1993). 34. R. A. London, M. D. Rosen, and J. E. Trebes, “Wavelength choice for soft x-ray laser holography of biological samples”, Appl. Opt. 28, 3397–3404 (1989). 35. M. H. J. Koch, M. C. Vega, Z. Sayers, and A. M. Michon, “The superstructure of chromatin and its condensation mechanism”, Eur. Biophys. J. 14, 307–319 (1987). 36. H. Wolter, “Spiegelsysteme streifenden Einfalls als abbildende Optiken f ür Röntgenstrahlen”, Annalen d. Physik 10, 94–114, 286 (1952). 37. D. Sayre, J. Kirz, R. Feder, D. M. Kim, and E. Spiller, “Transmission microscopy of unmodified biological #130677 $15.00 USD Received 25 Jun 2010; revised 7 Aug 2010; accepted 10 Aug 2010; published 16 Aug 2010 (C) 2010 OSA 30 August 2010 / Vol. 18, No. 18 / OPTICS EXPRESS 18599 materials: Comparative radiation dosages with electrons and ultrasoft x-ray photons”, Ultramicroscopy 2, 337– 341(1977). 38. J. M. Cowley and A. F. Moodie, “Fourier images. I. The point source”, Proc. Phys. Soc. B 70, 486–496 (1957).


Introduction
X-ray diffraction microscopy (XDM; also called coherent diffraction imaging or CDI) provides an alternative approach to more conventional forms of lens-based x-ray microscopy in that it does not rely on inefficient optics and thus helps reduce the radiation dose administered to the sample [1].This is especially important with regards to biological imaging where radiation dose is limiting the maximum achievable resolution [2].The idea of phase retrieval from recorded diffraction intensities alone was first conceived by Sayre in 1952 [3].The first experimental demonstration of XDM was achieved by Miao et al. in 1999 on a fabricated test pattern [4].Since then the technique has been successfully applied in 2D to biological [5][6][7] and material science samples [8], and in 3D to test structures [9], material science [10,11] and biological [12] samples.
A typical experimental setup involves recording the far-field diffraction pattern of a plane wave incident on an isolated object.Since the detector, usually a CCD, only records intensities, the phases need to be retrieved computationally using a reconstruction algorithm.The first algorithm to successfully retrieve phases from far-field intensity measurements was demonstrated by Fienup in 1978 [13].Several generalizations have since been developed [14,15], all of which are based on iteratively enforcing constraints in real and Fourier space.In Fourier space, the present guess of the complex amplitude is adjusted towards the measured Fourier magntiudes.In real space, the present guess of the object wavefield is adjusted to enforce a finite support constraint, so that pixels outside the support (the array subspace within which the object is supposed to lie) are assumed to produce no scattering.The support guess is periodically updated (either by hand or in an automated fashion using the shrinkwrap algorithm [16]) until a support is found that tightly fits the actual object.
The far-field diffraction geometry has certain advantages in experimental simplicity (no nanofocusing optics or nanopositioning stages are required), and in insensitivity to certain errors such as small shifts in the transverse position of the object (the shift theorem of Fourier transforms shows that such shifts produce only linear phase ramps in Fourier space which are not encoded in the Fourier plane intensities).At the same time, alternative experimental geometries have been developed with different tradeoffs.By using curved wavefront illumination in a near-field or Fresnel scheme [17,18] one gains more rapid and robust reconstruction convergence, while ptychographic [19][20][21][22] and keyhole [23] methods limit the illumination footprint and thus overcome the need for the object to be constrained inside a finite support.Because these other methods still involve the use of Fourier plane intensities and iterative algorithms for reconstruction, improvements to the data handling and object reconstruction of far-field methods can often be of benefit in these other techniques.
We describe here three improvements to the processing and iterative reconstruction of images from measured far-field intensities.In Sec. 2, we describe an algorithmic and automated procedure for improved merging of multiple Fourier plane intensity recordings.In Sec. 3, we show that incorporation of a Wiener filter into the phase retrieval transfer function (PRTF) improves the PRTF's interpretability and utility for judging reconstruction validity.In Sec. 4, we examine different approaches for iterate averaging [6,24] and their impact on reconstruction validity.The collective improvement on reconstructed image quality is illustrated using recent experimental data from beamline 9.0.1 at the Advanced Light Source at Lawrence Berkeley Laboratory that yielded 13 nm resolution images of specifically-labeled freeze-dried yeast cells [25].

Automated Merging Program (AMP) for Fourier intensities
When recording far-field diffraction intensities, one must be mindful of the experience in smallangle scattering that intensity I tends to drop off with spatial frequency as I( f ) ∝ f −m , where f = θ /λ is the spatial frequency and m = 3-4 with m = 4 suggested by Porod's law.Since data is usually recorded over at least two orders of magnitude range in spatial frequency, this means that the Fourier plane intensity tends to span six or more orders of magnitude.This can present challenges for many pixelated x-ray detectors; for example, in using direct detection on CCDs one generates several hundred electron-hole pairs per soft x-ray photon absorbed, which when coupled with a full-well charge capacity of 10 5 -10 6 electrons means that a dynamic range of only something over three orders of magnitude can be achieved in a single recording.(Pixel array detectors are beginning to overcome these limitations, but high pixel number detectors with good sensitivity for soft x rays are not yet widely available).As a result, a common experimental strategy is to to use an adjustable beamstop to block various parts of the strong, low spatial frequency signal while adjusting the exposure time to collect the weaker, high spatial frequency signals.These various intensity recordings must then be combined to yield a merged measurement of the Fourier plane intensities.These merged intensities must satisfy some key conditions.There should be no scaling errors between regions recorded with different exposure times.Saturated pixels should be removed before merging the raw data; as well as anomalously high pixel values due to cosmic rays incident on the CCD.Finally, noise in the raw data should be suppressed; this is especially important in the high spatial frequency regime, where the scattering signal is weak.
In previous work, we have been been merging multiple Fourier plane intensity recordings by using a per-dataset procedure based on manual adjustments of noise thresholds and requested exposure times.Besides being tedious, this has produced slight user-dependent variations in the assembled Fourier intensities.We have therefore developed an Automated Merging Program AMP to perform this task which we now describe, with its final results illustrated in Fig. 1.

Data assembly: previous practice
In a typical per-dataset assembly, the following procedure is performed for each beamstop position.Saturated pixels (where the full-well capacity of the CCD had been reached) are first removed.Next, pixels with anomalously high values due to large charge deposition by cosmic ray events are found and removed, as are pixels with anomalous values due to either manufacturing flaws or radiation-induced damage.Individual recordings are then normalized to the synchrotron beam current, after which images with the same exposure time are averaged and a noise threshold floor is applied.The area behind the beamstop is then masked.Beamnormalized averages from the different exposure times are then scaled and averaged, taking care to include only those pixels with non-zero signal.We refer to the result as a "hand-assembled" data set.

Automated assembly: improvements provided by AMP
The assembly performed by AMP improves upon this basic assembly protocol in several key areas.The first difference is a quantitative analysis of the CCD chip.Given a series of dark current images at different exposure times, AMP will calculate an average dark current and the variation in dark current either as an average for all pixels in the chip, or (if enough redundant dark current files are present) on a per-pixel basis.The variance in each pixel corresponds to the total CCD noise comprised of thermal noise and readout noise.From these data the scaling of average dark current and CCD noise with exposure time is determined from a linear fit.This dark current information is used twice: first to subtract an average dark current signal from each recorded image, and second to calculate an error value for each pixel.The latter is determined by the square root sum of CCD noise and noise due to initial photon statistics; this error array is kept throughout the entire assembly process and updated according to the rules of error propagation.It is a crucial ingredient to two other improvements that AMP introduces: weighted averages and weighted normalizations.
During the assembly process, arrays are frequently normalized with respect to some constant (such as exposure time or ring current) and subsequently averaged such that in the end there is only one data set containing all the information from all initially recorded images.Even though the arrays are normalized, problems may arise from insufficient knowledge of the normalization constants.We have found for instance that our shutter timing (which ultimately determines the exposure time) is not very accurate at short exposure times.This will lead to scaling errors between different regions of the final assembled array.To overcome this problem, AMP calculates a normalization correction based on pixels that are common to the two arrays about to be averaged.This correction is applied just after the "regular" normalization (i.e. with respect to beam current or exposure time), before the arrays are averaged.For both the calculation of the normalization correction and the averaging of two arrays, AMP makes use of their error arrays by weighting each pixel's influence on the result with its respective error.This is justified as we want pixels with smaller error to contribute more to the final result than pixels with higher uncertainties.Given two previously normalized arrays 1 and 2 with intensity values at the k-th pixel of I k,1 and I k,2 respectively, the normalization correction c is calculated from the minimum of the goodness-of-fit parameter where σ k is the effective total error for the k-th pixel.To calculate σ k we express the intensity at the k-th pixel of the i-th array I k,i as the sum of true signal and error σ k,i .With this, Eq. ( 1) becomes Rearranging the left hand side to and assuming c ≈ 1, we arrive at where we have assumed that the errors are uncorrelated, i.e. ∑ σ k,1 σ k,2 = 0. Now we can go back to the original idea and calculate the normalization constant by taking the derivative of Eq. ( 1) with respect to c Performing the derivation and solving for c, we end up with Note that the sum above is performed over pixels that are defined (i.e.greater than some threshold or zero and not saturated) in both arrays.The implementation of the weighted normalization in software is illustrated in pseudocode in the Appendix (Algorithm 1).After normalizing the arrays in the pre-described manner, we can average them.As with the normalization, we have to make sure that we give more weight to pixels with little uncertainty than to pixels with high uncertainty.Therefore AMP calculates for each pixel k the weighted average I avg k over all arrays i = 0, ...., N as where σ i,k is the previously normalized error of the k-th pixel in the i-th image.The new error σ k for each pixel can then be calculated as the square root sum of all errors of pixels that were averaged, or which can be used in subsequent analysis.The implementation of the weighted averaging in software is illustrated in pseudocode in the Appendix (Algorithm 2).
Apart from providing a more rigorous defined and consistent assembly of the data, AMP was also written to facilitate and speed up the process of assembling a 2D diffraction pattern.A simple script file indicating the names of the raw data files to be assembled is sufficient to start AMP.Given such a basic script file, AMP will attempt to infer all information it needs directly from the data; for all else, it prompts the user for input.As the assembly progresses, AMP will write important data-set-specific parameters it determined to the script file for future reference.It also automatically saves information that can be reused for a subsequent assembly of the same data and even for other data sets if applicable, such as if the same dark current parameters can be used for data sets recorded with the same CCD, or the same beamstop mask pattern for data sets that were recorded using the same beamstop.Finally, AMP will save the final assembled diffraction intensities along with meta data important for reconstruction into a custom defined file format based on the widely available, platform independent HDF5 standard.Automating these steps is especially important for data intensive three-dimensional x-ray diffraction microscopy [9,26], where 2D diffraction patterns are recorded over a wide angular range with small angular steps prior to mapping the resulting Ewald spheres into a 3D data cube.A flowchart of our software implementation of the program is shown in Fig. 8 of the Appendix.The software is also available through Concurrent Versioning System upon request.The 2D Fourier plane data assembled by the above automated procedure is referred to as "AMPassembled" data in what follows.
Figure 1 illustrates some advantages AMP-assembled data has over hand-assembled data.Subsections of the assembled diffraction intensities for both AMP-assembled data (black) and hand-assembled data (red) on a logarithmic intensity scale are shown on the left.The x-axis spatial frequency range in each case is from 0 to ≈ 48 µm −1 .The insets show a zoomed in view of the highest spatial frequencies on a false color linear scale.While the AMP-assembled array shows speckle with good contrast, the hand-assembled array is dominated by noise at these spatial frequencies.Scaling issues are present in the hand-assembled array but not in the AMP-assembled array.This is illustrated by the plot of the power spectral densities (PSD) for each array, shown on the right on a log-log scale.While the PSD of AMP-assembled data (in black) follows a straight line as would be expected for most objects, the PSD of hand-assembled data (red) changes its slope at a spatial frequency of around 10 µm −1 suggesting that low and high spatial frequency data have not been properly scaled.Another prominent difference is the occurrence of a sharp peak at ≈ 40 µm −1 in the PSD of the hand-assembled data.This peak, presumably due to a cosmic ray incident on our CCD at the time of data collection, is found in one single exposure of the recorded raw data.Due to the large standard deviation of the affected pixels it is filtered out by weighted averaging early on in the AMP assembly process.This is not true for the hand-assembled data where the peak ends up in the final assembled array, as is indicated by the white arrow in the image of the merged intensities of the hand-assembled data.We note that while a more careful assembly by hand is possible, it would be considerably more time consuming and its steps would have to be readjusted for each new data set.

Automated assembly: evaluation from reconstructed images
The ultimate judgement of the quality of data assembly comes from seeing the quality of the reconstructed image.In this section we compare images reconstructed from AMP-assembled versus hand-assembled diffraction data.Iterative phase retrieval in the far-field geometry works by finding a complex wavefield which satisfies real-space constraints such as the imposition of a finite support (and possibly others such as a limit on maximum phase variation), and the Fourier-space constraint of adjustment towards the measured diffraction magnitudes.Because reciprocal plane and real space information are related by a complex-valued Fourier transform, one can start the algorithm with random phases and converge to a solution.Since the real-space constraints are not known perfectly, and since random and systematic errors are possible in the measurement of the Fourier plane magnitudes, one cannot find a single, numerically unique solution to the complex wavefield (though in "good" reconstructions the variations between different possible solutions are small).As a result, various iterate averaging procedures have been adopted [6,9,24], based on the idea that consistent phases add coherently, while inconsistent phases add incoherently.This averaging is applied in the Fourier plane, where the magnitudes were measured but the phases were not.While Sec. 4 below involves a comparison between different iterate averaging procedures, in this section we used a variation of an already-demonstrated averaging procedure [24].
We first carried out a reconstruction where the object's support mask was found first from the autocorrelation of the diffraction pattern, then by application of the shrinkwrap algorithm [16] with occasional by-hand adjustment.This support mask was then used in 10 separate reconstructions with different random starting phases [27].In each reconstruction, the difference map algorithm [15] was used with a positivity constraint on the imaginary part of the object's exit wave (this corresponds to a maximum phase shift of π as induced by 1.5 µm of solid dry protein for X-rays of wavelength 1.65 nm), and a linear phase ramp was continuously removed (thus constraining the object to be centered in the real space array).In each of these separate reconstructions, every 50 th iterate from iterations 5,000 to 10,000 was set aside; the global or zero-spatial-frequency phase of each real-space iterate was adjusted to a common value [9], and the complex iterates were then averaged together.Finally, the 10 separate reconstructions were averaged together, again with the global phase adjusted to a common value (the global phase has no effect on diffraction intensities and thus is unconstrained by measured data).This procedure yields a reconstruction with minimal sensitivity to those phases that are poorly constrained by the data.
The images reconstructed using the above procedure on both hand-assembled and AMPassembled data are shown in Fig. 2. Magnitude is displayed as brightness, and phase as hue with a color bar illustrating the phase-hue relationship.(Note that because the global or zerospatial-frequency phase is unknown, the color bar serves only as an indicator for relative phase differences).Both reconstructions agree in key features; however, the AMP-assembled reconstruction shows less phase variation at low spatial frequencies.This is in better agreement with what would be expected from less-dense areas of the yeast cell which should have greater uniformity of projected thickness.It is also similar to the goal of maximum-entropy methods of image reconstruction, which seek to find the image with the least variation yet which is still consistent with the measured constraints.If we assume that the hand-assembled Fourier magnitudes have variations associated with erroneous assembly rather than with scattering properties of the specimen, then we would expect the reconstruction from hand-assembled magnitudes to give rise to more, but erroneous, contrast in the reconstructed image.

Wiener-filtered phase retrieval transfer function (wPRTF)
The first papers [4,5] in x-ray diffraction microscopy used the presence of measured diffraction signal as a function of spatial frequency (the power spectral density or PSD of the diffraction pattern) to estimate the resolution achieved in the reconstruction.However, the simple presence of signal is only part of the story: one must consider the presence of noise, partial coherence in the beam, and the possible presence of small scatterers outside of the assumed support constraint.Taken together, these effects can lead to a decrease in the consistency of the estimated phases, and Fourier plane pixels which cannot be reliably retrieved will not contribute useful and reproducible information to the reconstructed image.The iterative averaging procedure described in Sec.2.3 above provides a measure of the reproducibility of Fourier plane phasing through a phase retrieval transfer function (PRTF) [9] of which is essentially the square root of a similar measure called the intensity ratio [6,24].Measurement of the spatial frequency at which the PRTF has suffered a significant decline can be used to provide an estimate of the spatial resolution of the reconstructed image [6,9,24], since of course a PRTF value of 1 indicates perfectly reproducible phases while a value of 0 indicates completely random phases.Unfortunately no consensus has emerged on what PRTF value should be used to judge reconstructed image resolution, with various authors using values of about 0.4 [6], 0.1 [28], "close to zero" [29], or unspecified values [12] as their criteria.These various criteria can be evaluated by examination of Fig. 3, which shows the relationship between σ θ in Gaussian-distributed random phases, and the magnitude obtained by averaging unit-magnitude and random phase vectors.
The PRTF can also be difficult to interpret.The shaded "Not filtered" curves shown at left in Fig. 4 show the PRTF for the reconstructions of both the hand-assembled (in red) and AMPassembled (in black) Fourier plane intensities.The PRTF for the AMP-assembled data shows a steady decrease, with a "knee" at about 40 µm −1 corresponding to a real space half-period of 13 nm; this is consistent with the resolution estimated from examining real-space features [25].The PRTF for the hand-assembled reconstruction is more difficult to interpret, in that it decreases steadily to a spatial frequency of about 25 µm, but it then increases.This pathological behavior can result from a too-small support constraint, or from errors in measurement of the Fourier plane intensity, or from noise which might place consistent but erroneous structure within the support constraint.
What is needed is a way to combine the PRTF's measure of reconstruction consistency with a measure of data quality.We propose that a Wiener filter [30] provides such a measure.The Wiener filter is designed to optimally remove noise from a measured signal.It is applied in inverse space and suppresses the Fourier components of the measured signal that are dominated by noise.Here we will apply it to the PRTF to remove artifacts that are associated with noise so that it varies smoothly between 1 for signal dominated and 0 for noise dominated spatial frequencies.Since many noise sources (such as photon statistical noise, and thermal charge fluctuations in CCD detectors) are uncorrelated pixel-to-pixel, the power spectral density PSD of noise usually follows the form of the Fourier transform of a delta function: namely, a "flat" power spectrum consisting of a constant value at all spatial frequencies.The diffraction signal is much different; as was noted at the start of Sec. 2, it tends to decline as We can therefore follow a straightforward procedure to generate a Wiener filter from the power spectral density of a measured diffraction pattern: If we assume the measured signal C( f ) to consist of true signal S( f ) plus frequency independent noise N, such that its power spectral density is given by PSD then the trend of |C( f )| 2 can be found from a straight line fit in a log-log plot, while the square of the spatial frequency independent noise floor |N| can be found from where the power spectral density rolls off to a constant at high spatial frequencies.From these two quantities, we can extrapolate the square of the true signal as 2 and use this to determine the Wiener filter according to Eq. ( 11).This procedure is illustrated at right in Fig. 4; it has been used with success for image deconvolution [31] and phase contrast Fourier filtering [32] in lens-based x-ray microscopy.Application of the Wiener filter to the phase retrieval transfer function [wPRTF( f ) = W ( f ) PRTF( f )] provides an improved measure of the reconstructed image (here abbreviated as wPRTF).In Fig. 4, we show the wPRTF for the AMP-assembled and hand-assembled reconstructed images of Fig. 2. While the non-filtered PRTF of the hand-assembled data has a pathological increase at higher spatial frequencies, the wPRTF shows a sharp decrease.In addition, the wPRTF of the hand-assembled data is now below that of the AMP-assembled data, which is consistent with the improved visual impression of the reconstructed images in Fig. 2.

wPRTF and varied specimen exposures
To make sure that Wiener-filtered PRTFs are a reliable tool to assess the quality of reconstructions of a wide variety of diffraction data, we reconstructed diffraction data from a simulated object at various different incident photons per pixel values.The simulated object was designed to approximate a pair of frozen-hydrated biological cells in a 512 3 array with 15 nm pixel size, similar to simulated cells we have used in other computational studies [1].The larger cell has an outer diameter of 2.1 µm while the smaller cell has an outer diameter of 1.27 µm.Together they are embedded in a 30 nm thin layer of ice.Both cells have a 45 nm thick double-layer cell membrane made from 50/50 protein and lipid, and are filled with a 10:1 ice and protein mixture.Several lipid balls of 60 nm diameter are distributed throughout the volume of both cells.Each cell also has a cell nucleus (assumed to be filled with chromatin) with a 15 nm thin single layer cell membrane made from the same composition as the outer cell membrane.Finally, each cell has a vacuole that is filled with ice and has a 15 nm thin lipid membrane.The values of the refractive index are calculated according to tabulated data of Henke et al. [33] assuming a stoichiometric composition of H 48.6 C 32.9 N 8.9 O 8.9 S 0.3 and density of ρ = 1.35 g/cm 3 for protein, H 62.5 C 31.5 O 6.3 with ρ = 1.0 g/cm 3 for lipid [34], and H 49.95 C 24.64 N 8.66 O 15.57 P 1.07 S 0.03 and ρ = 1.527 g/cm 3 for chromatin [35].Assuming an x-ray energy within the "water window" [36,37] of 520 eV, an exit wave leaving the object was calculated using a multislice prop- The spatial frequency at which the wPRTF crosses the dashed 0.5 line is taken as effective resolution for each data set.On left, a power law fit to the power spectral density (PSD) of the data set with the highest photons per pixel value (black) is compared to a power law fit to the dose-resolution data (red) derived from the figure on the right.The magnitudes of both slopes agree within their error, indicating that the degree to which scattering decreases with spatial frequency in an object is equal to the degree at which reconstructed image resolution falls off with decreasing exposure [1].
agation process [24,38] and then propagated to the far-field.Diffraction patterns were simulated for 11 different exposures with photons per pixel values ranging from 10 1 to 10 6 , with simulated Poisson noise included [1].The power spectral density of the highest exposure diffraction pattern shown in the grey curve at left in Fig. 5 indicates that the simulated cell showed strong scattering out to a spatial frequency of about 13 µm −1 .Each data set was reconstructed similar to what has been described above for the experimental data, except that averaging was applied to every 10th iterate starting at 2,000 iterations up until a total of 10,000 iterations had been run.
Results from these simulations are shown at right in Fig. 5.As expected [1], lower exposures lead to poorer signal-to-noise values in the final reconstructions and thus poorer resolution.We took the spatial frequency at which the filtered PRTF curve falls below 0.5 as a measure of the effective resolution of the reconstruction at each photon exposure value.These values are plotted as red + marks at left in Fig. 5; plotting the values against the simulated photons per pixel values results in a power-law fit with an exponent of 3.68 ± 0.36 (after excluding resolution measures above the 13 µm −1 spatial frequency at which there was little signal present in the simulated object; these are shown as red × marks).Also shown in Fig. 5 is a fit to the power spectral density of the highest exposure diffraction pattern; this gave a slope of −3.59 ± 0.04.The magnitude of both exponents agree within error; this is as expected, since one needs signal at a spatial frequency to see structure over the corresponding length scale, so that achievable resolution should follow the same spatial frequency trend with exposure as the spatial frequency content of the object does [1].The fact that the Wiener-filtered PRTF provides such a straightforward illustration of this result of this confirms the utility of the wPRTF measure.

Iterate averaging procedures
Iterate averaging provides a way to improve image reproducibility, and to measure the resolution via the Wiener-filtered phase retrieval transfer function (wPRTF).In this section we to characterize the residual trend.
Figure 7 shows graphs of this analysis for reconstructions of A) the AMP-assembled data set, B) the hand-assembled data set, and C) the simulated data set.The calculated means of all 12 reconstructions with different iterate averaging frequencies are plotted as crosses with error bars indicating their standard deviation.The fitted function is plotted in red and its fit parameters are indicated for each respective graph.An arbitrary threshold of 0.001 RMS residual was chosen to define convergence of the wPRTF; it is marked in the graph by a horizontal dashed line.The number of iterates at which the fitted function falls below the threshold (i.e., the number of averages at which we declare the wPRTF to have converged) is indicated for each data set by a vertical dotted line.The reconstructions of both the AMP-assembled and the simulated data set converge after ≈ 30 averaged iterates, while the reconstruction of the hand-assembled data set converges only after about 50 averaged iterates.This result confirms that a AMP-assembly leads to data sets that have fewer systematic errors in the Fourier plane intensities.It also gives an estimate as to how many iterates need to be averaged for the PRTF to be a valid representation of the consistency in phase retrieval of a reconstruction.

Conclusion
We have developed an automated merging program, dubbed AMP, with a simple text file driven user interface that determines parameters relevant for the assembly directly from the raw data and thus speeds up the assembly process.This results in higher quality reconstructions compared to a standard hand assembly protocol, and it also aids 3D reconstructions where a large number of 2D diffraction projections need to be processed.We have looked in greater detail at the properties of the phase retrieval transfer function (PRTF), showing that the frequency of iterate averaging is not important and that averaging over 50 iterates should be sufficient for data with some degree of systematic error in the Fourier plane intensities.Finally, we propose that the PRTF be combined with a Wiener filter in a wPRTF for more reliable interpretation and estimation of the resolution of a reconstructed image.Taken together, these developments give us a more systematic understanding of the properties of finite support iterative phase retrieval of far-field diffraction data.
In summary, our studies indicate that in order to obtain high quality reconstructions one has to carefully assemble the raw data into a 2D diffraction pattern.In particular, one should perform weighted averaging and calculate a weighted normalization factor from commonly defined pixels.To evaluate both reconstruction consistency and maximum information transfer, one should use a Wiener-filtered PRTF, where the Wiener filter is determined from the PSD of the reconstructed image.This measurement will be valid if at least 50 iterates have been averaged to obtain the final result.for i = 0 to n − 1; i = k do using indices all k , calculate σ using Eq. ( 5) and c for arrays [i] and arrays[k] using Eq. ( 7) arrays[i] * = c end for else {normalizing in pairs instead} n i j ← number of elements of indices i j p, q ← indices of maxval(n i j ) for l = 0 to n − 2 do calculate total error σ from stddev[p] and stddev[q] using Eq. ( 5) using indices pq , calculate c for arrays[p] and arrays[q] according to Eq. ( 7) arrays[p] * = c p, q ← p, q n p q ← 0 p, q ← indices of maxval(n p * , n * q) end for end if

Fig. 1 .
Fig.1.Assembled diffraction intensities of data collected on a freeze-dried labeled yeast cell.On the left, the same quadrant of the entire array is shown on a false color logarithmic scale for both AMP-assembled data (in black) and data assembled by hand (in red).An inset shows the highest spatial frequencies of the merged intensities on a false color linear scale.The AMP-assembled intensities show good contrast for speckles all the way to highest spatial frequencies where the hand assembled intensities are dominated by noise.On the right, the power spectral densities for both arrays are plotted on a log-log scale.The handassembled data does not follow a straight power law indicating scaling errors between low and high spatial frequency data.The peak at 40 µm −1 in the PSD of the hand-assembled data is due to a cosmic ray; its location is indicated by the white arrow.

#Fig. 2 .
Fig.2.Final averaged reconstructions of both AMP-assembled diffraction intensities and hand-assembled diffraction intensities obtained in experiments on gold-labeled freezedried yeast[25].Magnitude is represented as brightness and phase as hue according to the inset color bar.The hand-assembled reconstruction shows streaks and other variations in intensity that would not be expected in the cell; the AMP-assembled reconstruction provides an improved visual appearance.

Fig. 3 .Fig. 4 .
Fig.3.The magnitude resulting from a sum of random phases with Gaussian phase distribution characterized by σ θ , calculated for a range of values of σ θ .Since the phase retrieval transfer function or PRTF measures the magnitude (at a particular spatial frequency) of the average of many iterates, this figure provides insight into the range of phase variations between the iterates.

Fig. 8 .
Fig. 8. Flowchart of AMP.The processes in red involve weighted normalization and weighted averaging as described in Sec.2.2 and outlined in pseudocode in Algorithm 1 and Algorithm 2, respectively.