Dear all,
I want to use the Image CorrelationJ plugin within a macro and retrieve some data from the result table at each cycle of a "for" loop. But, nResults gives a value of 0 and getResults("Slope", 1) brings up the following error message: "Results" table empty in line 30 The results table popping up is named "Image correlation. local region size = 4 pixels" I tried to select the window from the macro, it works. It tried to rename it, it does not. What do I do wrong ? Thank you ! Nico -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Nico,
Indeed, the IJ.renameResults does not seem to like the format. So far, a workaround that I found is as follows: //Select proper window, modify this to whatever you need selectWindow("Image correlation. Local region size = 3 pixels"); // Save as result and reopen right away saveAs("results", "D:\\temp.csv"); open("D:\\temp.csv"); You can now access the results... Best Oli BioImaging & Optics Platform, BIOP EPFL - SV - PTECH - BIOP > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of > Nicolas Brouilly > Sent: Saturday, May 9, 2015 2:38 > To: [hidden email] > Subject: Result table in plugin > > Dear all, > > I want to use the Image CorrelationJ plugin within a macro and retrieve some > data from the result table at each cycle of a "for" loop. But, nResults gives a > value of 0 and getResults("Slope", 1) brings up the following error message: > "Results" table empty in line 30 > > The results table popping up is named "Image correlation. local region size = 4 > pixels" > > I tried to select the window from the macro, it works. It tried to rename it, it > does not. > > What do I do wrong ? > > Thank you ! > > Nico > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Olivier,
Thanks for you reply ! That's exactly what I have been doing over the weekend... because, yes, when you're talking about thousands of tables, it takes days... So it was good enough as a proof of principle for the rest of my script but too slow for an actual use. I just realized that the IJ.deleterows function is recorded when I remove rows by hand (Selection of 2 rows, Edit/Clear ). However it does not work when called from a macro. Is this helping you to help me ? How to make it work via macro ? Is there an "IJ.copyrows"-like function somewhere ? Another option would be to modify the plugin so that the results are added to the conventional Result table instead but I don't know how to edit a class file. Any hints ? Thanks again ! Nico On 11/05/2015 10:20, Burri Olivier wrote: > Hi Nico, > > Indeed, the IJ.renameResults does not seem to like the format. > So far, a workaround that I found is as follows: > > //Select proper window, modify this to whatever you need > selectWindow("Image correlation. Local region size = 3 pixels"); > > // Save as result and reopen right away > saveAs("results", "D:\\temp.csv"); > open("D:\\temp.csv"); > > You can now access the results... > > Best > > Oli > BioImaging & Optics Platform, BIOP > EPFL - SV - PTECH - BIOP > > >> -----Original Message----- >> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of >> Nicolas Brouilly >> Sent: Saturday, May 9, 2015 2:38 >> To: [hidden email] >> Subject: Result table in plugin >> >> Dear all, >> >> I want to use the Image CorrelationJ plugin within a macro and retrieve some >> data from the result table at each cycle of a "for" loop. But, nResults gives a >> value of 0 and getResults("Slope", 1) brings up the following error message: >> "Results" table empty in line 30 >> >> The results table popping up is named "Image correlation. local region size = 4 >> pixels" >> >> I tried to select the window from the macro, it works. It tried to rename it, it >> does not. >> >> What do I do wrong ? >> >> Thank you ! >> >> Nico >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- Nicolas BROUILLY, PhD Zerial lab, Max Planck Institute of Molecular Cell Biology and Genetics Pfotenhauerstr. 108 01307 Dresden phone: +49 351 210-2489 e-mail: [hidden email] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Nico,
Like I said in the PM to you, I edited the .java file which is the source code of the plugin, which I found here: http://www.gcsca.net/IJ/ImageCorrelationJ.html I basically modified two functions: writeResults(double[] l, String l1, String l2) and writeResults(float i, float m, float s) These now output to a results table instead of to a text window. I also took the liberty of removing the Local Region Size value from the title and put it in as another column. The two results tables are declared as static near the top of the class, this allows for the results to be appended as we keep calling the plugin, so now you should be able to run it for all your images before you have to think about recovering the results. I will wait for the reply from the plugin's author before posting the resulting modifications somewhere public. I don't know how he likes to proceed. Best Oli -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Nicolas Brouilly
> On May 8, 2015, at 8:38 PM, Nicolas Brouilly <[hidden email]> wrote:
> > Dear all, > > I want to use the Image CorrelationJ plugin within a macro and retrieve some data from the result table at each cycle of a "for" loop. But, nResults gives a value of 0 and getResults("Slope", 1) brings up the following error message: > "Results" table empty in line 30 > > The results table popping up is named "Image correlation. local region size = 4 pixels" > > I tried to select the window from the macro, it works. It tried to rename it, it does not. > > What do I do wrong ? In the latest ImageJ daily build (1.49t19), the getResult() macro function works with the tables created by the Image CorrelationJ plugin and other plugins that create tables that are not named “Results”. You will need to use getValue("results.count") to get the size of the table since nResults() always returns the size of the “Results” table. Here is an example: selectWindow("Image correlation. Local region size = 3 pixels"); n = getValue("results.count"); for (i=0; i<n; i++) { selectWindow("Image correlation. Local region size = 3 pixels"); source = getResultString("Source", i); r = getResult("R", i); r2 = getResult("R2", i); slope = getResult("Slope", i); c = getResult("C", i); print(source, r, r2, slope, c); } -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Olivier and Wayne !
Thank you so much ! I can't wait to make the race between the two approaches to see which is the fastest ! Nico On 11/05/2015 22:27, Rasband, Wayne (NIH/NIMH) [E] wrote: >> On May 8, 2015, at 8:38 PM, Nicolas Brouilly <[hidden email]> wrote: >> >> Dear all, >> >> I want to use the Image CorrelationJ plugin within a macro and retrieve some data from the result table at each cycle of a "for" loop. But, nResults gives a value of 0 and getResults("Slope", 1) brings up the following error message: >> "Results" table empty in line 30 >> >> The results table popping up is named "Image correlation. local region size = 4 pixels" >> >> I tried to select the window from the macro, it works. It tried to rename it, it does not. >> >> What do I do wrong ? > > In the latest ImageJ daily build (1.49t19), the getResult() macro function works with the tables created by the Image CorrelationJ plugin and other plugins that create tables that are not named “Results”. You will need to use getValue("results.count") to get the size of the table since nResults() always returns the size of the “Results” table. Here is an example: > > selectWindow("Image correlation. Local region size = 3 pixels"); > n = getValue("results.count"); > for (i=0; i<n; i++) { > selectWindow("Image correlation. Local region size = 3 pixels"); > source = getResultString("Source", i); > r = getResult("R", i); > r2 = getResult("R2", i); > slope = getResult("Slope", i); > c = getResult("C", i); > print(source, r, r2, slope, c); > } > > -wayne > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- Nicolas BROUILLY, PhD Zerial lab, Max Planck Institute of Molecular Cell Biology and Genetics Pfotenhauerstr. 108 01307 Dresden phone: +49 351 210-2489 e-mail: [hidden email] -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |