Posted by
Krs5 on
May 22, 2020; 5:20pm
URL: http://imagej.273.s1.nabble.com/I-d-like-to-know-how-to-measure-all-ROIs-200000-500000-using-the-macro-as-fast-as-manual-measuring-tp5023346p5023367.html
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&data=02%7C01%7Ckrs5%40leicester.ac.uk%7C1d6d9a599911445aaaa408d7fe6f1600%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C637257625370864390&sdata=Lm57RdpMrH6USLSZGCC5uhSC%2FcRX7cE0%2BUL3qBv90LE%3D&reserved=0--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html