Find Maxima ... segmentation (macro issue)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Find Maxima ... segmentation (macro issue)

Christian R.-2
Hi all,

I've run into an issue when running the "Find Maxima..." segmentation algorithm by Michael Schmid:
Basically, running the segmentation from a macro produces different results than a manual run -
from the same image, with the same parameters provided.

Parameters: "prominence=32767 strict above output=[Segmented Particles]"

The image is a 500x500 px overlay of nuclei (values: 0, 65535) and cytosol markers (values: 0-32767),
which, in principle, works as a marker-based segmentation - when run manually.
But it looks like a marco run produces additional particles, which are lines with a width of single pixels.
I've tried to exclude those additional particles with the Analyze Particles... with size or circularity limits,
but unfortunately that also excludes valid results (particles derived from maxima).

Could I run the "Find Maxima..." segmentation from the macro in Java or JS as a workaround / for testing?
(I've consulted the ImageJ documentation, but unfortunately my understanding of ImageJ is still too limited.)

I'd like to troubleshoot this issue, since it's currently a roadblock in my image processing pipeline.


Thanks in advance,
Christian R.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Find Maxima ... segmentation (macro issue)

Gabriel Landini
Please post an image and a short macro so others can try to reproduce the
issue.
Thanks

Gabriel

On Tuesday, 21 July 2020 22:16:56 BST you wrote:

> Hi all,
>
> I've run into an issue when running the "Find Maxima..." segmentation
> algorithm by Michael Schmid: Basically, running the segmentation from a
> macro produces different results than a manual run - from the same image,
> with the same parameters provided.
>
> Parameters: "prominence=32767 strict above output=[Segmented Particles]"
>
> The image is a 500x500 px overlay of nuclei (values: 0, 65535) and cytosol
> markers (values: 0-32767), which, in principle, works as a marker-based
> segmentation - when run manually. But it looks like a marco run produces
> additional particles, which are lines with a width of single pixels. I've
> tried to exclude those additional particles with the Analyze Particles...
> with size or circularity limits, but unfortunately that also excludes valid
> results (particles derived from maxima).
>
> Could I run the "Find Maxima..." segmentation from the macro in Java or JS
> as a workaround / for testing? (I've consulted the ImageJ documentation,
> but unfortunately my understanding of ImageJ is still too limited.)
>
> I'd like to troubleshoot this issue, since it's currently a roadblock in my
> image processing pipeline.
>
>
> Thanks in advance,
> Christian R.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Find Maxima ... segmentation (macro issue)

Michael Schmid
In reply to this post by Christian R.-2
Hi Christian,

as Gabriel said, please provide a sample image where the results of the
manual and macro operations are different.

I agree that "Find Maxima" with output type "Segmented Particles" should
be usable as a marker-based segmentation if the marker pixels have
values that exceed the background by the the prominence or more.
If you also have a threshold ("Above lower threshold"), the markers must
have higher values than the surrounding pixels, and the background must
have pixel values below the lower threshold.
Here is a macro example that works for me (it uses the output of a
rather strict "Find Maxima" as seeds and adds it to the original image:

   run("Blobs (25K)");
   run("Multiply...", "value=0.5");
   run("Find Maxima...", "prominence=85 light output=[Single Points]");
   imageCalculator("Add", "blobs.gif","blobs.gif Maxima");
   selectWindow("blobs.gif");
   setThreshold(38, 255);
   run("Find Maxima...", "prominence=128 above light output=[Segmented
Particles]");


Concerning:
 > Could I run the "Find Maxima..." segmentation from the macro in Java
or JS as a workaround / for testing?
You can simply replace the "run" of a macro by "IJ.run" in java or
javascript.

macro:
   run("Find Maxima...", "prominence=32768 strict above
output=[Segmented Particles]");
java or javascript:
   IJ.run("Find Maxima...", "prominence=32768 strict above
output=[Segmented Particles]");


To me, it is astonishing that there should be a difference between
interactive operation and "run" from a macro. When running a macro,
ImageJ essentially fills in the parameters into the dialog and then does
the same as in an interactive operation.
Please make sure that the following are the same in both cases:
- threshold
- grayscale calibration ("Find Maxima" uses calibrated values)
- 'normal' or inverted lookup table.



Michael
________________________________________________________________
On 21.07.20 23:16, Christian R. wrote:

> Hi all,
>
> I've run into an issue when running the "Find Maxima..." segmentation algorithm by Michael Schmid:
> Basically, running the segmentation from a macro produces different results than a manual run -
> from the same image, with the same parameters provided.
>
> Parameters: "prominence=32767 strict above output=[Segmented Particles]"
>
> The image is a 500x500 px overlay of nuclei (values: 0, 65535) and cytosol markers (values: 0-32767),
> which, in principle, works as a marker-based segmentation - when run manually.
> But it looks like a marco run produces additional particles, which are lines with a width of single pixels.
> I've tried to exclude those additional particles with the Analyze Particles... with size or circularity limits,
> but unfortunately that also excludes valid results (particles derived from maxima).
>
> Could I run the "Find Maxima..." segmentation from the macro in Java or JS as a workaround / for testing?
> (I've consulted the ImageJ documentation, but unfortunately my understanding of ImageJ is still too limited.)
>
> I'd like to troubleshoot this issue, since it's currently a roadblock in my image processing pipeline.
>
>
> Thanks in advance,
> Christian R.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Find Maxima ... segmentation (macro issue)

Christian R.-2
In reply to this post by Gabriel Landini
Hi Gabriel,

Thanks for asking for the short macro - that helped me find the culprit:

I found a rogue "run("Watershed");" command in my code that would have
virtually no effect on the segmentation of the nuclei (round particles,
constant count), but that would have a dramatic effect on the segmentation
of the cytosol (irregularly shaped particles, count varying by threshold).

After having fixed my code, the issue does no longer persist.

Again, thank you very much!!



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Find Maxima ... segmentation (macro issue)

Christian R.-2
In reply to this post by Michael Schmid
Hi Michael,

I've only seen your response after my update. - Thanks for taking time to
brainstorm about my issue,
and of course for anwering my questions!

Yes, the issue was puzzling me - quite a bit. I thought that maybe a
parameter might not've been transferred to the (Java) function call from the
macro to the dialog or that maybe there was some issue with the numerical
representation of these parameters.

But actual the cause was an oversight of mine:

With the the combined nuclei/cytosol image, my macro ran an additional
watershed step (unintentionally) *after* I had confirmed the number of
maxima (using the "Find Maxima..." function) but *before* calling the
"Analyze Particle" function to count the number of maker-based segmented
particles. This would always cause too many particles to being produced.
If I then went back to segment the particles of the combined image manually,
the watershed step would be skipped and the number of nuclei and cytosol
would match perfectly.

The Find Maxima... segmentation works nicely and I'm very glad it's publicly
available in ImageJ.

If I can return the favor and help with testing or the documention, please
do not hesitate to contact me!

Chris





--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html