// $BACKGROUND$ //Script to measure and display the total dose rate (in millions of electrons per second) on the camera. //Run this script with the live view front-most in DigitalMicrograph and press the Spacebar key to stop it. //Script written by Ben Miller Updated Oct 2022 number gainfactor = 32 //gain factor should be 32 for Metro and for K3 IS. It should be set to the detector conversion efficiency (DCE) for non-counting cameras like OneView. result("\n press SPACE to stop this script, which runs in the background!") image VIEW imagedocument VIEWDoc imagedisplay VIEWDisp number exposure, intensity Component text1 //Get Live View Objects VIEW:=getfrontimage() VIEWDisp = VIEW.ImageGetImageDisplay(0) VIEWDoc=VIEW.ImageGetOrCreateImageDocument() //Add Text Annotation if (!VIEW.ImageGetTagGroup().TagGroupGetTagAsNumber( "Acquisition:Parameters:High Level:Exposure (s)", exposure )) Throw( "Exposure tag not found in image." ) text1 = NewTextAnnotation( 0, 0, "Total Dose Rate = ", 50 ) text1.ComponentSetForegroundColor(255,255,0) VIEWDisp.ComponentAddChildAtEnd( text1 ) //Update Text Annotation While(!SpaceDown()) { If(VIEWDoc.ImageDocumentIsDirty()) { intensity = VIEW.Sum()/gainfactor/exposure/1000000 text1.TextAnnotationSetText( "Total Dose Rate = "+intensity+ " million electrons per second" ) VIEWDoc.ImageDocumentClean() } } //End Script and Remove Annotation text1.ComponentRemoveFromParent() result("\n ended listening to VIEW") result("\nLast Measured Intensity: "+intensity+ " million electrons per second" )