// Liang Cai created for barbed end assay // For RGB tif file // i@cailiang.net // 2006.6.4 // Illustrated by "Expand/Shrink Selection" // Michael Schmid, version 05-Nov-2004 macro "MeasureEdge-RGB" { requires("1.34m"); run("Clear Results"); // inputs for the macro steppix = 2; // expand or shrink per 3 pix during the measure, about .33 um distance = 20; // total +/- distance from the edge, about 3 um Dialog.create("How to measure the edge"); Dialog.addMessage("To measure the edge of a cell:"); Dialog.addMessage(" 1. select the region you want to analyze and create a mask"); Dialog.addMessage(" 2. use threshold and wand tool to outline the cell and create another mask"); Dialog.addMessage(" 3. use the excel to graph the result"); Dialog.addNumber("Step Pixal per Measure:", steppix); Dialog.addNumber("Total Pixal Distance:", distance); Dialog.show(); steppix = Dialog.getNumber(); distance = Dialog.getNumber(); if ((distance % steppix) > 0) { exit("Remainder must be 0!"); } // initiate array realpair = distance / steppix; counts = realpair * 2 + 1; title = getTitle(); RGB = newArray("red", "green", "blue"); yMin = newArray(0,0,0); yMax = newArray(0,0,0); // creat data from shrinked/expanded mask, smaller to bigger, do 3 times for RGB // run("Create Mask"); use other way to get Mask!! selectWindow(title); run("RGB Split"); rename("blue"); run("Put Behind [tab]"); rename("green"); run("Put Behind [tab]"); rename("red"); run("Put Behind [tab]"); run("RGB Merge...", "red=red green=green blue=blue keep"); stepone = 0; while (isOpen("Mask")!=true && stepone == 0) { wait(1000); showStatus("Please Make Mask for ROI First"); } selectWindow("Mask"); rename("ROI-red"); run("Duplicate...", "title=ROI-green"); run("Duplicate...", "title=ROI-blue"); stepone = 1; selectWindow("RGB"); run("8-bit"); run("Enhance Contrast", "saturated=0.5 normalize"); while (isOpen("Mask")!=true && stepone == 1) { wait(1000); showStatus("Please Make Mask First"); } selectWindow("RGB"); close(); i = 0; while (i < counts) { selectWindow("Mask"); run("Duplicate...", "title=MaskRun"); if ((i - realpair) > 0) { selectWindow("MaskRun"); run("Maximum...", "radius="+((i - realpair) * steppix)); selectWindow("MaskRun"); run("Outline"); } else if ((i - realpair) == 0) { selectWindow("MaskRun"); run("Outline"); } else { selectWindow("MaskRun"); run("Minimum...", "radius="+((realpair - i) * steppix)); selectWindow("MaskRun"); run("Outline"); } selectWindow("MaskRun"); rename("MaskRun-red"); run("Duplicate...", "title=MaskRun-green"); run("Duplicate...", "title=MaskRun-blue"); for(rgbcycle=0; rgbcycle<3; rgbcycle++) { run("Image Calculator...", "image1=MaskRun-"+RGB[rgbcycle]+" operation=AND image2="+RGB[rgbcycle]); run("Image Calculator...", "image1=MaskRun-"+RGB[rgbcycle]+" operation=AND image2=ROI-"+RGB[rgbcycle]); setThreshold(1, 255); run("Set Measurements...", "area standard mean limit redirect=None decimal=2"); selectWindow("MaskRun-"+RGB[rgbcycle]); run("Measure"); callSD = getResult("StdDev", (nResults - 1)); callN = getResult("Area", (nResults - 1)); SEM = callSD / sqrt(callN); // 467 pix == 50 um xValues = ((i - realpair) * steppix) * 50 / 467; yValues = getResult("Mean", (nResults - 1)); yMin[rgbcycle] = minOf(yMin[rgbcycle], yValues); yMax[rgbcycle] = maxOf(yMax[rgbcycle], yValues); setResult("RGB-channel", (nResults - 1), rgbcycle); setResult("Distance", (nResults - 1), xValues); setResult("Intensity", (nResults - 1), yValues); setResult("SemOfInt", (nResults - 1), SEM); close(); } i ++; updateResults(); } selectWindow("Mask"); close(); selectWindow("ROI-red"); close(); selectWindow("ROI-green"); close(); selectWindow("ROI-blue"); close(); run("RGB Merge...", "red=red green=green blue=blue"); i = 0; while (i < counts) { for(j=0; j<3; j++) { setResult("PercInt", (i*3+j), ((getResult("Mean", (i*3+j)) - yMin[j]) / (yMax[j] - yMin[j]))); setResult("PercSEM", (i*3+j), (getResult("SemOfInt", (i*3+j)) / (yMax[j] - yMin[j]))); } i ++; } updateResults(); selectWindow("Results"); saveAs("Measurements", getDirectory("current")+"EdgeMeasure="+title+"=.xls"); beep(); wait(1000); close(); beep(); }