You are on page 1of 31

p1 of 31

DiffTools Script Package for


DigitalMicrograph™

D. R. G. Mitchell
www.dmscripting.com, July 2016
version 4.0
fig
p2 of 31

Introduction

DiffTools is a suite of scripts which add functionality for proceesing and analysing selected
area electron diffraction patterns to DigitalMicrograph™ (DM) (Gatan Inc.). The suite of
scripts can be downloaded freely from the internet (details follow). Following installation, a
DiffTools menu appears which give access to a range of menu commands and user-friendly
dialogs. A detailed description of the function of each of these scripts follows. If you find
these tools useful and they contribute to your published work, please consider citing the
following article:

DiffTools: Software Tools for Electron Diffraction in DigitalMicrograph, D. R. G. Mitchell,


Microscopy Research and Technique, 71 (2008) 588-593.

Acknowledgements.
In version 4.0 of this software an ‘AutoDiff’ script has been added. This script is based on an
idea by Miloslav Klinger where diffraction spots are fitted to a two dimensional Gaussian.
The size of the Gaussian is increased and the goodness of fit as a function of position and
Gaussian size is recorded in a 3D image. This is then mined to find the optimum fit/position
for each spot. Miloslav has created a really useful suite of free diffraction processing tools
(non-DM based) which are freely available and highly recommended
(http://www.fzu.cz/en/crystbox).

Updates included in this version and known issues.

Version 4.0 Contains one new piece of functionality – AutoDiff. This tool is designed to
automatically measure single crystal spot patterns. The user needs only set the centre
approximately and the pattern is analysed. Based on the fitted spot positions the centre
position can be refined. Tabulations of d-spacings can be produced very quickly.

Protecting your software.

WARNING: While every care has been taken to ensure that this software is bug-free and will
not damage your system, the possibility does exist. Proceed at your own risk. You MUST
make a copy of your DigitalMicrograph preference files before installing this software. If
problems do occur you can quickly reinstall your system with your saved preferences.
Without a saved set of preferences, this could be a very involved process and might even
involve a Gatan engineer call out.

DigitalMicrograph saves various bits of information in different preference files in


/ProgramFiles/Gatan/DigitalMicrograph/Prefs. Note In Windows 7, or if you installed
DigitalMicrograph for your use only, the preference file may live within your user folder – do
a search on ‘DigitalMicrographCF.8’ to find it.

If you install any standalone scripts, these get stored in the ‘DigitalMicrographCF.8’
preference file. All the information in the Global Info, which includes script, camera, GIF
preferences etc gets saved in the ‘DM Preferences.7’. There is also a ‘Microscope Data’
preference file which stores microscope hardware configuration data. These files are very
p3 of 31

important, and if they get corrupted, they may cause DM to become erratic or a connected
microscope to become inaccessible. It is quite common for a corrupted preference file to
result in a microscope camera becoming very sluggish. The solution is very easy – replace the
damaged preferences with a copy. It is very good practice to make regular backups of the
Prefs folder (DM should not be running at the time). Always make a fresh copy before
making any changes to your system – such as installing new plugins or other software. Call
the copy ‘Copy of Prefs YYMMDD’ - add a date signature. These folders can live inside the
DigitalMicrograph folder – as long as you change the name from ‘Prefs’. However, it is also a
good idea to keep a copy on a separate computer, in case you lose a hard disk. This does not
preclude the need for a sensible overall backup strategy for your computer.

If you do develop problems with your system, Gatan generally advise to make a copy of your
preferences, uninstall DM (except for the licenses), reinstall DM, then copy your old
preferences across. This is fine as long as you know you have a good copy of preferences.
Make a copy of your Prefs folder now.

Sourcing/Installing the Software.

The DiffTools suite of scripts consists of the following:

• DiffTools Uninstaller – an uninstaller script which will automatically remove all of the
DiffTools components.
• DiffTools.gtk – a package which adds all the scripting functionality.
• DiffTools Manual – instructions for installing and using DiffTools.
• Two example diffraction patterns – single crystal silicon and polycrystalline gold.

The above files are available as a zipped archive. It can be downloaded freely from Dave
Mitchell’s DigitalMicrograph Scripting Website.

http://www.dmscripting.com/difftools.html

Installation is very similar in both GMS environments (GMS 1 and 2). Note, due to
microscope dependencies I will not be doing any work with GMS 3 for the foreseeable future.
I have no doubt this script will work fine with GMS 3. However, if it does not, no assistance
will be given.

The major difference between using GMS 1 and 2 is the location of the plugins folder inside
the Gatan folder where the DiffTools package needs to be installed. The respective paths are:

Windows XP
GMS 1.8 and earlier: C:\Program Files\Gatan\DigitalMicrograph\PlugIns
GMS 2: C:\Program Files\Gatan\Plugins

Windows 7/8/10
Software installed for all users:
GMS 2: C:\ProgramData\Gatan\Plugins
Software installed for a single user
GMS 2: C:\Users\YourName\AppData\Local\Gatan\Plugins
(note YourName – is the name of your user account).

In Windows 7/8/10 The ProgramData and AppData folders are hidden by default. You will
not be able to see them unless you make them visible first. To do this in Windows 7 select
‘Control Panel\Folder Options\View Tab – select ‘showing hidden files, folders and drives’.
p4 of 31

In Windows 10 open the ‘Settings’ control panel and search for ‘Show Hidden’ to locate the
above control panel.

Installation Option 1: If a previous version of DiffTools is installed and the current set of
DiffTools preferences is to be preserved for use with the new version:
1. Shut down DigitalMicrograph.
2. Navigate to the plugins folder as shown above.
3. Remove the DiffTools.gtk plugin from the Plugins folder – store it in a temporary
folder, in case you need to revert to it.
4. Copy the new DiffTools.gtk package file from the downloaded archive into the
Plugins folder.
5. Restart DigitalMicrograph and the revised script menu should appear.
6. All previous preferences/crystal structures etc will still be accessible.

Installation Option 2: If a previous version of DiffTools is installed and the current set of
DiffTools preferences: is NOT to be preserved for use with the new version:
1. Open the DiffTools Uninstaller script in DigitalMicrograph, and ensure all
unsaved work is saved and closed.
2. With the uninstaller script front-most (title bar is blue), hit CONTROL + ENTER
to run the script.
3. Follow the prompts – DigitalMicrograph will shut down (in GMS 2 you’ll be
prompted to shut it down manually). All preference files and the DiffTools plugin
will be deleted.
4. Copy the DiffTools.gtk package file from the downloaded archive into the Plugins
folder as shown above.
5. Restart DigitalMicrograph and the revised script menu should appear. Fresh
preferences will be created as you use the relevant scripts.

Installation Option 3: If this is a new installation of DiffTools:


1. Shut down DigitalMicrograph.
2. Navigate to the plugins folder as shown above.
3. Copy the DiffTools.gtk package file from the downloaded archive into the Plugins
folder.
4. Restart DigitalMicrograph and the DiffTools menu should appear.

Uninstalling the Software.

The uninstaller script (DiffTools Uninstaller) can be used to remove all traces of DiffTools
from DigitalMicrograph. The files removed are the DiffTools.gtk plugin file from the Plugins
folder (see Sourcing and Installing the Software). It will also remove all DiffTools
preferences from the Global Info. These include any custom crystal structures, camera length
calibrations etc which have been created. The uninstaller script should only be used when you
wish to remove all traces of DiffTools from DigitalMicrograph permanently. For updating to
a newer version of the software, the preceding instructions for preserving preferences should
be followed.

Software Compatiblity/Disclaimer.

This software should be compatible with all versions of GMS 1.7 – 2.30 inclusive. The scripts
are likely to be compatible with GMS 3 (unsupported), but this has not been tested. Please
report any bugs or requests for improvements to the author:
p5 of 31

adminnospam@dmscripting.com (remove the nospam to make this email address work).

The software is provided on an as-is basis. No warranty as to its performance is given, nor
any responsibility accepted for any losses arising from failings in it

This software is designed ostensibly for single crystal selected area electron diffraction
patterns. Users may find ‘CHT Diffraction Analysis’ by the same author, of use in measuring
ring patterns from polycrystalline materials. The software can be downloaded free of charge
from the same location as this software. The operation of this script is described in D. R. G.
Mitchell, Ultramicroscopy, 108, (2008) 367-374. This script has been updated and is now
fully compatible with GMS 2.0.

Setting Preferences.

Dialog-based scripts save values when they are closed. If not, hold down ALT when closing
the dialog to be prompted to save the current values as the new defaults. Some scripts may
have ‘hidden’ preferences which are not accessible via the dialog interface. These can be
accessed using the DiffTools Preferences script. Non-dialog-based scripts preferences can
also be accessed and changed via this script

The DiffTools Menu.

After installation, a new menu appears in DigitalMicrograph called DiffTools. The menu is
shown in Fig. 1.

Fig. 1 The DiffTools Menu

The menu functions are described in detail below.


p6 of 31

1. Calibrate SADP…
The Calibrate SADP dialog is shown in Fig. 2.

Fig. 2 The Calibrate SADP... dialog

The camera lengths which appear in the dialog, and the calibration values used, are those for a
JEOL 2010F with imaging carried out on a Gatan Imaging Filter (GIF 2000) using a 1k x 1k
camera. Calibration data for a JEOL 2000FXII using a DualVision camera in the 35mm port
(1300 x 1030) is also included. TEM C-F contain dummy data. Calibration data for up to six
different TEM/camera combinatiions can be entered into this script. Users will need to
calibrate their systems and edit the data in the script accordingly (see below). Even where a
user has an identical configuration to one of those for which default data is provided, it is
essential that calibration be carried out.

The dialog also displays the maximum resolution of the camera as CCD X and CCD Y for
each set of calibration data. The script will expect the image being calibrated to have either
the same resolution as that specified in the dialog, or to be some integer divisible of it – due to
binning. Where the correct sized image or its binned counterpart is detected, then the
calibration will be scaled to suit (on the basis of the x axis dimension). However, if scaling of
the calibration is not required, selecting a camera length from the pulldown menu with the
ALT key held down, will apply the unbinned calibration to the image ie no scaling will occur.

If the image is not the correct size then an option to apply a ‘Scaled’ or ‘Direct’ calibration is
given. If, for example, the ‘Scaled’ option is selected for a 333 pixel wide image (original
CCD X size = 1000 pixels), the calibration will scale on the x-axis and report a binning of 3x.
Choosing the ‘Direct’ option will apply the unbinned calibration and an image binning of 1x
will be reported. This may introduce an error, but where the image size differs from the
original CCD size (in x) by only a few pixels, the error is negligible.

The calibration is done by selecting the tab for the microscope of interest (2010F, FXII etc)
then selecting the appropriate camera length from the pulldown menu. The foremost image is
then calibrated.

Camera length calibration can be done by capturing diffraction patterns from a polycrystalline
gold film at various camera lengths at the maximum CCD resolution. The objective lens
voltage must be constant (minimum contrast value with the specimen at the eucentric height)
throughout. The radius of each diffraction ring (in pixels) is measured and assigned to its
corresponding gold d-spacing in Ångstroms. Note it is essential that d-spacings are in
Ångstroms. A plot of 1/d-spacing vs ring radius (pixels) yields a straight line plot (provided
the assignment of d-spacings to rings is correct). The slope of this plot is the calibration factor
to be entered into the tag corresponding to the camera length used. The script ‘Gold
Calibrator’ (see below) enables much of this calibration process to be automated.
p7 of 31

If the ‘Calibrate SADP’ script is run with the ALT key held down, the ‘Calibrate SADP
Settings’ dialog appears showing all the data (microscope name, CCD X and Y, camera length
labels, calibration values and calibration errors) for the six TEMs. This data can be edited to
suit. Camera lengths should be entered as shown in the default data eg A. 1.5cm . . By
prefixing the camera lengths with A., B., C. etc the order in which the camera lengths appear
in the pulldown menu of the main dialog is preserved – they are sorted alphabetically.

Analysis of gold diffraction patterns used for camera length calibration can be carried out
with the ‘Gold Calibrator’ script. This carries out a linear regression of the data and reports
the calibration factor required here. It also reports the error in the slope. This value can be
entered into the ‘Error/%’ field in the ‘Calibrate SADP Settings’ dialog next to the
corresponding camera length. If this parameter has a non-zero value, then it is propagated to
all patterns subsequently calibrated with this script. The value appears as a tag on the image
(SADP Calibration:Calibration Error). If measurements are then made on such patterns with
the ‘Measure Spacings and Angles’ script, d-spacings are reported ± this percentage error.
The problem with using the calibration error is that it tends to underestimate the actual error
in measurement by up to a factor of four. This is because the calibration error does not include
the additional errors arising from location of the pattern centre and the centroids of diffraction
spots/rings. These errors are very user and pattern dependent and are difficult to quantify. An
alternative approach is to simply set ‘Error/%’ to some arbitrary value such as 1%. The
appropriate value can be assessed by analysing d-spacings from known phases and increasing
the error until all the measured d-spacings (± the error) agree with those expected. If the value
of ‘Error/%’ is left at its default (zero) value for a particular camera length, then ‘Measure
Spacing and Angles’ will not report any errors for patterns calibrated at that camera length.

Pressing the ‘Save’ button will replace the existing calibration data with that shown in the
dialog. Note, the default data can be restored by opening the Global Info (File/Global Info),
opening the DiffTools tag and deleting the ‘SADP Calibration’ tag. The next time the
‘Calibrate SADP’ script is run, the default set of calibrations will be recreated.

The ‘Calibrate SADP Settings’ dialog also has buttons called ‘Save Tags’ and ‘Load Tags’.
‘Save Tags’ will save the current calibration values in the Global Info as a settings file. (Note
any unsaved changes made in the settings dialog are not picked up by this action, so any
changes should be saved (Save), and then the tags saved (Save Tags)). In this way, if the
calibration data is lost for any reason, the entire setup can be quickly restored. Restoration is
achieved by pressing ‘Load Tags’ and pointing at the saved settings file to load the data into
the dialog. These saved data are then automatically loaded and saved into the Global Info. The
settings file can also be used to copy calibrations between PCs without having to manually re-
enter data. Simply copy the settings file to the target PC, run the ‘Calibrate SADP’ script with
the ALT key held down, and press the ‘Load Tags’ button and select the settings file. Data in
the file will be loaded into the settings dialog and is also saved into the Global Info. The
newly saved settings will be available when ‘SADP Calibration’ is next run.

The ‘Clear Fields’ button will clear all the fields in the ‘SADP Calibration Settings’ dialog.

1a. Calibrate SADP Preferences.


User editable preferences: SADP Calibrations

Note: Setting the values for ‘Calibrate SADP’ is done via a dialogue which appears when the
script is run with the ALT key held down. The only preference relating to ‘Calibrate SADP’
which appears in the DiffTools Preferences is the number of camera lengths, ie how many
camera length entries appear in the ‘Calibrate SADP’ (ALT) dialog.
p8 of 31

There are six sets of preferences – six microscope configurations. For a given microscope
configuration – eg A – which corresponds to the left-most tab in the dialog, there are camera
lengths (Camera Lengths A), TEM details (TEM A) and the calibration errors (Camera
Length A Errors). Edit these in the (ALT) dialog and when finished, click ‘Save’.

User editable preferences:Default Values


Number of Camera Lengths. This preference is accessed when the ‘DiffTools Preferences’
script is run and the ‘Calibrate’ tab is selected. This parameter sets the number of rows for
data entry in the ‘SADP Calibration Settings’ dialog which appears when the ‘SADP
Calibration’ script is run with ALT held down. The default value is 15.

2. Remove or Restore Calibration


This script removes or restores the calibration from the front-most image. It will work on
images and diffraction patterns. For simple measurements it can be easier to work in pixels
than reciprocal Angstroms. Removing a calibration results in the calibration data being
written to a temporary tag on the image. In this way, the script can restore these values, when
the script is next run. Obviously, the script can only restore a calibration on an image which
has had its calibration removed previously by this script – ie where the relevant tag exists on
the image.

2a. Remove SADP Calibration Preferences :


User Editable Preferences: None

3. Gold Calibrator…
The purpose of the Gold Calibrator script is to automate the analysis of calibration diffraction
patterns obtained from polycrystalline gold. The script dialog is shown in Fig. 3.

Fig. 3 Gold Calibrator… dialog.


p9 of 31

The starting point for using this script is a radial intensity profile from a diffractionpattern
from polycrystalline gold. The pattern should be captured under carefully standardised
conditions – specimen at eucentric height, objective lens at a standard setting. The profile can
be generated using the ‘Locate SADP Centre’ script to find the centre (see below), and then
the ‘Rotational Average’ script to generate the profile (see below). The pattern and resulting
profile need not be calibrated, since the Gold Calibrator script will simply read the peak
positions in pixels. The position of the peaks in the profile can be determined automatically
by having the profile front-most then clicking on the ‘Find Peaks’ button. This uses a top hat
filter to locate the peaks. The settings (Hat, Brim, Threshold) and operation of the top hat
filter are described for the standalone version of this script ‘THF Peak Locator’ (see below).
If the ‘Label’ checkbox is set, the peaks in the profile will be labelled as will data points in the
linear regression.

The ‘Find Peaks’ function should locate most of the peaks in the profile. Adjusting the
‘Threshold’ parameter will change the sensitivity. It is not essential to find all peaks. Very
weak peaks or unresolved shoulders on peaks can be ignored, especially if there is any
uncertainty in their positions. The peak finding routine may detect false peaks, such as the
edge of the beam stop. Any such false detections must be deleted from the marked up profile
by clicking on the small red cross on the vertical dashed line marking the peak. This should
then change from a cross to a red square. The marked peak can then be deleted by pressing
delete.

Once the peaks in the profile have been satisfactorily marked, the data can be read into Gold
Calibrator by pressing the ‘Data’ button. If more than 16 peaks are marked only the first 16
are read in. By default, the first peak position is assigned to the gold (111) spacing. This first
data point is used to generate an approximate calibration factor for automatic fitting of the
remaining peaks. The first peak can be assigned to a different gold spacing by holding down
the ALT key and pressing either the up or down arrow adjacent to the first d-spacing field.
This will assign to the data point the d-spacing of the next available gold spacing (up or
down) and all the other data will be refitted on the basis of the new approximate calibration of
the first data point.

The fitting process plots 1/d-spacing (in Å-1) versus diffraction ring radius (pixels). If the
measured radii are assigned to the correct gold spacings then the plot will be a straight line
and the slope of that line is the calibration factor required by the ‘SADP Calibration’ script
described earlier. The fitting of the gold spacings is carried out automatically and the plot
shown in the dialog. The equation of the fit and the correlation coefficient are also displayed.
Manual adjustment of the fit is possible by pressing the up or down arrows next to all the data
points. This will select the next gold spacing in the library of 43 gold spacings built into the
script. The effect of this change is displayed in the plot and in the various fit parameters
shown in the results section of the dialog. The ‘Error’ parameter is particularly useful for
judging how well the data are fitted. This value tends to a minimum when the first data point
is correctly assigned (to gold (111)) and all other peaks are correctly fitted. If one or more
data points do not fit well, this may be due to some error in determining their peak position –
examine the radial intensity plot. If that is the case, delete the markers of the relevant peaks,
press the ‘Clear’ button to reset the dialog, then press ‘Data’ followed by ‘Fit’.

The slope of the plot is displayed in the ‘Calibration/Å-1/pxl’ field. Also shown is the standard
error (Error/%) in the slope as a percentage. These two values are used in the ‘SADP
Calibration’ script. The ‘Volts/kV’ field refers to the microscope voltage and the ‘CCD
Pixel/µm’ to the pixel size of the camera. These two values are used only for computing the
camera length. If you do not require a camera length these fields can be ignored. The CCD
pixel size information can be found within the Global Info of DigitalMicrograph which is
p10 of 31

connected to the microscope. Open the Global Info (File/Global Info), click on General/Tags,
then navigate to the following tag group:

Camera Manager
Camera Configuration List
[0]
CCD
Pixel Size (um): 14+i14

This is the configuration for an Ultrascan (2k x 2k) Camera under GMS 1.8.3. The pixel size
is 14 x 14µm. We also have a second camera (Erlangshen) on this machine The details for this
camera appear under the [1] tag group, which appears below the [0] group shown above. The
pixel dimensions are 6.25 x 6.25µm. The location of the information may vary with DM
vintage and camera type.

If you cannot locate this information you should consult the documentation which came with
your camera or ask your local Gatan representative. More recent versions of DM allow users
to edit a calibration lookup table in diffraction mode. In this way, patterns are calibrated as
they are acquired. This calibration requires a camera length value. Be aware that the camera
length displayed on the TEM is for patterns captured at the plane of the film camera. The
camera length for the CCD camera may be quite different, especially where the camera field
of view is very different to that of film (often marked on the TEM fluorescent screen by
various corner markers – for different size film).

This script can also be used for calibrating data measured from film. The diffraction ring
diameters are measured, then halved to determine the ring radius. These values (in mm) are
entered into the Data fields. The CCD Pixel size is set to 1000µm.

The values currently displayed in the dialog can be saved as new default values by holding
down the ALT key when closing the dialog. A prompt appears asking if the current settings
are to be saved as new defaults. Settings can also be saved under the ‘Gold Calib’ tab in the
DiffTools Preferences… script.

3a. Remove SADP Calibration Preferences :


User Editable Preferences: None

The settings under ‘DiffTools Preference/Gold Calib are as follows:


Label Font Size: The size of the labels which appear in the linear regression plot in the
dialog: The default value is 14.
Spot Size: The size of the plotted points in the linear regression plot in the dialog: The default
size is 3.
Label Check Box (0-1): The default setting for the label check box at launch. Can be 0 (Off)
or 1 (On): The default value is 1.
Hat: The value in the Hat field. Sets the hat width in pixels for the top hat filter: The default
value is 11.
Brim: The value in the Brim field. Sets the brim width in pixels for the top hat filter. The
default value is 5
Threshold: The value in the Threshold field. Sets the threshold of the top hat filter: The
default value is 0.001.
Voltage: The value in the Volts field. Defines the microscope voltage used (in kV): The
default value is 200.
CCD Pixel Size: The value in the CCD Pixel field. Defines the size of the pixels in the CCD
camera (in µm). The default value is 6.25.
p11 of 31

4. Locate SADP Centre…


Any measurements on diffraction patterns with this software are dependent upon knowing the
pattern centre (ie the position of the central (000) beam) accurately. An accurate and robust
(CHT) method of locating the centre and measuring the pattern automatically, was developed
by this author – Circular Hough Transform Diffraction Analysis (D. R. G. Mitchell,
Ultramicroscopy, 108 (2008) 367-374). A second method based on ellipse fitting has also
been developed (Development of an ellipse fitting method with which to analyse selected area
electron diffraction patterns, D. R. G. Mitchell and J. A. Van den Berg, Ultramicroscopy
Ultramicroscopy, 160, 140-145 (2016).

For good quality powder diffraction patterns where accurate d-spacing information is
required, these fitting methods are robust. However, it does take a few minutes to run, and in
instances where approximate d-spacings will suffice, or where the pattern is not amenable to
CHT/Ellipse fitting analysis as it is from a single crystal/very coarse grained material or
where the approximate centre needs to be located prior to using the ‘Rotate and Inset…’ script
(see later), a quick manual method of defining the centre is desirable. This script provides a
tool for doing this with reasonable accuracy (probably to within ± 5 pixels or so). The dialog
is shown in Fig. 4.

Fig. 4 Locate SADP Centre… dialog

Pressing the ‘Get Image’ button will source the front-most image which should be a
diffraction pattern. The ‘Centre’ check box will draw a small red region of interest (ROI) at
the geometric centre of the pattern. When set, the ‘Mask’ check box will draw a series of
concentric rings about the centre. The ‘Rings’ box sets the number of rings in the concentric
mask. The purpose of this mask is to assist the user in locating the position of the central
(000) beam by aligning the rings with diffraction rings or a series of spots. The concentric
p12 of 31

rings are magenta and every nth ring is cyan – to aid mask and ring alignment. The selection
of which nth rings are highlighted in cyan can be set in the preferences – see below. The
direction arrows move the centre and mask in steps of 5 pixels. With the SHIFT key held
down this reduces to single pixel steps. The position of the centre in X and Y is shown below
the movement buttons. The size (arrow) buttons allow the size of the central red ROI to be
adjusted.

There are three options for finding the centre:


‘Manual’ – this takes whatever the current centre is set at and marks the image with a tag
which contains the details of this position. A number of other scripts in DiffTools will look
for, and use, this tag.
‘C. of G.’ – centre of gravity. Pressing this button will reposition the centre to the centre of
gravity of the image. This approach is fairly unreliable at locating the central beam position in
patterns which are not centro-symmetric. These may include off-axis patterns, high index
patterns, patterns with a beam stop in, or those with strong comet tails from electronic CCD
shuttering, Kikuchi lines etc. If the centre based on the centre of gravity is accepted the image
will be tagged appropriately. If the centre of gravity is not sufficiently accurate the ‘C. of G.’
button should be pressed while holding down the ALT key. This applies a threshold to the
image removing all intensity below the mean value of the image. Typically this will eliminate
weak features such as Kikuchi lines, and leave only the high intensity diffraction spots for
analysis

‘Auto’ begins by calculating the first moment of the image and uses this as an approximate
centre. The image is then rotated + and – about an angle which can be set in the preferences.
The difference between these two rotated images is a function of how close the guessed centre
is to the true centre. The difference will be at a minimum when the true centre is guessed. A
coarse matrix of guessed centres about the first centre is tested in this manner, and the centre
providing the best fit is retained. In the second pass a finer matrix of points centred on the
new centre is tested, and the centre further refined. This process is repeated though six passes
– it typically takes about a minute or so. The ROI and Mask (if displayed) are moved to the
new centre and the co-ordinates are displayed. The option to accept the chosen centre is given.

‘Clear’ will restore the pattern to its original condition and will delete any annotations/images
created by this tool. If the centre has been marked, a tag containing the centre position
information will remain on the image for use by other tools in this suite. The centre position
tag can be removed by holding down the ALT key and clicking on ‘Clear’. This will perform
the normal clear operations and also remove the centre position tags from the pattern.

4a. Locate SADP Centre… Preferences :


User Editable Preferences: Default Values

The settings under ‘DiffTools Preference/Locate Centre’ are as follows:


Mark the Centre (0-1) – determines whether the centre check box is on or off at launch. The
default value is 1 (on). Allowable values are 0 or 1.
Number of Mask Rings – the value which appears in the Rings field. The default value is 9
Centre ROI Width – the size of the red ROI in pixels which marks the centre. The default
value is 10.
Default Image Size – determines the vertical height (in pixels) at which images are displayed
on the screen. Set this to suit your display. This setting is common to all scripts in this suite.
The default value is 512.
Default Aspect Ratio – the aspect ratio (X/Y) of intensity profiles. This setting is common to
all scripts in this suite which create such profiles. The default value is 1.6.
p13 of 31

Highlight nth Ring – every nth ring in the concentric mask will highlighted in cyan, while
the rest of the mask is magenta. To turn the highlighting off, set this value to zero. The default
value is 3 –every 3rd ring is highlighted.
Auto Rotation Angle – the net angle over which the + and – images are rotated. The default
value is 15 degrees, which corresponds to +7.5° and -7.5° rotations of the respective images.

5. Rotate and Inset…


The change in lens configuration between imaging and diffraction mode may introduce a
rotation between an image and its corresponding diffraction pattern. If a Gatan Imaging Filter
(GIF) is used a further rotation between the imaging plane and the camera is introduced. To
determine crystallographic directions in images, this rotation must be determined and
compensated for. Traditionally MoO3 is used to calibrate the rotation (see ‘Transmission
Electron Microscopy’ by D. B. Williams and C. B. Carter p152). The result of a calibration
should be a table of rotations as a function of magnification.

This script allows the user to inset one image (typically an SADP) into another with a rotation
at a specified angle applied. An option to crop the image, to remove the black space from
rotation is also provided. The default position of the inset image is set with the position check
box and the size is set by the scale factor – which is the size of the inset image relative to the
parent image. The dialog is shown in Fig. 5.

Fig. 5 Rotate and Inset… dialog

The diffraction pattern is sourced with the ‘SADP’ button. As this script will rotate and excise
the central region of the image (if ‘Crop’ is selected), it is important that the centre of the
pattern has been defined with ‘Locate SADP Centre…’ prior to running this script. An alert
will be shown if the position of the central beam (000) has not been defined. If this centre has
not been set, the script will still operate, but the geometric centre of the SADP will be used
instead. The result of this is that if the SADP is not centred within its frame, the pattern will
appear off-centred as an inset. An image is selected with the ‘Image’ button. Thumbnails of
the SADP and image are shown as are their image labels.
p14 of 31

The position of the inset in the image – top right, top left etc is set with the ‘Position’
checkbox. To change the position, uncheck the current position and check the new one.
Rotating an image will introduce black space at its corners. This is most evident at a rotation
of 45 degrees. An option to crop the image to retain the largest possible square region of the
SADP (which does not contain any of the added black space) is provided when the ‘Crop’
option is checked. The angle of rotation specifies how the diffraction pattern is rotated relative
to the image. Positive angles correspond to rotating the pattern anticlockwise relative to the
image and negative angles vice versa. If you simply wish to inset one image into another
without rotation, set the angle to zero. The ‘Scale’ parameter is the displayed size of the inset
SADP relative to the displayed size of the image. The ‘Inset SADP’ button will carry out the
rotation and inset. The inset image is a floating layer and can be repositioned, stretched,
scaled and have its histogram/gamma etc adjusted to taste. If subsequently saved as a Gatan
(.dm3) file, the floating layer will be retained. If exported as a TIFF via ‘File/Save Display as
TIFF’, the inset becomes flattened into a single layer image and can no longer be changed
independently of the parent image. Note that if the ‘File/Save As . . TIFF’ option is used,
then only the parent image will be saved and the inset image is lost. If the ALT key is held
down when the ‘Inset SADP’ is pressed the inset pattern is also displayed as a standalone
image. This can be useful for creating centred copies of patterns where the largest square
region of the pattern, centred on the pattern centre, is required. The size of the excised image
can be controlled to some extent, by turning on the ‘Crop’ option and setting appropriate
rotation angles – an angle of 0° giving the largest d-spacing range, and around 45° the
smallest – depending on the location of the pattern centre.

5a. Rotate and Inset… Preferences:


User Editable Preferences: Default Values

The settings under ‘DiffTools Preference/Rotate and Inset’ are as follows:


Crop Inset Image (0-1) – determines whether the ‘Crop’ check box is set to on (1) or off (0)
when the dialog is launched. The default value is 1. Acceptable values are 0 and 1.
Inset Position (1-4) – determines which ‘Position’ checkbox is set when the dialog is
launched. 1=top right, 2=top left, 3=bottom right, 4=bottom left. The default value is 1.
Acceptable values are integers in the range 1 to 4 inclusive.
Inset Scaling (0.1-0.8) – determines the default value in the ‘Scale’ field when the dialog is
launched. The ‘Scale’ value is the displayed size of the inset/parent image. The default value
is 0.35. The range of acceptable values is 0.1-0.8 inclusive.
Inset Angle - determines the default value which appears in the ‘Angle’ box. The default
value is -47 degrees.

6. Rotational Average…
This enables rotational averaging to be performed on the front-most image. This should be a
diffraction pattern which has had its centre defined with ‘Locate SADP Centre…’. The script
carries out rotational averaging over an angular range defined by the start and end angles. It
also permits selection of an arc of diffracted intensity by defining both angular and radial
ranges over which to analyse. In this way diffracted intensity around a particular diffraction
feature can be analysed. The dialog is shown in Fig. 6.
p15 of 31

Fig. 6 Rotational Average… dialog

‘Get SADP’ will select the front-most diffraction pattern and enable the dialog. ‘Clear’ will
remove all images created with this script and reset the dialog. The angular range over which
averaging will be performed is specified by the ‘Start’ and ‘End’ angles. The 12 o’clock
position on patterns (relative to the centre) corresponds to zero degrees, and angles increase in
a clockwise manner. The start angle may be either positive or negative. A start position at 9
o’clock may therefore be specified as either 270° or as -90°. End angles may only be positive
in the range 0-360°. Values in all the fields may be changed by typing in values directly or by
using the ‘+’ and ‘-‘ buttons. These buttons change the value by 5. The magnitude of the
change can be modified by holding down various keys: SHIFT = +/- 1, ALT = +/- 10.

When the ‘Get SADP’ button is pressed a mask of arrows is superimposed onto the image
(Fig. 7), which identifies the angular range to be analysed. The start angle position is shown
by the cyan arrow and the end angle position by the magenta arrow. For straightforward
rotational averaging, this is all that needs be specified. Pressing the ‘Rot. Av.’ Button will
generate a rotational averaged intensity profile of the pattern over this angular range. Note,
the pattern will be averaged over a radial distance defined by the centre to nearest edge
distance. The length of the arrows has no influence on the radius over which averaging
occurs. If the ‘Normalise’ check box is checked, the intensity values in intensity profiles and
3D surface plots will be normalised to the maximum intensity, which will have a value of
100; otherwise the true intensities will be displayed. Note, due to limitations in the
interpolation function used to carry out the rotational averaging, errors of around 1.2% in the
intensities may be introduced. This should be borne in mind when attempting accurate
quantitative work.
p16 of 31

Fig. 7 SADP marked up by the Rotational Average… script. Rotational averaging will be
carried out over the angular range defined by the cyan arrow (start angle=90°) and the
magenta arrow (end angle=300°). The yellow arrows mark the angular range to be rotationally
averaged. This occurs over a radius range defined by the centre to nearest edge distance.

The following example (ordered TiO2 grown on MgO – Figs. 8a-c) demonstrates the use of
the arc segment extraction function. The ‘Range’ parameter enables a range of radii to be
selected to capture the full width of the diffraction feature. This is invoked by selecting the
‘Arc Select’ checkbox, and causes a pair of rings to be drawn on the pattern. The mean radius
of the annulus defined by these rings is that specified by the ‘Length’ parameter. The ‘Range’
parameter, which sets the width of the annulus, can be varied between 2 and 50, although the
upper limit can be changed in the DiffTools Preferences. Both the arrow length and the
diameter of the outer ring are limited so that they can not run off the edge of the image.
Therefore, when working with features which are very close to the edge of the image,
adjusting either the ‘Length’ or ‘Range’ parameters may cause the value of the other to be
limited.

Fig. 8a shows a pattern from textured anatase (TiO2) grown on (001) MgO. A feature in the
second inner-most diffraction has been chosen by selecting the ‘Arc Select’ check box. The
angular limits of 5 and 40°, have been set. Pressing the ‘Rot. Av.’ button extracts this arc
segment, warps it into a straight image, then averages it in the radial direction to produce an
intensity profile as a function of angle. The resulting plot is shown in Fig. 8b. This shows that
the arc of diffracted intensity in the main diffraction feature is made up of a number of intense
features, suggesting that a number of orientation variants are present. From this plot it is
possible to measure the angles between those variants.

It is also possible to display the selected arc segment as a 3D surface plot (Fig. 8c), by
selecting the ‘Surf. Plot’ checkbox. Pressing the ‘Rot. Av.’ Button will then cause the
rotational average of the pattern (between the start and end angle), the average intensity along
the arc segment, and the 3D surface plot of the arc segment to be displayed.
p17 of 31

a) b)

c)
Fig. 8. a) Diffraction pattern from textured TiO2 grown on an MgO substrate. The second
innermost diffraction ring has been selected with the ‘Arc Select’ feature and an arc defined
between 5 and 40°; b) Averaged intensity profile (averaged in the radial direction) along the
arc segment defined in a); c) 3D surface plot of the arc segment defined in a), created by
selecting the ‘Surf. Plot’ checkbox.

6a. Rotational Average… Preferences:


User Editable Preferences: Default Values

Start Angle – the starting angle for rotational average etc (in degrees). The default value is 0.
End Angle – the end angle for rotational average etc (in degrees). The default value is 359.
Radius Length – the length parameter which sets the length of the arrows in the mask, used to
define the radius of interest and identify the angular range of measurement. The default value
is 200 (pixels).
Radius Range – defines the range or width of the annulus created with the ‘Arc Select’
function. The default value is 20 (pixels).
Minimum Radius Range – The minimum value of the Radius Range parameter. The default
value is 2 (pixels).
Maximum Radius Range – The maximum value of the Radius Range parameter. The default
value is 50 (pixels).
p18 of 31

Inter –arrow Angle – Specifies the angular separation of yellow arrows drawn on the image.
This setting is not displayed on the dialog. The default value is 15 (degrees).

7. THF Peak Locator…


The THF Peak Locator dialog is shown in Fig. 9.

Fig. 9 THF Peak Locator dialog.

This dialog uses a top hat filter (THF) to process the front-most intensity profile. It will only
work on line profile images such as intensity profiles. Use the ‘Rotational Average’ script to
create an appropriate profile from a diffraction pattern. The dialog provides access to the top
hat filtering parameters – hat width, brim width and threshold. One advantage of using
rotational averaging to generate a profile is that the noise level is significantly reduced
compared to a simple linear profile. In very noisy profiles, a significant number of false peaks
may get identified. The default values for these three parameters work well with most
profiles. They may need adjusting for noisy profiles. Here, increasing widths and the
threshold value may help. If peaks are missed then decreasing the threshold value may help.
For poorly resolved doublets or shoulder peaks using narrow brim and hat widths may be
useful.

The dialog provides options to identify peak maxima or minima (Max’s, Min’s). It can also
add labels (Label) to identified peaks which give their peak position. The ‘Text’ check box
gives the option to output the measured data as a tab delimited text file. The left most column
of line numbers does not get saved with the data and can be ignored. To save the data click on
the ‘Save’ button at the bottom of the text window and select ‘Text .txt’ as the format. The
data saved are the peak positions, the reciprocal values of the peak positions, the peak
intensities and the normalised peak intensities at the channels corresponding to the peaks
(normalised to the most intense feature found). If the profile is created from a calibrated
diffraction pattern then these data correspond to reciprocal spacing, d-spacing and peak
intensity respectively.

With a profile foremost, pressing the ‘Measure’ button will create a copy of the foremost
profile and name it ‘Image Name (THF)’. Top hat filtering of this profile is then carried out,
and based on the THF parameters, peaks/troughs will be identified. When the ‘Report’ button
is pressed the positions of all the identified peaks are reported in the Results window. If the
p19 of 31

‘Text’ option is checked, the same data are also displayed in a new window as tab-delimited
text.

7a. THF Peak Locator… Preferences


User Editable Preferences: Default Values

THF Hat Width – the width of the Hat parameter in the THF Peak Locator dialog. The
default value is 11.
THF Brim Width – the width of the Brim parameter in the THF Peak Locator… dialog. The
default value is 5.
THF Threshold – the value of the threshold parameter in the THF Peak Locator dialog. The
default value is 0.001
Note the size and aspect ratio of the profile will be the same as the original profile.

8. AutoDiff

AutoDiff is designed for automated measurement of spot patterns. The only requirement is
that the centre of the pattern is defined. This can be done using the Locate SADP Centre
script. The pattern centre only needs to be set approximately, as following analysis, the
approximate centre can be refined. Fig. 10 shows a screen shot of the dialog.

The script finds diffraction spots by fitting a 2D Gaussian to the image to find the best fits.
The size of the Gaussian is increased in steps to find spots of different sizes. The resulting fit
image is a 3D volume with spatial dimensions in the x and y axes and Gaussian size along z.
Diffraction spots have a characteristic that their intensity goes through a maximum in the z
direction (provided the Gaussian size range spans the spot size. Other features such as haloes
around beam stops do not show this characteristic, and so spots can be identified with a high
degree of selectivity. The method is based on an idea by Miloslav Klinger, who has created a
really useful standalone suite of tools for measuring and simulating diffraction patterns. This
is freely available on the internet and is highly recommended.
(http://www.fzu.cz/en/crystbox).

The Analyse button takes the front-most pattern and fits Gaussians to the spots. The starting
size is 1 pixel wide, and that width increases with each successive step by one pixel. The
number of steps (and therefore largest spot full width half maximum in pixels) is specified by
the Fitting Steps parameter. The value chosen will depend on the size of the spots in your
pattern. Measure the full width half maximum (in pixels) of the largest spot you wish to
measure and use double that value in Fitting Steps. Very large values of Fitting Steps eg >50
will result in long analysis times. Search area is an area radius (in pixels) over which spots
will be looked for. For example when a spot is found a search is made on the opposite side of
the centre of the pattern to look for the opposing spot. Larger search areas provide more
reliable location, but take longer. Search areas which are too large may locate secondary spots
caused by twinning or double diffraction.

Find Spots specifies how may spots to locate. Spots are found in order of decreasing intensity.
The Threshold parameter is an intensity value below which diffraction features are ignored.
This thresholding ensures noise, Kikuchi features etc are ignored. The search for spots
continues until either the number of spots specified in Find Spots is found, or the Threshold
value has been reached. If you do not locate all the spots you wanted to locate, increase the
Find Spots value. If the number of spots found is less than that specified try reducing the
Threshold value.
p20 of 31

Once the Analyse procedure has been carried out, the pattern will be marked to identify the
spots which have been located. Depending on the Number, Ring and d-spacing check boxes,
the spots will be numbered in order of decreasing intensity, the spot will be ringed by a
circular notation and the d-spacing will be shown. The size of the marker rings and the text
labels can be changed in the Marker Size and Label Size fields respectively. Any changes
made to these fields/check boxes in the Mark Up section of the dialog will update the marked
pattern interactively. The Update button will force an update. If any markers had been deleted
or moved by the user, then they will be restored. Clear will remove all the markers and restore
the pattern to its original condition.

Fig. 11 shows a marked up pattern immediately following analysis. The centre spot is marked
in cyan. All other spots are ringed in yellow with the d-spacings listed in red. Red signifies
that the reported d-spacings are based on the distance to the original (approximate) pattern
centre. This may or may not be accurate. The accuracy of this centre can be assessed by
comparing d-spacings reported for several pairs of opposing reflections – the d-spacings of
each spot in a pair should be very similar if the pattern centre is close to the true centre.

AutoDiff allows for refinement of the initial centre by pressing the Refine button. Refinement
works by pairing up opposing spots (eg 200 and -200 reflections). The opposite spot is sought
by searching directly across from the initial centre. If a matching spot is found (they are not
always present), then the centre is taken to be the point half-way between the pair. This is
repeated for all spots to produce an average centre (location) made up of measurement of
many pairs. Some of these centres will be more accurate than others and so the data are
recursively refined to remove those centres which are furthest from the average. This is
repeated until the standard deviation of the centre of the remaining set is below the value
specified in the Max Error field. Following refinement a prompt is given showing the current
centre, the refined centre and the number of centre measurements which have been made and
which have been excluded by refinement. The option to apply this refinement or ignore it is
given. If the refinement is applied, the refined d-spacings are shown. To indicate they are
from refined data the colour is changed from red to yellow (Fig. 11b). The Report button will
create a list of d-spacings in decreasing order. This is shown as a standalone script window in
DigitalMicrograph. This can be saved in text format by saving it as a script file with the .s
extension. This is a plain text file which can be opened by Word, Excel etc.

8a. AutoDiff… Preferences:


User Editable Preferences: Default Values

Fittings Steps – range of Gaussian sizes starting from 1 used to fit the spots. The default
value is 30.
Find Spots – the number of spots to look for and identify. The default value is 20.
Search Area – the radius of the area (in pixels) in which to look for spots. The default value
is 40 (pixels).
Threshold – The intensity threshold below which spots are ignored by the detection routine.
The default value is 100.
Marker Size – The diameter of the circular markers (in pixels). The default value is 28.
Label Size – The font size (in points) of the labels. The default value is 28.
Number, Ring, d-spacing checkboxes. Determine whether numbers, ring markers and
measured d-spacings are applied to identified spots – default is on (1).
Max Error – any refined centres which lie outside the limit are excluded from the final
average used to produce the refined centre. Default value in 0.1 (pixels).
Marker Size – The diameter of the circular markers (in pixels). The default value is 28.
– any spot with a d-spacing larger than this value (extremely close to the initial centre) will be
determined to be the centre spot with a d-spacing of 0nm. The default value is 1.5nm.
p21 of 31

Fig. 10 AutoDiff Dialog.

Fig. 11 Marked up SADP created with AutoDiff


p22 of 31

9. Invert SADP.

This script works on images, but not on line profiles. It will simply invert the intensities of the
front-most image, so that a diffraction pattern will appear as black diffraction rings/spots on a
white background. Weak diffraction features are generally more visible in this mode when
displayed in hard copy form. The relative intensities of diffraction features are unchanged.

9a. Preferences
User Editable Preferences: None.

10. Reveal Weak Reflections

This script works on images but not line profiles. It copies the front-most image and applies
an exponent to it. The default value is –(1/3) – a negative cube root. The new image is
renamed with the value of the exponent used appended to it. This negative cube root serves to
a) invert the image intensities and b) apply a cube root which greatly compresses the contrast
range and greatly increases the visibility of very weak features. Fig. 12 shows the effect of
applying a) a simple intensity inversion to the image and b) the negative cube root. The
weakest outer reflections are far more visible in b). Obviously this script changes the relative
intensity levels in a diffraction pattern, precluding subsequent measurements of intensities.
However, it is useful for illustrating weak reflections due to phenomena such as ordering,
second phase precipitation etc.

a) b)
Fig. 12 Effect of applying a) ‘Invert SADP’ and b) ‘Reveal Weak Reflections’ scripts on a
diffraction pattern of gold. Weaker reflections are more apparent in b)

10a. Reveal Weak Reflections Preferences


User Editable Preferences: Defaults

Exponent – the exponent applied to the pattern. The default value is an inverse cube root (-
0.333).
p23 of 31

11. Measure Spacings and Angles…


This is a utility which can be used for measuring the d-spacings of spots and rings in
diffraction patterns with sub-pixel precision. It can also determine the angles between spots
and their corresponding d-spacings (if the pattern has been appropriately calibrated). The ratio
of the reciprocal spacings of the two selected spots is also reported. Even in the absence of a
calibration, the interspot angle and this ratio enables reflections and zone axes to be identified.
The dialog is shown in Fig. 13.

Fig. 13 Measure Spacings and Angles dialog

This tool requires that the SADP’s centre has been located beforehand. If the centre is not set,
the script will proceed and use the geometric centre of the pattern. This is useful if
measurements on Fast Fourier Transforms (FFTs) are required, where the centre of the FFT is
the geometric centre.

There are two measurement modes: Centre <-> d and d<->d. With Centre<->d selected,
pressing ‘Mark’ will apply three regions of interest (ROI) to a copy of the front-most image.
The size of the copied image is scaled to match the vertical size of the front-most image.
Stretch the vertical size of this to the required height before pressing ‘Mark’. The copied
image has the same name as the original with ‘(Angles)’ appended to it. This image can be
saved at the end of the measurement session. The original image is not changed. This script
will work on both normal contrast patterns (white diffraction features on a black background)
and on patterns which have inverted contrast due to application of the ‘Invert SADP’ script.

The centre of the pattern is marked with a blue ROI which cannot be moved. A red and green
ROI are also added and these can be manually positioned on diffraction spots to be measured.
Fig. 14a shows a pattern where the red ROI has been moved close to one spot with the green
ROI is in its initial location. It is not necessary to position the ROI over the spot of interest
with any accuracy. The centre of gravity button (‘C. of G.’) will automatically relocate the
ROI to centre it on the spot. This should be fairly accurate even where streaking in the spots is
p24 of 31

present, provided the streaking or other intensity variation is centro-symmetric about the spot.
Fig. 14b shows the effect of pressing the ‘C. of G.’ button on the position of the ROIs. Spot
labelling cab be turned on by checking the ‘Label Spots’ option. The font size of the labels in
set in the ‘Label Size’ field. The red ROI, which was close to a spot has become centred on it.
The green ROI is in a region of uniform (low) intensity and has not moved. The user would
need to relocate this ROI onto a spot and then press ‘C. of G.’ again to centre it. The centre of
gravity method is iterative. It measures the centre of gravity within the ROI – moves the ROI
to that centre – recalculates the centre of gravity etc. The number of times this iteration occurs
is set in the ‘CoG Number of Iterations’ preference (see the end of this section). The default
number of iterations is 20, and execution takes about a second or so. A smaller number of
iterations may help speed things up, but the ROI may then not be at the true centre of gravity,
if its starting position was a long way away from the centre of gravity. If this is a possibility,
simply pressing ‘C. of G.’ again will refine the ROI positions further, if they are not currently
at the centre of gravity.

a) b)
Fig. 14 Diffraction pattern after selecting the ‘Mark’ option in ‘Measure Spacings and
Angles’.a) The user has positioned the red ROI over a spot of interest approximately; b) After
pressing the ‘C. of G.’ button, the red ROI is then automatically centred on the spot. The
green ROI is too far from a spot to locate it – it will need to be repositioned closer to a spot of
interest.

If the ALT key is held down when the ‘C. of G.’ button is pressed, the red and green ROIs are
thresholded before their centre of gravity is determined. The threshold point is the mean value
of each region, with everything below the mean being set to zero. This effectively eliminates
weak features such as comet tails and Kikuchi lines, leaving only the most intense part of the
diffraction spot upon which to determine the centroid.

When the ‘Measure’ button is pressed, the lengths of the vectors from the centre of the pattern
to the ROI centres are calculated and are shown in the ‘Red’ and ‘Green’ fields of the dialog.
If the location of the ROIs has been set using the ‘C. of G.’ button the reported position is the
calculated centre of gravity. If the ROI has been manually positioned and the ‘Measure’
option selected, the reported position is the geometric centre of the ROI. The option to locate
spots automatically and manually was included to allow for streaky or diffuse spots where
automatic location may fail. If labelling is selected the colour of the label reflects whether the
measurement was based on manual location (magenta label) or via a centre of gravity
approach (white label). If a position is determined via centre of gravity and then measured, the
p25 of 31

d-spacing will be displayed in the label (white text) on the image. If the ‘Measure’ button is
pressed again without moving the ROI, the spot is remeasured and is treated as a manual
measurement (the label is magenta). Small differences between these two measurements are
due to sub-pixel differences between the centre of gravity position (non-integer values) and
the centre of the ROI (integer values).

The reciprocal distances (d-spacings if the pattern is calibrated) are shown in the ‘1/Red’ and
‘1/Green’ fields. If an error value has been entered into the ‘Calibrate SADP’ script
calibration values, then this value will be used to calculate the error in both the vector
determination and the corresponding reciprocal thereof – the d-spacing. The errors are shown
in the results window as ± percentages of the main values. See the ‘Calibrate SADP’ section
for information on how to include errors into this measurement. If the error is left at its default
(zero) value, then no error values will be reported when using this script. The interspot angle
is shown in the ‘Angle/deg’ field. Finally the ratio of the two distances on the pattern are
shown in the ‘Red/Green’ field. These data are also reported in the Results window.

Measurement of further spots simply entails moving the ROIs to be centred approximately on
the spots of interest, pressing the ‘C. of G.’ button to centre them, and finally pressing the
‘Measure’ button to generate the data. ‘Clear’ will close the measured image. The option to
save the labelled image is given.

If the second measurement option is selected (d<->d), the measurement effectively ignores
the centre position and makes measurements between pairs of reflections across the centre.
Pressing the ‘Mark’ button adds a Red and Grn ROI, which should be manually positioned
over reflections as described above. Pressing ‘C. of G.’ will then centre these ROIs on their
reflections. It also creates two new ROIs at mirror image locations across the centre. Note the
centre location does need to be defined to carry out this measurement. However, the location
need only be approximate as it is only used to position approximately the two mirror image
ROIs (Der and Nrg) over the equivalent reflections to those marked by the user (equivalent
reflections means if the user marks a (200) reflection with the Red ROI, then the equivalent
reflection ( 200) is marked with the Der ROI). These new ROIs are then centred on the
equivalent reflections using the centre of gravity approach. This method relies on the ‘C. of
G.’ button being pressed. Only then will the ‘Measure’ button be enabled. Manual positioning
of ROIs for measurement cannot be performed in this mode.

Pressing the ‘Measure’ button causes the vector lengths to be extracted by measuring the
distance between pairs of marked reflections (ie the Red-Der and Grn-Nrg distances) and
halving them. The centre of the pattern is calculated from the crossover point between the
Red-Der and the Grn-Nrg vectors. This centre is used when calculating the interspot angle –
ie the angle subtended by Red – Crossover Point – Grn. The originally marked (approximate)
centre is ignored for this measurement. The originally defined centre can be refined to use the
centre calculated as the crossover point. Holding down the ALT key when pressing ‘Measure’
will cause the position of the original centre and the new crossover point to be displayed
along with the option to Refine the centre to the crossover point or keep the existing centre.
This is an alternative method with which to locate the centre accurately. Simply use the
‘Locate SADP Centre’ tool to set the centre approximately, then carry out the above
procedure and refine the centre. Maximum accuracy in the crossover point should be obtained
when the Red-Der and Grn-Nrg vectors cross each other at right angles, and when using
higher index reflections, which are furthest from the pattern centre. If the ‘Label’ option is
checked when carrying out measurements in d<->d mode, d-spacing values will be added as
labels to spots. The labels are cyan in colour to differentiate them from measurements made in
Centre<->d mode (C. of G. = white labels, Manual=magenta labels).
p26 of 31

The four check boxes change the way the pattern is marked up during measurement:

Angles: when selected this will draw lines from the centre to each spot, and the angle between
them will then be labelled.
Ratios: when selected the ratio of the length of the red to the green vector is added to the
display.
Cell: when selected a line is drawn between the two spots. This is useful for outlining the
symmetry of the cell in a zone axis pattern.
Yellow: the above three functions will be drawn in different colours for each pair of spots
measured. If Yellow is selected all subsequent mark-ups will be done in yellow. This provides
higher contrast for publication. Alternatively, if white is preferred, click and drag across all of
the markings to select them, the right click and select: Foreground Color and select white or
the colour of choice.

11a. Measure Spacings and Angles… Preferences


User Editable Preferences: Default Values

Centre ROI Size – the size (in pixels) of the blue ROI which marks the centre. The default
value is 20.
Spot ROI Size – the size (in pixels) of the red and green ROIs (in pixels) used to mark the
spots of interest. The default value is 20.
CoG Number of Iterations – the number of iterations used when the ‘C. of G.’ button is
pressed. The centre of gravity (CoG) of the red and green ROIs is determined and the ROIs
are then moved to be centred on the calculated value. This is repeated the number of times set
by this value. The default value is 20.
Add Labels (0-1). – sets the default condition of the ‘Label Spots’ check box at launch. 1=on,
0=off, the default is 1. When the dialog is closed the current setting for this becomes the new
default value.
Angle Measurement Mode (0-1) – Sets the default condition for which measurement mode
(Centre<->d (0) or d<->d (1) is used. The default value is Centre<->d (0). When the dialog is
closed the current setting for this becomes the new default value.
Label Size – sets the default value for the ‘Label Size’ field – which controls the font size (in
points) of the labels. The default value is 18. Acceptable values are 8-72 inclusive. When the
dialog is closed the current setting for this becomes the new default value.

12. Point and Measure . . .

This is a ‘quick and dirty’ script for measuring diffractions patterns crudely. The script will
select the front-most pattern. A caption on the pattern informs the user to select spots by
moving the cursor over them and hitting the SPACE bar to mark them. If the pattern centre
has not been defined previously, then the first point marked is assumed to be the centre and
will be labelled with [000]. Every subsequent spot will be marked with the d-spacing. The
script makes no adjustment for incorrect location of the centre or the spot. The script is not
intended for accurate measurement, but simply to ‘eyeball’ a pattern and see whether the d-
spacings are in the ballpark of a target value.

12a. Point and Measure Preferences


User Editable Preferences: None
p27 of 31

13. Background Stripper…


Background stripper enables the background intensity of a profile or spectrum to be modelled
and then stripped away. The dialog is shown in Fig. 15. The script acts on whichever image is
front-most. Only 1D images, such as intensity profiles can be processed with this script. There
are four background models available. In all cases at least one region of interest (ROI) must
be fitted to the front-most intensity profile. In the case of the polynomial model two ROIs
must be present and for the spline fitting, two or more ROIs must be fitted. It is essential that
the ROIs are added from left to right and that they do not overlap.

Where multiple profiles of very similar data are to be processed, the ROIs need only be fitted
to the front-most profile. Pressing the ‘ROI>>’ button will propagate the ROIs to all open
profiles (2D images will be ignored). The ROIs can be propagated by channel number or by
the calibrated values, by selecting the ‘Channel’ or ‘Calib’n’ option in the dialog.

There are four background models which can be selected with the ‘Background Model’
pulldown menu:

‘Log-normal’. Electron diffraction pattern backgrounds can be modelled as a log-normal


curve, though generally only over a limited range of reciprocal space values. When this option
is selected, the log-normal parameters (Scaling, Sigma, Range) become available, and a log-
normal curve is fitted. This is scaled to match the intensity at the lower limit of the ROI. The
curve shape can be adjusted by modifying the log-normal parameters. These values can be
entered either directly into the relevant fields, or the values can be changed by clicking the +
and – buttons. The magnitude of the changes produced by these buttons can be increased by a
factor of 10, by holding down the SHIFT key, and decreased a factor of 10 by holding down
the ALT key. The ROI should be fitted to the region over which it is intended to background
strip. Moving the ROI will not change the curve fit, only the range over which the strip
occurs. The log-normal fit will most likely be poor if the region of reciprocal space selected is
too large.

Fig. 15 Background Stripper screen shot

‘Polynomial’: To fit a polynomial curve two ROIs must be fitted to the front-most intensity
profile. The three points to which the polynomial is fitted are the intensity values at the left
hand ROI lower and upper limit, and the right hand upper limit (the lower limit of the right
hand ROI is ignored). The polynomial fit can be dynamically adjusted by moving the ROIs.
p28 of 31

Care must be taken to select the ROI limit (left or right) of choice. If the ROI limit is missed
and the background is clicked and then dragged, a new ROI will be added, existing ROIs will
be deleted and the dynamic updating of the polynomial will be broken. If this happens, simply
reapply the ROIs, reselect ‘Polynomial’ from the pulldown menu and try again. This also
applies for spline and linear fits, which achieve dynamic updating via ROI repositioning.

‘Spline’. To fit a cubic spline curve two or more ROIs must be present on the front-most
image. The spline curve is fitted through the intensity values at the upper and lower limits of
all fitted ROIs. The spline fit will be updated dynamically when any of the ROIs limits are
moved. The spline is perhaps the most versatile background fitting routine. However, care
must be taken not to create unrealistic backgrounds. These may touch the minima between all
peaks in the profile, but form a very convoluted background which has no physical meaning.
Aim to create a smooth background curve with no inflections.

‘Linear’. To fit a linear background, one ROI must be present on the front-most image. The
linear fit is updated dynamically when the ROI limits are moved. Clearly a linear fit can not
be used on steeply sloping and curving profiles, but it may be of use in EELS or EDS spectra
over narrow spectral ranges where the background is very flat.

Once the background has been applied and adjusted, it can be removed from the profile by
selecting ‘Strip’. The stripped profile has the value displayed in the ‘Offset’ field added to it.
This may be useful for overlaying multiple profiles with various offsets to allow comparison.
If the ALT key is held down whilst pressing ‘Strip’, then both the stripped profile and the
background fit will be displayed as separate images.

‘Reset’ will remove any fitted background from the image, and will reset the dialog. If ALT is
held down whilst pressing ‘Reset’ then in addition to the above, the dialog values will be
restored to the default values.

If ALT is held down whilst closing the dialog, then a prompt will appear asking if the current
settings of the dialog should be saved as the new defaults. Dialog preferences for this script
may also be edited in DiffTools Preferences, by clicking on the ‘Bkgd Strip’ tab.

13a. Background Stripper… Preferences


User Editable Preferences: Default Values

ROI by Channel or Calib’n (0-1) – sets the method by which the ROIs are calibrated -
either by ‘Channel’ (0) or by ‘Calib’n’ (1).
Sigma – the value in the log-normal ‘Sigma’ field. Default value is 0.66.
Range – the value in the log-normal ’Range’ field. The default value is 5.
Offset – the value in the ‘Offset’ field. This is the offset applied to stripped backgrounds. The
default value is 10.
Note: Scaling is not saved as a default value, since the scaling is calculated each time the log-
normal curve is applied.

14. Crystal Tools…


This dialog provides a basic crystallographic calculator to aid in the indexing of diffraction
patterns. It provides a simple interface and is easy to use. It does not supplant the need for
full-strength commercial diffraction programs, but avoids the need for switching in an out of
DigitalMicrograph when doing simple calculations. The dialog is shown in Fig. 16.
p29 of 31

The crystal system is set with the radio buttons on the left. The lattice parameters and unit cell
angles are set in the top right hand corner. Once this information has been entered,
calculations can be performed. The pulldown menu below the crystal selection buttons allows
selection of data for a number of predefined crystal systems. There are approximately twenty
of these crystal structures/data sets included with the script. However, this crystal data set can
be readily expanded to include users’ own crystallographic data.

To enter custom crystallographic data. Set the pulldown menu to blank so that no structure is
selected. Then select the crystal lattice, set the lattice parameters and the unit cell angles.
Below the ‘Hex < - > Rhomb’ check box is a text window wherein the name of the new
crystal can be entered. Crystal structures are sorted alphabetically in the pull down menu, and
so some consistency with naming structures is required – eg label elements with their symbol
followed by their name (eg ‘Au-Gold’). Compounds can be given a common mineral name
(eg Rutile) or formula (TiO2). Probably formulae are best, as some compounds do not have
simple names. Also, in the case of polymorphs/allotropes consider adding a qualifier (mineral
name or crystal structure) to the name (eg TiO2 – Rutile, Co-hex) to help differentiate the
polymorphs/allotropes. Pressing the ‘+’ button will show the details of the structure that has
been entered. If this is all correct pressing ‘Save’ will save it. The structure is added to the
structure catalogue associated with this script. However, it will not be available in the pull
down menu until the script is next launched. Calculations based on the newly entered data can
still proceed. The ‘Hex < - > Rhomb’ check box will report the equivalent hexagonal data
when working with rhombohedral structures and vice versa.

Fig. 16 Crystal Tools dialog.

To avoid losing crystal data inadvertently, the data should be saved as a settings file every
time a new crystal is added to it. The data can be saved by holding down the ALT key and
presing the ‘+’ button. This brings up a dialog to save the entire set of crystal data in a file
called ‘CrystalTools_Settings_20100607’. The reverse date stamp at the end of the file name
will change with the date. If the crystal data are inadvertently lost from the Global Info, they
can be restored by loading the information from a settings file by holding down the ALT key
and pressing ‘Clear’. This brings up a dialog to select a Crystal Tools Setting file. This
method can also be used to transfer suites of Crystal Tools crystal data to other PCs.

Four main types of calculation are possible with Crystal Tools : d-spacings, interplanar
angles, interdirection angles and zone axis calculations. For a given set of crystallographic
p30 of 31

data, the four panels providing access to these calculations are accessible by clicking on the d
Spacings, Planes, Directions and Zones tabs.

Calculations are performed by pressing the ‘Calc’ button. At present creating tabulations of
data is only implemented for d spacings. Other tabulations functions may be added later if
requested. To create a tabulation of d spacings enter/select the crystallographic data, select the
‘d Spacing’ tab, then press ‘Table’. A prompt to select a maximum value of h or k or l or a
minimum d spacing value will appear, and the table will then be computed.

With the ‘d Spacings’ tab selected entering the three Miller indices (hkl) for the reflection of
interest and pressing ‘Calc’ will calculate the d-spacing. If the crystal structure is hexagonal,
then the display will request a Miller-Bravais indice (hkil) (i=-(h+k)). Only the h, k and l
indices need be entered, the i index is calculated automatically.

With the planes tab selected the prompt changes to Miller (or Miller-Bravais) indices.
Pressing ‘Calc’ computes the interplanar angle for these two planes. Similar calculations can
be performed for directions.

The ‘Zones’ tab computes the zone axis for two planes, based on the Weiss law. For
consistency, the h2,k2,l2 values must be of a reflection which is anticlockwise on the pattern
relative to h1,k1,l1.

14a. Crystal Tools… Preferences


User Editable Preferences: Crystal Tools

Crystal tools preferences are not displayed in DiffTools Preferences.

Crystals - The catalogue of crystallographic structures and data is found in the ‘Crystals’ tag
group within the ‘Crystal Tools’ tag. Typically you would need to edit these data tags only to
completely remove a structure which was no longer wanted or to edit incorrect data. Ensure
the Crystal Tools dialog is not open when editing the catalogue. If you incorrectly name a
structure (eg if you called it CaTiO4 instead of CaTiO3) you can not change crystal names.
The only option is to delete the incorrect crystal (see below) then re-enter the data from within
the Crystal Tools dialog.

To remove a crystal, open the ‘Crystals’ tag group in the Global Info (File/Global
Info/Tags/DiffTools/Crystal Tools/Crystals) and right click on the crystal you wish to delete –
select delete.
To edit the data for a crystal, open the ‘Crystals’ tag group and right click on the parameter
you wish to change and select ‘Edit’. Enter the new information. The parameters are : a,b, c in
Ångstroms, alpha, beta, gamma in degrees and Lattice. Lattice takes the following values:
0=cubic, 1=tetragonal, 2=orthorhombic, 3=hexagonal, 4=rhombohedral, 5=monoclinic and
6=triclinic.

15. Tilt Angle Calculator…


This computes the net tilt between two sets of goniometer positions when using a double tilt
holder. Simply enter the initial and final tilts in X and Y and press calculate to compute the
net tilt in degrees. This is useful for tilting between zones axes. Here, a knowledge of the net
tilt can help confirm zone axis identification.

15a. Tilt Angle Calculator Preferences


p31 of 31

User Editable Preferences: None

16. DM Calculator…
This is a scientific calculator, useful for various calculations.

16a. DM Calculator Preferences


User Editable Preferences: None

17. DiffTools Preferences ...


This displays the preferences for the DiffTools scripts (Fig. 17).

Fig. 17 DiffTools Preferences… dialog

Descriptions of the preferences for each of the scripts appear at the end of the relevant section
above.

17a DiffTools Preferences


User Editable Preferences: None

You might also like