User Manual for
eRDF Analyser v1.0 (2017)
eRDF Analyser is an interactive and integrated tool for electron reduced density function analysis. This tool allows users to input an electron diffraction pattern (obtained from a TEM) and guides them interactively through a streamlined process of pre-processing, fitting and extracting the reduced density function (RDF) for their material.
Copyright © 2017
J Shanmugam*, KB Borisenko**
Electron Image Analysis Group, Department of Materials, University of Oxford
* janaki.shanmugam@materials.ox.ac.uk; **konstantin.borisenko@materials.ox.ac.uk
This tool is available as open source code and a Windows executable (both covered under the terms of the GNU General Public License version 3). We ask that you cite the following paper, “eRDF Analyser: An interactive GUI for electron reduced density function analysis” (in preparation) if you use output from this program in your own work.
Table of Contents
1 Introduction to RDF analysis
2.1 Features available in eRDF Analyser v1.0
2.2 Installation (for standalone package)
3.3.1 Input diffraction pattern
3.3.2 Input azimuthally average intensity profile of diffraction pattern
In statistical mechanics, a pair correlation or distribution function (PDF) describes the probability of finding a neighbouring particle at a distance r from a reference particle. Radial distribution function is an example of such a function, which is experimentally accessible through diffraction experiments using X-rays, neutrons or electrons. This enables characterisation of structural order of material systems e.g. defects in crystals, nanocrystallinity or medium-range order in nanoparticles, and short-range order in amorphous materials or glasses.
While diffraction data from X-rays and neutrons has been widely used in PDF analysis with the exception of synchrotron techniques, their scattering cross-section is too small for the study of atomic short-range order within nanovolumes of materials. Electron diffraction is particularly useful in this regard. Radial distribution function and its associated reduced density function (RDF) analysis of electron diffraction intensities or electron energy loss spectra can provide information on average interatomic distances and average coordination.
The theoretical basis of
RDF extraction from experimental electron diffraction data, as performed by the
eRDF Analyser software, is presented in the manuscript (in preparation).
Although there are a few other available packages which can perform RDF analysis on electron diffraction patterns, their dependence on host software platforms may present compatibility issues. eRDF Analyser was developed independently (based on in-house programs) on an alternative platform to offer users a streamlined approach to electron RDF analysis. It also takes into account most recent developments in parametrisation of atomic scattering functions. It is now freely distributed as an integrated GUI written in MATLAB which allows users to start from an initial diffraction pattern and obtain the RDF without having to use other routines. The output from eRDF Analyser can be directly used as input into Reverse Monte Carlo (RMC) software for refinements of atomic models based on diffraction data. This version only produces the RDF G(r) and not the radial distribution function J(r).
§ Accepts text input of entire electron diffraction pattern or azimuthally averaged intensity
§ Allows free-hand customised masking of beam stop and any other anomalies in diffraction pattern
§ Colour contour plotting of the diffraction pattern for easy definition of the circles with equal intensity and finding the centre of diffraction pattern
§ Optional automated routine to optimise user-defined centre of diffraction pattern
§ Azimuthally (radially) averages intensity to give experimental I(q)
§ Also calculates azimuthal variance (to be further developed in future versions)
§ Enables optimisation of data range (q-range) for fitting I(q)
§ Allows choice of parameterisation using Kirkland’s updated fitting coefficients1 or those proposed by Lobato and van Dyck2 for elastic electron scattering factors
§ Provides an automated fitting of experimental I(q) as a basis for further manual optimisation
The source code (.m and .fig files) is packaged in the Github repository with the following:
(1) ‘Parameter_files’ folder containing the scattering factor parameters,
(2) ‘Help’ folder containing user manual documentation, and
(3) ‘Test_data’ folder containing example diffraction data (a polycrystalline aluminium diffraction pattern, an amorphous SiO2 diffraction pattern [use calibration factor 0.00167] and another amorphous SiO2 diffraction intensity profile [use calibration factor 0.00167]).
The standalone package (executable) requires MATLAB Runtime version 9.0 (2015b) to run. This can be downloaded from http://www.mathworks.com/products/compiler/mcr/index.html. After a one-time installation, eRDF Analyser should launch similar to any other software program on Windows OS. (The first launch after a system restart may take some time for the runtime environment to initialise but subsequent launches should proceed much faster.) It can also be run using the Windows console command. You can download the ‘Test_data’ folder from the Github repository for example diffraction data.
The software GUI has two panels, ‘Diffraction Data’ (for processing the diffraction pattern and choosing data range) and ‘RDF Plot’ (for fitting and obtaining RDF). At start up, the first panel ‘Diffraction Data’ (Figure 1) is displayed by default. The process flow is documented in the following sections.
Help Options
Pop-up dialog boxes guide the user on the next steps to take but if further help is required, hovering over text fields and the ? icons can provide hints. Clicking on the ? icons will open the relevant section of the user manual in a browser window (requires Internet connection). An offline PDF user manual can also be accessed via the Help Menu in the toolbar. The dialog boxes which pop up when the GUI is launched or when switching to the RDF Plot panel can be hidden, but clicking ‘Re-enable dialog boxes’ under the Help Menu will display them again.
Figure 1: eRDF Analyser GUI Panel 'Diffraction Data'
At start up, the software prompts the user to input a calibration factor and load the diffraction data (see section 3.3). Calibration of the scattering vector is crucial for accuracy of the r values in the RDF G(r). Input the pixel size in terms of reciprocal space (Å-1 per pixel) as the calibration factor (ds = dq/2π).
If using a polycrystalline standard (ring pattern) and calibration factor is not yet available at this point, you can input this at a later stage – eRDF Analyser allows a workaround (see #Note in section 3.3.2) for accurate determination of the calibration factor. Meanwhile, continue to load the standard diffraction data and extract its intensity profile.
You can choose to load the diffraction data in the form of either a two-dimensional diffraction pattern (continue to section 3.3.1) or a one-dimensional intensity profile (section 3.3.2). The software only accepts text file formats.
1. Choose the type of diffraction pattern (Polycrystalline or Amorphous) to be loaded. This choice affects the optional routine to optimise the centre of the diffraction pattern. The Polycrystalline routine only works for patterns whose central beam is within the bounds of the image (centred pattern), while the Amorphous routine works for patterns recorded with centred and off-centred beams. However, if optimisation of the centre is not necessary, this does not matter.
2. Load the relevant data (text) file by clicking ‘Open’. If the diffraction pattern is still in a native format (e.g. .dm3), save it as a text file in the microscope software before loading it in eRDF Analyser. Only symmetrical patterns are accepted (e.g. 2048 by 2048 pixels).
3. An image of the diffraction pattern is loaded. Optionally apply a median filter to remove salt-and-pepper noise.
4. If a beam stop is present, draw a freehand ROI to mask beam stop. Additional freehand definitions can be used to mask any other distorted areas in the image that could affect the azimuthal averaging. Click and drag continuously to mark the region, drawing outside the bounds of the beam stop to ensure full coverage. If masking is not required, just click anywhere on the image.
Figure 2: Images of diffraction patterns of amorphous SiO2 before masking (left); and after masking the beam stop (right) in colour contour mode, with adjustable marker resized and positioned to fit a contour
5. Adjust and resize the white circular marker on the image to fit one of the inner coloured contours (in black / blue / green) (Figure 2). This will be used to define the centre of the diffraction pattern. Double-click inside the marker once done.
6. You can choose to continue with the user-defined centre or carry out optional optimisation of the centre of the diffraction pattern.
For polycrystalline patterns, the software only carries out optimisation for patterns recorded with centred beams (patterns centred in the image such that majority of contours are fully visible within its bounds). The user is asked to input values for number of radial projections, distance of an additional contour from the edge of the array (in terms of pixels) (Figure 3) and size of grid scan (in terms of pixels) (Figure 4), or can continue with the default values displayed. The software then generates a concentric circle larger than the initial user-defined 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 sides of line scans along the radial lines (radial projections) within the two concentric circles, is then constructed and minimised.
For amorphous diffraction patterns (recorded with centred or off-centred beams), the user is asked to input values (in terms of pixels) to define the limit to search for pixels of equal intensity (Figure 3) and the size of grid scan (Figure 4), or can continue with the default values displayed. The software generates a concentric circle larger than the initial user-defined circle (with a difference in radii defined by the limit value) and highlights pixels with equal intensity value within the limits defined by the two circles. A circular function is fitted to these highlighted pixels (in red).
Figure 3: Additional larger circular markers created as part of the optimisation routine; For polycrystalline patterns (left), the new marker is created at a specified distance from the nearest edge of the pattern field array; For amorphous patterns (right), the difference in radii between the initial and new markers is specified by the ‘limit to search for pixels of equal intensity’
In both cases, optimisation of the position of the centre is performed by a grid scan around the user-defined centre. If users are reasonably confident of their initial centre definition and there is minimal intensity variation in the contours, decreasing the value of the size of grid scan can result in noticeably faster completion of the optimisation routine. It is our experience that due to colour contour plotting of the diffraction pattern the initial guess in centre definition is fairly accurate and optimisation rarely results in deviation from the initial guess position by more than 5 pixels.
Figure 4: Depiction of a 2-by-2 grid scan around the user-defined centre (xuser,yuser), where optimisation of the functional calculated at each of the pixel positions in the grid leads to an optimised centre (xopt,yopt).
The user can choose to accept the results of the optimisation, reject it and continue with the initial user-defined centre, or try optimisation again. For polycrystalline patterns, a “Centrefinder fit” window (Figure 5), showing a comparison of intensity line profiles from opposite sides of the diffraction pattern relative to the centre, is also displayed at the top left corner of the screen. A well-optimised centre position should result in good agreement of peak positions and minimal difference between the two line profiles.
Figure 5: ‘Centrefinder fit’ window displayed during ‘Polycrystalline’ centre optimisation routine – showing the difference between intensity line profiles from opposite sides of the diffraction pattern relative to the centre.
7. Azimuthally averaged intensity and variance is then calculated and plotted in a figure window on the left edge of the screen.
*Note: The azimuthal variance is also a good indicator of accurate definition of the position of the centre of polycrystalline patterns. If peaks are not sharp or well-defined (Figure 6), optimisation of the centre may need to be carried out. It is harder to tell for amorphous patterns as high variance at low pixel values is usually due to the beam stop masking and intensity peaks are not as sharp.
8. The user is prompted to select a folder to save the raw data (with default filenames ‘<Diffraction pattern filename>_azav.txt’ and ‘<Diffraction pattern filename>_azvar.txt’). You can continue without saving but saving the raw data will allow you to resume / repeat analysis at a later stage by loading the intensity profile directly.
9. The intensity profile plot is displayed in the main GUI window. Continue to section 3.3.2.
Figure 6: Plots showing azimuthal variance of intensity profiles from accurately defined centre (left) and inaccurately defined centre (right) of a polycrystalline diffraction pattern
Users have the option to directly input the averaged intensity if they already have the information without processing the diffraction pattern. Click “Open” and select the desired text file containing the intensity data as a single column (averaged azimuthally / as a radial distribution from the centre of a diffraction pattern). The one-dimensional intensity profile will be plotted in the GUI (top plot) as intensity vs. pixel values.
For users who have processed the pattern using eRDF Analyser or loaded the ‘<Diffraction pattern filename>_azav.txt’ file and arrived at this step, continue with the following.
1. Using the Data Cursor tool at the top of the menu to look at the pixel values, the user can survey the pixel values and choose a suitable data range to be used in subsequent steps for fitting, e.g. maximising the range but excluding noisy regions at the edges of the profile.
2. The ‘Start’ and ‘End’ fields should be filled in, allowing the user to check these values and modify them if necessary (by keying in new values). A magnified view of the beginning and end of the data range is presented in the bottom two plots (Figure 7).
Figure 7: Selection of data points from intensity profile of amorphous SiO2 diffraction pattern
3. Check that a calibration factor has been input.
NOTE: If the intensity profile is that of a polycrystalline calibration standard, use the Data Cursor tool in the toolbar to get the pixel values (x-axis) of the first few peak positions (Figure 8). Additional data cursors can be added by pressing Shift+Click. By dividing the known reciprocal lattice spacings by the respective pixel values, and averaging the results, an average value for the calibration factor is obtained. The user can now return to section 3.3.1, input this calibration factor and load the sample diffraction pattern to continue with analysis.
Figure 8: Intensity profile of polycrystalline evaporated aluminium calibration standard
4. Click ‘Calibrate and plot selected data range’. This will update the selected data range (as shown in the bottom two plots), calibrate the data and plot it in the next panel.
Click ‘RDF Plot’ tab at the top of the GUI to switch to the next panel. The calibrated intensity profile should be displayed in the first plot (Figure 9). The default fitting uses Kirkland coefficients but users have the option to use Lobato coefficients instead. Choose the elements present in the sample. Input the elemental material composition in terms of atomic ratios, leaving other fields unchanged if there are less than 5 elements. Users can choose to have the software automatically fit (section 3.4.1) an atomic scattering curve to the experimental scattering intensity I(q), with further optional manual optimisation, or to perform manual fitting from scratch (section 3.4.2).
Figure 9: eRDF Analyser ‘RDF Plot’ Panel
For automated fitting, click ‘Auto Fit’. The default fitting is performed over the entire q range (Figure 10); however, users can choose to only use the tail end (approximately last third of the q range) for this fitting. The latter approach has been found to give better fits (Figure 10) for diffraction data in some cases e.g. those obtained from thicker samples or with extended q-range that will benefit from heavier weights at the tail end.
The resulting fit as well as reduced scattering intensity φ(q) and RDF G(r) are plotted in the GUI. The maximum q value, value of coefficient N and a default damping factor of b = 0.3 are shown in the readout displays. The sum of squared deviations (SS) between experimental I(q) and I(q)fitted is also displayed for reference. The step size of r in the G(r) calculations can be adjusted using the dr value (default 0.01 Å).
While results of the automated fitting have been found to produce reasonable fits for experimental data of good quality, some optimisation may still be required. The damping factor for φ(q) can be adjusted within the automated routine, but manual fitting allows users to make further adjustments to certain parameters used in the fitting.
Figure 10: Results of automated fitting
There are a few considerations when assessing goodness of fit. Adjustments can be made to both q and N until φ(q) oscillates about zero (q-axis) or close to it. Another way is to try and minimise the unphysical peaks (below 1Å or the first inter-atomic distance) in G(r). An additional measure is provided by the ‘‘SS’ readout which displays the sum of squared deviations between experimental I(q) and I(q)fitted. Sometimes, the user may need to revisit the data chosen in the first panel to select a range of better quality data.
To make I(q)fitted fit the experimental I(q), adjust the values for q and N. Here, q is the point on the I(q) curve where I(q) = I(q)fitted, and N approximately relates to the number of material’s compositional units present in the scattering volume. Best practice would be to use the highest possible q value to extend the q-range – this is used as the default q value in the automated fitting procedure. The user can input any value in the ‘Fit at q’ field and the software will find the closest q data point that is available. If optimising the automated fit, the values used will be updated in the GUI. Further adjustments to the q value at which to fit the curve can be made by fixed increments/decrements using the toggle buttons (Figure 11). The step sizes can be changed by keying in desired values. Adjusting the value of N, changes the gradient of I(q)fitted. Click ‘Manual Fit’ after each adjustment of q or N to check the fit. A damping factor less than 0.5 has been found to be a reasonable value in reducing errors of truncation.
Figure 11: Optimised fit of I(q) and final RDF(Gr) of amorphous SiO2
After optimising the fit and obtaining the RDF G(r), the user may want to save export the raw data or edit the plots further before saving / exporting them.
* Within the GUI, the legends in the plots can be moved by dragging them around.
* The x-axis range of the G(r) plot can be adjusted using the r(max) value (default 10 Å).
Export plots / raw data:
There are three save / export options available in the File menu. Note: Since these files have generic names, generating and saving new results will overwrite existing files in the same folder.
1. Save Plots as JPEG: This saves the three plots of I(q), φ(q) and G(r) as separate .jpeg files.
2. Export Results as CSV: This exports the raw data of all three plots and the parameters used for fitting to three .csv files. This method is recommended for users on Mac OS or those who do not have Excel installed on their systems.
3. Export Results to Excel: This exports the raw data of all three plots and the parameters used for fitting to a single Excel workbook. This only works on Windows OS.
Edit plots before saving:
Users also have the option to open the I(q), φ(q) and G(r) plots in separate figure windows for editing (e.g. line width and colour properties). To do so, ensure the Zoom / Data Cursor tools are inactive, then right-click in the area of each plot and choose ‘Open plot in new figure’. This will display the plots on the right edge of the screen in separate windows with tools for editing. Users can then save / export the plots to any available format.
1. Kirkland, E. J. in Advanced Computing in Electron Microscopy 40, 243–260 (Springer US, 2010).
2. Lobato, I. & Van Dyck, D. An accurate parameterization for scattering factors, electron densities and electrostatic potentials for neutral atoms that obey all physical constraints. Acta Crystallogr. Sect. A Found. Adv. 70, 1–13 (2014).