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


STEM Averager
Captures sequences of STEM images using either slow or fast acquisition modes. These images can be used for: time-lapse imaging; drift-corrected summing to remove the drift-induced shearing found in single, long-exposure images; making standalone AVI movie files (using ImageJ), enabling the STEM imaging of dynamic effects.
version:20170714, v2.0
D. R. G. Mitchell
The fast acquisition method used here is based on that developed by Vincent Hou and Bernhard Schaffer.

Use this script to capture a time-lapse series of STEM acquisitions - with a delay (or not) between frames. Data is captured to a 3D stack or spooled to hard disk. The latter process avoids limitations due to RAM availability. This script can be used for time-lapse STEM imaging - making movies etc. An option to spool files to disk in either TIFF or .dm4 formats is given. TIFF files can be subsequently assembled into an AVI movie file, using the free ImageJ software. Detailed instructions on doing this are provided in the script header.

There are two capture modes - slow and fast. In slow mode the DigiScan overhead of around 3s and the frame exposure time (typically 5-20s), make this method good for time lapse imaging with high quality images, where delays between frames may be 30s or more. The fast mode creates a continuous scan and frames are captured directly from this continuous image. After the first frame, the DigiScan overhead is neglible in this mode and frame (1k x 1k) rates of around 2 per second can be obtained. Such images are very noisy, but smaller frame size, with longer dwells can compenstate for this.

Images can be saved in a 3D Stack or spooled to disk. The Stack method is convenient as a single image file results, albeit extremely large. A 10 frame stack of 1k x 1k images is around 120MB.This stack can be subsequently aligned and summed to give a good signal to noise ratio single image. This might be useful where drift would seriously compromise a single slow (eg 10s) acquisition. The effect of drift is greatly reduced where say 10 x 1s frames have been acquired, drift corrected and then summed. The Stack Alignment script can be used for processing the acquired stacks. This includes splitting stacks into their component images, merging individual images into a stack, aligning a stack and playing it like a movie.

Very large stacks eg >100 frames, may not be possible due to RAM limitations. Spooling frames to disk effectively enables limitless acquisition (subject to disk space). Where such frames are saved in TIFF format, the option to reassemble them into a standalone movie file is then possible, using ImageJ.

Updates in this version: Aside from bug fixing, this is a major rewrite to enable files to be directly spooled to disk - in either .dm4 or TIFF format. TIFF files have no intrinsic calibration, and so when such files are written a small text file is also written which describes calibration and acquisition conditions.


System Requirements
This script has been tested using GMS 2.32 and Gatan's DigiScan II. Compatibility with older DigiScans and GMS 1.x is unknown.
Known Issues

I find DigiScan scripting to be a bit temperamental. Sometimes hangs can occur which necessitate restarting DigitalMicrograph or even the entire Gatan hardware suite. Please ensure all work is saved before testing this script. The script is provided in good faith, but with no warranty as to fitness of purpose. Use entirely at your own risk.

The movie making capability of this script is particularly interesting. I have experimented with getting the frame rate as high as possible. The minimum DigiScan dwell (per pixel) is 0.5us for 2 byte precision. For a 1k x 1k image this results in a 0.5s exposure time (2fps). Reducing the frame size increases the frame rate. However, I have found that very small frame sizes (eg 256 x 256) when combined with the shortest dwells possible (0.5us), result in a badly mangled scan. This is probably due to inadequante settling time for the overscan. This is easily resolved by increasing the dwell to say 1 or 2us. Once you have decided on the frame size you wish to use, choose the shortest dwell which produces a distortion-free scan. Here the fastest possible frame rate may be 4-5fps. Not exactly movie-rate (25fps), but still adequate for recording many in-situ processes.

Included Files
Main script.
Source Code

see attached script