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

 

Stack Slicer
Function
Excises a smaller stack from a larger stack.
Version
version:20190624, v1.0
Author
D. R. G. Mitchell
Acknowledgements
-
Comments

3D stacks are useful because they allow images to be stacked in a sequence. These may be a time series or may be a rastered series of images from a scanned acquisition (eg 4D STEM). Huge amounts of data can be acquired into a single (albeit large) image (stack). Several of my acquisition scripts make use of stacks to record series of images, such as TEM Recorder and STEM Averager. Often only a sub-section of these stacks contain the key information, such as the interesting part of an in-situ test. This script will allow a stack to be sliced to excise a smaller stack.

With a stack open the script will source the stack and then select the start and end positions of the stack to be excised, based on dialog settings. The excision can run from the start of the stack to the current slice; from the current slice to the end of the stack or from two user-defined positions. Single frames can also be extracted by specifying the current slice as the start and end position. Use this script in conjunction with the Slice control in the Gatan interface. Instructions for use are provided at the start of the source code.

System Requirements
Tested on GMS 2.3 but should work with all versions from GMS 2 onwards.

Known Issues

Stacks can be immense and require a large amount of system memory (RAM). 32bit versions of DigitalMicrograph will have access to around 2GB of RAM. Be aware that each new stack you create will use up RAM too, so if your stacks are very big (>300MB), always close a stack as soon as you have finished with it, and do not have too many open (ideally only two) at any one time. Bear in mind also, that the script will hold copies of the source and excised stacks in memory, even if you close the actual stacks. Always close the Stack Slicer dialogue as soon as you have finished with it, in order to free up that memory. If memory gets tight, you will find the system runs very slow as data is spooled to hard disk, which gets used as virtual memory. Be patient and let it finish spooling then close stacks and dialogues as soon as you are finished with them. 64bit versions of DigitalMicrograph can access all system RAM, and provided you have lots (>=8GB), you shouldn't have problems. However, before working on very large stacks, it is strongly recommended that you save and close all open work, and do not have other applications running which might also compete for available RAM.

Supported
Yes.
Included Files
Source code.
Source Code

See attached script