// Calib_EMGain macro by Christophe Leterrier // 02/02/2012 // automate the EMCCD EM gain measurement explained at http://www.photometrics.com/resources/learningzone/calculating-electron-multiplication-gain.php // keep the illumination constant when acquiring all images ! // for each gain/exposure time couple, acquire two images: // - a "bright" images named gXXXX_YYYY.tif with XXXX = gain value (padded to 4 digits with zeros) and YYYY = exposition value (in ms padded to 4 digits with zeros) // - a "dark" image with no illumination light names gXXXX_dark.tif (same exposure time). // The first couple will be "no gain" i.e. gain = 1 g0001_YYYY.tif and g0000_dark.tif (a point at EM gain = zero is necessary) // just point the macro to the folder containing the images (and no other files!) and it will output a table with the theoretical gain (slider value) vs experimental gain (measured). // Then you can save the table as a txt or xls file. macro "Calib_EMGain" { // Choose a folder InputDir = getDirectory("Please Choose Acquired Stacks Directory"); Files = getFileList(InputDir); // initialize results arrays nCond = Files.length/2; GainsTheo = newArray(nCond); Expo = newArray(nCond); BrightMean = newArray(nCond); DarkMean = newArray(nCond); GainsExp = newArray(nCond); setBatchMode(true); // loops on all files in the folder (only tif files from the experiment!) for (i=0; i