eRDF Analyser: An interactive GUI for electron reduced density function analysis

developedasanintegratedtoolwithaneasy-to-useinterfacethatoffersastreamlinedapproachtoextract


Introduction
Radial distribution or pair correlation function (also known as pair distribution function (PDF)) is an effective way of describing average local structure of disordered materials in terms of the probability of finding a pair of atoms separated by a distance r. The function is experimentally accessible through diffraction experiments using X-rays, neutrons or electrons and enables characterisation of structural order in polycrystalline and nano particulate materials and short-range order in amorphous materials or glasses. Reduced density function (RDF) analysis of electron diffraction intensities, similarly to X-ray and neutron diffraction intensities, can provide information on average interatomic distances and coordination in these materials. While diffraction data from X-rays and neutrons has been widely used particularly with synchrotron radiation, the cross-section of X-rays and neutron beams is too large for the study of atomic short-range order within nano volumes of materials. Electron diffraction, however, is particularly useful in this regard, especially using aberration corrected probes. This paper presents 'eRDF Analyser' software, an interactive and customisable tool for extracting the RDF from electron diffraction data. The output from this tool can be directly used in Reverse Monte Carlo (RMC) software as a reference for refinement of atomic models.

Theory of radial distribution function
Following [1], considering a system of N particles occupying points in real space at r = r i , a two-particle distribution function, defined as n (2) (r 1 , r 2 ) = n (1) (r 1 ) n (2) (r 2 ) g (2) (r 1 , r 2 ) , (1) denotes the probability of two particles existing simultaneously at r 1 and r 2 . While higher-order functions can be defined similarly, the pair distribution function g (2) (r 1 , r 2 ), or simply g(r), can be measured experimentally. With the origin on an atom, the average number of atoms in a spherical shell of thickness dr at distance r is given by where n 0 = N V is the average density of N atoms in volume V. The radial distribution function J(r) is thus defined as where g(r) is the pair distribution function directly related to the local density of atoms at distance r from a central atom. A so-called reduced density function (RDF) can be defined as where ρ 0 is the macroscopic average density.

Extraction of RDF from electron diffraction data
The extraction of RDF function, G(r), from experimentally obtained electron diffraction patterns recorded using selected area or nano beam diffraction under parallel illumination in a transmission electron microscope (TEM) is outlined below. The derivation of G(r) from the recorded diffraction data involves a number of numerical procedures that assume elastic single scattering conditions. First, the recorded diffraction pattern is converted into azimuthally averaged scattered intensity, I(q), as a function of the scattering vector q, where θ is the scattering half-angle and λ is the wavelength of the electron. We note that in the electron diffraction literature, computations are frequently performed and reported in terms of the vector s (s = q/2π ). In the present manuscript and software functions are visualised in terms of q although the backend calculations are performed in terms of s. The scattered intensity I(q) is given by the Debye formula, and neglecting small scattering angles, can be expressed as By defining a reduced intensity function, information about the local order is expressed in the deviation of total scattered intensity I(q), that consists of both individual and atomic pair contributions, from the scattering intensity of individual atoms present in the material. Here, N i is the number of atoms of type i and f i (q) is the atomic scattering factor. Practically, this is implemented by calculating after fitting the contribution from individually scattered atoms, I(q) fitted , through the oscillations of the experimental total scattering intensity I(q) experimental . The RDF, G(r), is then obtained by Fourier transformation of ϕ(q), expressed as Due to practical limitations, such as masking of the central beam, finite detector sizes and camera lengths, there is a minimum and maximum cut-off for the q values. This leads to a truncation of the Fourier series, which can cause spurious or unphysical peaks. Hence, a damping function of the form exp , where b is the damping factor, is introduced in ϕ(q) before the Fourier Transform to reduce effects of the limited q-range and high frequency noise (at high q). The truncated G(r) is then computed as,

Motivation and significance
There are other free-to-use software packages available online which are capable of similar electron RDF/PDF analysis, notably the Digital Micrograph (DM) plugins RDFTools [2] and PASAD [3]. These packages, however, are dependent on the Gatan Microscopy Suite and version incompatibility can prevent the use of routines. Hence, eRDF Analyser was created independently on an alternative backward compatible platform to provide better flow of research projects. Its executable form offers a significant advantage as a standalone package (that only requires the runtime environment to run), while the open source code allows easy integration into future packages or suites and customisation. We also note a similar recent publication on SUePDF [4], a MATLAB-based GUI available as a standalone package only.
Although eRDF Analyser shares many features with the abovementioned packages, there are differences in the underlying implementations. For example, modelling of atomic scattering background in eRDF Analyser is based on the physically accurate elastic atomic scattering intensities, while it is performed by an empirical background fitting in SUePDF [4] that includes correction for inelastic scattering. Modelling the atomic scattering contribution based on a physical model is a feature that allows judgement of suitability of the experimental diffraction data for RDF analysis, which is entirely based on elastic scattering. Some additional functionalities in the DM plugins, while seemingly comprehensive, may lead to a complex host of options for the user to choose from at each step of the analysis. In contrast, eRDF Analyser aims to offer a streamlined process flow by simplifying the user's role and standardising the process with no detrimental effects on the output RDF. In addition, a feature in the eRDF Analyser to output azimuthal variance is not available in any of the existing software. Analysis of azimuthal variance can reveal orientational order [5], especially when examining polycrystalline or nano volumes of amorphous materials.
SUePDF only accepts inputs in the form of intensity profiles which would have to be pre-processed, whereas eRDF Analyser offers an integrated approach beginning with the recorded diffraction pattern. Successful RDF extraction requires accurate determination of the calibration factor, which is generally obtained using a polycrystalline standard sample. The determination of this calibration factor is also facilitated by eRDF Analyser, as the diffraction pattern from the standard can be imported and analysed in the software.
The interactive interface of eRDF Analyser guides the user along every step of the analysis, which is particularly helpful for users who may be new to RDF analysis. As an additional advantage, the software also takes into account the most recent developments in parameterisation of atomic scattering factors. Together with Kirkland's revised parameterisation [6], the eRDF Analyser also includes the parameterisation developed recently by Lobato et al. [7]. Although the current version of eRDF Analyser only outputs the RDF G(r), a future version of the software is expected to include the J(r) function and its associated functionalities.

Software architecture
eRDF Analyser is designed as MATLAB graphical user interface (GUI), which can run in MATLAB or as a standalone tool. An overview of the process flow is shown in Fig. 1, from user input of either the original electron diffraction data or an averaged intensity profile, to extraction of the RDF for further analysis.

Software functionalities
eRDF Analyser can be used to extract the RDF from electron diffraction experimental data. The user is guided through this process via interactive prompts in the software. Where further help may be required, hints are provided on mouse-overs at text fields. Help (?) icons in the GUI also direct the user to relevant sections in an online user manual, while an offline PDF manual is also accessible via the menu bar.
The software generates an azimuthally averaged intensity profile and variance from the input diffraction pattern. Some key features used to determine the centre of the diffraction pattern include visualisation of the pattern in a coloured contour mode and an optimisation routine that improves the user-defined centre as described subsequently. The software also facilitates parametric fitting of the atomic scattering to the total experimental scattering intensity and performs numerical computations to determine the reduced scattering intensity function ϕ(q) (Eq. (8)) and RDF G(r) (Eq. (10)). Fitting is an iterative process that has been streamlined for the user with an automated fitting that provides the basis for further manual optimisation. This includes optimisation of the data range and fitting parameters, that is enabled by visualisation of the resulting functions ϕ(q) and G(r).

Illustrative example
This paper illustrates the use of eRDF Analyser in the analysis of two different materials: 18 nm thick amorphous silica (SiO 2 ) film and polycrystalline gold nanoparticles on a carbon grid. Selected area electron diffraction data were recorded from these materials using a JEM-2100 at 200 kV and JEM-ARM300F at 160 kV, respectively. In general, parallel illumination conditions are important using either selected area or nano beam diffraction. While this section provides an illustrative example of the features in eRDF Analyser using the amorphous SiO 2 data, results of the analysis for both materials are discussed in Section 4.

Azimuthally averaged intensity
Electron diffraction data is first input in text format with an appropriate calibration factor (ds = dq/2π , in units of reciprocal Angstroms per pixel) in the Diffraction Data GUI panel. The software allows the user to mask beam stops (Fig. 2a, b) and any other distorted areas (Fig. 2c, d) in the displayed diffraction pattern with freehand definition of these regions. Users can easily define the centre of the diffraction pattern by fitting contours with equal intensity in a coloured contour mode (Fig. 2b, d), and choose to let the software optimise the user-defined centre. The software then generates azimuthally averaged intensity data and azimuthal variance of the intensity.
Two different approaches are used to optimise the initial guess for the position of the centre, depending on the type of the diffraction pattern being investigated. For centred patterns, e.g. polycrystalline calibration standard, the software generates a concentric circular contour with a radius larger than the initial guess circle, such that it does not exceed the field of the diffraction pattern array. A functional, representing a sum of squared differences between two opposite sites of line scans along the radial lines within the two concentric circles, is then constructed and minimised. For diffraction patterns from amorphous materials, the software first generates a concentric circular contour with radius larger than the initial circle defined by the selected limits. A circular function is fitted to pixels of equal intensity within the defined limits of the two circles. In both cases, the global optimisation of the functional is performed by a grid scan, computing an array of values as a function of different positions of the centre. It is our experience that due to coloured contour plotting of the diffraction pattern, the initial guess of the centre position is fairly accurate, such that only a small area for grid scan is required for optimisation.

Fitting of atomic scattering and RDF extraction
The azimuthally averaged intensity profile is then used as input for the next step of fitting the atomic scattering background, I(q) fitted . Users can choose to input this intensity data directly if available, instead of averaging the original electron diffraction pattern in the previous step. The desired range of data points are chosen from the intensity profile (Fig. 3), maximising the q range while avoiding noise at higher q. The selected data is calibrated and plotted in the RDF Plot GUI panel (Fig. 4). Users have a choice of fitting the experimental data (I(q)) with Kirkland [6] or Lobato [7] atomic scattering factors. These factors are weighted according to the material composition, which is entered as atomic ratios.

I(q) fitted is fitted in the form I(q) fitted
N is the dose-dependent scale factor relating the recorded number of detector counts to the total number of atomic formula units in scattering volume, p i is the atomic fraction of atomic species of type i, f i (q) is the corresponding atomic scattering factor and C is a correction for dark current in the recorded diffraction pattern.  (c) An off-centre pattern (diffraction rings only partially visible) that was collected on a CCD that requires correction at the right-hand edge; (d) Same pattern in coloured contour mode with the right-hand edge masked and a marker positioned to fit a well-defined inner contour.  The goodness of fit can be represented by the sum of squared differences (SS) between I(q) fitted and I(q) experimental curves. The resulting function ϕ(q) should ideally oscillate about zero, and unphysical peaks (below 1 Å or the first bond length) in the RDF G(r) should be minimised as much as possible. Fitting is an iterative and interactive process that may require the user to revisit the Diffraction Data panel and select a different data range, as well as adjusting the parameter values in the RDF Plot panel to obtain the best possible fit. To make this process easier, the automated fitting routine provides a reasonably good fit to the experimental scattering intensity of good quality, as the basis for further manual optimisation, if required. The value entered under 'Fit at q' determines the closest intensity data point used for cut-off in the I(q) fitted curve and the upper bound of the truncated RDF (q max in Eq. (10)). This is also the value where I(q) fitted curve intersects the I(q) experimental curve -the maximum q value in the dataset is used by default in the automated fitting.
Analytical solution for the coefficients N and C in I(q) fitted is derived by minimising the following weighted functional with weights w j : where summation runs over all data points j.
, and assuming that the I(q) fitted = NF (q) + C curve intersects the I(q) experimental curve at a point q k , we can define the solution as This system of equations can be rewritten as This functional is a variable of N and the solution for N can be found equating the first derivative of the functional by N to zero Solving this equation gives (see equation given in Box I) The computed value of N can then be used to obtain C using the equation: Weights can be used to select the experimental data range for fitting. In the software, full range of the data and the last third of the data range (tail end) can be selected. The damping factor b is used in the damping function to suppress effects of truncation in the Fourier Transform of ϕ(q). Values of these parameters (q, N, b) used in the automated fitting are updated in the GUI such that further adjustments can be made manually to optimise the fit.

Results and discussion
The software optimises the position of the centres of diffraction patterns recorded with centred beams with an error of ±1 pixel.
Ellipticity can cause a larger deviation, especially when using a larger (lower intensity) contour to define initial guess in diffraction patterns recorded with off-centred beams. While it is best practise to use the innermost high intensity contours to define the initial guess, an error in the centre position of ±2 pixels does not have any notable effect on the averaged scattering intensity curves for amorphous diffraction data. Similarly, a deviation of ±2 pixels in position of the intensity peaks for polycrystalline standard results in ±2e-6 Å −1 error in the calibration factor, with deviation in the positions of RDF peaks of less than 0.01 Å. Fig. 5a shows the I(q) experimental scattering intensity and I(q) fitted background curves of the centred and off-centred diffraction data recorded from amorphous silica, as in Fig. 2a and Fig. 2c, respectively. All experimental intensity curves were generated after optimisation of the diffraction pattern centre to reduce user bias.

Amorphous silica
Intensity data up to q = 20 Å −1 was selected for fitting the contribution from individual atomic scattering (excluding noisy data at high q values). Automated fitting of the I(q) experimental curves obtained from both diffraction data gives I(q) fitted curves that are similar to those fitted manually. However, in the case of the offcentred diffraction data, fitting at just the tail end of the data range allows the scattering intensity at higher q values to be fitted more accurately than when fitting over the entire q range. The RDF curves extracted from both automatically and manually optimised fitted background curves for both sets of diffraction data are shown in Fig. 5b. As demonstrated in the figure, manual fit improves RDF curves in the region below 1 Å.

Polycrystalline gold
The data from polycrystalline gold sample was recorded using 50 µm selected area aperture and 100 nm condenser lens aperture with the C s corrector turned on. RDF analysis of the data was performed using eRDF Analyser, with the results shown in Fig. 6. Such polycrystalline diffraction data from known samples are useful as a calibration standard. After masking of the beam stop, the electron diffraction data (Fig. 6b) was azimuthally averaged to obtain the experimental scattering intensity (I(q) experimental ) and an automatically fitted background (I(q) fitted ) (Fig. 6c).
Intensity data up to q = 19 Å −1 was selected and a damping factor of b = 0.1 was used to reduce truncation effects in the reduced intensity function ϕ(q) (Fig. 6d). Fig. 6e show peaks diminishing in amplitude and reaching the lowest height at about 50 Å, suggesting that the mean particle size of the gold nanoparticles in the sample is

RDF curves in
(15) Box I. approximately 5 nm. This is corroborated by the ADF STEM image of the sample presented in Fig. 6a. The first relevant peak position at 2.87±0.01 Å in the RDF as well as following major peaks (shown in inset in Fig. 6e) at 4.98 ± 0.01 Å and 7.62 ± 0.01 Å are in close agreement with Au...Au interatomic distances found in facecentre cubic (FCC) structure with lattice constant a = 4.08 Å [12]. The ϕ(q) and RDF curves from this sample also closely resemble those presented in [13], with deviations in minor peak positions possibly due to the differences in the particle size distributions in the samples.

Conclusions
The eRDF Analyser software described in this paper is an integrated tool that facilitates RDF extraction from experimental electron diffraction data via a visual and interactive process. It is built on the MATLAB platform as an alternative to existing packages, with its open source nature allowing users the flexibility to customise their analysis. The software also takes into account the most recent developments in electron scattering factor parameterisation. The executable package should allow new users, who are less familiar with the technique or not currently using any form of RDF analysis software, to easily perform the basic analysis in a robust manner. Such a routine analysis is expected to form the basis for development of further electron diffraction data analysis techniques.