// Liang Cai created for barbed end assay // For RGB tif file // i@cailiang.net // 2006.3.4 // Illustrated by "Expand/Shrink Selection" // Michael Schmid, version 05-Nov-2004 macro "MeasureEdge-RGB" { requires("1.34m"); // inputs for the macro steppix = 3; // expand or shrink per 3 pix during the measure, about .33 um distance = 27; // total +/- distance from the edge, about 3 um Dialog.create("How to measure the edge"); 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; xValues = newArray(counts); yValues = newArray(counts); SEM = newArray(counts); title = getTitle(); RGB = newArray("red", "green", "blue"); j = 1; // 1 then no measure on red channel // 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"); while (isOpen("Mask")!=true) { wait(1000); showStatus("Please Make Mask First"); } selectWindow("RGB"); close(); while (j < 3) { title = RGB[j]; i = 0; run("Clear Results"); 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"); } run("Image Calculator...", "image1=MaskRun operation=AND image2="+title); setThreshold(1, 255); run("Set Measurements...", "area standard mean limit redirect=None decimal=2"); selectWindow("MaskRun"); run("Measure"); callSD = getResult("StdDev"); callN = getResult("Area"); SEM[i] = callSD / sqrt(callN); setResult("SEM", (nResults - 1), SEM[i]); // 467 pix == 50 um xValues[i] = ((i - realpair) * steppix) * 50 / 467; yValues[i] = getResult("Mean", i); if (i == 0) { yMin = getResult("Mean", 0); yMax = getResult("Mean", 0); } else { yMin = minOf(yMin, (yValues[i] - SEM[i] - steppix)); yMax = maxOf(yMax, (yValues[i] + SEM[i] + steppix)); } close(); i ++; updateResults(); } xMin = xValues[0] - 0.1; xMax = xValues[counts-1] + 0.1; Plot.create("Edge Measure of " + title + " (Mean-SEM)", "um from the edge of ROI", "Gray Value", xValues, yValues); Plot.setLimits(xMin, xMax, yMin, yMax); Plot.setColor(title); Plot.add("circles", xValues, yValues); Plot.add("error bars", SEM); Plot.show(); j++; } selectWindow("Mask"); close(); run("RGB Merge...", "red=red green=green blue=blue"); }