Posted by
TimFeinstein on
URL: http://imagej.273.s1.nabble.com/Translation-error-in-ROI-generated-macros-tp5013047.html
Hello,
We want to know if something localizes to the axoneme of a cilium, but the signal is too noisy to do a simple Pearson's correlation. I wrote a short macro to create a large number of randomly translated 'clones' of a linear ROI made by the user over the body of a cilium; if the labeled protein is significantly in the axoneme then the profile should show greater localization (area under the curve, greater minima etc) than clones randomly positioned on the image.
The macro works well, except for one annoying problem. Whenever I run this macro the first ROI, the one that the user draws, has been saved in the ROI manager in a slightly different position. Oddly it seems as if the Translate... function was applied to it with the defaults (10, 10) left in. The code is below. Any help would be greatly appreciated.
Thanks,
Tim
Timothy Feinstein, Ph.D.
Research Scientist
University of Pittsburgh Department of Developmental Biology
________________________________
macro "Cilia Transect Analyzer [k]" {
// the user draws a segmented line over the cilium
roiManager("Add");
// add 20 randomly positioned ROIs:
for (i=0; i<20; i++) {
lateral = (((random*2)-1)*getWidth)/2;
vertical = (((random*2)-1)*getHeight)/2;
roiManager("Select", 0);
roiManager("translate", lateral, vertical);
run("Rotate...", "angle=" + (random*365-180));
roiManager("Add");
}
// delete ROIs touching the edge
n = roiManager("count");
for (i=n-1; i>=0; i--) {
roiManager("select", i);
getSelectionBounds(x, y, w, h);
if (x<=0||y<=0||x+w>=getWidth||y+h>=getHeight)
roiManager("delete");
}
// select all ROIs and plot the transects
roiManager("Deselect");
roiManager("Multi Plot");
}
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html