Macro: Can't get data from Results table

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

Macro: Can't get data from Results table

Maart
Dear group,

I'm an ImageJ-beginner and want to write a macro that reads values from the Results window/table.
First I run the "Color Histogram" plugin. It creates a nice histogramm window and writes data to the Results window.
Then I try to read the mean red value but I always get the error message: "Results table empty in line 2".

This is the code I'm using:
  run("Color Histogram");
 mred = getResult("red",0);

The Results window shows this:
 -     red         green    blue
mean 235.51 240.76 219.23
st.dev 5.97 4.54 4.73

Any suggestions or hints?

Thanks in advance

Maart
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Can't get data from Results table

chenyanpei
I also find this problem.how you do next? after three years
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Can't get data from Results table

Michael Schmid
Hi,

do you think that everyone still remembers a post 3 years ago?

After looking it up:

It seems that you are trying to access a table that is not the ImageJ  
Results Table by getResult(). The getResult macro function works only  
on the usual Results table named "Results". Also I don't think you  
can access the summary data such as mean or std deviation of a  
Results table with getResult.

Michael
________________________________________________________________

On 24 Sep 2010, at 16:45, chenyanpei wrote:

> I also find this problem.how you do next? after three years
> --
> View this message in context: http://imagej.588099.n2.nabble.com/ 
> Macro-Can-t-get-data-from-Results-table-tp633088p5567101.html
> Sent from the ImageJ mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Can't get data from Results table

chenyanpei
I just feel susprise that  someone met same problem, I have no other mean.....
infact, I find Gabriel  write
On Monday 30 August 2010, you wrote:
> As I understood, the Results Table is the "object" wich might be
> manipulated by macro commands...in a recent mail I found the info that you
> can rename any table to Results...that way it should be possible to
> manipulate data in whatever table, one just has to switch between
> names...unfortunatly the command IJ.renameResults("Results") doesn't work
> for me, when I test the command in a little piece of macro I get an error
> message with function unknown...

I have been assuming (but I might be out of date on this) that there is only
one Results table (that is a number of data arrays) where one can use the
macros commands:
getResultLabel(row)
getResult("Column", row)
nResults
setResult("Column", row, value)
setResult("Label", row, value)

One can of course have more than one text window "tables" formatted with
columns generated with IJ.log() or IJ.write from a plugin, but I believed that
from these seemingly-but-not-quite-result tables, one cannot retrieve the
values using the macro get* commands above as they are not "in" the Results
table arrays despite what one sees on screen.

To put those values in the Results table and be able to retrieve them back one
needs to  use the methods listed in:
http://rsb.info.nih.gov/ij/developer/api/ij/measure/ResultsTable.html

However seeing some recent comments about more than one results table, I
wonder if this might have changed.
It would be very useful to have this clarified.

Regards

I modify some:



 IJ.setColumnHeadings("parameter\tred\tgreen\tblue");
            IJ.write("mean\t"+IJ.d2s(histMean[0],2)+ "\t"+IJ.d2s(histMean[1],2)+"\t"+IJ.d2s(histMean[2],2));
            IJ.write("st. dev\t"+IJ.d2s(histStdev[0],2)+ "\t"+IJ.d2s(histStdev[1],2)+"\t"+IJ.d2s(histStdev[2],2));
            IJ.write("area fraction\t"+IJ.d2s(histArea[0],4)+ "\t"+IJ.d2s(histArea[1],4)+"\t"+IJ.d2s(histArea[2],4));
       // }


to





 ResultsTable rt = new ResultsTable();
           
            rt.setValue(RED, 0,histMean[0]);
            rt.setValue(GREEN, 0,histMean[1]);
            rt.setValue(BLUE, 0,histMean[2]);
            rt.setValue(RED,1,histStdev[0]);
            rt.setValue(RED,2,histArea[0]);
            rt.setValue(GREEN,1,histStdev[1]);
            rt.setValue(GREEN,2,histArea[1]);
            rt.setValue(BLUE,1,histStdev[2]);
            rt.setValue(BLUE,2,histArea[2]);
but  
java.lang.IllegalArgumentException: row>=counter
at ij.measure.ResultsTable.setValue(ResultsTable.java:308)
at ij.measure.ResultsTable.setValue(ResultsTable.java:297)
at RGB_Measure_Plus.run(RGB_Measure_Plus.java:143)
at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:249)
at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:102)
at ij.IJ.runUserPlugIn(IJ.java:186)
at ij.IJ.runPlugIn(IJ.java:151)
at ij.Executer.runCommand(Executer.java:124)
at ij.Executer.run(Executer.java:61)
at java.lang.Thread.run(Unknown Source)


Gabriel
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Can't get data from Results table

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by chenyanpei
On Sep 24, 2010, at 10:45 AM, chenyanpei wrote:

> I also find this problem.how you do next? after three years
> --
> View this message in context: http://imagej.588099.n2.nabble.com/Macro-Can-t-get-data-from-Results-table-tp633088p5567101.html
> Sent from the ImageJ mailing list archive at Nabble.com.

There is an updated version of the Color_Histogram plugin (Analyze>Tools>Color Histogram command) at

     http://imagej.nih.gov/ij/plugins/color-histogram.html

that fixes this bug. You can upgrade by dragging and dropping Color_Histogram.jar onto the "ImageJ" window and saving it in the plugins/Analyze folder. You can also get statistics from RGB images by using the MeasureRGB macro at

    http://rsb.info.nih.gov/ij/macros/MeasureRGB.txt


-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Can't get data from Results table

Gabriel Landini
On Sep 24, 2010, at 10:45 AM, chenyanpei wrote:
> but  
> java.lang.IllegalArgumentException: row>=counter

Maybe this error is because the counter was not increased with:

http://rsb.info.nih.gov/ij/developer/api/ij/measure/ResultsTable.html#incrementCounter()

Cheers

Gabriel