Analyze Particle Overlay - Odd Behavior in Macro


I am working on a macro to track the area of motile single cells over time, with images taken every 2 minutes for ~ 3 hours. Each data set has 1~10 cells, and I have dozens of data sets. The contrast is good, and segmentation via automatic thresholding works well.

I am then using analyze particles to get the area of each cell, and I pass that data into Matlab to sort (analyze particles produces out results that are ordered by frame not by cell, and so the results are out of order, especially when cells leave or enter the frame).

Then, I want to pass the indices of deleted rows back into ImageJ, and remove them from the results/overlay, then give the user an opportunity to compare the original image with the overlays to ensure only appropriate cells are being counted for area quantification.

Now here’s where I run into a slight issue. If I use my mouse to click on a row in the results table and delete it, the overlay disappears from the image. But, if I use Table.deleteRows(), the row is deleted but the overlay is not. The macro recorder shows both operations being exactly the same, but their behavior is not. So, without physically clicking on the row and deleting it (obviously not viable), I cannot figure out a way to remove the overlay. Seems like Table.deleteRows() should do the trick, but I have no idea why doesn’t work.

For reference, these are the options I am using for analyze particles: run(“Analyze Particles…”, “size=” + min_cell_area + “-Infinity pixel show=Overlay display exclude clear summarize stack”);

Appreciate any help, thanks!

Upgrade to the latest ImageJ daily build (1.52q21) and Table.deleteRows() will work as expected. Here is macro that reproduces the problem:

  run("Blobs (25K)");
  run("Analyze Particles...", "show=Overlay display exclude clear");
  Table.deleteRows(0, 22);

Awesome, that did the trick - thank you!!

Another odd behavior of Table.deleteRows. Whenever I use it on a table, it empties the table and opens a new Results table with the resulting edit e.g.

for (n=0,row=0; n<10; n++,row++) {
	Table.set("Col1", row, n+1);
Table.deleteRows(0, 4);

or tweaking Wayne’s example code ( by renaming the table and then using Table.deleteRows:

run("Blobs (25K)");;
run("Set Measurements...", "area mean centroid feret's");
run("Analyze Particles...", "display include in_situ");
Table.rename("Results", "Rename");
code = "FeretMinimum=MinFeret; FeretMaximum=Feret;"
	+"FeretAngleCopy=FeretAngle; FeretStartX=FeretX;"
Table.renameColumn("FeretAngleCopy", "FeretAngle");
Table.deleteRows(0, 4);

For my purpose I can work around by renaming the table after every use of Table.deleteRows, but I imagine that under some circumstances that might not be possible.


OK, I found the solution to exclude this behavior in the preamble to the Table Functions in the macro function descriptions ( “an optional title argument can be provided (must be last argument)”. I should have read the description of the whole group of functions and not assumed that all of the arguments are included in the boldfaced name of each function.

for (n=0,row=0; n<10; n++,row++) {
	Table.set("Col1", row, n+1);
Table.deleteRows(0, 4, "Test_table");