Problem with creating ring like ROIs with particle analyzer

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

Problem with creating ring like ROIs with particle analyzer

Straub, Volko A. (Dr.)
Dear All,


I have encountered a problem using the particle analyzer and I was wondering whether anybody had a suggestion for a solution.

I am trying to create ring-like ROIs to measure the intensity around a central region. I can create the ring-like ROIs by first creating a selection of the central regions using the particle analyzer and then use the 'Make Band' function to create rings for each ROI. This is okay, but gets very slow when images are large and contain hundreds or thousands of ROIs.

So, instead I tried to use the maximum filter to dilate the ROIs and then subtract the original ROIs. This produces the desired rings, which can be analysed with the particle analyzer. This works and inspecting the measurement in the results table shows the expected results. However, when these regions are added to the ROI manager, the ROIs now include the central hole rather than just the ring. So, any subsequent measurements using these ROIs measure not just the ring but the ring plus the hole.

This issue has previously been discussed on the mailing list (http://imagej.1557.x6.nabble.com/ROI-with-holes-Particle-Analyzer-vs-ROI-Manager-td5009887.html) and the suggested solution was to use the 'Limit to Threshold' option in measurements. That works okay for the binary images of the rings, however I can't get this to work if I want to use the ROIs to measure the pixel intensity on another image. I also tried to use the redirect option in "Set Measurements", but I don't seem to get this to work either.


I attach a small sample image and some macro to illustrate the issue. The image contains three nuclei. I am trying to measure the intensity of the ring around the nuclei. The first three ROIs are created using the 'Make Band' function, while ROIs 4-6 are created by dilation and subsequent subtraction of the original image. Both approaches produce the same results for measurements on the binary 'Border' image (compare results 1-3 and 4-6). However, using the ROIs to measure the intensity of the ROIs on the original image ('Test') produces different results for the ROIs created using the 'Make Band' function (1-3) and the ROIs created by dilation and subsequent subtraction (4-6) as these ROIs contain the whole area and not just the ring.


Sorry for the lengthy email. I hope that this makes sense and would be very grateful for any suggestions.

Thanks,

Volko



Test Macro:


image=getTitle();
run("Duplicate...", "title=Nuclei");
setAutoThreshold("Default dark no-reset");
setOption("BlackBackground", true);
run("Convert to Mask");

run("Set Measurements...", "area mean center limit redirect=None decimal=1");
run("Analyze Particles...", "display clear add");
for(i=0;i<roiManager("count");i++){
roiManager("Select", i);
run("Make Band...", "band=2");
roiManager("Update");
};

run("Select None");
run("Duplicate...", "title=Border");
run("Maximum...", "radius=2");
imageCalculator("Subtract", "Border","Nuclei");
run("Analyze Particles...", "display add");

setThreshold(100,255);

roiManager("multi-measure append");
selectWindow("Test");
roiManager("multi-measure append");




ImageJ - ROI with holes / Particle Analyzer vs. ROI Manager<http://imagej.1557.x6.nabble.com/ROI-with-holes-Particle-Analyzer-vs-ROI-Manager-td5009887.html>
imagej.1557.x6.nabble.com
ROI with holes / Particle Analyzer vs. ROI Manager. Dear all, the Particle Analyzer can "exclude" holes when measuring particles, gives reasonable results on my data.



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

Test.tif (11K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problem with creating ring like ROIs with particle analyzer

Herbie
Good day Volko,

did you try making ring-ROIs from two circular selections using the
XOR-feature of the ROI-manager?

Here is an example macro:

// ROI-xor Demo
newImage("Test", "8-bit ramp", 256, 256, 1);
makeOval(52, 59, 128, 128);
roiManager("Add");
run("Enlarge...", "enlarge=-16");
roiManager("Add");
roiManager("Select", newArray(0,1));
roiManager("XOR");
roiManager("Add");
roiManager("Select", newArray(0,1));
roiManager("Delete");
roiManager("Show All with labels");

Regards

Herbie

::::::::::::::::::::::::::::::::::::::::::::::::::::
Am 23.07.18 um 09:00 schrieb Straub, Volko A. (Dr.):

> Dear All,
>
>
> I have encountered a problem using the particle analyzer and I was wondering whether anybody had a suggestion for a solution.
>
> I am trying to create ring-like ROIs to measure the intensity around a central region. I can create the ring-like ROIs by first creating a selection of the central regions using the particle analyzer and then use the 'Make Band' function to create rings for each ROI. This is okay, but gets very slow when images are large and contain hundreds or thousands of ROIs.
>
> So, instead I tried to use the maximum filter to dilate the ROIs and then subtract the original ROIs. This produces the desired rings, which can be analysed with the particle analyzer. This works and inspecting the measurement in the results table shows the expected results. However, when these regions are added to the ROI manager, the ROIs now include the central hole rather than just the ring. So, any subsequent measurements using these ROIs measure not just the ring but the ring plus the hole.
>
> This issue has previously been discussed on the mailing list (http://imagej.1557.x6.nabble.com/ROI-with-holes-Particle-Analyzer-vs-ROI-Manager-td5009887.html) and the suggested solution was to use the 'Limit to Threshold' option in measurements. That works okay for the binary images of the rings, however I can't get this to work if I want to use the ROIs to measure the pixel intensity on another image. I also tried to use the redirect option in "Set Measurements", but I don't seem to get this to work either.
>
>
> I attach a small sample image and some macro to illustrate the issue. The image contains three nuclei. I am trying to measure the intensity of the ring around the nuclei. The first three ROIs are created using the 'Make Band' function, while ROIs 4-6 are created by dilation and subsequent subtraction of the original image. Both approaches produce the same results for measurements on the binary 'Border' image (compare results 1-3 and 4-6). However, using the ROIs to measure the intensity of the ROIs on the original image ('Test') produces different results for the ROIs created using the 'Make Band' function (1-3) and the ROIs created by dilation and subsequent subtraction (4-6) as these ROIs contain the whole area and not just the ring.
>
>
> Sorry for the lengthy email. I hope that this makes sense and would be very grateful for any suggestions.
>
> Thanks,
>
> Volko
>
>
>
> Test Macro:
>
>
> image=getTitle();
> run("Duplicate...", "title=Nuclei");
> setAutoThreshold("Default dark no-reset");
> setOption("BlackBackground", true);
> run("Convert to Mask");
>
> run("Set Measurements...", "area mean center limit redirect=None decimal=1");
> run("Analyze Particles...", "display clear add");
> for(i=0;i<roiManager("count");i++){
> roiManager("Select", i);
> run("Make Band...", "band=2");
> roiManager("Update");
> };
>
> run("Select None");
> run("Duplicate...", "title=Border");
> run("Maximum...", "radius=2");
> imageCalculator("Subtract", "Border","Nuclei");
> run("Analyze Particles...", "display add");
>
> setThreshold(100,255);
>
> roiManager("multi-measure append");
> selectWindow("Test");
> roiManager("multi-measure append");
>
>
>
>
> ImageJ - ROI with holes / Particle Analyzer vs. ROI Manager<http://imagej.1557.x6.nabble.com/ROI-with-holes-Particle-Analyzer-vs-ROI-Manager-td5009887.html>
> imagej.1557.x6.nabble.com
> ROI with holes / Particle Analyzer vs. ROI Manager. Dear all, the Particle Analyzer can "exclude" holes when measuring particles, gives reasonable results on my data.
>
>
>
> --
> 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: Problem with creating ring like ROIs with particle analyzer

Gabriel Landini
In reply to this post by Straub, Volko A. (Dr.)
On Monday, 23 July 2018 08:00:14 BST Straub, Volko A. (Dr.) wrote:
> However, when
> these regions are added to the ROI manager, the ROIs now include the
> central hole rather than just the ring. So, any subsequent measurements
> using these ROIs measure not just the ring but the ring plus the hole.

This will not strictly answer your question on ROIs but might be a useful
alternative if you do not find a solution.
Rather than using ROIs I prefer using a binary mask of the objects to analyse
and get the pixel data via Redirection. I use Particles 8 for this, it
restricts the data collection to the pixels set in white in the mask. It you
chose redirection it automatically gets the pixel stats (gresycale or RGB).

Cheers
Gabriel

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

Re: Problem with creating ring like ROIs with particle analyzer

Straub, Volko A. (Dr.)
Thanks Herbie & Gabriel for your suggestions.


The suggestion to use the 'Enlarge' function with the ROI managers 'XOR feature' to create the rings resulted in significant speed improvements compared to using the 'Make Band' function. The relative speed improvements are dependent on number of particles and image size, and are particularly striking for larger images with many particles. For example, for an image with 120 particles (image size 664x650 pixels), using the XOR approach is about 2x faster than the 'Make Band' approach. For an image with 1300 particles (image size 2504x2320 pixels), the speed improvement is about 5x. I was surprised by this as using the 'XOR feature' requires the temporary creation of 3x as many ROIs (original ROI, enlarge ROI and combination of the two).


Gabriel's suggestion to use binary masks and redirect the measurements to the original image seems even faster, but can cause problems when the creation of the ring masks by dilation and subsequent subtraction of the original image leads to contact between neighbouring particles. This can be avoided by using some non-merging dilation,  but I found that the order in which the measurements of the ring masks and the cores (original particles) are shown in the results table are not necessarily the same (probably because some of the rings are incomplete due to the way they where created). This is a problem as I try to compare measurements of the core and the surrounding area, and at the moment I can't figure out a simple way to check that core and surrounding area measurements correspond.


Thanks again,

Volko




________________________________
From: Gabriel Landini <[hidden email]>
Sent: 23 July 2018 11:22:22
To: [hidden email]
Subject: Re: Problem with creating ring like ROIs with particle analyzer

On Monday, 23 July 2018 08:00:14 BST Straub, Volko A. (Dr.) wrote:
> However, when
> these regions are added to the ROI manager, the ROIs now include the
> central hole rather than just the ring. So, any subsequent measurements
> using these ROIs measure not just the ring but the ring plus the hole.

This will not strictly answer your question on ROIs but might be a useful
alternative if you do not find a solution.
Rather than using ROIs I prefer using a binary mask of the objects to analyse
and get the pixel data via Redirection. I use Particles 8 for this, it
restricts the data collection to the pixels set in white in the mask. It you
chose redirection it automatically gets the pixel stats (gresycale or RGB).

Cheers
Gabriel

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

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