Scripting Resources for DigitalMicrograph™ |
Cryo Fluence Measurement |
|
Function |
Reports an average electron flux for an image, on the basis of the CCD conversion efficiency. |
Version |
version:20100715, v1.0 |
Author |
D. R. G. Mitchell |
Acknowledgements |
|
Comments |
Set the conversion efficiency for your camera by running the script with ALT held down. |
System Requirements |
Should be compatible with all recent versions of DigitalMicrograph. |
Known Issues |
|
Supported |
Yes |
Included Files |
Main script file. |
Source Code |
// Script to compute the electron fluence of an image (e-/≈2) on the basis // of the image's spatial calibration, mean intensity and the CCD sensitivity. // The sensitivity of the CCD is stored in a default value (6.262 cts per electron for Gatan Ultrascan 2k x 2k) // This can be changed by running the script with the ALT key held down.
// D. R. G. Mitchell, adminnospam@dmscripting.com (remove the nospame to make this address work) // version:20100715, v1.0
// Create a default setting for the CCD sensitivity
number sensitivity=6.262 // CCD sensitivity in terms of counts per electron
if(!getpersistentnumbernote("Cryo Tools:Dose Calculator:Sensitivity",sensitivity)) { setpersistentnumbernote("Cryo Tools:Dose Calculator:Sensitivity",sensitivity) }
// If ALT is held down change the default setting
if(optiondown()) { if(getnumber("Enter default CCD sensitivity (counts per electron)",sensitivity, sensitivity)) { setpersistentnumbernote("Cryo Tools:Dose Calculator:Sensitivity",sensitivity) showalert("Default CCD sensitivity set to "+sensitivity+" counts per electron.",2) } }
// Ensure at least one image is open
number nodocs=countdocumentwindowsoftype(5) if(nodocs<1) { showalert("Ensure an image is displayed.",2) exit(0) }
// Get the front-most image or a roi thereof
image front string imgname=getname(getfrontimage()) front:=getfrontimage()[] // picks up an ROI if present
// Get some data from the image
number xcal, ycal, imgsum, multiplier, xsize, ysize, origin, scale, format string units
imgsum=sum(front) getsize(front, xsize, ysize) front.imagegetdimensioncalibration(0,origin, scale, units, format)
// Trap to avoid line plots
if(ysize==1) { showalert("This script only works on images.",1) exit(0) }
// Multiplier converts the calibration unit into ≈
multiplier=0 if(units=="µm") multiplier=10000 if(units=="nm") multiplier=10 if(units=="≈") multiplier=1
// If none of the units above match then the image is not correctly calibrated - bail out.
if(multiplier==0) { showalert("The image must be calibrated in µm, nm or ≈.",1) exit(0) }
// Calculate the dose
number area=(xsize*scale*multiplier)*(ysize*scale*multiplier) number electrons=imgsum/sensitivity number dose=electrons/area
result("\n\nElectron Fluence of '"+imgname+"' ="+format(dose,"%5.3f")+" e-/≈2.") showalert("Electron Fluence of '"+imgname+"' ="+format(dose,"%5.3f")+" e-/≈2.",2)
|