Scripting Resources
4D STEM maximum spot mapping
Python - Gatan
Produce a colorful map of crystalline regions from a 4D STEM dataset open in DigitalMicrograph using a simple algorithm that finds the location and intensity of the maximum pixel in each pattern. While the result looks like an orientation map, it does not perform proper orientation mapping.
Add a ROI to two images (identical or cloned)
DigitalMicrograph - Gatan
If the identical ROI is added to multiple displays, it is only a single memory object. Changes (such as movements) affect both displays simultaneously. The ROIs appear to be linked. ROIs are automatically cloned when the image is saved.
Calling a Command-Line command from script and showing its output
DigitalMicrograph - Gatan
The script uses the Command-Line command "ipconfig" and outputs its results into a new text window of DigitalMicrograph. The script is a useful blueprint for similar tasks that can be performed from the regular Windows Command-Line.
Create a system response file
DigitalMicrograph - Gatan
Generates a relative system response to correct for non-linearities in a system's sensitivity over a wavelength range. Requires a known reference spectrum, e.g., from a temperature calibrated black body source or calculated transition radiation spectrum.
Create and show RGB image
Python - Gatan
This script creates 3 images in Python and utilizes a DM-script to create and show a color-overlay image. It is an example of how Hybrid scripts can be used to access functionality not (yet) available in the Python language directly. The script shows how image-labels can be used to address images across the two scripts.
Extract ROI-selection as separate image
DigitalMicrograph - Gatan
The script performs the same action as copying an ROI selection (Ctrl + C) and pasting it as a new image on the workspace (Ctrl + Alt + V). It works for both 2D and 1D images. For 3D images, it copies the integrated intensity seen on the display.
Extract sum-diffraction patterns from all points of 4D STEM diffraction image
DigitalMicrograph - Gatan
The first two numbers specify input (N) and output (M) dimensionality. The next N values give a sampling start point, and the next M triplets define sampling for each output dimension.
In-situ 4D STEM maximum spot mapping
Python - Gatan
Produce a series of colorful maps of crystalline regions from an in-situ 4D STEM dataset open in DigitalMicrograph. This uses a simple algorithm that finds the location and intensity of the maximum pixel in each pattern. The resulting in-situ video of color maps automatically syncs with the original data in DigitalMicrograph. While the results look like orientation maps, the script does not perform proper orientation mapping.
In-situ dataset radial profile Diff or FFT
Python - Gatan
Compute radial-max profiles from an in-situ dataset in DigitalMicrograph. The data can be HRTEM images (from which the FFT will be computed) or diffraction patterns over time. The primary result is a single 2D display of these profiles over time, with time as one dimension and radius as the other. The script also generates an automatically synced in-situ dataset of the 1D radial profiles.
Launching an external application and regularly checking if it is still running
DigitalMicrograph - Gatan
Example script showing how the external application Notepad.exe can be launched. The script regularly polls whether or not Notepad.exe is still open so that actions can be performed once the external application is closed.
Live FFT color map
Python - Gatan
Code to process the live-view image in DigitalMicrograph, producing a series of maps of crystalline regions in real-time. It computes a grid of small FFTs from each image. It then treats this grid similar to a 4D STEM data cube, where it finds the brightest spot in each FFT and displays its orientation and intensity as an updating color map.
Live radial profile Diff or FFT
Python - Gatan
Compute radial-max profiles of either the FFTs of HRTEM images or diffraction patterns over time. You can compute profiles from the 2D live-view image in DigitalMicrograph or in-situ 2D image data played back via the In-Situ Player. The result is a single 2D display of these profiles over time, with time as one dimension and radius as the other. Profiles are computed as often as possible.
Live thresholding with plots
Python - Gatan
Code to process the live-view image in DigitalMicrograph, producing a binary display. The live image is thresholded, and several morphological operations are applied to create a binary display. Then the largest contiguous bright region is found and circled. A plot of the position of the center of mass of that bright region is also updated live.
Process 2D in-situ datasets
Python - Gatan
Process in-situ camera or in-situ STEM imaging datasets in DigitalMicrograph. The script handles several in-situ file formats used by DigitalMicrograph and produces results that are automatically synced with the original data when played back in DigitalMicrograph. The script supports custom processing of each frame by modifying a frame processing function.
Sort images onto separate workspaces
DigitalMicrograph - Gatan
This automation script iterates over all currently shown images and selects them one by one. The user is asked to press either ALT or CTRL to move the shown image to one of two newly created workspaces, or SHIFT to end the script.
Start an external executable
DigitalMicrograph - Gatan
Mini-example of how the command LaunchExternalProcess() is used. This command can execute any external application. It provides a powerful method to access hardware outside the DigitalMicrograph environment from within DigitalMicrograph.
Waterfall
DigitalMicrograph - Gatan
Adds a defined offset to a collection of spectra when the display type is set to a LinePlot data set; useful for displaying multiple spectra in a single image display, e.g., spectrum image (SI) time series, SI line scan, or (SI) multi-point acquisition modes.