Scripting Resources for DigitalMicrograph™

banner

Dave Mitchell's DigitalMicrograph™ Scripting Website

Home | Scripts | Examples | Functions | Recent Updates | Tutorials | Resources | Publications | Consulting | Projects | Contact & Bio |PyJEM| Search

 

SADP Background Removal
Function
Removes the background of a 2D diffraction pattern by thresholding or modelling.
Version
version:20221118, v1.0
Author
D. R. G. Mitchell
Acknowledgements
-
Comments

Diffraction patterns from thick regions of specimen can show a high background due to inelastic scattering. This script attempts to remove that by using sequential thresholding to estimate the background - then subtracting it. This approach will work well on spot patterns where the background intensity is rotationally symmetric about the centre. Where the background intensity is not symmetric in all radial directions the rotationally averaged background will be a poor fit. The technique relies upon estimating the background by sequential thresholding to select a percentage of pixels with the lowest intensity at a given reiprocal distance. The mean intensity of these is then taken as the background intensity at that reciprocal distance. Clearly, where the pattern is a ring pattern, rather than a spot pattern, the intensity will be uniformly high at all radial angles at the reciprocal distances where strong diffraction occurs and a meaningful estimation of the background cannot be made. For this reason, the option to fit a modelled background is provided. Here a spline fit can be applied to regions either side of a strong diffraction ring, and the background can then be interpoloated under said peak. Detailed instructions are supplied in the script.

The pattern relies on the centre having been located with the Locate SADP Centre tool from DiffTools. It will excise the largest square region about that centre, and this can be used to create a centred (square) pattern from a non-centred (square or rectangular) pattern.

System Requirements
Should be compatible with all recent versions of DigitalMicrograph.
Known Issues

The method warps the pattern into polar coordinates (unwrapping the pattern about its centre), and then after thresholding it unwarps the computed background back into the original form. However, the warping only occurs out to the minimum radius (centre to nearest edge), leading to empty corners in the unwarped background. A linear interpolation is used to scale the peripheral intensity at the minimum radius, down to zero in the pattern corners. This ensures that a circular artefact from background subtraction is not present in the processed images. However, the background in the corners has no physical basis.

The presence of a beam stop shadow can be dealt with by excluding it from the thresholding at higher reciprocal distances. However, the central shadow of the beam stop represents a discontinuity in background and this typically appears as a bright(er) circular region in the pattern centre. This can be blanked to zero using the blanking radius setting in the script.

Supported
Yes
Included Files
Main script file.
Source Code

see attached script.