Posted by
gnelson on
URL: http://imagej.273.s1.nabble.com/Help-to-create-macro-tp5022778p5022782.html
That may be overkill if I understand the original question. Do you just need to count the objects inside the ROIs? If that is the case, then you can cycle through each ROI in the ROI manager and find local maxima in each ROI on the channel of interest. The manual code below will let you do it. Obviously, you can automate the whole thing. If you need/want other data for the spots, then obviously this won't work, and I would consider Gabriel's option, or you could try cycling through each ROI and duplicating that ROI as a new image to allow analysis of the spots in that- I have considered doing this before- you need to delete data outside the ROI after duplicating, since it duplicates a rectangle around the ROI. I abandoned this since I was more interested in counts, and it was getting a bit complicated for my abilities!
------
//collect ROIS (e.g. nuclei) from one image,then swap to object of interest (e.g. foci) channel and count the spots.
//Assumes you have both images open (the one for finding the ROIs, eg nuclear counterstain and the one for the spots inside it.
var tolerance = 30;
originalImage = getTitle();
run("8-bit");
run("Overlay Options...", "stroke=red width=1 fill=none set");
run("Median...", "radius=6");
run("Subtract Background...", "rolling=125 sliding");
run("Threshold", "method=Default white");
roiManager("Reset");
run("Analyze Particles...", "pixel exclude clear add");
waitForUser("Select the image for spot counting");
run("8-bit");
run("Gaussian Blur...", "sigma=1");
run("Subtract Background...", "rolling=25");
for(i=0; i<roiManager("count"); i++) {
roiManager("select", i);
run("Find Maxima...", "noise="+tolerance+" output=[Count]");
run("Find Maxima...", "noise="+tolerance+" output=[Point Selection]");
run("Add Selection...");
}
------
Glyn
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html