Manipulation of Results table

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

Manipulation of Results table

karo03
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
Regards
Karsten
Reply | Threaded
Open this post in threaded view
|

Re: Manipulation of Results table

Gabriel Landini
On Sunday 21 December 2008 23:40:51 Karsten Rodenacker wrote:
> Hallo experts,
> I try to manipulate the Results table in a macro. I would like to
> delete some lines.

Hi Karsten,
Have a look at the Import Results Table macro by Jerome Mutterer at Wayne's
site or the Thin Results Table macro in my morphology collection.
You could modify any of those to do what you want.
I am not aware of another method to delete some of the results, but perhaps
there is some better way of doing it.

I hope it helps

G.
Reply | Threaded
Open this post in threaded view
|

Re: Manipulation of Results table

Ben Tupper
In reply to this post by karo03
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
Reply | Threaded
Open this post in threaded view
|

Re: Manipulation of Results table

karo03
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]