Scripting Resources for DigitalMicrograph™ |
SEM Stage Scanning |
|
Function |
Drives an SEM or STEM stage in an X-Y raster while capturing scanning images using DigiScan to build up a large area montage. |
Version |
version:20201117, v2.1 |
Author |
D. R. G. Mitchell |
Acknowledgements |
Thanks to Drs Mitchell Nancarrow and Tobias Schulz for assistance with testing and suggestions for improvements. |
Comments |
This script is designed to be used on an SEM which has DigiScan attached. Typically, this will be a CL system. It creates a large area montage by moving the stage in an X-Y raster while capturing snapsphots from a continuously running DigiScan image. There is no post-capture alignment, such as cross-correlation. It simply relies on the accuracy of stage positioning. This script was designed to capture large area survey images at very low magnification (eg 250x), and under these conditions, the stage should be reasonably accurate. No automatic focusing is applied either. Provided the specimen is flat and the magnification is low, this should not be an issue. Images are copied into a montage to create a large map. Images can be either pasted or merged. The former produces a montage which contains lots of floating sub-images. This doubles the size of the final image, but does allow individual frames to be selected and manually repositioned. This would allow manual correction of any minor stage errors, provided the montages contain only a small number of images. Merging images result in a montage which is a single image, and which does not allow for post-acquisition repositioning. The merged image is around half the size of the pasted counterpart as it is only a single image.The absence of alignment/focusing and the fast image capture from a continuous acquisition makes mapping very fast. A montage of some hundred or so images (1.2mm x 2mm area!) took around 20mins to capture. In contrast, using a proprietary routine on commercial EDS software with position realignment would have taken over 2hrs. This script was written to provide a way of mapping large areas in CL mode, to look for zircons - which can be present at very low density. The aim was to write a companion script to then interrogate the map via thresholding or other image processing, to move the stage to regions containing potentially interesting particles. It turns out that in the Oxford EDS system we have on the same microscope, we can import this large map, and then link the current stage position with the image. Thereafter, clicking anywhere on the large map will move the stage to the selected position automatically. Mission accomplished. I have tested this script on a TEM/STEM and it does work. However, the absence of any image realignment, means that it can only be realistically used at a magnification of perhaps 2,000x or lower. During script testing I ran it my my JEOL ARM STEM - which has a minimum magnfication of 20,000x. The misalignments are quite large (up to 1/3rd of a frame) at this magnfication. It is possible to create reasonable montages, but a fairly large overlap (eg 50%) is needed to ensure that there are no gaps between images. It is not really designed with materials STEM in mind. Biology folk might find it useful for imaging large areas of sections. I would recommend using the paste rather than merge option, so that you have the option to manually adjust any individual frame positions. Detailed instructions on choosing the paste or merge options are provided at the start of the script. Updates in this version: Modified the EMGetStage . . () and EMSetStage.. () commands to be universally compatible with my hardware (JEOL 6490 SEM and ARM200F STEM). Added some taggroups to the saved images, to ensure compatibility with the Image Montaging script. The option to save individual frames as they are acquired in either TIFF or .dm4 files has been provided. The companion script Image Montaging can be used to assemble individual images (saved from this script) into a a raw montage (unaligned) and to align raw montages, using cross correlation and manual methods.
|
System Requirements |
This script has been tested using GMS 2.3 and Gatan's DigiScan II. Compatibility with older DigiScans and GMS 1.x is unknown. Tested on a JEOL 6490L SEM, but should be compatible with most SEMs which have a DigiScan attached. Tested on a JEOL ARM200F STEM - it works, but the minumum magnification is quite large (20kx) and misalignments between frames can be significant, necessitating use of a large overlap during acquisition. |
Known Issues |
WARNING: This script moves the microscope stage. There is the potential to drive inclined or incorrectly set specimens into a detector or the polepiece. A CL mirror may be particularly vulnerable to damage if the specimen colides with it. This script does not monitor stage to detector/polepice distances, and does not protect against collisions. Users must ensure that the specimen height is appropriate over the scanned areas. This script is provided in good faith, but with no warranty as to its fitness for purpose. Anyone using this script does so entirely at their own risk. The author accepts no responsibility for any damages or losses which may occur from its use. Scripting is generally very reliable, provided only Gatan hardware is involved. Once you introduce third party hardware (microscope columns), odd things can happen. As originally written, this script worked fine with my JEOL 6490 SEM. However, when I tested it on my ARM200F STEM it behaved erratically. This was because the commands which get or set the stage XY positions were working correctly on the SEM - setting the absolute values of the stage. However, on the STEM, these same commands applied relative shifts to the current positions. Most likely this is an unintended bug in the microscope control plugin. As such there is nothing I can do to fix it. However, a simple workaround was found. All the EMGet. . and EMSet . () commands initally used were those designed to set both the X and Y values at the same time. Changing these commands to the single axis versions - ie having one command to set X and then one to set Y, worked fine on both SEM and STEM. So the script was modified to use those commands. A detailed description of the problem and the workaround can be found near the end of the descriptive text at the start of the script. If you run into problems with erratic stage movement - try that fix. If it does not work, then unless you happen to have the same hardware as I do, I will not be able to assist. I have not implemented this script as a background thread, so you will not be able to do other things in DM while it is running. To halt the script simply hold down the SPACE BAR. This script can create seriously large images, especially if you are using high resolution DigiScan settings such as 1k x 1k. 32bit versions of DM will be limited to images no larger than 2GB, which will take some doing. Be aware that if you paste images (into a larger montage image), you have to deal with the size of the large image as well as all the small component images. If you use the merge option, then you only have to deal with the size of the large image. If you need to make really big images, consider using the merge option. This is set through the Global Info Tags - see the start of the script for more details. In GMS 2.32 I have found that the script paste commands (used here) can run into a problem - and an error can appear saying you do not have access or similar. This seems to be a bug in the scripting language (not in my script). I think it is caused by a memory buffer used for storing images not getting flushed. The solution is to quit DigitalMicrograph, then restart it and then run the script. You may find that over time the error returns, and another restart is necessary. You can set an overlap between adjacent images. A small value like 5% is good. If you set it to zero, you will end up with some narrow black lines between some images due to minor stage errors. If you set the value to be large (eg 30%), then the total acquisition time will increase significantly. I have not implemented image alignement by cross-correlation, so large overlaps offer no benefit, unless you intend to montage the images using a third party tool (in which case you would also need to select the 'Save Files' option). It would be fairly easy to implement alignment, but my aim here was speed, and this is quick. Also, the stage seems pretty good on the microscope I tested it on. I have included a backlash correction option. There are two settings which you will need to set if you want to use the Backlash (correction) option (in the Global Info Tags). These are the backlash correction percentages. They have a sign and a magnitude. The percentage is a displacement as a fraction of the individual frame size. The sign dictates which direction the offset is applied. The correction is applied at the start of each row of images. Where scanning is left to right and top to bottom, then the stage backlash correction should be upwards and to the left at the start of the row, before moving back to the starting row position. This ensures that the stage is being driven in the direction it will next move, before the row scan starts. A backlash value of 5-10% seems reasonable and the sign will depend on your system - some stages may have flipped axes. Chose positive values and run the script to see what the stage does when you do an acquisition. Then reverse the direction of any correction which is not correct. MAKE SURE that scan rotation is turned off in the SEM and in DigiScan before running this script. My SEM had an option to link rotation correction to magnification. This deals with the fact that the image rotates slightly as the magnification is changed. In order to get reliable mapping, this had to be set to on. To keep things fast, DigiScan runs continously and the script takes snapshots of the resulting image. For this reason it is essential that the Settling Time (the time the script waits after a stage movement) is sufficient for at least one complete frame to be captured by DigiScan in which no stage movement or drift is present. Typically, the Settling Time should be twice the DigiScan exposure time. The script will set ensure a suitable minimum time is applied - but this can be extended if required. |
Supported |
Yes. |
Included Files |
Main script. |
Source Code |
see attached script |