Posted by
Ben.BigHair on
Aug 07, 2006; 4:55pm
URL: http://imagej.273.s1.nabble.com/RoiManager-Combine-tp3701796p3701798.html
Wayne Rasband wrote:
>> Hello,
>>
>> I am having difficulty understanding the "Combine" operation for the
>> RoiManager. Here is an example...
>>
>> (1) run the "RoiManagerAddParticles.txt" example macro availbale at
>>
>>
http://rsb.info.nih.gov/ij/macros/RoiManagerAddParticles.txt>>
>>
>> (2) select the first and second ROIs by shift-clicking on...
>>
>> 0005-0063
>> 0014-0108
>>
>> (3) press the "Combine" button (both ROIs are highlighted)
>>
>> (4) then press the "Measure" button
>>
>> At this point two measurements are added - identical to the originals.
>> I expected a single measurement. Is there a way to have ImageJ treat
>> the two as a single ROI?
>
> Press the "m" key (Analyze>Measure) and ImageJ will treat the two as a
> single ROI. Or add the combined ROI to the ROI Manager, select it and
> press the "Measure" button.
>
Ah! Thanks. I folled myself into thinking that "Combine" would replace
the two automatically and "Add" - but that would be too destructive.
Within a macro I can get the two to combine and be added, I can delete
the original two, but when I select the last element to measure it
selects all of the ROIs. This is different than if I manually combine
add and measure the two.
Here is the example I am using...
// RoiManagerAddParticles2
// This macro demonstrates how to add particle analyzer
// outlines to the ROI Manager. Note that doWand() may
// not work reliably unless the objects being traced
// have been highlighted in red using setThreshold().
//Nothing clear record
requires("1.33f");
run("Blobs (25K)");
setThreshold(125, 248);
run("Analyze Particles...", "minimum=1 maximum=999999 bins=20 show
=Nothing display clear record");
for (i=0; i<nResults; i++) {
x = getResult('XStart', i);
y = getResult('YStart', i);
doWand(x,y);
roiManager("add");
}
run("Record...");
print("Count after Analyze: " + roiManager("Count"));
// select 1 and 2 to combine - add them as a new ROI
roiManager("Deselect");
roiManager("Select", 1);
roiManager("Select", 2);
roiManager("Combine");
roiManager("Add");
print("Count after Combine and Add: " + roiManager("Count"));
// now remove 1 and 2 (in reverse order)
roiManager("Deselect");
roiManager("Select", 2);
roiManager("delete");
print("Count after first deletion: " + roiManager("Count"));
roiManager("Select",1);
roiManager("delete");
print("Count after first deletion: " + roiManager("Count"));
// finally, select the last element and measure that
roiManager("Deselect");
n = roiManager("count");
print("Count at end: " + n);
lastIndex = n-1;
print("Index to select and measure: " + lastIndex);
roiManager("Select",lastIndex);
run("Measure");