Skip to main content

Posts

Showing posts from March, 2021

Making a GUI in dm-script

 // 2 button dialog example  // To invert the most front image. // Modified from http://www.dmscripting.com/files/Example_Button_Enabling_Dialog.s // Renfong // 2021/03/24 // Global variables taggroup firstbutton, secondbutton number true=1 number false=0 image src // the class createbuttondialog is of the type user interface frame (UIFrame), and responds to interactions // with the dialog - in this case pressing buttons class CreateButtonDialog : uiframe { void button1response(object self) { //the response when the button is pressed self.SetElementIsEnabled("first", false); // these commands set the button as enabled or not enabled self.SetElementIsEnabled("second", true); // "second" in this command is the identifier of the button 'secondbutton' // put action1 here src.GetFrontImage() result(src.GetName()+" is picked.\n") }; void button2response(object self) { //the response when the second button is press...

Extract information from an existed TagGroup in DM

The dm3/dm4 files contain the acquisition parameters and other information in its unique data structure: "TagGroup". In this example, I will show you how to extract the information from an existed taggroup. The tag structure in an SI image is like this: The following code will show how to obtain the operation voltage from the tag group ====================================================== // An example shows how to extract info from an existed taggroup image src := GetFrontImage() TagGroup tg = src.ImageGetTagGroup() TagGroup parenttg string path, label // Asign tag path If (!GetString("Enter path to tag", "Microscope Info:Voltage", path)) Exit(0) result("path : " + path + "\n") tg.TagGroupParseTagPath(path, parenttg, label) parenttg.TagGroupOpenBrowserWindow("Parent of "+label, 0) // Get value from a given path number val TagGroupGetTagAsFloat(tg,path,val) result(label + " : "+val+"\n") ==================...

LatticeEnhancedFilterV2

This is a band-enhanced filter. ref: Ondrej L. Krivanek et. al., Nature 464, 571-574 ============================================================ // Lattice enhanced filter // Reference : Ondrej L. Krivanek et. al., Nature 464, 571-574 // // Version 2 // The filter enhance the lattice feature without removing background. // Set the weight factor in the background and high frequency region  = 1 // And the weight factor of the enhanced feature  = 3.5 // // The first window will show the radial average of the FFT of the image // enhanced feature (look for the peak) then key the value into the window // // 2021/03/15 // Renfong // windless@gmail.com // sub-function1 : radial average // This script is retrived and  modified from  // http://www.gatan.com/sites/default/files/Scripts/Rotational%20Average.s image Rotational_Average(image img) { // Define neccessary parameters and constants number xscale, yscale, xsize, ysize number centerx, centery, halfMi...