Particle counting inside RoIs -Please help!

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Particle counting inside RoIs -Please help!

Stoyan Pavlov
Hi all,
I know my question is stupid but I really can't solve this issue and I
would appreciate your help. Probably I didn't describe my problem
correctly so I will explain it once again:
I use the following recorded macro to count particles within specific RoIs:

   n = roiManager("count");
        for (i=0; i<n; i++)  {
        roiManager("select", i);
         run("Analyze Particles...", "size=2-infinity
circularity=0.00-1.00 show=Nothing display summarize");
       
}
The problem is that the most important data to me -  the summaries,
which include the particle counts, are displayed in separate summary
windows. My question is:
Is there a way to redirect the summarize data to a single table? If
not, is there a way to create a macro that produces a single table
which includes  RoI lable, particle count, total particle area, mean
particle size and RoI area?

Stoyan Pavlov



---------- Forwarded message ----------
From: Stoyan Pavlov <[hidden email]>
Date: 2010/8/18
Subject: Particle counting inside RoI
To: ImageJ Interest Group <[hidden email]>


Dear all,
I have used ImageJ for quite some time for Image Analysis. However I
am not very good with the macro language and I don't have time to
study it in detail. Whenever I needed a macro I have either used the
Macro Recorder and/or modified a preexisting macro to my needs. I
couldn't find a way however to do something very simple. Here is my
"problem":
 I have a set of RoIs. I need a macro which counts and measures the
particles inside each RoI and afterwards returns in a table The RoI
lable, Area of  RoI, number of particles inside the RoI (including
particles only partly included in the RoI), Area covered by the
particles in the RoI (for the particles which cross the RoI borders
only the area which is inside the Roi).
Thank you in advance!

Stoyan Pavlov

--
Dr. Stoyan P. Pavlov, MD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
 Bulgaria
Tel: +359 (0) 52 - 677 - 050 #2638
e-mail: [hidden email]



--
Dr. Stoyan P. Pavlov, MD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
 Bulgaria
Tel: +359 (0) 52 - 677 - 050 #2638
e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Gabriel Landini
On Monday 23 August 2010, you wrote:

> I know my question is stupid but I really can't solve this issue and I
> would appreciate your help. Probably I didn't describe my problem
> correctly so I will explain it once again:
> I use the following recorded macro to count particles within specific RoIs:
>
>    n = roiManager("count");
>         for (i=0; i<n; i++)  {
>         roiManager("select", i);
>          run("Analyze Particles...", "size=2-infinity
> circularity=0.00-1.00 show=Nothing display summarize");
>
> }

If you remove the "summarize" string from the call to the particle analyzer
and add after it a new line:

run("Summarize");
It seems to write the summary to the Results table.

Cheers,
G.
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Arne Seitz
And with the getResult("Column", row) command you should be able to access the summarized data. Thus it should be rather easy to write a macro which can put the summarized data in one table/file.

Cheers Arne


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Gabriel Landini
Sent: lundi 23 août 2010 11:33
To: [hidden email]
Subject: Re: Particle counting inside RoIs -Please help!

On Monday 23 August 2010, you wrote:

> I know my question is stupid but I really can't solve this issue and I
> would appreciate your help. Probably I didn't describe my problem
> correctly so I will explain it once again:
> I use the following recorded macro to count particles within specific RoIs:
>
>    n = roiManager("count");
>         for (i=0; i<n; i++)  {
>         roiManager("select", i);
>          run("Analyze Particles...", "size=2-infinity
> circularity=0.00-1.00 show=Nothing display summarize");
>
> }

If you remove the "summarize" string from the call to the particle analyzer
and add after it a new line:

run("Summarize");
It seems to write the summary to the Results table.

Cheers,
G.
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Stoyan Pavlov
Thank you very much for your answers,
but run("Summarize"); command returns just the result table summary
(averages and st devs). What i need is the particle analyzer summary -
counts, total area, area fraction etc. Isn't there a way to just merge
all the different summary windows into a single table? I can do it
manually after all !?

Stoyan


2010/8/23 Seitz Arne <[hidden email]>:

> And with the getResult("Column", row) command you should be able to access the summarized data. Thus it should be rather easy to write a macro which can put the summarized data in one table/file.
>
> Cheers Arne
>
>
> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Gabriel Landini
> Sent: lundi 23 août 2010 11:33
> To: [hidden email]
> Subject: Re: Particle counting inside RoIs -Please help!
>
> On Monday 23 August 2010, you wrote:
>> I know my question is stupid but I really can't solve this issue and I
>> would appreciate your help. Probably I didn't describe my problem
>> correctly so I will explain it once again:
>> I use the following recorded macro to count particles within specific RoIs:
>>
>>    n = roiManager("count");
>>         for (i=0; i<n; i++)  {
>>         roiManager("select", i);
>>          run("Analyze Particles...", "size=2-infinity
>> circularity=0.00-1.00 show=Nothing display summarize");
>>
>> }
>
> If you remove the "summarize" string from the call to the particle analyzer
> and add after it a new line:
>
> run("Summarize");
> It seems to write the summary to the Results table.
>
> Cheers,
> G.
>



--
Dr. Stoyan P. Pavlov, MD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
 Bulgaria
Tel: +359 (0) 52 - 677 - 050 #2638
e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Gabriel Landini
On Monday 23 August 2010, you wrote:
> Thank you very much for your answers,
> but run("Summarize"); command returns just the result table summary
> (averages and st devs).

Ah, yes, sorry it is a different kind of summary.

> What i need is the particle analyzer summary -
> counts, total area, area fraction etc. Isn't there a way to just merge
> all the different summary windows into a single table? I can do it
> manually after all !?

I get one Results table and one Summary table, not many.

I am not aware of a way of getting all in one unless doing some macro writing
as suggested by Arne.

Regards

Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Stoyan Pavlov
I can't say how this happens, but I get one summary for each Roi,
instead of one summary table with one row per RoI.

2010/8/23 Gabriel Landini <[hidden email]>:

> On Monday 23 August 2010, you wrote:
>> Thank you very much for your answers,
>> but run("Summarize"); command returns just the result table summary
>> (averages and st devs).
>
> Ah, yes, sorry it is a different kind of summary.
>
>> What i need is the particle analyzer summary -
>> counts, total area, area fraction etc. Isn't there a way to just merge
>> all the different summary windows into a single table? I can do it
>> manually after all !?
>
> I get one Results table and one Summary table, not many.
>
> I am not aware of a way of getting all in one unless doing some macro writing
> as suggested by Arne.
>
> Regards
>
> Gabriel
>



--
Dr. Stoyan P. Pavlov, MD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
 Bulgaria
Tel: +359 (0) 52 - 677 - 050 #2638
e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Gabriel Landini
On Monday 23 August 2010, you wrote:
> I can't say how this happens, but I get one summary for each Roi,
> instead of one summary table with one row per RoI.

Sorry I do not know what might be happening because I cannot replicate it.

I suppose that you are running an updated ij.jar and that all the rois are
listed in the roi manager?
I am running 1.44f, under linux, java 1.6.0_20 (64-bit) if that might be of
any help.

Cheers
Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Stoyan Pavlov
I am running it (1.44f) under windows, I use the JRE included in the
Imagej package ( , however this used to happen on a different computer
with different installment an year ago! Could this be a WindowsXP
issue?
Stoyan

2010/8/23 Gabriel Landini <[hidden email]>:

> On Monday 23 August 2010, you wrote:
>> I can't say how this happens, but I get one summary for each Roi,
>> instead of one summary table with one row per RoI.
>
> Sorry I do not know what might be happening because I cannot replicate it.
>
> I suppose that you are running an updated ij.jar and that all the rois are
> listed in the roi manager?
> I am running 1.44f, under linux, java 1.6.0_20 (64-bit) if that might be of
> any help.
>
> Cheers
> Gabriel
>



--
Dr. Stoyan P. Pavlov, MD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
 Bulgaria
Tel: +359 (0) 52 - 677 - 050 #2638
e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Unsubscribe please! Thx!

Leow, ChingChing
Please take me off this mailing list.

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Unsubscribe please! Thx!

dscho
Hi,

On Mon, 23 Aug 2010, Leow, ChingChing wrote:

> Please take me off this mailing list.

How did you get on this list, if not by going to

        http://rsb.info.nih.gov/ij/list.html

and following the instructions on "Subscribing"?

Well, I guess you (or anybody else who is in danger of asking the list to
unsubscribe her/him) could follow the instructions on the same page on
"Leaving the List".

> Thank you.

Thank you,
Johannes
Reply | Threaded
Open this post in threaded view
|

update ImageJ on non-networked computers

Robert Dougherty
Hi,

I have some users who cannot connect their computers to the web because they have to classify them as laboratory instruments, not computers, to be left alone by their system administrators.  What is the current process for upgrading ImageJ in that case?  Help/Update ImageJ... has problems.  In the past, I would have suggested downloading the latest ij.jar on a connected machine  and smuggling it to the plugins folder, but I don't think it is that simple any more, at least on OS-X.  I don't see ij.jar there.  Plan C might be to move the whole ImageJ folder to a networked machine, do Help/Update ImageJ..., and move it back, but I'm not sure about that.  Any advice?

Bob

Robert Dougherty, Ph.D.
President, OptiNav, Inc.
4176 148th Ave. NE
Redmond, WA 98052
Tel. (425)891-4883
FAX (425)467-1119
www.optinav.com
[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: update ImageJ on non-networked computers

Glen MacDonald-2
Hi Bob,
With OSX, right click on the ImageJ.app, select 'Show Package Contents>Content>Resources>Java>ij.jar
replace the old ij.jar with the newer version.

HTH.
Glen

Glen MacDonald
Core for Communication Research
Virginia Merrill Bloedel Hearing Research Center
Box 357923
University of Washington
Seattle, WA 98195-7923  USA
(206) 616-4156
[hidden email]








On Aug 23, 2010, at 12:47 PM, Robert Dougherty wrote:

> Hi,
>
> I have some users who cannot connect their computers to the web because they have to classify them as laboratory instruments, not computers, to be left alone by their system administrators.  What is the current process for upgrading ImageJ in that case?  Help/Update ImageJ... has problems.  In the past, I would have suggested downloading the latest ij.jar on a connected machine  and smuggling it to the plugins folder, but I don't think it is that simple any more, at least on OS-X.  I don't see ij.jar there.  Plan C might be to move the whole ImageJ folder to a networked machine, do Help/Update ImageJ..., and move it back, but I'm not sure about that.  Any advice?
>
> Bob
>
> Robert Dougherty, Ph.D.
> President, OptiNav, Inc.
> 4176 148th Ave. NE
> Redmond, WA 98052
> Tel. (425)891-4883
> FAX (425)467-1119
> www.optinav.com
> [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: update ImageJ on non-networked computers

dscho
In reply to this post by Robert Dougherty
Hi Bob,

On Mon, 23 Aug 2010, Robert Dougherty wrote:

> I have some users who cannot connect their computers to the web because
> they have to classify them as laboratory instruments, not computers, to
> be left alone by their system administrators.  What is the current
> process for upgrading ImageJ in that case?  Help/Update ImageJ... has
> problems.  In the past, I would have suggested downloading the latest
> ij.jar on a connected machine and smuggling it to the plugins folder,
> but I don't think it is that simple any more, at least on OS-X.  I don't
> see ij.jar there.

On MacOSX, the ImageJ application is actually a folder. You will have to
Ctrl+click to see the context menu of the ImageJ icon, where you can
select "Show Package Contents". This will bring you inside the ImageJ.app
folder, where you should see ij.jar either right away, or in a
subdirectory.

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: update ImageJ on non-networked computers

Robert Dougherty
In reply to this post by Glen MacDonald-2
Glen,

It will be so.  Thanks.  

Bob

On Aug 23, 2010, at 1:36 PM, Glen MacDonald wrote:

> Hi Bob,
> With OSX, right click on the ImageJ.app, select 'Show Package Contents>Content>Resources>Java>ij.jar
> replace the old ij.jar with the newer version.
>
> HTH.
> Glen
>
> Glen MacDonald
> Core for Communication Research
> Virginia Merrill Bloedel Hearing Research Center
> Box 357923
> University of Washington
> Seattle, WA 98195-7923  USA
> (206) 616-4156
> [hidden email]
>
>
>
> On Aug 23, 2010, at 12:47 PM, Robert Dougherty wrote:
>
>> Hi,
>>
>> I have some users who cannot connect their computers to the web because they have to classify them as laboratory instruments, not computers, to be left alone by their system administrators.  What is the current process for upgrading ImageJ in that case?  Help/Update ImageJ... has problems.  In the past, I would have suggested downloading the latest ij.jar on a connected machine  and smuggling it to the plugins folder, but I don't think it is that simple any more, at least on OS-X.  I don't see ij.jar there.  Plan C might be to move the whole ImageJ folder to a networked machine, do Help/Update ImageJ..., and move it back, but I'm not sure about that.  Any advice?
>>
>> Bob
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Stoyan Pavlov
In reply to this post by Stoyan Pavlov
I just tried the same macro in the Linux 64bit version of imageJ 1.44f
and it still produces a summary window for each RoI.
I guess I'll have to dig deeper into the macro language to solve this.
Thanks anyway!

2010/8/23 Stoyan Pavlov <[hidden email]>:

> I am running it (1.44f) under windows, I use the JRE included in the
> Imagej package ( , however this used to happen on a different computer
> with different installment an year ago! Could this be a WindowsXP
> issue?
> Stoyan
>
> 2010/8/23 Gabriel Landini <[hidden email]>:
>> On Monday 23 August 2010, you wrote:
>>> I can't say how this happens, but I get one summary for each Roi,
>>> instead of one summary table with one row per RoI.
>>
>> Sorry I do not know what window  be happening because I cannot replicate it.
>>
>> I suppose that you are running an updated ij.jar and that all the rois are
>> listed in the roi manager?
>> I am running 1.44f, under linux, java 1.6.0_20 (64-bit) if that might be of
>> any help.
>>
>> Cheers
>> Gabriel
>>
>
>
>
> --
> Dr. Stoyan P. Pavlov, MD
> Departament of Anatomy, Histology and Embryology
> Medical University "Prof. Dr. Paraskev Stoyanov", Varna
> Prof. Marin Drinov Str.55
> 9002 Varna
>  Bulgaria
> Tel: +359 (0) 52 - 677 - 050 #2638
> e-mail: [hidden email]
>



--
Dr. Stoyan P. Pavlov, MD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
 Bulgaria
Tel: +359 (0) 52 - 677 - 050 #2638
e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Gabriel Landini
On Tuesday 24 August 2010, you wrote:
> I just tried the same macro in the Linux 64bit version of imageJ 1.44f
> and it still produces a summary window for each RoI.
> I guess I'll have to dig deeper into the macro language to solve this.
> Thanks anyway!

This is the way I get all the summaries in the same Summary window (mind the
line breaks).

run("Bridge (174K)");
makeRectangle(25, 24, 109, 110);
roiManager("Add");
makeRectangle(227, 41, 115, 186);
roiManager("Add");
makeRectangle(396, 49, 92, 235);
roiManager("Add");
makeRectangle(42, 306, 174, 96);
roiManager("Add");
makeRectangle(293, 334, 203, 144);
roiManager("Add");

setThreshold(0, 125);
n = roiManager("count");
for (i=0; i<n; i++) {
  roiManager("select", i);
  run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
show=Nothing display summarize");
}

Cheers

G.
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Stoyan Pavlov
Thank you very much!
The code you've send me works as expected - one summary window for all
rois. May be I didn't mention that i try to use this commands on a
stack of images and Rois are associated with slices - on the first
slice I have for example two RoIs on the next slice ten etc. When I
run  this
n = roiManager("count");
for (i=0; i<n; i++) {
 roiManager("select", i);
 run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
show=Nothing display summarize");
}
it produces separate windows called "Summary of stack" for each Roi.
although when it runs on single image it produces single neat summary
window .
Once again excuse me for the misinformation and thank you for the help.
S P
--
Dr. Stoyan P. Pavlov, MD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
 Bulgaria
Tel: +359 (0) 52 - 677 - 050 #2638
e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Particle counting inside RoIs -Please help!

Stoyan Pavlov
Hi all,
Since there were no more posts on this subject I dug deeper (deeper
for me) into the macro language and came up with a crude yet working
solution. I am posting the macro so if anyone meets this problem may
use and modify it:

// This Macro counts particles inside specific Roi and otputs the
number to TAB separated Log window which after saving can be imported
to excel.
print ("RoiNumber"," ","SliceLabel"," ","RoIName"," ","Count"," ","RoIArea"," ","
ParticlesCoveredArea"," ","AreaFraction") ;
setAutoThreshold("Default dark");
 n = roiManager("count");
        for (i=0; i<n; i++)  {
        roiManager("select", i);
        run("Set Measurements...", "area redirect=None decimal=4");
        run("Measure");
        r=getResult("Area");
run("Set Measurements...", "area area_fraction limit display
redirect=None decimal=4");
run("Measure");
s=getResult("Area");
t=getResult("%Area");
run("Analyze Particles...", "size=0-9999999 circularity=0.00-1.00
show=Nothing display clear ");
        m=nResults;
  q=getInfo("slice.label");
        print (i," ",q," ",call("ij.plugin.frame.RoiManager.getName",
i)," ",m," ",r," ",s," ",t) ;
}


I just have a question is it possible to generate a table similar to
the results table instead of TAB separated text file.

Best regards
Stoyan Pavlov

2010/8/24 Stoyan Pavlov <[hidden email]>:

> Thank you very much!
> The code you've send me works as expected - one summary window for all
> rois. May be I didn't mention that i try to use this commands on a
> stack of images and Rois are associated with slices - on the first
> slice I have for example two RoIs on the next slice ten etc. When I
> run  this
> n = roiManager("count");
> for (i=0; i<n; i++) {
>  roiManager("select", i);
>  run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
> show=Nothing display summarize");
> }
> it produces separate windows called "Summary of stack" for each Roi.
> although when it runs on single image it produces single neat summary
> window .
> Once again excuse me for the misinformation and thank you for the help.
> S P
> --
> Dr. Stoyan P. Pavlov, MD
> Departament of Anatomy, Histology and Embryology
> Medical University "Prof. Dr. Paraskev Stoyanov", Varna
> Prof. Marin Drinov Str.55
> 9002 Varna
>  Bulgaria
> Tel: +359 (0) 52 - 677 - 050 #2638
> e-mail: [hidden email]
>



--
Dr. Stoyan P. Pavlov, MD
Departament of Anatomy, Histology and Embryology
Medical University "Prof. Dr. Paraskev Stoyanov", Varna
Prof. Marin Drinov Str.55
9002 Varna
 Bulgaria
Tel: +359 (0) 52 - 677 - 050 #2638
e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Variables, functions and Memory Management

Mario Faretta
In reply to this post by Gabriel Landini
  A question regarding memory management and user-defined functions in a
macro: what happens to the let's say non-global variable once the
function has been executed? Trying to explain better: I load data from a
file inside a function using the openAsString command and store into an
array that is then passed to a macro. I have to pass through a couple of
splitting event creating also "transition array". What's the fate of the
string containing the file and of these transition array when the
function work is concluded? Is their content still present in memory and
I have to remove it (in this case what's the best choice to do it?) or
they are automatically cleaned up since they are no global?
Thanks a lot for every suggestion
Mario

--
Mario Faretta
Department of Experimental Oncology
European Institute of Oncology
c/o IFOM-IEO Campus for Oncogenomics
via Adamello 16 20139 Milan Italy
Phone: ++39-02574303054
email: [hidden email]
http://www.ifom-ieo-campus.it
Reply | Threaded
Open this post in threaded view
|

Re: Variables, functions and Memory Management

Michael Schmid
Hi Mario,

you can easily test this with a small macro:

makeLargeArray();
wait(1000);
waitForUser("out of function, click on status bar to check memory");
exit;

function makeLargeArray() {
   a=newArray(10000000);
   waitForUser("in function, click on status bar to check memory");
}

If you click on the status bar of the ImageJ panel, you will see the  
memory in use.

This will show that the memory for the array (which needs about 340  
MB) is deallocated after leaving the function. You might need to  
click more than once: clicking on the status bar calls the Java  
Garbage Collector, which is responsible for reclaiming free memory,  
and it does that only if it thinks it has to...

Michael
________________________________________________________________

On 10 Sep 2010, at 07:59, Mario Faretta wrote:

>  A question regarding memory management and user-defined functions  
> in a macro: what happens to the let's say non-global variable once  
> the function has been executed? Trying to explain better: I load  
> data from a file inside a function using the openAsString command  
> and store into an array that is then passed to a macro. I have to  
> pass through a couple of splitting event creating also "transition  
> array". What's the fate of the string containing the file and of  
> these transition array when the function work is concluded? Is  
> their content still present in memory and I have to remove it (in  
> this case what's the best choice to do it?) or they are  
> automatically cleaned up since they are no global?
> Thanks a lot for every suggestion
> Mario
>
> --
> Mario Faretta
> Department of Experimental Oncology
> European Institute of Oncology
> c/o IFOM-IEO Campus for Oncogenomics
> via Adamello 16 20139 Milan Italy
> Phone: ++39-02574303054
> email: [hidden email]
> http://www.ifom-ieo-campus.it
12