Scripting Resources for DigitalMicrograph™


Dave Mitchell's DigitalMicrograph™ Scripting Website

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


Through-Focus Acquisition
Scripts to enable the acquisition of through-focus image series in TEM or STEM mode.
version:20160916, v1.0
D. R. G. Mitchell

These scripts will enable acquisition of a series of through-focus images captured in either TEM or STEM modes. Two scripts are provided - one designed for TEM mode only, and the other for either TEM or STEM mode. Hardware dependencies are described below.

The scripts enable either relative focus changes from the current focus position, or absolute focus changes - where the standard focus position corresponds to 0nm of defocus. Image are acquired using background threads, and so DM can still be used during acquisition. An option to save individual frames to disk as standalone images is given. During acquisition, the data are acquired into a 3D data stack. This can be explored using the Slice control in DigitalMicrograph. The Stack Alignment script can be used to account for any image shifts during acquisition. Ensure the microscope's current centre is corrected before acquisition - to minimise image movement with focus change.

System Requirements

These scripts should be compatible with all recent versions of DigitalMicrograph. They have specific Gatan hardware dependencies. The TEM version is designed for use in TEM mode only, with images captured from a Gatan camera which supports the recent Camera Manager object. This has been tested on an Ultrascan CCD camera, but should be OK with most fairly recent Gatan cameras. The TEM and STEM version of the script requires both a current generation Gatan Camera and DigiScan to be present. This script was tested on a system with an Ultrascan CCD and DigiScan II. Compatibility with DIgiScan I is unknown, but likely.

All testing of the script was done under GMS 2.32 on a JEOL ARM200F. The script uses generic EM. . .() commands which should work on modern instruments from all major vendors. Earlier and later versions of GMS should work too. This script will not work with older JEOL microscopes (such as the JEOL 2010F) which use serial communication. Instruments of this vintage do not support the generic EM . . . () microscope control commands.

If you encounter hardware compatibility issues, feel free to get in touch. However, as I do not have access to instruments other than JEOL, I may not be able to help you much.

Known Issues

The script runs in background, so running other scripts and DM functionality should work fine. A 3D data stack is used to store images as they are captured. For large images with many focus steps, this can produce very, very large stacks. These stacks are not saved by default. Make sure you save a stack as soon as it is captured. Avoid having several such stacks open at any one time. You may run of memory and DM will become slow or crash. Due to hardware dependencies. the TEM and STEM version will report errors if you try and use it on a system without appropriate DigiScan hardware present. Use the TEM only version instead.

The script does not use any form of drift correction. Prior to acquisition, give the specimen several minutes of standing time to allow any stage or beam-induced drift to settle. Use electronic image shifts (rather than the stage controls) to do any final positioning prior to starting the series. If you use the Stack Alignment script mentioned above, you can correct drift caused by the specimen/stage as well as focus changes after acquisition.

This script will only change the defocus in a positive direction. Magnetic lenses suffer from hysteresis, which means that they produce different fields depending on whether you have just increased the lens current or decreased it. They can also 'remember' a large offset to some degree. Fox example after being in low magnification mode (objective lens off) and returning to normal mag mode, the objective lens field at standard focus can be quite different to that typical of the standard focus setting after degaussing. Consider degaussing your lenses (at standard focus) before starting a series (this is called Lens Relaxation on modern JEOL systems). Also for maximum reproducibility set the initial defocus to a value below that at which the focal series begins (eg set the initial defocus to -500nm before acquiring a series starting at say -400nm defocus). This is preferable to starting at say 0nm defocus and then have the script change the defocus to -400nm, and then work back up to positive defoci values. This method ensures that during acquisition, the defocus moves in one direction only, and provided the objective lens has been degaussed at standard focus beforehand, then consistent offsets between frames should be achievable.

The scripts have some detailed information on their use at the start of the listing. Please note that the smallest focal step in STEM mode is +1nm. DO NOT use the Super Fine focus control available on JEOL microscopes. This setting is stored in a seperate memory register which is not accessible to the script language. Do all setting of focus values/calibration using the focus knob on the JEOL user console only.

Included Files
zip archive containing two scripts: the TEM only version and TEM and STEM version.
Source Code

see attached script.