//02.09.12 16:31 var uvArr = newArray(0, 0, 0), expArray = newArray("0.047","0.15","0.1"), expMsArray = newArray(100, 100, 100), currentStackID = 0, grabbedID = 0, counter = 0, nChannels = 2, nFrames = 8, suffix = 0, baseName = "Untitled", prevNChannels = 0, currentStackSize = 0, ; macro "Grab next Channel [F1]"{ //incrementCounter(); counter++; print(counter); grabNextChannel(); } macro "Redo Channel [F2]"{ if(counter == 0) return; grabNextChannel(); } function grabNextChannel(){ channel = (counter + nChannels - 1) % nChannels + 1; grabChannel(channel); selectImage("Snap"); //wait(100); run("Select All"); run("Copy"); //run("Select None"); if (!isOpen(currentStackID)){ ww = getWidth; hh = getHeight; run("New Hyperstack...", "title=HyperStack type=16-bit display=Grayscale width=" + ww + " height=" + hh + " channels="+ nChannels + " slices=1 frames=" + nFrames); rename(baseName+"_" + suffix+".tif"); currentStackID = getImageID; waitForUser("Click 'OK' to continue"); } selectImage(currentStackID); if (counter > nSlices || counter <= 0){ counter = 0; currentStackID = 0; suffix++; exit("Counter error, please save your stacks manually and continue"); } setSlice(counter); run("Paste"); run("Enhance Contrast", "saturated=0"); run("Select None"); full = counter == nSlices; if (full){ counter = 0; currentStackID; saveAs("Tiff", ""); close; suffix++; waitForUser("Click 'OK' to continue"); } } selectImage(grabbedID); } function grabChannel(chn){ run("BX Control", "Exposure=" + expMsArray[chn - 1]); if (uvArr[chn -1] == 1) run("BX Control", "Shutter=1"); run("BX Control", "Grab=1"); grabbedID = getImageID; if (uvArr[chn -1] == 1) run("BX Control", "Shutter=0"); } macro "Dialog [F5]"{ Dialog.create("BX-Settings"); Dialog.addString("File base name", baseName); Dialog.addNumber("Suffix", 0); exposures = split("0.002 0.003 0.005 0.007 0.01 0.015 0.022 0.033 0.047 0.068 0.1 0.15 0.22 0.33 0.47 0.68 1 1.5 2.2 3.3 4.7"); Dialog.addNumber("Channels:", nChannels); Dialog.addCheckbox("UV-1", uvArr[0]); Dialog.addChoice("Exp-1:", exposures, expArray[0]); Dialog.addMessage(""); Dialog.addCheckbox("UV-2", uvArr[1]); Dialog.addChoice("Exp-2:", exposures, expArray[1]); Dialog.addMessage(""); Dialog.addCheckbox("UV-3", uvArr[2]); Dialog.addChoice("Exp-3:", exposures, expArray[2]); Dialog.show(); baseName = Dialog.getString; suffix = Dialog.getNumber; //channelsStr = Dialog.getChoice(); nChannels = Dialog.getNumber; for (chn = 0; chn <3; chn++){ uvArr[chn] = Dialog.getCheckbox(); expArray[chn] = Dialog.getChoice(); expMsArray[chn] = 1000 * parseFloat(expArray[chn]); } if (prevNChannels != nChannels){ currentStackID = 0; prevNChannels = nChannels; } } macro "Open Shutter [F6]"{ run("BX Control", "Shutter=1"); } macro "Close Shutter [F7]"{ run("BX Control", "Shutter=0"); } macro "AutoRun" { run("Micro-Manager Studio"); } macro "About BX_Control" { run("BX Control", "About"); } macro "AutoShutter on" { run("BX Control", "autoshutter=1"); } macro "AutoShutter off" { run("BX Control", "autoshutter=0"); }