Analyze Particles on (empty) ROI from ROI Manager

Hi everyone,

I seem to have run into an issue with Analyze Particles and the ROI Manager.

The macro below creates a set of ROIs and adds them to the ROI Manager. Subsequently, it activates one of the ROIs from the Manager on another image (that’s also created by the macro) and runs Analyze Particles. I would expect to get the same error that you get when selecting the first ROI from the Manager on the second mask and try to run Analyze Particles: “no particles detected” (which is perfectly right).

Instead, however, I get a Results Table with all the ROIs from the manager? :unamused:

roiManager("reset")

/* Open sample image */
run("Dot Blot (7K)");
input = getImageID();

/* Create first binary mask from input (mask0) */
run("Duplicate...", " ");
setAutoThreshold("Default");
run("Convert to Mask");
mask0 = getImageID();

/* Create second binary mask from input (mask1) */
selectImage(input);
run("Duplicate...", " ");
setThreshold(0, 85);
run("Convert to Mask");
mask1 = getImageID();

/* Run Analyze Particles on first mask (only add to Roi Manager) */
selectImage(mask0);
run("Analyze Particles...", "add");

/* Run Analyze Particles on second mask for one ROI from mask0 */ 
selectImage(mask1); // Select mask1
roiManager("select", 0); // Set ROI (extracted from mask0)
run("Analyze Particles...", "display");

Am I missing an obvious point here? Can someone replicate the issue on his/her machine?

Best,
Stefan

PS: I have tried with the latest nightly build of ImageJ1 (1.51m) as well as 1.51k within Fiji on Ubuntu 16.04.

Hi @stelfrich,

I replicated the macro behavior – on IJ 1.51k, Fiji, Mac (Sierra), I also get no error message running your macro.

But, strangely, I don’t get the error you mentioned when manually analyzing particles on an ROI containing no particles – whether the ROI is in the manager or not.

If Summarize is selected then I get a total of 0 added to the Summary table, but nothing added to the Results table and no error message.

Hope this helps.

That’s weird. Thanks for testing, @tswayne! Could you also check if the following macro produces the error shown below it:

newImage("TestAnalyzeParticles", "8-bit white", 40, 40, 1);
makeRectangle(13, 12, 17, 17);
// Run Analyze Particles manually with Display results enabled

But you do get a Results Table with 21 rows? Sorry for being pedantic, just want to be absolutely sure that I haven’t gone crazy :wink:

Yes, I do.

And I DO get the error with this procedure.

But still, running the original macro, I don’t get the error.

We have different settings for Process > Binary > Options > Black Background. I have it enabled, meaning that the white image that is created by the second macro is all foreground for me. For you, however, it is all background (assuming the Black Background option is disabled, so there are not particles to be detected.

Could you take a look at the initial macro and check why a Results Table is created although the active selection should not contain any particles, @Wayne? Sorry for not being able to further reduce the size of the initial macro (might not be an optimal MCVE) :unamused:

Ah, I see, and I understand the original issue a little bit better too.

It seems related to the interaction of ROI Manager and Analyze Particles, because if I substitute run("Measure"); for the final Analyze Particles step, I get the correct answer – the area of the ROI, not the whole image.