Login  Register

Re: Manipulation of Results table

Posted by karo03 on Dec 22, 2008; 11:48am
URL: http://imagej.273.s1.nabble.com/Manipulation-of-Results-table-tp3694199p3694201.html

Hi Ben, hi Gabriel,
thank you for that quick aid.

Gabriel, in fact I new already the things used in your and Jeromes  
macros, but did not combine the things as necessary.

Ben, this quick java extension is working very well. I think I have to  
extend my java reading capabilities to writing! Although, that is the  
wrong way around: In Waldorschools the students learn first to write  
and than to read (with surprising efficiency)!

Best regards and seasonal greetings
Karsten

Am 22.12.2008 um 03:45 schrieb Ben Tupper:

> On Dec 21, 2008, at 6:40 PM, Karsten Rodenacker wrote:
>
>> Hallo experts,
>> I try to manipulate the Results table in a macro. I would like to  
>> delete some lines.
>> e.g.
>> for (i=nResults()/2; i<nResults(); i++) print("[Results]","\
>> \Update"+i+":");
>> deletes the last half of Results lines but does not really the job,  
>> since a succeeding
>> updateResults();
>> reestablishs everything.
>> Possibly there is a hidden command to delete any line (and reset  
>> the counter nResults()), e.g.
>> print("[Results]","\\Clear<n>); ?
>>
>> Thanks in advance
>>
>
> Hi Karsten,
>
> I think this static class will work - I followed the example from  
> the CallDemo macro to create a class with a static method.  The  
> method gets the ResultTable and then calls the table's deleteRow  
> method.
>
> Cheers,
> Ben
>
> *****MACRO TO TEST WITH STARTS HERE (the macro culls all but the  
> first two and last three rows)
> run("Blobs (25K)");
> setThreshold(125, 255);
> run("Convert to Mask");
> run("Set Measurements...", "area center display redirect=None  
> decimal=3");
> run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00  
> show=Nothing display clear include record");
> for (i = (nResults()-3); i>2; i--) {
> call("TableHandler.deleteRow", i);
> }
> ***MACRO ENDS HERE
>
> ****CLASS STARTS HERE (don't forget to place it in the plugins  
> directory and do "Compile and Run"
> import ij.*;
> import ij.process.*;
> import ij.gui.*;
> import ij.measure.*;
> import ij.plugin.*;
> import ij.plugin.filter.*;
>
> public class TableHandler {
>
>  public static String deleteRow(String row){
>    Integer iRow = new Integer(row);
>    ResultsTable rt = Analyzer.getResultsTable();
>    rt.deleteRow(iRow.intValue());
>    rt.show("Results");
>    return "deleted row in TableHandler:" + row;
>  }
>
> }
> ***CLASS ENDS HERE

Karsten Rodenacker
[hidden email]