I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

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

I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

hatopop100
Dear all,

I'd like to measure all ROIs (200000~500000) using the macro.
So, I performed the macro referred to the past post as below.

----------------------------------
count=roiManager("count");
array=newArray(count);
for(i=0; i<count;i++) {
        array[i] = i;
}
roiManager("Select", array);
roiManager("Measure");
----------------------------------

But it worked very slow compared with the method manually select all ROIs
and put on the "Measure" button on ROI Manager.

Because I have to measure many slices (each has 200000~500000 ROIs), I'd
like to use the macro.
How should I do macro as fast as the manual method?
 
Sincerely,
Hayato



--
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: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

Jeremy Adler
Dear Hayato,

1)
you can avoid using the loop to populate the array

nRois=roiManager("count");// entries in ROI Manager.
testArray=Array.getSequence(nRois); // creates an array with nRois entries, numbered sequentially. from 0 upwards
roiManager("Select", testArray);// select all ROIs.
roiManager("Measure");// measure all ROIs.

2)
but I suspect the slow part is measuring  and printing your 200,000+ ROIs and the results
so, consider where your ROIs came from,
if they came from    a thresholded image  and Analyze Particles,
the measurements can be made at the same time by selecting the Display results checkbox

3)
to check on how fast a part of your macro runs
add
timeBefore=getTime();// before part of the macro.
and
timeAfter=getTime();// after the part.
print("time ",timeAfter-timeBefore; //

Jeremy Adler
Uppsala U

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of hatopop100
Sent: Thursday, May 21, 2020 5:51 AM
To: [hidden email]
Subject: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

Dear all,

I'd like to measure all ROIs (200000~500000) using the macro.
So, I performed the macro referred to the past post as below.

----------------------------------
count=roiManager("count");
array=newArray(count);
for(i=0; i<count;i++) {
        array[i] = i;
}
roiManager("Select", array);
roiManager("Measure");
----------------------------------

But it worked very slow compared with the method manually select all ROIs and put on the "Measure" button on ROI Manager.

Because I have to measure many slices (each has 200000~500000 ROIs), I'd like to use the macro.
How should I do macro as fast as the manual method?

Sincerely,
Hayato



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

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








När du har kontakt med oss på Uppsala universitet med e-post så innebär det att vi behandlar dina personuppgifter. För att läsa mer om hur vi gör det kan du läsa här: http://www.uu.se/om-uu/dataskydd-personuppgifter/

E-mailing Uppsala University means that we will process your personal data. For more information on how this is performed, please read here: http://www.uu.se/en/about-uu/data-protection-policy

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

Re: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

Krs5
In reply to this post by hatopop100
Dear Hayato

If you just want to measure all ROIs and nothing else than:

----------------------------------
roiManager("Deselect");
roiManager("Measure");
----------------------------------

should do the job. If no ROIs are selected in the ROI Manager than all are used when you use roiManager("Measure");

Best wishes

Kees
________________________________
From: hatopop100 <[hidden email]>
Sent: 21 May 2020 04:50
To: [hidden email] <[hidden email]>
Subject: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

Dear all,

I'd like to measure all ROIs (200000~500000) using the macro.
So, I performed the macro referred to the past post as below.

----------------------------------
count=roiManager("count");
array=newArray(count);
for(i=0; i<count;i++) {
        array[i] = i;
}
roiManager("Select", array);
roiManager("Measure");
----------------------------------

But it worked very slow compared with the method manually select all ROIs
and put on the "Measure" button on ROI Manager.

Because I have to measure many slices (each has 200000~500000 ROIs), I'd
like to use the macro.
How should I do macro as fast as the manual method?

Sincerely,
Hayato



--
Sent from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.1557.x6.nabble.com%2F&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7C6f784f5132b24cd6535408d7fd3bbade%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637256305300350766&amp;sdata=mQy9FYRPypgbalIm%2FuYAuRR1OLNiaK2s0Lx6pyFWUDc%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7C6f784f5132b24cd6535408d7fd3bbade%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637256305300350766&amp;sdata=GiBieb2NTj8xnvRNXepVMUQDjmp9JcFcQaMf3ypRfpM%3D&amp;reserved=0

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

Re: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

hatopop100
In reply to this post by Jeremy Adler
Dear Jeremy Adler,

Thank you so much for your quick support.

1)
I pasted your macro on "Script..." (language: IJ1 Macro; Is it OK?) and
performed it for measuring 180785 ROIs as below.

-----
timeBefore=getTime();// before part of the macro.

nRois=roiManager("count");// entries in ROI Manager.
testArray=Array.getSequence(nRois); // creates an array with nRois entries,
numbered sequentially. from 0 upwards

roiManager("Select", testArray);// select all ROIs.
roiManager("Measure");// measure all ROIs.

timeAfter=getTime();// after the part.
print("time ",timeAfter-timeBefore); //
-----

I could obtain a time-log like "time 126667".
But I think it's not fast because it took ~5 sec by manual operation.

2)
I'd like to analyze cells stained with multi-colors by immunocytochemistry.
Therefore, after I obtained ROIs using "Analyze Particles..." for one of the
colors, I always stored as "RoiSet.zip" for analyzing other color images.
And I have already had many RoiSet.zip for slices.

3)
I didn't know how to check on how fast a part of the macro runs.
It's very useful.

Again, I appreciate your help.

Sincerely,
Hayato




--
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: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

hatopop100
In reply to this post by Krs5
Dear Kees,

Thank you so much for your quick support.

1)
I pasted your macro on "Script..." (language: IJ1 Macro; Is it OK?) and
performed it for measuring 180785 ROIs as below.

-----
timeBefore=getTime();// before part of the macro.

roiManager("Deselect");
roiManager("Measure");

timeAfter=getTime();// after the part.
print("time ",timeAfter-timeBefore); //
-----

I could obtain a time-log like "time 66700".
But I think it's not fast because it took ~5 sec by manual operation.

If possible, I'd like to know why my macro was slow than manual operation.

Again, I appreciate your help.

Sincerely,
Hayato



--
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: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

Krs5
Dear Hayato,

Yes, IJ1 macro is correct.

I can reproduce what you see, not really explain it, but maybe others on the list have an idea. It might be that this is a result of the fact that running Java is in general (much) faster than running macro code.

I created 77147 ROIs on t1-head.

When I select manually "Measure" from the ROI manager I also get results in 2-3 sec on my system and there is no ongoing visual measurements on the image. However, if there is already data in the Results table this goes up to >12s. Same if I delete the data but leave the Results table open.

When I run the macro code (as below in your email) I notice that it is actually measuring the ROIs (indicated in status bar) and the slider moves through the stacks when this happens. Time is between ~13000 and ~18000 and results appear at once in the window. If I do the whole analysis in batch mode (opening image and ROI list included) it even gets worse, ~22000 to ~24000 and I can see the Results table filling up while the macro goes thought the ROI list. This seems strange as batchMode should speed up the macro.

For the macro code with an open Results table the time goes up to almost 25000 (not in batch mode). Sometimes I see the deleted data first appearing back in the Results table before the data is replaced with the new data. However, this increase in time is not always reproducible. Some runs are the same as without a results table but at the higher end of the scale, around ~17000 - ~18000. In batch mode the macro is faster if the results table is already open, time down to just above 16000 (from ~22000-~24000).

So it looks like the way the results are obtained might be different. I cannot explain the results with an open Results table nor the results using the batchMode.

Best wishes

Kees


________________________________
From: ImageJ Interest Group  on behalf of hatopop100 <[hidden email]>
Sent: 21 May 2020 16:47

Subject: Re: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

Dear Kees,

Thank you so much for your quick support.

1)
I pasted your macro on "Script..." (language: IJ1 Macro; Is it OK?) and
performed it for measuring 180785 ROIs as below.

-----
timeBefore=getTime();// before part of the macro.

roiManager("Deselect");
roiManager("Measure");

timeAfter=getTime();// after the part.
print("time ",timeAfter-timeBefore); //
-----

I could obtain a time-log like "time 66700".
But I think it's not fast because it took ~5 sec by manual operation.

If possible, I'd like to know why my macro was slow than manual operation.

Again, I appreciate your help.

Sincerely,





--
Sent from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.1557.x6.nabble.com%2F&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7C0f8071dd3c7f40f71cd508d7fd9e67dc%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637256729096317806&amp;sdata=6ZAv8fJvlE3OxGzMUlJ0yNhO43zqR1SzRc7uelzE084%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7C0f8071dd3c7f40f71cd508d7fd9e67dc%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637256729096317806&amp;sdata=JdNOUSSTI6Nzb8hSXw1Fvn5BpObJ0lvQ41g5%2Fz0pF08%3D&amp;reserved=0

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

Re: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

Wayne Rasband-2
> On May 22, 2020, at 12:34 PM, Straatman, Kees (Dr.) <[hidden email]> wrote:
>
> Dear Hayato,
>
> Yes, IJ1 macro is correct.
>
> I can reproduce what you see, not really explain it, but maybe others on the list have an idea. It might be that this is a result of the fact that running Java is in general (much) faster than running macro code.
>
> I created 77147 ROIs on t1-head.

Dear Kees,

Please make available the macro code you used to create the 77,147 ROIs so we can try to reproduce your results.

-wayne

> When I select manually "Measure" from the ROI manager I also get results in 2-3 sec on my system and there is no ongoing visual measurements on the image. However, if there is already data in the Results table this goes up to >12s. Same if I delete the data but leave the Results table open.
>
> When I run the macro code (as below in your email) I notice that it is actually measuring the ROIs (indicated in status bar) and the slider moves through the stacks when this happens. Time is between ~13000 and ~18000 and results appear at once in the window. If I do the whole analysis in batch mode (opening image and ROI list included) it even gets worse, ~22000 to ~24000 and I can see the Results table filling up while the macro goes thought the ROI list. This seems strange as batchMode should speed up the macro.
>
> For the macro code with an open Results table the time goes up to almost 25000 (not in batch mode). Sometimes I see the deleted data first appearing back in the Results table before the data is replaced with the new data. However, this increase in time is not always reproducible. Some runs are the same as without a results table but at the higher end of the scale, around ~17000 - ~18000. In batch mode the macro is faster if the results table is already open, time down to just above 16000 (from ~22000-~24000).
>
> So it looks like the way the results are obtained might be different. I cannot explain the results with an open Results table nor the results using the batchMode.
>
> Best wishes
>
> Kees
>
>
> ________________________________
> From: ImageJ Interest Group  on behalf of hatopop100 <[hidden email]>
> Sent: 21 May 2020 16:47
>
> Subject: Re: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.
>
> Dear Kees,
>
> Thank you so much for your quick support.
>
> 1)
> I pasted your macro on "Script..." (language: IJ1 Macro; Is it OK?) and
> performed it for measuring 180785 ROIs as below.
>
> -----
> timeBefore=getTime();// before part of the macro.
>
> roiManager("Deselect");
> roiManager("Measure");
>
> timeAfter=getTime();// after the part.
> print("time ",timeAfter-timeBefore); //
> -----
>
> I could obtain a time-log like "time 66700".
> But I think it's not fast because it took ~5 sec by manual operation.
>
> If possible, I'd like to know why my macro was slow than manual operation.
>
> Again, I appreciate your help.
>
> Sincerely,

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

Fw: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

Krs5
Hi Wayne,

Something like this should work

Creating ROI list.

 run("T1 Head (2.4M, 16-bits)");
setOption("BlackBackground", true);
run("Convert to Mask", "method=Default background=Dark black");
for (i=0;i<20;i++) run("Analyze Particles...", "add stack");

Testing the measurements

//setBatchMode(true);
//roiManager("Open", "C:/Users/kees_/Desktop/Large_RoiSet.zip");
//open("C:/Users/kees_/Desktop/Large_RoiSet.zip");
//run("T1 Head (2.4M, 16-bits)");

timeBefore=getTime();// before part of the macro.

roiManager("Deselect");
roiManager("Measure");

timeAfter=getTime();// after the part.
//waitForUser("Ready?");
print("time ",timeAfter-timeBefore);



Kees

________________________________
From: ImageJ Interest Group on behalf of Wayne Rasband <[hidden email]>
Sent: 22 May 2020 17:41
To:
Subject: Re: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

> On May 22, 2020, at 12:34 PM, Straatman, Kees (Dr.) <[hidden email]> wrote:
>
> Dear Hayato,
>
> Yes, IJ1 macro is correct.
>
> I can reproduce what you see, not really explain it, but maybe others on the list have an idea. It might be that this is a result of the fact that running Java is in general (much) faster than running macro code.
>
> I created 77147 ROIs on t1-head.

Dear Kees,

Please make available the macro code you used to create the 77,147 ROIs so we can try to reproduce your results.

-wayne

> When I select manually "Measure" from the ROI manager I also get results in 2-3 sec on my system and there is no ongoing visual measurements on the image. However, if there is already data in the Results table this goes up to >12s. Same if I delete the data but leave the Results table open.
>
> When I run the macro code (as below in your email) I notice that it is actually measuring the ROIs (indicated in status bar) and the slider moves through the stacks when this happens. Time is between ~13000 and ~18000 and results appear at once in the window. If I do the whole analysis in batch mode (opening image and ROI list included) it even gets worse, ~22000 to ~24000 and I can see the Results table filling up while the macro goes thought the ROI list. This seems strange as batchMode should speed up the macro.
>
> For the macro code with an open Results table the time goes up to almost 25000 (not in batch mode). Sometimes I see the deleted data first appearing back in the Results table before the data is replaced with the new data. However, this increase in time is not always reproducible. Some runs are the same as without a results table but at the higher end of the scale, around ~17000 - ~18000. In batch mode the macro is faster if the results table is already open, time down to just above 16000 (from ~22000-~24000).
>
> So it looks like the way the results are obtained might be different. I cannot explain the results with an open Results table nor the results using the batchMode.
>
> Best wishes
>
> Kees
>
>
> ________________________________
> From: ImageJ Interest Group  on behalf of hatopop100 <[hidden email]>
> Sent: 21 May 2020 16:47
>
> Subject: Re: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.
>
> Dear Kees,
>
> Thank you so much for your quick support.
>
> 1)
> I pasted your macro on "Script..." (language: IJ1 Macro; Is it OK?) and
> performed it for measuring 180785 ROIs as below.
>
> -----
> timeBefore=getTime();// before part of the macro.
>
> roiManager("Deselect");
> roiManager("Measure");
>
> timeAfter=getTime();// after the part.
> print("time ",timeAfter-timeBefore); //
> -----
>
> I could obtain a time-log like "time 66700".
> But I think it's not fast because it took ~5 sec by manual operation.
>
> If possible, I'd like to know why my macro was slow than manual operation.
>
> Again, I appreciate your help.
>
> Sincerely,

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7C1d6d9a599911445aaaa408d7fe6f1600%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C637257625370864390&amp;sdata=Lm57RdpMrH6USLSZGCC5uhSC%2FcRX7cE0%2BUL3qBv90LE%3D&amp;reserved=0

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

Re: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

hatopop100
In reply to this post by Krs5
Dear Kees,

Thank you so much for reproducing my problem.
I appreciate it.

Sincerely,
Hayato



--
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: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

hatopop100
Dear all,

I updated ImageJ with the latest daily build 1.53b39 fixed by Wayne.
Thanks to Wayne, it now runs on the event dispatching thread which
prevents excess updating events in the Results, ROI Manager, and image
windows.

I performed the macro for measuring 180785 ROIs as below.

-----
roiManager("Deselect");
roiManager("Measure");
-----

As a result, roiManager(“measure”) is now as fast as clicking on “Measure”
in the ROI Manager
 (This time, I did not include "getTime();" used in the previous macro
because the code now runs on a separate thread).

Again, I really appreciate it.


Sincerely,
Hayato



--
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: I'd like to know how to measure all ROIs (200000~500000) using the macro as fast as manual measuring.

hatopop100
Dear all,

Thanks to Wayne, the problem with timing roiManager(“measure”) is fixed by
waiting until the separate
thread it runs on finishes.

I performed the macro on "v1.53b40" of ImageJ for measuring 180785 ROIs as
below.

-----
timeBefore=getTime();// before part of the macro.

roiManager("Deselect");
roiManager("Measure");

timeAfter=getTime();// after the part.
print("time ",timeAfter-timeBefore); //
-----

This time, I could obtain the time-log like "time  2896" on ImageJ
(v1.53b40).

It's about 23-times faster than "time  67012" obtained by the previous
version of ImageJ (v1.53a).

I really appreciate it.

Sincerely,
Hayato



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

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