Scripting Resources for DigitalMicrograph™ |
Calibration
- Access Image Calibration Information: An example script which shows how to access the calibration information in a lineplot/image/data cube.
Component (ROIs, text annotations etc).
- Adding/Removing Text Annotations to/from an Image: Shows how to add text annotations to an image, specifying the font, colour and display mode. The annotations are then removed.
- Adding Annotations to an Image in an ImageDocument: Shows how to add annotations (lines, arrows and text) to three images in the same ImageDocument.
Add a Listener to an ROI in a Spectrum: Shows how to add a Listener to an ROI in a spectrum. When the ROI is changed, its updated position is output to the Results window. Controlling Annotations with Component Commands: Simple example showing how to add text, oval and arrow annotations to images as components, and then set the appearance of the component using various commands.- Deselect All Selected Components: An example script which shows how to use the Component commands to deselect all selected components such as text annotations, ROIs etc, which are currently selected.
- Find Coordinates of an ROI: Example script which shows how to source the coordinates of a rectangle or line ROI.
Dialog
- Bevel Buttons Dialog: An example script to show how to use Bevel Buttons in a dialog. These change appearance when pressed. Enabling/disabling buttons and use of hard coded graphic elements is also shown.
- Button Enabling Dialog: Shows how to create a simple dialog with buttons, which can be enabled and disabled in response to inputs into the dialog.
- Creating a Dialog Using Constructors and Destructors: Demonstrates how to create a simple dialog using constructors and destructors. This approach helps reduce the problem of memory leaks, caused by dialogs not destructing properly and leaving variables in scope (in memory).
- Create an Interactive Sub-Dialog: Shows how to create a sub-dialog from within a dialog with interactive buttons and fields.
- Create a Periodic Table Dialog: Creates a periodic table with elements as buttons which report chemical information.
- Creating a Subdialog Within a Dialog: Shows how to create a subdialog within a dialog.
- Image Selection Dialog: Shows how to create an image selection pulldown menu in a dialog, displaying all the currently open images.
- Panel Functions in Dialogs: Demonstrates the use of panel functions in dialogs.
- Periodic Table Dialog: Shows how to use pulldown menus containg elemental data, buttons and fields to create a display of elemental atomic numbers and weights.
- Progress Bar in Dialog: An example script which shows how to implement a progress bar in a dialog. This is useful where script processes may take a long time. The use of ValidateView() to force updates of the dialog is also demonstrated.
- Running a Thread within a Dialog:Shows how to run a dialog class method as a thread. This makes controlling the thread and access by the thread to the dialog values and elements straightforward.
- Set and Reset Pulldown Menu: An example dialog script which shows how to create a dialog where a user can make a selection from a pulldown menu, and then reset that menu by pressing a Reset button.
- Single Button Dialog: An example script which shows the basic elements which go to make up a dialog. In this case the dialog has a single button which tells you when it has been pressed.
- Thread and Dialog Interaction: Shows how to get a dialog to start and stop a thread, and how to have that thread communicate with the dialog - to source information, such as values in fields and to reset buttons, LEDs etc.
- Using an Event Listener from Within a Dialog: An example script to show how to use an event listener from within a dialog.
Display
- Create a Chequerboard Image: Example script which creates a chequerboard image of black and white squares.
- Display the Colour Selection Tool: Shows how to call up the colour selection tool and apply the colour to an image.
- Export an ImageDisplay as an RGB image: Exports an image display as an RGB image.
- Extract RGB Channels: An example script which shows how to extract the reg, green and blue images from an RGB image.
- Calculate Histogram: A short script which shows how to calculate a histogram from the frontmost image using the ImageCalculateHistogram() function.
- Storing Images in a Data Cube: Shows how to store images in a 3D image (data cube).
EELS
- Fit a Background to an EELS Spectrum: Shows how to fit a background to an EELS spectrum.
File Input and Output
- Changing the Default Open-Save Directory: Shows how to change the default directory which DM uses when Open or Save commands are invoked.
- Creating Hard Code from a Text File: Shows how to read in numbers from a text file to create script code which will recreate this data as settings (tags) in the Global Info.
- Open an Image from Disk: Shows how to open an image which has been saved to disk.
- Reading Data from a Text File: Shows how to read in data from a text file.
- Reading Data from a Text File and Creating a Settings File: Shows how to read data in from a text file and save it as a taggroup (settings) file of type .gtg.
GIF/Camera/Microscope
- Beam Blanking with the CameraManager: Example script which shows how to use the CameraManager commands to blank the beam.
- Capture an Image Using the Cameramanager Object: An example script which shows how to acquire an image from a camera using the Cameramanager object.
- DigiScan Beam Control: An example script which shows how to control the beam position using DigiScan.
- Folder Monitor for External DM Control: An example script to show how to use a background thread to monitor a folder for a change - when the change is detected it triggers a response in DM.
- Image Filter Control Commands: An example script which shows how to set the GIF drift tube voltage, and also lists the script commands which can be used to control the Gatan Image Filter.
- Live Image-Spectrum Acquisition: Shows how to acquire a live image and convert it to a spectrum.
- Selecting a Camera from Script: An example script which shows how to select a camera using the ObjectList object returned from the Camera Manager.
- Stop or Start a Camera View Image: An example script which shows how to find a Camera View imageand either stop or start/restart it.
Image Processing
- Accumulating ROIs and Other Components to Create a Mask: A script which shows how to create a filtering mask from conventional FFT masks and other components such as oval annotations, rectangular and freehand drawn regions of interest.
- Adding and Controlling Bandpass Filters: An example script which shows how to add and control bandpass filters using script-. These are normally added via the FFT masking tools in the menu.
- Butterworth Filter: An example script which shows how to create a Butterworth filter - useful for spatial filtering with FFT.
- Convolving and Deconvolving Image Blur: An example script which shows how to convolve a blur vector with an image to create a blurred image and how to deconvolve said blur, to restore the image.
- Deconvolute Gaussian Peak Shape: A short example script which shows how to deconvolute a Gaussian-shaped peak from a signal using FFT methods.
- FFT Manipulation: Demonstrates various FFT processes, such as Butterworth filtering and computing the inverse FFT, phase, power spectrum etc.
- FFT Manipulation II: Shows how to avoid the problem of images splitting into four transposed quadrants following mathematical operations in frequency space.
- FFT Masks: Shows how to work with FFT masks to carry out filtering.
- Image Transformations using Matrices: An example script which shows how to transform (eg stretch, rotate etc) a set of coordinates using matrix manipulation.
- itheta and iradius: An example script which shows how to use these intrinsic image variables.
- Radon Transform: An example script which shows how to calculate the Radon Transform and how to back-project it to reconstruct the original image.
- Set Image Threshold: Image thresholding is demonstrated.
- Smoothed Annular Mask Function: A function which creates an annular mask, the edges of which can be smoothed to a gaussian shape. This can be useful for FFT filtering.
- Warp and Unwarp Images: Demonstrates the use of the warp function to unfold an image about its centre, and how to reverse the process.
LinePlotImageDisplay
- Lineplot Cursor Position and Show: Demonstrates how to position the cursor (vertical black line) in a lineplot. Lineplots include EELS spectra, intensity plots etc.
- LinePlotImageDisplay Manipulation: An example script which shows how to manipulate lineplots. This script includes adding/deleting, hiding, selecting, scaling, offsetting, renaming, labelling, adding an ROI and cursor.
Scripting
- Adding a key listener to an image: Shows how to add a listener to an image which will react to key strokes.
- Addding an event listener to an image: Shows how to add an event listener to an image. This will listen for an event such as the image updating.
- Capture Mouse Click Position: An example script based on Gatan's demonstration code which shows how to capture the position of mouse clicks.
- Declaring Function Prototypes: Demonstrates how to declare function prototypes.
- Matrix Processing: Shows how to demonstrate matrix multiplication, inversion and determinant calculation.
- Triggering an Image Event Listener with a Background Thread: Shows how to add an event listener to an image. This image is subsequently updated by a background thread - which repeatedly triggers the event listener.
- Using the Unique Image ID Script Object: An example script which shows how to use the UID script object.
- Using Two Listeners to do Live Processing:Shows how to use an event listener to monitor updates in a live image (used to to create a live FFT). A key listener is then used to monitor the live FFT image to detect when it has been closed.
TagGroup
- Reading the Contents of a Directory into a Taggroup: Shows how to read the contents of a directory into a taggroup and subsequently use that taggroup to access files in the folder.
- Source tag information and save as a text : Shows how to source information from the taggroup of an image and save it as a text file.
- Taggroup Creation-Saving-Adding to Global Info: Shows how to add bits of information to a taggroup. This taggroup can be added directly to the the Global Info, or saved as a settings file.
- Traversing Persistent Tag Group: Shows how to navigate through the persistent tag group to locate the tag group names, where the taggroup name is known.
- Using a TagList: An example script which shows how to use the taglist structure to store lists of information.