teaching and education Illustrated Fourier transforms for crystallography

Journal of

Applied Crystallography

Emmanuel Aubert* and Claude Lecomte

ISSN 0021-8898

Laboratoire de Cristallographie et Mode´lisation des Mate´riaux Mine´raux et Biologiques, UMR UHP–CNRS 7036, Faculte´ des Sciences et Techniques, Nancy-Universite´, Boulevard des Aiguillettes, BP 239, 54506 Vandoeuvre-le`s-Nancy, France. Correspondence e-mail: [email protected]

Received 26 March 2007 Accepted 5 September 2007

# 2007 International Union of Crystallography Printed in Singapore – all rights reserved

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. (http://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

ðrÞ ¼

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 (http://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 ðrÞ is given by EðHÞ ¼ Ee FðHÞ ðHÞ;

ð1Þ

where Ee is the amplitude scattered by one electron, ðHÞ is the interference function giving rise to the sharp Bragg diffraction peaks, and Z ðrÞ expð2iH  rÞ dr ð2Þ FðHÞ ¼ cell

is the structure factor associated with the reciprocal-lattice vector H. 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  2 IðHÞ / FðHÞ ¼ FðHÞ F  ðHÞ:

ð3Þ

The structure factors are the Fourier coefficients of the electron density ðrÞ of the motif inside the unit cell: J. Appl. Cryst. (2007). 40, 1153–1165

1 X FðHÞ expð2iH  rÞ: Vcell H

ð4Þ

Structure factors are generally complex quantities and can be represented in polar form:   FðHÞ ¼ FðHÞ exp½i’ðHÞ; ð5Þ   with the modulus FðHÞ and the phase ’ðHÞ. However, according to (3), the diffraction   process leads to the determination of only the moduli FðHÞ, the information about the phase being lost. Specialized experimental techniques such as multi-beam X-ray diffraction or convergentbeam 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 2max < 180 , depending on the experimental setup), and secondly because one uses nonzero wavelength  (from the Bragg law the reciprocal resolution is jHj=2 ¼ sin =, 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 (timelimited licence) demo version of a very simple but nevertheless powerful software (DigitalMicrograph from Gatan; http :/ /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. 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. doi:10.1107/S0021889807043622

1153

teaching and education

Figure 1

Figure 2

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).

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

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).

ð7Þ

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). The Fourier transform of an I(n, m) image is defined as Fðh; kÞ ¼

N 1 X N 1 X

Iðn; mÞ exp½ð2i=NÞðhn þ kmÞ

In the following we will limit ourselves to real I(n, m) signals [in our analogy the electron density ðrÞ 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)]. 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).

Figure 3

(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 Aubert and Lecomte

N=21 N=21 1 X X F ðh; kÞ exp½ð2i=NÞðhn þ kmÞ: 2 N h¼N=2 k¼N=2

ð6Þ

n¼0 m¼0

1154

I ðn; mÞ ¼



Illustrated Fourier transforms

(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). J. Appl. Cryst. (2007). 40, 1153–1165

teaching and education Table 1

Table 2

Pixel values of Fig. 3(a).

Fourier transform of Fig. 3(a).

n m 0 1 2 3

0

1

2

3

127 176 183 196

46 179 5 157

255 70 190 136

241 241 243 94

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, xA1 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 Fðh; 0Þ ¼ jF j expði’Þ, one finds the same results, the recomposed image being  I ðn; mÞ ¼ ð1=162 Þ jF j expði’Þ exp½ð2=16Þiðhn þ 0mÞ  þ jF j expði’Þ exp½ð2=16Þiðhn þ 0mÞ ¼ ð1=162 Þ jF j 2 cos½ð2=16Þhn  ’: 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

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 1 0 1

313 + 0i 30 + 255i 127 + 0i 30  255i

301 + 434i 4  89i 31 + 432i 246 + 3i

41 + 0i 48  83i 2539 + 0i 48 + 83i

301  434i 246  3i 31  432i 4 + 89i

(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 x4). 3.1. Dirac delta function and convolution

The two-dimensional Dirac delta function ðx  x0 Þ (defined in real space) is non-zero only at position x0 ; one of its properties is to select the value at x0 of a given function f ðxÞ: Z Z f ðxÞ ðx  x0 Þ dx ¼ f ðx0 Þ: If the Dirac function is centred on the origin [x0 ¼ ð0; 0Þ], the Fourier representation of digital images given in x2 [ð0; 0Þ ¼ 1] gives the Fourier transform as simply   XX FT ðn; mÞ ¼ ðn; mÞ exp½ð2i=NÞðhn þ kmÞ ¼ 1: Thus the Dirac delta function [(0, 0) = 1] is the inverse Fourier transform of the constant 1:

Figure 5

Figure 4 Representation in the complex plane of two F(h, k) Fourier coefficient couples from Table 2. J. Appl. Cryst. (2007). 40, 1153–1165

Complex arrays (upper row, 16  16 Fourier coefficients) with only some nonzero Fourier coefficients appearing as white squares (they are Dirac peaks, defined in x3.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) highestfrequency sine wave. Aubert and Lecomte



Illustrated Fourier transforms

1155

teaching and education ðn; mÞ ¼

N=21 N=21 1 X X exp½ð2i=NÞðhn þ kmÞ: N 2 h¼N=2 k¼N=2

The convolution between two two-dimensional functions f ðxÞ and gðxÞ is defined by Z Z ðf  gÞðuÞ ¼ f ðu  xÞ gðxÞ dx; and the convolution theorem relates the Fourier transform of the convolution product to the product of the Fourier transforms of the original functions:       FT ðf  gÞðuÞ ¼ FT f ðxÞ FT gðxÞ : As an example, Fig. 6 displays the convolution between a twodimensional 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 xA2). 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. From a mathematical point of view, this corresponds to [with one Gaussian gðxÞ centred at x1 and one Dirac peak centred at x0 ] Z Z   ð  gÞðuÞ ¼ ðu  x  x0 Þ exp ðx  x1 Þ2 dx   ¼ exp ðu  x0  x1 Þ2

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

that is to say that unlike electron density ðrÞ, this function 2 can be directly computed from experimental IðHÞ / FðHÞ 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 xA3. The resulting Patterson function is shown in Fig. 7; it displays 12 peaks around the origin (image centre) corresponding to the N2  N = 12 interatomic vectors for the N = 4 ‘atoms’.

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 i.e. a Gaussian centred at x0 þ x1 . use masking tools such as those indicated in Fig. 2 (xA4). The results using a circular masking tool, displayed in Fig. 8, 3.2. Patterson function illustrate that the Fourier coefficients far from the origin In crystallography, the Patterson function PðuÞ, used to (centre of the FT) encode details of the image such as the leafs solve structures containing heavy atoms, is defined as the behind the statue, whereas the Fourier coefficients close to the autocorrelation function of ðrÞ, or in other words as the origin encode large-scale intensity variation (e.g. the statue is convolution of ðrÞ with ðrÞ: white on dark background forest). For a more quantitative approach we consider Fig. 9(a) (256 PðuÞ ¼ ðrÞ  ðrÞ Z  256 pixels), composed of two black disks (15 pixels in ¼ ðrÞ ðu þ rÞ dr: diameter) separated by 40 pixels, and ask what is the minimal number of Fourier coefficients that is required for the two One important property of PðuÞ is that its Fourier transform is disks to be visually separable? simply One can consider that the lowest frequency necessary to    2 distinguish the two disks corresponds to a sine wave having a 2 1 FT PðuÞ ¼ jF j ; PðuÞ ¼ FT jF j ; 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 Figure 6 radius does not permit one to distinConvolution of a two-dimensional Gaussian function with four Dirac peaks.

1156

Aubert and Lecomte



Illustrated Fourier transforms

J. Appl. Cryst. (2007). 40, 1153–1165

teaching and education 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 x6). 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 Figure 8 Original image (a) and its Fourier transform (d ); low-resolution image (b) corresponding to the FT peaks at the corners create duplicate (e) (with the central zone magnified in the bottom-right inset); high-resolution image (c) images outside the boundary of the corresponding to the FT ( f ). display but may lead to some artefact close to the edges of the image). The convoluted final image guish the two disks, whereas the image calculated with eight (Fig. 11f ) can thus be seen as the sum of copies of the original Fourier coefficient radii clearly allows one to conclude the image shifted and weighted according to the shape of presence of two objects on the original image. Fig. 11(e). In the limiting case of an infinite mask (thus no In our analogy these disks can be seen as two atoms; the shortest interatomic distance that one can expect in a masking), the inverse FT of the mask is simply a Dirac peak ˚ ). Using the compound is, for example, a C—H bond ( 1 A centred on the top-left corner, and the resulting image is then ˚ , one deduces that the Bragg law 2d sin  ¼  and with d = 1 A identical to the original one (convolution of the original image with a Dirac peak placed at the origin). If the mask narrows in X-ray diffraction experiment has to collect diffracted beams ˚ 1 [corresponding to reciprocal space, its inverse FT widens in direct space (see x6), up to diffraction angle sin = ¼ 0:5A ˚ )] in order to with increasing contributions far from the top-left corner, and 2 ’ 41 for Mo K radiation ( = 0.711 A blurring is more and more pronounced in the final image. In 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

Figure 10 Figure 9 Image composed of two black disks separated by 40 pixels (a) and its Fourier transform (b). J. Appl. Cryst. (2007). 40, 1153–1165

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. Aubert and Lecomte



Illustrated Fourier transforms

1157

teaching and education

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

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 ˚ 1, then, according to the Bragg law, the smallest to 1 A observable detail without using a model for the structure is ˚ . However, in structure reports, typical estimated stan0.5 A dard deviations in C—C bond lengths, for example, are of the ˚ , which is far below the diffraction limit. This order of 0.002 A ‘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 tetracyanoquinodimethane (TCNQ) with different molecules [benzidine: BD-TCNQ; p-terphenyl: PTP-TCNQ; bis(thiodimethylene)tetrathiafulvalene: BTDMTTF-TCNQ; see Appendix B]. Using exactly

1158

Aubert and Lecomte



Illustrated Fourier transforms

the same data for IAM and multipolar models on these compounds, the cyano bond distances in TCNQ were ˚ for mutlipolar models 1.1604 (7), 1.1602 (7) and 1.1615 (9) A of BD-, PTP- and BTDMTTF-TCNQ, respectively, but ‘only’ ˚ for the corresponding 1.1539 (9), 1.1532 (7) and 1.1551 (10) A 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

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

teaching and education 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. 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 (tetrafluoroterephthalonitrile) also possesses a C N bond whose length ˚ using all converged from an IAM refinement to 1.1489 (8) A 1 ˚ of the structure-factor data set (sin/ < 1.15 A ); however, ˚ if only high-order data this distance increased to 1.1538 (4) A 1 ˚ ˚ 1). This underwere used (0.85 A < sin/ < 1.15 A

estimation 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 x6 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 ˚ when using an IAM underestimated by as much as 0.1 A 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 xA5.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. 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 FðHÞ ¼ F  ðHÞ around (h, k) = (0, 0) must be imposed on these random values and this could be achieved using more complex scripts (xA5.2). Each pixel of an image built from a Fourier transform (i.e. using an inverse Fourier transform operation) is the result of

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 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.

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. J. Appl. Cryst. (2007). 40, 1153–1165

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]. Aubert and Lecomte



Illustrated Fourier transforms

1159

teaching and education

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.

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. 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 cylind-

1160

Aubert and Lecomte



Illustrated Fourier transforms

rical 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. 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). 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 J. Appl. Cryst. (2007). 40, 1153–1165

teaching and education

Figure 19 Fourier transform (b) of a one-dimensional vertical lattice (a) (the width of the Dirac peaks is exaggerated for clarity).

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 )].

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. 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 ðHÞ of equation (1) in the case of a large number of unit cells], with the FT of the motif, which is the structure factor FðHÞ 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: F ðHÞ ¼

Nat X

  fj ðHÞ exp 2iH  rj ;

j¼1

where fj ðHÞ 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-diffractionangle 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 J. Appl. Cryst. (2007). 40, 1153–1165

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).

(Coppens, 1997) [see Aubert et al. (2003, 2004) for an example of charge density and electrostatic potential studies]. 6.2. Effect of the crystal shape

In single-crystal X-ray diffraction a typical size of the specimen is about 100 mm 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 Aubert and Lecomte



Illustrated Fourier transforms

1161

teaching and education

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.

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. 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.

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.

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

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

1162

Aubert and Lecomte



Illustrated Fourier transforms

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 (xA6). 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 J. Appl. Cryst. (2007). 40, 1153–1165

teaching and education

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 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 ).

Figure 27 Average of the 20 objects extracted from Fig. 25(a) (after 120 rotation), revealing the weak signal hidden in the noise.

observed (i.e. electron density reorganization owing to chemical bonding) is weak.

8. Conclusions 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.

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. 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 J. Appl. Cryst. (2007). 40, 1153–1165

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 http://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 (http://www.gatan.com/imaging/ downloads.php). Aubert and Lecomte



Illustrated Fourier transforms

1163

teaching and education APPENDIX A Procedures and scripts used for the examples developed in the text A1. (x3. 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. (x3.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. (x3.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  2  Using the relation PðuÞ ¼ iFT jF j2 : calculate F ðHÞ 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. (x4.1. Resolution: aesthetic and quantitative point of view)

Open image Process > Fourier Transform Apply the masking tool to that FT Process > Apply Mask Process > Inverse FFT

1164

Aubert and Lecomte



Illustrated Fourier transforms

A5. (x5. 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] J. Appl. Cryst. (2007). 40, 1153–1165

teaching and education 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. (x7. 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: Z CðuÞ ¼ AðxÞ Bðx þ uÞ dx; which can be seen as the convolution of AðxÞ with BðxÞ. 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)

APPENDIX B Diffraction data BD-TCNQ: space group: C2/m; temperature: 100 K; sin/max ˚ 1; multipolar model: R = 0.023, Rw = 0.024; g.o.f. = 0.605; =1A IAM: R = 0.038, Rw = 0.049, g.o.f. = 1.208. PTP-TCNQ: space ˚ 1; multigroup: P1 ; temperature: 120 K; sin/max = 1.09 A

J. Appl. Cryst. (2007). 40, 1153–1165

polar 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 ˚ 1; multigroup: C2/m; temperature: 15 K; sin/max = 1.14 A polar model: R = 0.027, Rw = 0.025, g.o.f. = 0.957; IAM: R = 0.035, Rw = 0.037, g.o.f. = 1.397. The authors thank Dr Eric Chabrie`re for fruitful discussions, and Professor Enrique Espinosa and Ange´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. Aubert, E., Porcher, F., Souhassou, M. & Lecomte, C. (2004). J. Phys. Chem. Solids, 65, 1943–1949. Coppens, P. (1997). X-ray Charge Densities and Chemical Bonding, IUCr Texts on Crystallography. Oxford University Press. Dahaoui, S. (2007). Personal Communication. Dumas, P., Vanwinsberghe, J. & Cura, V. (2006). Crystallographic Teaching Commission of the IUCr Newsletter, No. 1, pp. 4–10. Espinosa, E., Molins, E. & Lecomte, C. (1997). Phys. Rev. B, 56, 1820– 1832. Hansen, N. K. & Coppens, P. (1978). Acta Cryst. A34, 909–921. Harburn, G., Taylor, C. A. & Welberry, T. R. (1975). Atlas of Optical Transforms. London: G. Bell. Hecht, E. (2002). Optical Physics, 4th ed. San Francisco: Addison Wesley. Lecomte, C., Aubert, E., Legrand, V., Porcher, F., Pillet, S., Guillot, B. & Jelsch, C. (2005). Z. Kristallogr. 220, 373–384. Lipson, S. G., Lipson, H. & Tannhauser, D. S. (1995). Optical Physics, 3rd ed. Cambridge University Press. Livet, F. (2007). Acta Cryst. A63, 87–107. Schoeni, N. & Chapuis, G. (2006). http://lcr.epfl.ch/page37304.html Seiler, P., Schweizer, W. B. & Dunitz, J. D. (1984). Acta Cryst. B40, 319–327. Spence, J. C. H. & Zuo, J. M. (1992). Electron Microdiffraction. New York: Plenum. Stewart, R. F. (1976). Acta Cryst. A32, 565–574. Williams, D. B. & Carter, C. B. (1996). Transmission Electron Microscopy. New York: Plenum Press.

Aubert and Lecomte



Illustrated Fourier transforms

1165