Login  Register

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

Posted by chenyanpei on Sep 24, 2010; 4:27pm
URL: http://imagej.273.s1.nabble.com/Macro-Can-t-get-data-from-Results-table-tp3686805p3686810.html

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