DiffMap: A new free computer program to process scanned electron diffraction patterns

,


INTRODUCTION
Traditional electron microscopic imaging evaluates two-dimensional (2D) images recorded with different contrast mechanisms. Similarly, an electron diffraction (ED) pattern recorded at any locations of the sample is also 2D. This 2D-ED pattern carries structural information about the given location of the sample. Scanning transmission electron microscopes (STEMs) brought the possibility to record such 2D-ED patterns systematically from many locations in a single experiment. The beam is scanned line-by-line along a rectangle and an image is formed by a pre-selected electron detector (e.g. a high angle annular dark-field (HAADF) detector). There is also an additional possibility to record a 2D-ED at each position of the beam (each position corresponding to a pixel of the HAADF image). This mode of data collection produces a four-dimensional (4D) data set, since at each pixel of a 2D image a 2D-ED is saved. Some authors name it 4D-ED or 4D STEM. Others call it scanned electron diffraction (SED). There is a wealth of information in such 4D data sets, depending both on the type of electron diffraction recorded (e.g. selected area (SAED), nanobeam (NBD), convergent beam (CBED)) and also on the means of recording (e.g. taking picture of the viewing screen, recording with conventional CCD or CMOS cameras or with pixelated detectors).
There are several different solutions in the literature both for the recording and for the evaluation of such 4D-ED data sets. A commercial solution offers both hardware ([1] that contains beam scanning and precession for TEMs and optical camera to photo the viewing screen) for recording the data set and software for creating phase maps and orientation maps from it [2]. Koch developed 4D ED solution by not scanning, but by tilting the beam around 2 axes [3]. Other more sophisticated applications of 4D STEM use high speed pixelated detectors and report electric field and charge density variations in the sample with a list of literature for other applications of 4D STEM related techniques [4]. Another review paper overviews the use of the four-dimensional STEM experiments for virtual diffraction imaging, phase, orientation and strain mapping, measurements of medium-range order, thickness and tilt of samples, and phase contrast imaging methods [5].
The present paper reports the development of a computer program (called DiffMap) for off-line evaluation of such 4D-ED data sets, recorded with nearly parallel electron beam in the STEM independently from this program. It determines phase maps and orientation maps together with usual fit quality maps. It also facilitates individual inspection of any diffraction pattern, selected from the phase map, providing a means for validation of the correctness of indexing of any one pattern. The program's development was stimulated by the fact that 4D-ED data set can be recorded in modern STEMs without the need for additional hardware but manufacturers do not offer programs for the evaluation of such data sets. DiffMap is distributed as a free off-line data reduction solution to the community (https:// public.ek-cer.hu/∼labar/DiffMap.htm).

FUNCTIONALITIES OF THE PROGRAM
The input data consist of a set of TIF images recorded by any types of camera on any types of STEM. The experience of the author suggests that with properly selected experimental parameters (camera length and intensity) diffraction patterns recorded in 512 p 512 pixel images with 8 bit data depths are more than enough for processing. The diffraction patterns in this manuscript are recorded with 256 p 256 pixels, still facilitating identification. Taking into account the fact that even a modest STEM image should contain several thousand pixels and a diffraction pattern belongs to each pixel of the STEM image it means a large number of ED patterns requiring a huge data space on the storage device for each 4D-ED experiment. Calibration of the camera constant is usually done in a separate step from a (set of) pattern(s) recorded under identical conditions on a known material (e.g. the nanocrystalline Pt protecting layer used during FIB cutting of the TEM lamella). The backbone of the program is the generation of a result-file from this huge number of measured patterns. The result-file is used in separate later steps by the program to display the phase and orientation maps and the results of any further operation. Identification of phases and orientations is based on a comparison of simulated diffraction patterns to the measured ones, similarly to the template method in [2].

Generation of simulated patterns
Simulated diffraction patterns are calculated from crystalline unit cell data and stored as a set of reciprocal lattice vectors. The user must provide a list of phases to be considered during the fitting. In other words, this program does not determine structure of unknown phases from the measurements, but selects, which one of the known and suspected phases fits the measured patterns the best.
One diffraction pattern is simulated for each orientation (i.e. for each direction of the electron beam of the STEM, expressed in the crystal coordinate system of the given crystalline phase). Orientations are only considered from the asymmetric unit of orientations, since the rest of orientations are provided by the symmetry operations of the crystal. Orientations are considered from a discrete grid of solid angles with a given angular step size. The simulated diffraction pattern is rotated within the plane of the pattern during the fitting procedure. It is also rotated with discrete steps of angles, identical to that used for stepping the orientations.
Unit cell data can be input from two alternative formats of pre-saved data. On the one hand, CIF files [7] can be read. On the other hand, the format used by the ProcessDiffraction program [8] for structural data can also be used. Whenever the atomic positions are not known, positions of the reciprocal vector endpoints (the diffraction spots) are only calculated and intensity is only considered as a consequence of the curvature of the Ewald-sphere. For this step of the simulation assumed value of the local thickness and the effective size of the camera is taken into account. This latter value might be smaller than the true size of the camera chip, since part of it might be blocked by the HAADF detector. Effect of the structure factor is only calculated as an option for complete structural data sets, which also include atomic coordinates.

Fitting criteria
For any given orientation and any given rotation of the simulated pattern the quality of the fit is calculated. The quality of fit is a sum of products between the simulated intensity and the found net intensity above a background. If local intensity does not exceed the background, the product gets a negative sign, reducing the quality of fit value. Pixels around each simulated diffraction spots are only considered within a circle with user-specified radius (R 0 ). Pixels farther than R 0 from the simulated spots are not considered in the measured pattern for fitting. This approach reduces the sensitivity to local crystal thickness, which affects the extent of observable spots in reciprocal space. (The length of the relrods are determined by the local sample thickness and diffraction spots are only observed in the experiment, where the Ewald-sphere cuts a relrod. These spots can originate either from the zero order Laue-zone (ZOLZ) or from any of the higher-order Laue-zones (HOLZ)). It also helps finding the dominant phase in a troubled diffraction pattern, where spots from different crystallites are simultaneously present in a region of overlapping grains. That procedure is repeated for each orientation and rotation of each assumed phase and the one with the best quality of fit value is selected as a solution 1 to the measured pattern. This approach also facilitates setting a threshold for the quality of the fit later during display of results to exclude data with poor fit. However, the best fitting solution is still saved, so reasons for poor fit can be examined manually for any selected pattern in retrospect (in an optional validation step).

Displaying maps from the result-file
A colour-coded phase map shows the best fitting phase pixel-by pixel in the STEM image. Effect of setting threshold for the quality of the fit can be easily examined. Orientation maps are also colour-coded with a key to designation of colours shown in the right part of the map. Orientation maps visualize the distribution of native crystallographic directions of the grains looked from the directions of the coordinate axes (X, Y and Z) of the laboratory system.

Displaying integral data directly from the set of measured patterns
Measured patterns may also be post processed to collect intensity data from the individual patterns and allocate it to  Fig. 1c (White cross: fcc; white pentagon: hcp; white circle: bcc; white small ellipse: non-identified pattern from overlapping region). c) Phase map. Pixels with Fit Quality above 0.7 are only shown to belong to any phase. Patterns with poorer Fit Quality are indicated as Non-identified, even though the program assigns phase and orientation to those points, too. These areas correspond to overlapping regions of grains (as shown in Fig. 1b), where less reliable identification is based on the dominant diffraction point-set in the complex pattern. Orientation data p measured for the pixel marked with the white cross are shown right to the map. (Pixels are marked to show the origin of patterns in Fig. 1b: White cross: fcc; white pentagon: hcp; white circle: bcc; white small ellipse: non-identified pattern from overlapping region.) Pixel size is 4 nm. p The Frame "Orientation" indicates the name of the phase and 3-index notation of a crystal real space vector pointing to the Cartesian coordinate axes (X, Y and Z) of the photo (Lab system). d) Fit quality map. Minimal intensity indicates fit quality FQ 5 0.056 and the highest intensity indicates FQ 5 3.769. FQ 5 0.056 corresponds to missing pattern, since the camera was closed in the first 44 pixels (out of the total 2,500 pixels) to produce a reference to worst fit. (These black pixels are seen in the left part of the top row.) Pixel size is 4 nm the pixels of the map. In that way virtual bright field (VB) images and virtual dark field (VDF) images can be created by selecting different regions (direct beam or scattered beams) of each measured diffraction pattern.

EXAMPLES OF APPLICATION
A multicomponent alloy is selected as an example for the application of the method. Detailed preparation and analysis of the sample is published separately [6]. The examined TEM lamella was cut by focused Ga þ ion beam (FIB) from a larger multiphase sample from a different location than which was published in [6]. Presence of the major phases within different regions of the large sample were predetermined by x-ray diffraction (XRD) [6]. The part, selected for the present example is from a region, where XRD found fcc as the majority phase. In other locations of the sample bcc and hcp phases were also found by XRD.

Experimental details
Experimental data for the demonstration of operation are collected in a Thermo Fisher Titan Themis G2 200 STEM (Thermo Fisher Scientific,Waltham, MA, USA). A fine, almost parallel 2 electron beam is generated using 20 mm aperture in the C2 condenser lens and spot size 7. The resulting spot pattern is practically a nanobeam pattern, where the localization of the information is provided by the limited size of the illuminated area and no selected area aperture was used. 3 The size of the beam was <1 nm, but definitely not atomic size, in accordance with the requirements of the present problem. The area around the examined region was recorded on a TEM BF image (Fig. 1a). An area of 200 p 200 nm 2 was scanned and 50 p 50 diffraction patterns were recorded, corresponding to 4 nm spatial extent of a pixel. Examples of individual diffraction patterns are shown in Fig. 1b Since most of the examined grain size was several tens of nanometres (with a few grains in the examined area) this resolution was optimal for the given experiment. The location and the size of the area were previously selected in both TEM and STEM modes. The camera length was selected in a way to ensure that a recognizable angular That selection ensured that we could record a HAADF STEM image simultaneously with the measurement of the diffraction patterns. Later calibration determined this camera length to be 140 mm. Spot size 7 (determining the intensity of the primary beam), binning 4 in the camera and the 0.1s exposure time were selected not to damage the camera while making use of the dynamic range of it (maximal counts less, but close to 128,000 in the effective "pixel" of the 16 physical pixels provided by the binning). The diffraction patterns were recorded on a CETA 16M CMOS camera (Thermo Fisher Scientific, Waltham, MA, USA). The TIA program (FEI, Eindhoven, The Netherlands) of the STEM manufacturer was used to control the STEM experiment (scanning the beam and recording a diffraction pattern from the camera at each 0.1 s). The 2,500 individual patterns were later exported into 8-bit Tif format files from the single huge file (in proprietary format) of TIA. DiffMap processed these 2,500 files off-line in a separate computer.

Results
The phase map in Fig. 1c shows that in addition to the majority fcc phase, both bcc and hcp grains are present in that region of the sample. The black (poorly identified) borders between any two large grains correspond to overlapping grains producing troubled diffraction patterns. The same regions with poor fit quality can also be identified in the Fit quality map (Fig. 1d). DiffMap enables the user to check the appearance of and validate the indexing of any diffraction patterns, selected by a moving cross in the phase map (Fig. 1c). This is illustrated by showing an individual pattern of poor fit quality (bottom right corner of Fig. 1b). It can be seen that spots from different grains are present simultaneously in the diffraction pattern, causing the poor fit in the bottom right pattern of Fig. 1b. The patterns from within a grain are very similar resulting in homogeneous, identically oriented regions (corresponding to the grains) in the orientation maps (and example of such orientation maps is in Fig. 2). Although the majority of the pixels in the phase map (Fig. 1c) belong to larger grains, some pixels can also be seen as individually belonging to a different phase than its neighbours. Such grains, which appear to be so small (∼4 nm) can be a result of cutting a lamella from a 3D sample, where the corner of a larger grain from below appears in the lamella as an individual small grain.

CONCLUSIONS
An easy to use computer program is introduced. It does not need any additional hardware elements and it is available free from the home page of the author. It processes a large number of diffraction patterns off-line to produce phase and orientation maps, which can complement usual elemental composition maps. The recorded diffraction data represent a 4D dataset, since a 2D electron diffraction pattern is stored at each positions of the beam (corresponding to each pixel of the relevant 2D STEM image). Advice how to set the parameters of the STEM for data collection is given in the Experimental details section for a Titan STEM, but it can be generalized for other models with 3-condenser illumination system, too.