21.11.2014 Views

Digital Micrograph Scripting

Digital Micrograph Scripting

Digital Micrograph Scripting

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Digital</strong> <strong>Micrograph</strong> <strong>Scripting</strong><br />

Vincent Richard<br />

GATAN France, Division de Roper Scientific. vrichard@gatan.com<br />

1<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


DM <strong>Scripting</strong> – WHY ? – AND WHY NOT ?<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Where to go from here?<br />

The help-documentation of DM is a the starting point and the only “official” documentation. It is<br />

listing most of the available commands. (You launch the documentation by pressing F1 within DM.)<br />

•The DM script database hosted at HTTP://www.felmi-zfe.at has lots of scripts both as simple<br />

examples and as useful tools shared by other DM users. An exhaustive list of DM script functions<br />

and procedures can be found in this website<br />

• At HTTP://lists.asu.edu/archives/dmsug.html you can sign up a mailing list about DM scripting.<br />

Please also check the archives of the list prior to sending your questions. The answer might already<br />

be there!<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Script examples<br />

Image Filters Diffraction / FFT Other examples<br />

Tilt series<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Install scripts in DM<br />

Use the menu File…/ Install Script…<br />

Menu<br />

Librarie<br />

Plug in<br />

The scripts are now stored in the preference files of<br />

DM (<strong>Digital</strong><strong>Micrograph</strong>CF.8.prf) , could be launched<br />

from custom menu.<br />

The scripts are now stored in the preference files of<br />

DM (<strong>Digital</strong><strong>Micrograph</strong>CF.8.prf) and are<br />

automatically loaded on launching DM.<br />

To deinstall scripts or functions, use the menu<br />

File…/Remove Script… , then select the library you<br />

want to deinstall and press “Remove”.<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Compile scripts in Plug-In with Package Creator<br />

1) Launch Package Creator script<br />

2) Regroup the scripts in one directory<br />

3) Select them in Package creator windows<br />

4) Create the Plug-In : .gtk<br />

5) It will automatically create and save in :<br />

C:\ProgramFiles\Gatan\<strong>Digital</strong><strong>Micrograph</strong>\<br />

PlugIns<br />

6) The Command will be display in the<br />

Tomography menu<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


<strong>Scripting</strong> Window<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


First scripting window – GMS 1.8.0<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


First script<br />

• While a script is running, no other tasks can be performed in DM. The mouse cursor becomes an hourglass.<br />

After the script finishes, the mouse cursor becomes an arrow again.<br />

•A running script can be interrupted by pressing the keys Ctrl and Break simultaneously.<br />

• The following script command prints output to the results window: result(string) where string can be a<br />

variable or any text within quotes, e.g.: result(“Hello word!\n”) prints to the results window: Hello world!<br />

The two characters \n add a line break.<br />

Write in the results window :<br />

// This is the first line of my script! Just a comment.<br />

// The purpose of the script is to demonstrate the RESULT command.<br />

result("My name is Vincent Richard")<br />

result("\n\n\n\n")<br />

result("And who are you?") // I will always comment my scripts!<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Images as number arrays<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Directly addressing images<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Directly addressing images areas<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Useful commands for image evaluation<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Script example: pixel by pixel operation<br />

Calculate the relative thickness map t/λ by script from<br />

unfiltered and Zero loss images :<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


tert () – a powerful command<br />

This script creates a binary mask from image B<br />

Each point, where < 10000 counts, becomes 1,<br />

each other point 0.<br />

ShowImage (tert( t( B < 10000 , 0 , 1 ))<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


warp () – another powerful command<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Variables (numbers and strings)<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


A third type of variables : images type<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Image related commands<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Condition in script<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


WHILE loops<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


FOR Loops<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Writing a function<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Functions: arguments and optional arguments<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Functions: image arguments<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


How to create a customized dialog<br />

Example : View / Focus / acquire dialog box<br />

Window size and position<br />

Name of the Button<br />

Name of the function<br />

Buttons positions<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


How to perform a task on all open images<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


How to open/save a file<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


“ChooseMenuItem command”<br />

This command allows you to launch a functions or a script present in <strong>Digital</strong> <strong>Micrograph</strong> menu.<br />

Syntaxe : ChooseMenuitem(“menu“ ,“submenu“ ,“function")<br />

Example : this following function will acquire a live image in view mode<br />

=<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Hardware control by scripts<br />

Microscope control ->setup -> test : Common microscope functions:<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Hardware control by scripts<br />

List of universal commands (works for any TEM):<br />

> EMGetMagnification( number mag )<br />

> EMImageShift( dac, dac )<br />

> EMBeamShift( dac, dac )<br />

> EMChangeFocus( dac )<br />

> EMChangeTilt( dac,dac )<br />

> EMGetBrightness()<br />

> EMSetBrightness( dac )<br />

> EMGetSpotSize()<br />

> EMSetSpotSize( dac )<br />

> EMGetStageX()<br />

> EMSetStageX( um )<br />

> EMGetStageY()<br />

> EMSetStageY( um )<br />

> EMGetStageZ()<br />

> EMSetStageZ( um )<br />

> EMGetStageAlpha()<br />

> EMSetStageAlpha( deg )<br />

Example : function to set alpha stage to 30°<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


JEOL COM microscope control by scripts<br />

MICROSCOPES DE TYPE 2100/1400/2200 use the universal commands :<br />

EMGet(or)SetCommand (dac,dac)<br />

Or<br />

Specific JEOL commands can be used like screen commands<br />

JEOLCOM_SetScreen( 0 ) set fluorescent to 0°<br />

JEOLCOM_SetScreen(1) set fluorescent to 7°<br />

JEOLCOM_SetScreen( 2 )<br />

set fluorescent to 90°<br />

Or for JEOL 2200FS filter : Jeolcom_getslitwith(). Script example (deflector change button) :<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


Serial JEOL microscope control by scripts<br />

JEM 2010 /2011/3010/3011/2010F/1010/1011/1200EXII/2000EX/FXI<br />

Jeolcommand is the <strong>Digital</strong> <strong>Micrograph</strong> command to sent an order to the<br />

microscope :<br />

Reply=jeolcommand(« command », »ok »)<br />

Serial commands examples :<br />

gmove (x,y)<br />

move x/y stage<br />

Objf x OL value change<br />

gtilt (alpha,beta) move alpha/beta stage<br />

Bright x CL3 value (brightness) change<br />

gmovez (z)<br />

move z<br />

Dfc n,x,y<br />

deflector n change of x,y values<br />

Htset<br />

Change HT<br />

Gun 1 n=0<br />

SCRSET 2<br />

Screen up<br />

Gun 2 n=1<br />

SCRSET 0<br />

Screen down<br />

Cla 1 n=5<br />

SPOTDN<br />

Spot size down<br />

Cla 2 n=6<br />

.<br />

Pla n=11<br />

All microscope commands available are listed in the JEOL microscope manual.<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009


JEOL Serial microscope script examples<br />

By Michel Ribardière<br />

Journées du Cercle des Microscopistes JEOL Physique, 1 et 2 décembre 2009

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!