# Direct methods (electron microscopy)

In crystallography, direct methods is a set of techniques used for structure determination using diffraction data and a priori information. It is a solution to the crystallographic phase problem, where phase information is lost during a diffraction measurement. Direct methods provides a method of estimating the phase information by establishing statistical relationships between the recorded amplitude information and phases of strong reflections.

## Background
### Phase Problem

In electron diffraction, a diffraction pattern is produced by the interaction of the electron beam and the crystal potential. The real space and reciprocal space information about a crystal structure can be related through the Fourier transform relationships shown below, where $f({\textbf {r}})$ is in real space and corresponds to the crystal potential, and $F({\textbf {k}})$ is its Fourier transform in reciprocal space. The vectors ${\textbf {r}}$ and ${\textbf {k}}$ are position vectors in real and reciprocal space, respectively.
    $f({\textbf {r}})=\int _{-\infty }^{\infty }F({\textbf {k}})e^{2\pi i{\textbf {k}}\cdot {\textbf {r}}}dk$
    $F({\textbf {k}})=\int _{-\infty }^{\infty }f({\textbf {r}})e^{-2\pi i{\textbf {k}}\cdot {\textbf {r}}}dr$
$F({\textbf {k}})$, also known as the structure factor, is the Fourier transform of a three-dimensional periodic function (i.e. the periodic crystal potential), and it defines the intensity measured during a diffraction experiment. $F({\textbf {k}})$ can also be written in a polar form $F({\textbf {g}})$, where ${\textbf {g}}$ is a specific reflection in reciprocal space. $F({\textbf {g}})$ has an amplitude term (i.e. $|F({\textbf {g}})|$) and a phase term (i.e. $e^{i\phi _{g}}$). The phase term contains the position information in this form.
    $F({\textbf {g}})=|F({\textbf {g}})|e^{i\phi _{g}}$
During a diffraction experiment, the intensity of the reflections are measured as $I({\textbf {g}})$:
    $I({\textbf {g}})=|F({\textbf {g}})|^{2}$
This is a straightforward method of obtaining the amplitude term of the structure factor. However, the phase term, which contains position information from the crystal potential, is lost.
Analogously, for electron diffraction performed in a transmission electron microscope, the exit wave function of the electron beam from the crystal in real and reciprocal space can be written respectively as:
    $\psi ({\textbf {r}})=a({\textbf {r}})e^{-i\phi ({\textbf {r}})}$
    $\Psi ({\textbf {u}})=A({\textbf {u}})e^{-i\phi ({\textbf {u}})}$
Where $a({\textbf {r}})$ and $A({\textbf {u}})$ are amplitude terms, the exponential terms are phase terms, and ${\textbf {u}}$ is a reciprocal space vector. When a diffraction pattern is measured, only the intensities can be extracted. A measurement obtains a statistical average of the moduli:
    $I({\textbf {r}})=\langle |\psi ({\textbf {r}})|^{2}\rangle =\langle |a({\textbf {r}})|^{2}\rangle$
    $I({\textbf {u}})=\langle |\Psi ({\textbf {u}})|^{2}\rangle =\langle |A({\textbf {u}})|^{2}\rangle$
Here, it is also clear that the phase terms are lost upon measurement in an electron diffraction experiment. This is referred to as the crystallographic phase problem.

### History

In 1952, David Sayre introduced the Sayre equation, a construct that related the known phases of certain diffracted beams to estimate the unknown phase of another diffracted beam. In the same issue of Acta Crystallographica, Cochran and Zachariasen also independently derived relationships between the signs of different structure factors. Later advancements were done by other scientists, including Hauptman and Karle, leading to the awarding of the Nobel Prize in Chemistry (1985) to Hauptman and Karle for their development of direct methods for the determination of crystal structures.

### Comparison to X-Ray Direct Methods

The majority of direct methods was developed for X-ray diffraction. However, electron diffraction has advantages in several applications. Electron diffraction is a powerful technique for analyzing and characterizing nano- and micron-sized particles, molecules, and proteins. While electron diffraction is often dynamical and more complex to understand compared to X-ray diffraction, which is usually kinematical, there are specific cases (detailed later) that have sufficient conditions for applying direct methods for structure determination.

## Theory
### Unitary Sayre Equation

The Sayre equation was developed under certain assumptions taken from information about the crystal structure, specifically that all atoms considered are identical and there is a minimum distance between atoms. Called the "Squaring Method," a key concept of the Sayre equation is that squaring the electron-density function (for X-ray diffraction) or crystal potential function (for electron diffraction) results in a function that resembles the original un-squared function of identical and resolved peaks. By doing so, it reinforces atom-like features of the crystal.
Consider the structure factor $F({\textbf {k}})$ in the following form, where $f({\textbf {k}})$ is the atomic scattering factor for each atom at position ${\textbf {k}}$, and ${\textbf {r}}$ is the position of atom $l$:
    $F({\textbf {k}})=\sum _{l}f({\textbf {k}})e^{2\pi {\textbf {k}}\cdot {\textbf {r}}_{l}}$
This can be converted to the unitary structure factor $U({\textbf {k}})$ by dividing by N (the number of atoms) and $f({\textbf {k}})$:
    $U({\textbf {k}})={\frac {1}{N}}\sum _{l}e^{2\pi {\textbf {k}}\cdot {\textbf {r}}_{l}}$
This can be alternatively rewritten in real and reciprocal space as:
    $u({\textbf {r}})={\frac {1}{N}}\sum _{l}\delta ({\textbf {r}}-{\textbf {r}}_{l})=Nu({\textbf {r}})^{2}$
    $U({\textbf {k}})=N\sum _{h}U({\textbf {k-h}})U({\textbf {h}})$
This equation is a variation of the Sayre equation. Based on this equation, if the phases of $U({\textbf {k-h}})$ and $U({\textbf {h}})$ are known, then the phase of $U({\textbf {k}})$ is known.

### Triplet Phase Relationship

The triplet phase relationship is an equation directly relating two known phases of diffracted beams to the unknown phase of another. This relationship can be easily derived via the Sayre equation, but it may also be demonstrated through statistical relationships between the diffracted beams, as shown here.
For randomly distributed atoms, the following holds true:
    $N\langle U({\textbf {k-h}})U({\textbf {h}})\rangle ={\frac {1}{N}}\sum _{l}e^{2\pi i{\textbf {k}}\cdot {\textbf {r}}_{l}}=U({\textbf {k}})$
Meaning that if:
    $U({\textbf {k}})\approx N\langle U({\textbf {k-h}})U({\textbf {h}})\rangle$
Then:
    $|U({\textbf {k}})-NU({\textbf {k-h}})U({\textbf {k}})|^{2}=|U({\textbf {k}})|^{2}+N^{2}|U({\textbf {k-h}})U({\textbf {h}})|^{2}-2N|U({\textbf {k}})U({\textbf {k-h}})U({\textbf {h}})|\times cos(\phi ({\textbf {k}})-\phi ({\textbf {k-h}})-\phi ({\textbf {h}}))$
In the above equation, $\langle |U({\textbf {k}})-NU({\textbf {k-h}})U({\textbf {k}})|^{2}\rangle =0$ and the moduli are known on the right hand side. The only unknown terms are contained in the cosine term that includes the phases. The central limit theorem can be applied here, which establishes that distributions tend to be Gaussian in form. By combining the terms of the known moduli, a distribution function can be written that is dependent on the phases:
    $P(U({\textbf {k}})-NU({\textbf {k-h}})U({\textbf {k}}))\approx Ce^{-|U({\textbf {k}})-NU({\textbf {k-h}})U({\textbf {k}})|^{2}}$
    $P(U({\textbf {k}})-NU({\textbf {k-h}})U({\textbf {k}}))\approx De^{2N|U({\textbf {k}})-NU({\textbf {k-h}})U({\textbf {k}})|\times cos(\phi ({\textbf {k}})-\phi ({\textbf {k-h}})-\phi ({\textbf {h}}))}$
This distribution is known as the Cochran distribution. The standard deviation for this Gaussian function scales with the reciprocal of the unitary structure factors. If they are large, then the sum in the cosine term must be:
    $\phi ({\textbf {k}})-\phi ({\textbf {k-h}})-\phi ({\textbf {h}})\approx 2n\pi ,~~n=0,1,2...$
    $\phi ({\textbf {k}})\approx \phi ({\textbf {k-h}})-\phi ({\textbf {h}})$
This is called the triplet phase relationship ($\Sigma _{2}$). If the phases $\phi ({\textbf {k-h}})$ and $\phi ({\textbf {h}})$ are known, then the phase $\phi ({\textbf {k}})$ can be estimated.

### Tangent Formula

The tangent formula was first derived in 1955 by Jerome Karle and Herbert Hauptman. It related the amplitudes and phases of known diffracted beams to the unknown phase of another. Here, it is derived using the Cochran distribution.
    $\prod _{h}P(U({\textbf {k}})-NU({\textbf {k-h}})U({\textbf {k}}))\approx 2NCe^{\sum _{h}|U({\textbf {k}})U({\textbf {k-h}})U({\textbf {k}})|\times cos(\phi ({\textbf {k}})-\phi ({\textbf {k-h}})-\phi ({\textbf {h}}))}$
The most probable value of $\phi ({\textbf {h}})$ can be found by taking the derivative of the above equation, which gives a variant of the tangent formula:
    $tan(\varphi ({\textbf {k}}))\approx {\frac {\sum _{h}|U({\textbf {k}})-NU({\textbf {k-h}})U({\textbf {h}})|sin\phi ({\textbf {k-h}})+\phi ({\textbf {h}})}{\sum _{h}|U({\textbf {k}})-NU({\textbf {k-h}})U({\textbf {h}})|cos\phi ({\textbf {k-h}})+\phi ({\textbf {h}})}}$

## Practical Considerations

The basis behind the phase problem is that phase information is more important than amplitude information when recovering an image. This is because the phase term of the structure factor contains the positions. However, the phase information does not need to be retrieved completely accurately. Often even with errors in the phases, a complete structure determination is possible. Likewise, amplitude errors will not severely impact the accuracy of the structure determination.

### Sufficient Conditions

In order to apply direct methods to a set of data for successful structure determination, there must be reasonable sufficient conditions satisfied by the experimental conditions or sample properties. Outlined here are several cases.
* Kinematical Diffraction
One of the reasons direct methods was originally developed for analyzing X-ray diffraction is because almost all X-ray diffraction is kinematical. While most electron diffraction is dynamical, which is more difficult to interpret, there are instances in which mostly kinematical scattering intensities can be measured. One specific example is surface diffraction in plan view orientation. When analyzing the surface of a sample in plan view, the sample is often tilted off a zone axis in order to isolate the diffracted beams of the surface from those of the bulk. Achieving kinematical conditions is difficult in most cases—it requires very thin samples to minimize dynamical diffraction.
* Statistical Kinematical Diffraction
Even though most cases of electron diffraction are dynamical, it is still possible to achieve scattering that is statistically kinematical in nature. This is what enables the analysis of amorphous and biological materials, where dynamical scattering from random phases add up to be nearly kinematical. Furthermore, as explained earlier, it is not critical to retrieve phase information completely accurately. Errors in the phase information are tolerable.
Recalling the Cochran distribution and considering a logarithm of that distribution:
    $D(\phi ({\textbf {k}})-\phi ({\textbf {k-h}})-\phi ({\textbf {h}}))=A({\textbf {k,h}}){\sqrt[]{I({\textbf {k}})I({\textbf {k-h}})I({\textbf {h}})}}\times cos(\phi ({\textbf {k}})-\phi ({\textbf {k-h}})-\phi ({\textbf {h}}))$
    $D(\phi ({\textbf {k}})-\phi ({\textbf {k-h}})-\phi ({\textbf {h}}))=B({\textbf {k,h}})cos(\phi ({\textbf {k}})-\phi ({\textbf {k-h}})-\phi ({\textbf {h}}))$
In the above distribution, $A({\textbf {k}})$ contains normalization terms, $I({\textbf {k}})$ terms are the experimental intensities, and $B({\textbf {k,h}})$ contains both of these for simplicity. Here, the most probable phases will maximize the function $D({\textbf {k,h}})$. If the intensities are sufficiently high and the sum in the cosine term remains $\approx 0$, then $B({\textbf {k,h}})$ will also be large, thereby maximizing $D({\textbf {k,h}})$. With a narrow distribution such as this, the scattering data will be statistically within the realm of kinematical consideration.
* Intensity Mapping
Consider two scattered beams with different intensities. The magnitude of their intensities will then have to be related to the amplitude of their corresponding scattering factors by the relationship:
    $I({\textbf {k}})>I({\textbf {k'}})~~iff~|F({\textbf {k}})|>|F({\textbf {k'}})|$
Let $T({\textbf {k}}$) be a function that relates the intensity to the phase for the same beam, where $N({\textbf {k}})$ contains normalization terms:
    $T({\textbf {k}})=e^{i\phi ({\textbf {k}})}{\sqrt[]{I({\textbf {k}})}}/N({\textbf {k}})$
Then, the distribution of $T({\textbf {k}})$ values will be directly related to the values of $F({\textbf {k}})$. That is, when the product $|F({\textbf {k}})F({\textbf {k-h}})F({\textbf {h}})|$ is large or small, $|T({\textbf {k}})T({\textbf {k-h}})T({\textbf {h}})|$ will also be large and small. So, the observed intensities can be used to reasonably estimate the phases for diffracted beams. The observed intensity can be related to the structure factor more formally using the Blackman formula.
Other cases to consider for intensity mapping are specific diffraction experiments, including powder diffraction and precession electron diffraction. Specifically, precession electron diffraction produces a quasi-kinematical diffraction pattern that can be used adequately in direct methods.
* Dominated Scattering
In some cases, scattering from a sample can be dominated by one type of atom. Therefore, the exit wave from the sample will also be dominated by that atom type. For example, the exit wave and intensity of a sample dominated by channeling can be written in reciprocal space in the form:
    $\Psi ({\textbf {k}})=A({\textbf {k}})\sum _{l}e^{2\pi i{\textbf {k}}\cdot {\textbf {r}}_{l}}$
    $I({\textbf {k}})=|A({\textbf {k}})|^{2}{\bigg |}\sum _{l}e^{2\pi i{\textbf {k}}\cdot {\textbf {r}}_{l}}{\bigg |}^{2}$
$A({\textbf {k}})$ is the Fourier transform of $a({\textbf {r}})$, which is complex and represents the shape of an atom, given by the channeling states (e.g. 1s, 2s, etc.). $A({\textbf {k}})$ is real in reciprocal space and complex in the object plane. If $B({\textbf {k}})$, a conjugate symmetric function, is substituted for $A({\textbf {k}})$, then it is feasible to retrieve atom-like features from the object plane:
    $B({\textbf {k}})=S({\textbf {k}})|A({\textbf {k}})|,where~S({\textbf {k}})=\pm 1$
In the object plane, the Fourier transform of $B({\textbf {k}})$ will be a real and symmetric pseudoatom ($b({\textbf {r}})$) at the atomic column positions. $b({\textbf {r}})$ will satisfy atomistic constraints as long as they are reasonably small and well-separated, thereby satisfying some constraints required for implementing direct methods.

## Implementation

Direct methods is a set of routines for structure determination. In order to successfully solve for a structure, several algorithms have been developed for direct methods. A selection of these are explained below.

### Gerchberg-Saxton

The Gerchberg-Saxton algorithm was originally developed by Gerchberg and Saxton to solve for the phase of wave functions with intensities known in both the diffraction and imaging planes. However, it has been generalized for any information in real or reciprocal space. Detailed here is a generalization using electron diffraction information. As illustrated in image to the right, one can successively impose real space and reciprocal constraints on an initial estimate until it converges to a feasible solution.

### Constraints

Constraints can be physical or statistical. For instance, the fact that the data is produced by a scattering experiment in a transmission electron microscope imposes several constraints, including atomicity, bond lengths, symmetry, and interference. Constraints may also be statistical in origin, as shown earlier with the Cochran distribution and triplet phase relationship ($\Sigma _{2}$).
According to Combettes, image recovery problems can be considered as a convex feasibility problem. This idea was adapted by Marks et al. to the crystallographic phase problem. With a feasible set approach, constraints can be considered convex (highly convergent) or non-convex (weakly convergent). Imposing these constraints with the algorithm detailed earlier can converge towards unique or non-unique solutions, depending on the convexity of the constraints.

### Examples

Direct methods with electron diffraction datasets have been used to solve for a variety of structures. As mentioned earlier, surfaces are one of the cases in electron diffraction where scattering is kinematical. As such, many surface structures have been solved for by both X-ray and electron diffraction direct methods, including many of the silicon, magnesium oxide, germanium, copper, and strontium titanate surfaces.
More recently, methods for automated three dimensional electron diffraction methods have been developed, such as automated diffraction tomography and rotation electron diffraction. These techniques have been used to obtain data for structure solution through direct methods and applied for zeolites, thermoelectrics, oxides, metal-organic frameworks, organic compounds, and intermetallics. In some of these cases, the structures were solved in combination with X-ray diffraction data, making them complementary techniques.
In addition, some success has been found using direct methods for structure determination with the cryo-electron microscopy technique Microcrystal Electron Diffraction (MicroED). MicroED has been used for a variety of materials, including crystal fragments, proteins, and enzymes.

## Software
### DIRDIF

DIRDIF is a computer program for structure determination through using the Patterson function and direct methods applied to difference structure factors. It was first released by Paul Beurkens and his colleagues at the University of Nijmegen in 1999. It is written in Fortran and was most recently updated in 2008. It can be used for structures with heavy atoms, structures of molecules with partly known geometries, and for certain special case structures. Detailed information can be found at its website: http://www.xtal.science.ru.nl/dirdif/software/dirdif.html.

### EDM

Electron Direct Methods is a set of programs developed at Northwestern University by Professor Laurence Marks. First released in 2004, its most recent release was version 3.1 in 2010. Written in C++, C, and Fortran 77, EDM is capable of performing image processing of high resolution electron microscopy images and diffraction patterns and direct methods. It has a standard GNU license and is free to use or modify for non-commercial purposes. It uses a feasible set approach and genetic algorithm search for solving structures using direct methods, and it also has high-resolution transmission electron microscopy image simulation capabilities. More information can be found at the website: http://www.numis.northwestern.edu/edm/index.shtml. The code is no longer being developed.

### OASIS

OASIS was first written by several scientists from the Chinese Academy of Sciences in Fortran 77. The most recent release is version 4.2 in 2012. It is a program for direct methods phasing of protein structures. The acronym OASIS stands for two of its applications: phasing One-wavelength Anomalous Scattering or Single Isomorphous Substitution protein data. It reduces the phase problem to a sign problem by locating the atomic sites of anomalous scatterers or heavy atom substitutions. More details can be found at the website: http://cryst.iphy.ac.cn/Project/IPCAS1.0/user_guide/oasis.html.

### SIR

The SIR (seminvariants representation) suite of programs was developed for solving the crystal structures of small molecules. SIR is updated and released frequently, with the first release in 1988 and the latest release in 2014. It is capable of both ab initio and non-ab-initio direct methods. The program is written in Fortran and C++ and is free for academic use. SIR can be used for the crystal structure determination of small-to-medium-sized molecules and proteins from either X-ray or electron diffraction data. More information can be found at its website: http://www.ba.ic.cnr.it/softwareic/sir2014/.