## teaching and education

 JOURNAL OFAPPLIEDCRYSTALLOGRAPHY
ISSN: 1600-5767
Volume 40| Part 6| December 2007| Pages 1153-1165

## Illustrated Fourier transforms for crystallography

aLaboratoire de Cristallographie et Modélisation des Matériaux Minéraux et Biologiques, UMR UHP–CNRS 7036, Faculté des Sciences et Techniques, Nancy-Université, Boulevard des Aiguillettes, BP 239, 54506 Vandoeuvre-lès-Nancy, France
*Correspondence e-mail: emmanuel.aubert@lcm3b.uhp-nancy.fr

(Received 26 March 2007; accepted 5 September 2007)

Concepts such as Fourier transformation, convolution and resolution that are required to understand crystallography are illustrated through visual examples. These concepts can be explained pedagogically in a very direct way using the DigitalMicrograph software from Gatan Inc. (https://www.gatan.com/imaging/downloads.php ), originally intended for electron microscopy data collection and analysis, and practical exercises developed around this tool can be used in teaching crystallography.

### 1. Introduction

Teaching crystallography implies the development of concepts such as Fourier transformation, convolution, resolution etc. that are not necessarily obvious for beginners. In order to help students new to this field, some interactive web sites have been created (e.g. Schoeni & Chapuis, 2006) and practical exercises using the Mathematica software were recently developed by Dumas et al. (2006). Practicals were also developed in Nancy University for the Signal Processing' lectures intended for second-year university students (Licence Science de la Vie L2) and for the National CNRS Thematic School Structural Analysis by X-ray Diffraction, Crystallography under Perturbation', held in Nancy in September 2006 (https://www.lcm3b.uhp-nancy.fr/nancy2006/ ).

In single-crystal X-ray diffraction and under kinematic conditions, the amplitude of the X-ray beam diffracted by a crystal of electron density is given by

where Ee is the amplitude scattered by one electron, is the interference function giving rise to the sharp Bragg diffraction peaks, and

is the structure factor associated with the reciprocal-lattice vector . Since it is the Fourier transform of the thermally smeared electron density, the structure factor contains information about the unit-cell content (the motif composition). The diffracted intensities for a crystal composed of a large number of unit cells are then determined by

The structure factors are the Fourier coefficients of the electron density of the motif inside the unit cell:

Structure factors are generally complex quantities and can be represented in polar form:

with the modulus and the phase .

However, according to (3), the diffraction process leads to the determination of only the moduli , the information about the phase being lost. Specialized experimental techniques such as multi-beam X-ray diffraction or convergent-beam electron diffraction offer possibilities to measure relative phases between some structure factors (see for example Spence & Zuo, 1992).

Moreover, it is not possible to measure all Fourier coefficients of the electron density, firstly because of spatial limitations around the diffractometer (the diffraction angle has maximum practical value 2θmax < 180°, depending on the experimental setup), and secondly because one uses nonzero wavelength λ (from the Bragg law the reciprocal resolution is , and since λ is finite the resolution cannot be infinite).

This paper aims to present examples that can be used to illustrate graphically Fourier transform properties in crystallography courses, introducing notions such as resolution, convolution and signal-to-noise ratio using the free (time-limited licence) demo version of a very simple but nevertheless powerful software (DigitalMicrograph from Gatan; https://www.gatan.com/imaging/downloads.php ), originally intended for electron microscopy data collection and analysis.

We draw an analogy between a single-crystal X-ray experiment and manipulation of digital images, as shown in Fig. 1.

 Figure 1 Analogy between single-crystal X-ray diffraction and image manipulation. The bright spot at the centre of the Fourier transform (FT) of the photograph directly corresponds to the F(0, 0, 0) spot in the diffraction pattern. The diffraction pattern of a crystal is composed of peaks as a result of the periodicity of the crystal (top), whereas the photograph is a single' object: its FT is continuous' (bottom).

The crystal is replaced by a two-dimensional digital image that consists of pixels having integer values. It is thus possible to calculate the Fourier transform (FT) of that two-dimensional image, modifying it with user-friendly tools (e.g. removing Fourier coefficients far from the origin) and calculating to which object it corresponds in direct space.

In the following we will first describe how digital images are coded and introduce Fourier transformations, and then we will use the analogy with X-ray diffraction to address some points about resolution, the phase problem in crystallography, and the relation between direct and reciprocal space. Finally, an example showing the important effect of multiple measurements on signal-to-noise ratio will be presented.

Another possible approach is to use Abbe's theory of image formation with a rather simple optical bench, and various examples have been given by e.g. Hecht (2002), Harburn et al. (1975) and Lipson et al. (1995).

### 2. Digital representation of an image and its Fourier transform

The reference image (Fig. 2) is a digital photograph composed of 256 × 256 pixels coded in 8 bit greyscale [i.e. pixels have integer values from 0 (black) to 255 (white)]. All images used in this practical are in 8 bit greyscale TIFF format and are opened with the pull-down menu option File > Open, or are directly downloaded using the browser. As shown in Fig. 2, the mouse pointer is on an almost dark (value = 2) pixel of coordinates (x, y) = (211, 78).

 Figure 2 Our reference image opened in DigitalMicrograph is composed of 256 × 256 pixels coded in 28 greyscale values, from 0 (black) to 255 (white).

The Fourier transform of an I(n, m) image is defined as

(with N = 256 in our example), which is similar to the definition of the structure factor from the electron density [equation (2)]. The inverse Fourier transform is

In the following we will limit ourselves to real I(n, m) signals [in our analogy the electron density is a real quantity], which implies that F* (h,k) = F( - h, - k). Moreover, in order to use the fast Fourier transform algorithm implemented in DigitalMicrograph, these images must have square N × N pixel sizes with N a power of two.

Fourier transform calculations can be illustrated on a smaller image (Fig. 3a), composed of only 4 × 4 pixels. Table 1 displays the integer values of each of the 16 pixels, and Table 2 (visualized in Fig. 4) displays the values of the corresponding Fourier coefficients [note the origin definition (h = 0, k = 0)].

 Table 1Pixel values of Fig. 3(a)
n
m 0 1 2 3
0 127 46 255 241
1 176 179 70 241
2 183 5 190 243
3 196 157 136 94
 Table 2Fourier transform of Fig. 3(a)
 A complex conjugate relationship (in italics) is visible around the F(0, 0) Fourier coefficient (bold). A graphical representation is given in Fig. 4.
h
k −2 −1 0 1
−2 313 + 0i −301 + 434i 41 + 0i −301 − 434i
−1 −30 + 255i 489i 4883i 2463i
0 127 + 0i 31 + 432i 2539 + 0i 31432i
1 −30 − 255i 246 + 3i 48 + 83i 4 + 89i
 Figure 3 (a) A small 4 × 4 pixel image. (b) Moduli of the Fourier coefficients of Fig. 3(a); symmetry is visible around (h, k) = (0, 0). (c) Phases of the Fourier coefficients of Fig. 3(a); antisymmetry is visible around (h, k) = (0, 0). Maximum (minimum) values of moduli and phases are white (black).
 Figure 4 Representation in the complex plane of two F(h, k) Fourier coefficient couples from Table 2.

As can be seen from Table 2 and generalizing to an N × N pixel image, the centre of the Fourier transform (h, k) = (0, 0) is placed at the (N/2 + 1)th row and column. This implies, as the original image and its Fourier transform are N × N, that all Fourier coefficients are related by a complex conjugate relationship centrosymmetric about (0, 0), except those in the first row (k = −2) and column (h = −2).

### 3. Significance of the Fourier coefficients of an image

In order to illustrate the significance of the Fourier coefficients of an image, it is possible to look at which image corresponds to a limited number of Fourier coefficients. As a first example we start from an all-zero 16 × 16 complex image and then set F(−1, 0) = 1 − i, F(1, 0) = 1 + i and calculate its inverse Fourier transform (see Appendix A, §A1 for the procedure in DigitalMicrograph). This leads to the horizontal sine wave of lowest frequency displayed in Fig. 5(a). Then, using F(−h, 0)/F(h, 0) couples, further and further from (0, 0) (Figs. 5b and 5c), one sees that these conditions correspond to sine waves of increasing frequencies. The highest frequency is a special case (Fig. 5c), coded only in one Fourier coefficient, i.e. F(−8, 0); this special treatment for the highest-frequency coefficients simply allows the use of arrays of identical sizes (N × N) for the images and their Fourier transforms. Starting from equation (7) and setting , one finds the same results, the recomposed image being

The complicated image represented in Fig. 2 can thus be seen as resulting from the interference (sum of amplitudes taking into account the relative phases) of the different sine waves generated from each F(h, k)/F(−h, −k) pair. This example also illustrates that Fourier coefficients close to the origin (0, 0) bear information on large-scale intensity variations across the image, whereas the F(h, k) far from the origin encode precise details of the image (this point will be further developed in §4).

 Figure 5 Complex arrays (upper row, 16 × 16 Fourier coefficients) with only some nonzero Fourier coefficients appearing as white squares (they are Dirac peaks, defined in §3.1), and corresponding images obtained by inverse Fourier transformation (lower row, 16 × 16 pixels). (a) Lowest-frequency horizontal sine wave; (b) intermediate-frequency sine wave; (c) highest-frequency sine wave.

#### 3.1. Dirac delta function and convolution

The two-dimensional Dirac delta function (defined in real space) is non-zero only at position ; one of its properties is to select the value at of a given function :

If the Dirac function is centred on the origin [], the Fourier representation of digital images given in §2 [] gives the Fourier transform as simply

Thus the Dirac delta function [δ(0, 0) = 1] is the inverse Fourier transform of the constant 1:

The convolution between two two-dimensional functions and is defined by

and the convolution theorem relates the Fourier transform of the convolution product to the product of the Fourier transforms of the original functions:

As an example, Fig. 6 displays the convolution between a two-dimensional Gaussian function centred at position (x, y) = (200, 200) on a 1024 × 1024 pixel grid, and an image made of four Dirac peaks located at (100, 300), (400, 200), (300, 300) and (450, 450) pixels coordinates (see §A2). The final image is calculated in this example using the convolution theorem, but the result can be seen as being obtained by applying' the Gaussian function to the four Dirac peaks, taking into account that the Gaussian function is shifted from the origin.

 Figure 6 Convolution of a two-dimensional Gaussian function with four Dirac peaks.

From a mathematical point of view, this corresponds to [with one Gaussian centred at and one Dirac peak centred at ]

i.e. a Gaussian centred at .

#### 3.2. Patterson function

In crystallography, the Patterson function , used to solve structures containing heavy atoms, is defined as the autocorrelation function of , or in other words as the convolution of with :

One important property of is that its Fourier transform is simply

that is to say that unlike electron density , this function can be directly computed from experimental data by inverse Fourier transformation.

Starting from the previous image (Fig. 6) composed of the four Gaussian functions that can be seen as analogous to a four-atom structure, the Patterson function can be calculated in different ways, given in §A3. The resulting Patterson function is shown in Fig. 7; it displays 12 peaks around the origin (image centre) corresponding to the N2N = 12 interatomic vectors for the N = 4 atoms'.

 Figure 7 Patterson function (b) of the four atoms' (a).

### 4. Resolution

#### 4.1. Resolution: aesthetic and quantitative point of view

Starting from the original image (Fig. 2), one wonders how it will be modified if one keeps only a selected part of its Fourier transform. In order to perform such modifications, we use masking tools such as those indicated in Fig. 2A4).

The results using a circular masking tool, displayed in Fig. 8, illustrate that the Fourier coefficients far from the origin (centre of the FT) encode details of the image such as the leafs behind the statue, whereas the Fourier coefficients close to the origin encode large-scale intensity variation (e.g. the statue is white on dark background forest).

 Figure 8 Original image (a) and its Fourier transform (d); low-resolution image (b) corresponding to the FT (e) (with the central zone magnified in the bottom-right inset); high-resolution image (c) corresponding to the FT (f).

For a more quantitative approach we consider Fig. 9(a) (256 × 256 pixels), composed of two black disks (15 pixels in diameter) separated by 40 pixels, and ask what is the minimal number of Fourier coefficients that is required for the two disks to be visually separable?

 Figure 9 Image composed of two black disks separated by 40 pixels (a) and its Fourier transform (b).

One can consider that the lowest frequency necessary to distinguish the two disks corresponds to a sine wave having a periodicity equal to the separation between the disks. From the first part we know that the first Fourier coefficient close to the origin corresponds to a sine wave of one period on the image, i.e. 256 pixels. Thus the sine wave with a period of 40 pixels corresponds to the sixth or seventh Fourier coefficient starting from the origin (256/40 = 6.4). Indeed, as displayed in Fig. 10(a), the image reconstructed using only a central area of the first five Fourier coefficients in radius does not permit one to distinguish the two disks, whereas the image calculated with eight Fourier coefficient radii clearly allows one to conclude the presence of two objects on the original image.

 Figure 10 Images (and horizontal profiles) recomposed from the FTs of Fig. 9(a) on which we selected only a central circular area of five [(a) and (c)] or eight [(b) and (d)] Fourier coefficients in radius.

In our analogy these disks can be seen as two atoms; the shortest interatomic distance that one can expect in a compound is, for example, a C—H bond (∼1 Å). Using the Bragg law and with d = 1 Å, one deduces that the X-ray diffraction experiment has to collect diffracted beams up to diffraction angle [corresponding to 2θ ≃ 41° for Mo Kα radiation (λ = 0.711 Å)] in order to distinguish H atoms from their neighbours.

#### 4.2. Interpretation of the aesthetic effect of resolution using the convolution theorem

The blurred appearance of the low-resolution image in Fig. 8(b) can be explained using the convolution theorem. This image is the inverse FT of the FT of the original image (Fig. 8a), of which we only kept a circular central area. This modified FT can be considered to be the simple product in reciprocal space of the FT of the original image and a circular mask displayed in Fig. 11(b). In direct space, the fuzzy image in Fig. 11(f) is thus the convolution of the original image and the inverse FT of the circular mask (more examples of FTs of simple objects are given in §6).

 Figure 11 The images of the lower row are inverse FTs of the corresponding upper-row images.

Indeed, the inverse FT of the circular mask (Fig. 11e) is characterized by four peaks surrounded by oscillations that rapidly decrease in magnitude. It should be noted that the most important contribution to the final image (Fig. 11f) arises from the top-left peak corresponding to the coordinate origin (the three other peaks at the corners create duplicate images outside the boundary of the display but may lead to some artefact close to the edges of the image). The convoluted final image (Fig. 11f) can thus be seen as the sum of copies of the original image shifted and weighted according to the shape of Fig. 11(e). In the limiting case of an infinite mask (thus no masking), the inverse FT of the mask is simply a Dirac peak centred on the top-left corner, and the resulting image is then identical to the original one (convolution of the original image with a Dirac peak placed at the origin). If the mask narrows in reciprocal space, its inverse FT widens in direct space (see §6), with increasing contributions far from the top-left corner, and blurring is more and more pronounced in the final image. In the other limiting case the mask is reduced to a single Dirac peak of height 1, of which the inverse FT is a constant image (1/N2). In that case the original image is totally' blurred, leading to an image having a constant value (which is the average value of the original image).

#### 4.3. Resolution in crystal structure analysis

Assuming that an X-ray diffraction experiment allows the determination of all structure factors in moduli and phases up to 1 Å−1, then, according to the Bragg law, the smallest observable detail without using a model for the structure is 0.5 Å. However, in structure reports, typical estimated standard deviations in C—C bond lengths, for example, are of the order of 0.002 Å, which is far below the diffraction limit. This extra resolution' is induced by the model inserted to fit the observations (and solve the phase problem); the crystal is composed of atoms of known (usually spherical) shapes. This extra resolution may be misleading because it is strongly linked to the model, and this is not unique; usually one uses spherical atoms (independent atom model, IAM) to model X-ray diffraction data, but atoms are not spherical because of chemical bonds with their neighbours. This asphericity of the valence electron density may be taken into account in more sophisticated atomic models [e.g. multipolar models (Stewart, 1976; Hansen & Coppens, 1978)] and offers precise characterization of interatomic and intermolecular interactions (Lecomte et al., 2005). Bond distances may be significantly different between the IAM and multipolar models. Dahaoui (2007) and Espinosa et al. (1997) performed charge density studies of complexes of tetra­cyano­quinodimethane (TCNQ) with different molecules [benzidine: BD-TCNQ; p-ter­phenyl: PTP-TCNQ; bis(thio­dimethyl­ene)­tetrathia­fulvalene: BTDMTTF-TCNQ; see Appendix B]. Using exactly the same data for IAM and multipolar models on these compounds, the cyano bond distances in TCNQ were 1.1604 (7), 1.1602 (7) and 1.1615 (9) Å for mutlipolar models of BD-, PTP- and BTDMTTF-TCNQ, respectively, but only' 1.1539 (9), 1.1532 (7) and 1.1551 (10) Å for the corresponding IAM models. These bond lengths differ between the two atomic models by as much as Δ/σ = 7.2, 10 and 6.4 for BD-, PTP- and BTDMTTF-TCNQ, respectively, σ being the larger bond length standard deviation from the two models. The reason for these significant discrepancies between IAM and multipolar models is illustrated in Fig. 12, where the static deformation density through the TCNQ molecular plane is plotted. This density is defined as the difference between the electron density derived from the multipolar model and the electron density of the corresponding IAM model, and thus it shows the redistribution of valence electron density due to chemical bonding. As can be seen from this figure, the valence density in C≡N bonds is strongly shared between the two atoms, leading to a substantial displacement of the electronic centroids of both the C and the N atoms and therefore to a biased bond length if an IAM model is used.

 Figure 12 Static deformation density of TCNQ (multipolar density minus IAM density) showing the redistribution of valence electrons as a result of chemical bonding (contour intervals are at the 0.1 e Å−3 level; solid lines are positive, dotted lines are negative, and the zero contour is dashed) (Dahaoui, 2007).

Consistent with that finding but in a different way, Seiler et al. (1984) showed that, for a given refinement model, structural parameters depend on the data set extension used to refine these parameters. Their compound (tetrafluoro­terephthalonitrile) also possesses a C≡N bond whose length converged from an IAM refinement to 1.1489 (8) Å using all of the structure-factor data set (sinθ/λ < 1.15 Å−1); however, this distance increased to 1.1538 (4) Å if only high-order data were used (0.85 Å−1 < sinθ/λ < 1.15 Å−1). This underestimation of bond lengths when using an IAM model is explained by the fact that valence electrons (responsible for biased interatomic distances) contribute mainly to low-order reflections (see §6 for an explanation of valence/core contributions to diffraction).

This biasing of bond distances is mainly encountered in strongly polar interactions, where the electron density is shared between atoms. An even more obvious example is X—H bonds (X = C, N, O), in which the distance can be underestimated by as much as 0.1 Å when using an IAM model. Because H atoms have their electronic clouds strongly deformed in such bonds, one must use neutron nuclear diffraction (where neutrons interact with nuclei, not with electrons) to perform a precise structure determination or charge density modelling.

### 5. Phase and modulus

In this section we consider the relative importance of the modulus and phase of the Fourier coefficients. Starting from two images (Figs. 13a and 13b), one can extract the moduli and phases of their respective Fourier transforms and recombine them (modulus of FT of image a with phase of FT of image b and reciprocally; see §A5.1). As shown in Fig. 14, the images obtained are closer to the image from which we took the phase than that one from which we extracted the modulus.

 Figure 13 Two images (a) and (b), and the Fourier transform of (a) represented as the log of its modulus (c) and its phases (d).
 Figure 14 Images obtained by combining the moduli and phases of the FTs of the images given in Figs. 13(a) and 13(b): (a) moduli of Fig. 13(b) and phases of Fig. 13(a); (b) moduli of Fig. 13(a) and phases of Fig. 13(b). This shows that the phases are more important than the moduli.

It is also possible to use random moduli (Fig. 15a) or random phases (Fig. 15b): one has to note, however, that in order to obtain real images the relation around (h, k) = (0, 0) must be imposed on these random values and this could be achieved using more complex scripts (§A5.2).

 Figure 15 Image (a) composed with random moduli and phases of image Fig. 13(a); Image (b) composed with random phases and moduli of image Fig. 13(a). This shows that phases are more important than moduli.

Each pixel of an image built from a Fourier transform (i.e. using an inverse Fourier transform operation) is the result of the interference (addition in the complex plane) of the contributions of each Fourier coefficient (Fig. 16). If phases are strongly modified, the resulting amplitude will be strongly affected. Comparing Fig. 14(a) (created with moduli of Fig. 13b) and Fig. 15(a) (created with random moduli), one can easily see that the former is closer to the original image (Fig. 13a); this is explained by noting that the moduli of Fig. 13(b) resemble' more closely the moduli of the original image Fig. 13(a) (with a central strong peak and decreasing Fourier coefficients away from the centre), whereas the random moduli used here are uniform in reciprocal space.

 Figure 16 The intensity at a pixel is proportional to the sum of the Fourier coefficients [here φ(h, k) includes the spatial propagation phase term].

The importance of the phases relative to the moduli is also evidenced by repeating these examples with different sets of random phases or moduli. Whereas the images (not shown here) composed with random moduli are aesthetically very similar (one can recognize the edges of the statue), the images obtained with random phases are clearly different from one another and do not resemble the original object.

### 6. Shape and symmetry relations between direct and reciprocal space

#### 6.1. Fourier transformation of individual objects

In order to explain, for example, the shape' of the Fourier transform of a crystal or the contributions of core and valence electron densities to diffraction, one must illustrate the relations between direct and reciprocal space.

Fig. 17 underlines the well known Fourier transform property that a shape-restricted object (direct space) corresponds to an extended Fourier transform and vice versa (Figs. 17a–17d). Also evident is the symmetry relationship between the two spaces: a cylindrical object (Fig. 17a) will have a cylindrical FT (Fig. 17b); a rectangular object (Fig. 17e) will have an FT (Fig. 17f) that is an assembly of rectangles but with their smallest extension in the same direction as the greatest dimension of the object. The polygon displayed in Fig. 17(g) has then an FT characterized by tails perpendicular to its edges, since this object has restricted extension along these directions [the five edges of the polygon give rise in the FT (Fig. 17h) to five tails crossing at the origin]. Remembering images of the sun recorded in movies (often observed as a disk surrounded by six tails), one recalls that usually hexagonal diaphragms are used in front of the camera.

 Figure 17 Relations between direct and reciprocal space. To a small disk (a) corresponds a large Fourier transform (b) and vice versa [(c) and (d)]. A rectangular object (e) gives rise to a rectangular FT (f), the largest extension of which corresponds to the thinner direction of the object. A complex object such as the polygon (g) results in an FT (h) (with the central zone magnified in the bottom-right inset), having extensions in directions perpendicular to the faces of the object.

Starting from Fig. 17(e) one can see that the FT of an infinite vertical slit is obtained from Fig. 17(f) where the horizontal oscillations are kept (they are linked to the slit width) but the vertical ones are condensed in the horizontal direction. Adding a second vertical slit leads to interference (Young's two-slit experiment), where the spacing between the minima is linked to the slit separation (Fig. 18d). If more and more equidistant slits are inserted, secondary maxima of decreasing height are created between the principal maxima, which sharpen, and in the limiting case of an infinite number of slits giving rise to a lattice, the Fourier transform becomes a Dirac row (Fig. 19).

 Figure 18 From slits to lattices. The combination of two slits (a) leads to interferences (d), where the spacing between minima is linked to the slit separation. Adding more and more slits [(b) and (c)] creates secondary maxima of decreasing intensity between the principal maxima [(e) and (f)].
 Figure 19 Fourier transform (b) of a one-dimensional vertical lattice (a) (the width of the Dirac peaks is exaggerated for clarity).

A two-dimensional lattice can then be constructed by crossing vertical and horizontal one-dimensional lattices, as displayed in Fig. 20(a). This lattice being infinite, its Fourier transform is then also a lattice [in Fig. 20(b) the Dirac peaks are artificially enlarged for clarity]. The direct lattice (Fig. 20a) can be seen as the convolution of a Dirac peaks lattice and the motif composing the unit cell' (Fig. 20d): indeed, its Fourier transform is the simple product between the reciprocal lattice (FT of the direct lattice) and the FT (Fig. 20e) of the motif (Fig. 20d). The two black horizontal lines In Fig. 20(b) arise from the fact that a node of the FT (Fig. 20e) falls on the same position as a row of the reciprocal lattice that samples this function.

 Figure 20 Two-dimensional lattice (a) and its Fourier transform (b). The intensity variation (c) across the horizontal line of (b) arises from the Fourier transform (e) of the motif (located in any unit cell) (d), which decorates the lattice (a).

Returning to crystallography, the crystal is the convolution of a three-dimensional direct lattice with a motif that describes or decorates' the unit cell; its Fourier transform (related to the diffraction pattern) is then the simple product of the reciprocal lattice, giving rise to sharp diffraction spots [it is the interference function of equation (1) in the case of a large number of unit cells], with the FT of the motif, which is the structure factor which leads to intensity variations from spot to spot and to (non-lattice) systematic extinctions.

The structure factors are the sum of the contributions of the Nat different atoms composing the unit cell:

where is the atomic scattering factor of atom j and is the Fourier transform of its electron density. Electrons of non-H atoms may be defined as core and valence electrons and have distinct contributions in reciprocal space because of their different locations in real space. As shown in Fig. 21 the iron core electrons tightly bound to the nuclei contribute in the whole diffraction angle range, whereas valence electrons spread in direct space have noticeable contributions only for small diffraction angles, i.e. close to the origin of the reciprocal space owing to the FT properties. This implies that in charge density (in which one wants to observe and model the distribution of valence electrons) or accurate thermal motion studies one has to collect accurately low- and high-diffraction-angle reflections in order to distinguish valence effects from thermal displacements (static or dynamic) since the FT of the structure factors is the thermally smeared electron density (Coppens, 1997) [see Aubert et al. (2003, 2004) for an example of charge density and electrostatic potential studies].

 Figure 21 Atomic scattering factor of Fe and Fe3+ as a function of diffraction angle θ. These two curves only significantly differ for low diffraction angles where the contribution of valence electrons is the strongest.

#### 6.2. Effect of the crystal shape

In single-crystal X-ray diffraction a typical size of the specimen is about 100 µm in length in each direction, the optimal size being a compromise between the diffracting power proportional to the crystal volume and the absorption phenomenon. Crystal size has a less important effect with the X-ray technique than it has in electron diffraction, where the crystal must be very thin to be transparent to the electron beam (Williams & Carter, 1996).

Given the infinite perfect crystal displayed in Fig. 22(a), one wonders how its diffraction pattern will be modified if its shape is changed. Because the crystal is infinite, its Fourier transform is a regular array of Dirac peaks of varying heights across the image.

 Figure 22 An infinite perfect crystal (a) and its Fourier transform (b).

According to what was seen in the preceding section, if one restricts the object shape in one direction its Fourier transform will expand in that direction. Examples of different crystal shapes are given in Fig. 23, together with their Fourier transforms. These latter can be explained using the convolution theorem: in direct space, the finite size crystal can be seen as the simple product of the infinite crystal with a mask giving the crystal shape; in reciprocal space the Fourier transform of the finite crystal is then the convolution of the Fourier transform of the infinite crystal (array of Dirac peaks) by the Fourier transform of the mask.

 Figure 23 A rectangular crystal (a) and its Fourier transform (b). The extension of the FT is larger in the direction where the crystal is thinner. A spherical crystal (c) and its Fourier transform (d). The Fourier transforms are the convolution of the FT of the infinite crystal with the FT of the shape of the finite crystal.

#### 6.3. Playing: bird in cage…

As a recreation, one can play with the well known example of the captive bird shown in Fig. 24(a), the aim being to release the flying animal. As displayed in Fig. 24(b) one can recognize the respective contributions of the bird (complex intensity variation with a global decreasing from the origin) and of the cage (which is a simple vertical one-dimensional lattice) giving rise to sharp spots in the equatorial line. The bars of the cage will then disappear if one masks their contributions in the reciprocal space as in Fig. 24(c). The final image still displays traces of the bars because the cage contribution spreads beyond the section that was hidden. In direct space, the original image is the simple product of the bird and of the cage; thus in reciprocal space it corresponds to the convolution of the FT of the bird on the Dirac peaks of the FT of the cage.

 Figure 24 How to release a captive bird. The original image is in (a) and its FT in (b). By removing with a mask part of the contribution of the bars in the FT (c) the cage disappears' in direct space (d).

### 7. Signal on heavy noise

As a final application, we present an example related to electron microscopy; in Fig. 25(a) are displayed 20 objects that are assumed to be identical and related by translation only (i.e. no rotation). As can be seen, the high noise level allows the identification of these objects on the image but precludes the observation of the possible details inside them. Because the noise is assumed to be random across the image, one can thus average the 20 objects in order to increase their signal to noise ratio (§A6).

 Figure 25 (a) 20 identical objects are spread on a random high-level noise. (b) Zoom on three objects; the noise level precludes any signal detection inside the objects.

The first step is to find the precise position of each object on the image; one extracts one of the objects (Fig. 26a) and computes the cross correlation between this extracted object and the full image. The result, shown in Fig. 26(b), displays sharp peaks corresponding to the repetitive positions of the extracted object on the original image (these peaks give the coordinates in the image frame of the top-left corner of the square selection that have to be used to extract and average the 20 objects). The average image (Fig. 27 after adequate rotation) is then obtained by summing the objects extracted from the original image using the coordinates derived from the cross correlation; it reveals the weak signal hidden by the high level noise.

 Figure 26 (a) One extracted object placed in a new otherwise zero image. (b) Cross correlation between the original image (Fig. 25a) and the extracted object (a).
 Figure 27 Average of the 20 objects extracted from Fig. 25(a) (after 120° rotation), revealing the weak signal hidden in the noise.

This example of utilization of correlation also illustrates the importance of multiple measurements of structure factors in single-crystal X-ray diffraction in order to increase their signal-to-noise ratio. This is of the utmost importance, for instance, in charge density modelling, where the effect to be observed (i.e. electron density reorganization owing to chemical bonding) is weak.

### 8. Conclusions

This paper illustrates the Fourier transformation and its properties used in crystallography with emphases on X-ray diffraction. Obviously, the demonstrations are not restricted to crystallographic applications but are relevant to all domains where Fourier transformation, convolution, correlation, resolution etc. are important. The example of X-ray imaging that uses synchrotron and the promising free electron laser sources is particularly relevant. Figs. 17(b) and 17(f) of the present paper correspond to Figs. 7 and 8 of the Livet lead article on diffraction with an X-ray coherent beam (Livet, 2007).

Some other examples of image manipulations are given at https://www.lcm3b.uhp-nancy.fr/lcm3b/Pages_Perso/Aubert/sommaire.html . These illustrations show, for example, how to use Fourier transform for zooming on an image or to insert a digital signature into a photograph.

The free demonstration version of DigitalMicrograph software is available from Gatan (https://www.gatan.com/imaging/downloads.php ).

### Procedures and scripts used for the examples developed in the text

#### A1. (§3. Significance of the Fourier coefficients of an image)

File > New > Width 16 Height 16 Complex 8 Bytes Constant (0)

Object > Display Type > Spreadsheet

Modify F(h, k) by double click on it

Object > Display Type > Raster

Process > Inverse FFT

Object > Display > Complex Display Real Part

#### A2. (§3.1. Convolution)

File > New > 1024 1024 Real 4 Ramp X → Image A

File > New > 1024 1024 Real 4 Ramp Y → Image B

File > New > 1024 1024 Real 4 Constant 0 → Image C

File > New > 1024 1024 Real 4 Constant 0 → Image D

In one script:

c = exp(-1e-3*((a-200)**2+(b-200)**2))

d = 0

d[100,300] = 1

d[400,200] = 1

d[300,300] = 1

d[450,450] = 1

Process > FFT on images C and D (results in E and F)

Process > Simple Math > E*F (results in G)

Process > Inverve FFT on G (results in H)

Edit > Change Data Type > Real > Real Component

#### A3. (§3.2. Patterson function)

Directly using the implemented function:

Process > Auto correlation (results in I)

Using the convolution theorem:

Process > Rotate 180° (results in J from H)

iFFT on the product of FFT of H and FFT of J

Using the relation : calculate from H:

Process > FFT (result in J)

Edit > Change Data Type > Real > Modulus

Process > Simple Math > a**b with b = 2 (results in K)

Edit > Change Data Type > Complex

Process > Inverse FFT

#### A4. (§4.1. Resolution: aesthetic and quantitative point of view)

Open image

Process > Fourier Transform

Apply the masking tool to that FT

Process > Inverse FFT

#### A5. (§5. Phase and modulus)

A5.1. Open the two images (results in A and B)

Process > Fourier Transform on these two images (results in A, B → C, D)

mp = complex(modulus(c)*cos(phase(d)), modulus(c)*sin(phase(d)))

pm = complex(modulus(d)*cos(phase(c)), modulus(d)*sin(phase(c)))

A5.2. With random moduli and phases of the Chinese Musician:

File > New > 256 256 Real 4 Random (image A)

In a script: (image C)

b = a[1,1,256,256]

FlipHorizontal(b)

FlipVertical(b)

c = a

c[129,1,256,256] = b[128,0,255,255]

deleteimage(b)

d = c[128,1,129,256]

FlipHorizontal(d)

c[128,1,129,128] = d[0,0,1,127]

deleteimage(d)

d = c[0,1,1,256]

FlipHorizontal(d)

c[0,1,1,128] = d[0,0,1,127]

deleteimage(d)

d = c[1,0,256,1]

FlipVertical(d)

c[1,0,128,1] = d[0,0,127,1]

deleteimage(d)

Open image of the Chinese Musician (image B)

Process > FFT (image D)

z = complex(c*cos(phase(d)),c*sin(phase(d))) (image Z)

Process > Inverse FFT (Z → E)

Edit > Change Data Type > Real > Real Component (on E)

With random phases and moduli of the Chinese Musician:

File > New > 256 256 Real 4 Random (image A)

In a script: (image D)

b = (a-0.5)*2*pi()

c = b[1,1,256,256]

FlipHorizontal(c)

FlipVertical(c)

d = b

d[129,1,256,256] = -c[128,0,255,255]

e = d[128,1,129,256]

FlipHorizontal(e)

d[128,1,129,128] = -e[0,0,1,127]

deleteimage(e)

e = d[0,1,1,256]

FlipHorizontal(e)

d[0,1,1,128] = -e[0,0,1,127]

deleteimage(e)

e = d[1,0,256,1]

FlipVertical(e)

d[1,0,128,1] = -e[0,0,127,1]

deleteimage(e)

deleteimage(b)

deleteimage(c)

d[0,0] = 0

d[128,128] = 0

d[0,128] = pi()

d[128,0] = pi()

Open image of the Chinese Musician (image B)

Process > FFT (image C)

z = complex(modulus(c)*cos(d),modulus(c) *sin(d)) (image Z)

Process > Inverse FFT (Z → E)

Edit > Change Data Type > Real > Real Component (on E)

#### A6. (§7. Signal on heavy noise)

Open the 20 object image (image A)

Draw a square 256 × 256 pixel selection around a given object

File > New > 2048 2048 Real 4 Constant (a) (image B)

In a script: b[0,0,256,256] = a[]

Now we have to compute the cross correlation between A and B:

which can be seen as the convolution of with .

Process > Rotate (180°) (image B → image C)

Process > FFT (A → D)

Process > FFT (C → E)

Process > Simple Math (D × E → F)

Process > Inverse FFT (F → G)

### Diffraction data

BD-TCNQ: space group: C2/m; temperature: 100 K; sinθ/λmax = 1 Å−1; multipolar model: R = 0.023, Rw = 0.024; g.o.f. = 0.605; IAM: R = 0.038, Rw = 0.049, g.o.f. = 1.208. PTP-TCNQ: space group: ; temperature: 120 K; sinθ/λmax = 1.09 Å−1; multipolar model: R = 0.031, Rw = 0.032, g.o.f. = 1.476; IAM: R = 0.045, Rw = 0.048, g.o.f. = 2.122. BTDMTTF-TCNQ: space group: C2/m; temperature: 15 K; sinθ/λmax = 1.14 Å−1; multipolar model: R = 0.027, Rw = 0.025, g.o.f. = 0.957; IAM: R = 0.035, Rw = 0.037, g.o.f. = 1.397.

### Acknowledgements

The authors thank Dr Eric Chabrière for fruitful discussions, and Professor Enrique Espinosa and Angélique Lagoutte for their help during the practical training session at the CNRS thematic school Structural Analysis by X-ray Diffraction, Crystallography under perturbation' held in Nancy in September 2006. EA thanks Dr S. Pillet for the invitation to this CNRS school. We are grateful to Dr Slimane Dahaoui for providing accurate bond lengths and charge density results on TCNQ complexes, before publication, and to the referees for constructive comments and corrections of the manuscript.

### References

Aubert, E., Porcher, F., Souhassou, M. & Lecomte, C. (2003). Acta Cryst. B59, 687–700.  Web of Science CrossRef CAS IUCr Journals Google Scholar
Aubert, E., Porcher, F., Souhassou, M. & Lecomte, C. (2004). J. Phys. Chem. Solids, 65, 1943–1949.  Web of Science CrossRef CAS Google Scholar
Coppens, P. (1997). X-ray Charge Densities and Chemical Bonding, IUCr Texts on Crystallography. Oxford University Press.  Google Scholar
Dahaoui, S. (2007). Personal Communication.  Google Scholar
Dumas, P., Vanwinsberghe, J. & Cura, V. (2006). Crystallographic Teaching Commission of the IUCr Newsletter, No. 1, pp. 4–10.  Google Scholar
Espinosa, E., Molins, E. & Lecomte, C. (1997). Phys. Rev. B, 56, 1820–1832.  CrossRef CAS Web of Science Google Scholar
Hansen, N. K. & Coppens, P. (1978). Acta Cryst. A34, 909–921.  CrossRef CAS IUCr Journals Web of Science Google Scholar
Harburn, G., Taylor, C. A. & Welberry, T. R. (1975). Atlas of Optical Transforms. London: G. Bell.  Google Scholar
Hecht, E. (2002). Optical Physics, 4th ed. San Francisco: Addison Wesley.  Google Scholar
Lecomte, C., Aubert, E., Legrand, V., Porcher, F., Pillet, S., Guillot, B. & Jelsch, C. (2005). Z. Kristallogr. 220, 373–384.  Web of Science CrossRef CAS Google Scholar
Lipson, S. G., Lipson, H. & Tannhauser, D. S. (1995). Optical Physics, 3rd ed. Cambridge University Press.  Google Scholar
Livet, F. (2007). Acta Cryst. A63, 87–107.  Web of Science CrossRef CAS IUCr Journals Google Scholar
Schoeni, N. & Chapuis, G. (2006). https://lcr.epfl.ch/page37304.html  Google Scholar
Seiler, P., Schweizer, W. B. & Dunitz, J. D. (1984). Acta Cryst. B40, 319–327.  CSD CrossRef CAS Web of Science IUCr Journals Google Scholar
Spence, J. C. H. & Zuo, J. M. (1992). Electron Microdiffraction. New York: Plenum.  Google Scholar
Stewart, R. F. (1976). Acta Cryst. A32, 565–574.  CrossRef CAS IUCr Journals Web of Science Google Scholar
Williams, D. B. & Carter, C. B. (1996). Transmission Electron Microscopy. New York: Plenum Press.  Google Scholar