Creating a multi-point selection / find maxima on stack

Dear all,

I have a stack of binary mask and would like to create a multi-point selection marking each object within the mask (within a macro).

Example-File:
https://1drv.ms/f/s!AoHaKvCx7DHVlFCSZDeVCwBZy7iT

For now I tried the following:

  • find the ultimate eroded points.
  • run “find Maxima” for each slice and add to the roiManager the point selection of each slice.

The problem is that the point selection created in this way cannot be modified, meaning I cannot add further points or delete. This would be needed to manually correct the segmentation result.
I would be happy about any help or work-around to create a modifiable multi-point selection for every slice.

I would like to add one thing:
It seems to be a problem with Process > Find Maxima… running on a stack.
If I create a multipoint selection using Find Maxima… on a single image (not a stack), I can add further points with ALT+Click and remove points with Control+Click.
Is there another way to create a multipoint selection inside a macro other than the Find Maxima… trick?

You can use a particle analysis and add the results to the ROI Manager, see:

https://imagej.nih.gov/ij/docs/guide/146-30.html#toc-Subsection-30.2

https://imagej.nih.gov/ij/docs/guide/146-30.html#sub:ROI-Manager

The particle analysis will be done for the whole stack and you can save, add and edit the ROI’s in the ROI Manager easily.

The particle analysis can be recorded.

1 Like

Thank you for the help (again)! The particle analyzer would work, yes, but I was hoping for an easier solution. I only need the counts of two populations, the moving cells vs. the non-moving cells. So my workflow would be: a) segment original image and get mask, b) distinguish moving from non-moving objects b) find centroids or UEPs c) transform these into a multipoint tool d) manually add non-detected cells and wrongly sorted cells, e) count both populations and export result.

I have found a related thread:

Here the centroid-position of each object was determined using “Analyze Particles…”, the result was converted to XML and then loaded to the Cell Counter plugin. This could be a solution for me. However, I don’t know how to convert the x/y-centroid-result to XML. I am fine with the macro language and the built-in macro functions, but I do not know how to apply the java/jython solutions suggested by @ctrueden.
How to import results to use with the Multipoint tool OR how to add “Alt click” to Cell Counter?

Any help is highly appreciated, thank you!

You can measure the moving cells (or static cells) with the particle analyzer and then rename then in the ROI manager.

Macro to rename type 1:

count=roiManager("count");
for (i=0; i<count; i++) { 
    
         roiManager("Select", i);
         roiManager("Rename", "Type_1_"+i);
    
}

Now delete and add ROI’s (cells) in the ROI Manager and name them accordingly.

Now both types are easily to distinguish can be sorted and measured easily (see menu ‘More’).

You can also select all cells of type 1 or type 2 (Shift+mouse-click or CTRL+Mouse-click) and then use the measure function of the ROI Manager to get two different results tables.

Of course you could also automatize the particle analysis of moving and static cells in a macro.

Do you use the image calculator to extract the moving cells (static -static signatures = 0)?

Here an example of one moving cell in an artificial example :

run("Blobs (25K)");
run("Make Binary");
run("Duplicate...", " ");
makeRectangle(34, 16, 24, 24);
run("Copy");
run("Paste");
makeRectangle(98, 33, 24, 24);
makeRectangle(34, 15, 24, 25);
run("Fill", "slice");
imageCalculator("Subtract create", "blobs.gif","blobs-1.gif");
selectWindow("Result of blobs.gif");
1 Like

You are right, renaming the ROIs should be the easier solution to correct the object-classification compared to taking a detour via the cell counter.
Exactly, I extract the moving cells by subtraction of the images using the image calculator, and I am doing it already in a macro, so there I am fine.
Thank you very much for you help!