ResultsTable questions

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

ResultsTable questions

Michael Doube
Hi all

I am writing a method that will collate results into the same row of a
result table when running different plugins on the same image, so each
image will get 1 row with results from different plugins in the cells.

1. Is there a value other than 0 that represents an empty cell? At the
moment, if no value is entered for a cell when another cell in the same
row is updated, 0 is shown in the table.  This is not the same as 'no
data' - null seems more appropriate.

2. I can create a new results table and call it "Measurements" like this:
ResultsTable rt = new ResultsTable();
rt.show("Measurements");
But how do I check whether the "Measurements" table already exists, and
write to it instead of overwriting it with a new instance each time?
This is trivial if I use the system Results table,
ResultsTable rt = ResultsTable.getResultsTable();
but I want to leave the "Results" table free for other stuff and have a
dedicated table for my plugins' results.

Cheers

Mike
Reply | Threaded
Open this post in threaded view
|

Re: ResultsTable questions

Michael Schmid
Hi Mike,

(1) you can't set the value of a cell to null, but you can set it to  
Double.NaN (not a number) to signify an empty cell. Use Double.isNaN
(x) to test for it.

(2) did you try WindowManager.getFrame("Measurements")? It should  
tell you whether a non-image frame with this title has been added to  
the list of windows.

Michael
________________________________________________________________

On 3 Jun 2009, at 19:52, Michael Doube wrote:

> Hi all
>
> I am writing a method that will collate results into the same row  
> of a result table when running different plugins on the same image,  
> so each image will get 1 row with results from different plugins in  
> the cells.
>
> 1. Is there a value other than 0 that represents an empty cell? At  
> the moment, if no value is entered for a cell when another cell in  
> the same row is updated, 0 is shown in the table.  This is not the  
> same as 'no data' - null seems more appropriate.
>
> 2. I can create a new results table and call it "Measurements" like  
> this:
> ResultsTable rt = new ResultsTable();
> rt.show("Measurements");
> But how do I check whether the "Measurements" table already exists,  
> and write to it instead of overwriting it with a new instance each  
> time? This is trivial if I use the system Results table,
> ResultsTable rt = ResultsTable.getResultsTable();
> but I want to leave the "Results" table free for other stuff and  
> have a dedicated table for my plugins' results.
>
> Cheers
>
> Mike
Reply | Threaded
Open this post in threaded view
|

Re: ResultsTable questions

dscho
In reply to this post by Michael Doube
Hi,

On Wed, 3 Jun 2009, Michael Doube wrote:

> 1. Is there a value other than 0 that represents an empty cell? At the
>    moment, if no value is entered for a cell when another cell in the
>    same row is updated, 0 is shown in the table.  This is not the same
>    as 'no data' - null seems more appropriate.

AFAICT no, there is no way... ResultsTable can only contain doubles, and
there is no null double...

> 2. I can create a new results table and call it "Measurements" like
>    this:  ResultsTable rt = new ResultsTable();  
>    rt.show("Measurements");  But how do I check whether the
>    "Measurements" table already exists, and write to it instead of
>    overwriting it with a new instance each time? This is trivial if I
>    use the system Results table, ResultsTable rt =
>    ResultsTable.getResultsTable();  but I want to leave the "Results"
>    table free for other stuff and have a dedicated table for my plugins'
>    results.

The only way I could imagine to do this is to look through
WindowManager.getNonImageWindows().

But if the table could only be constructed by _your_ code, you could make
it a singleton... (i.e. private static ResultsTable measurements; [...] if
(measurements == null) [...])

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: ResultsTable questions

Fernando Sales
Michael,

i was writing my reply and Johannes has just described what i was
thinking...
Try to use the Singleton Pattern (http://www.javacamp.org/designPattern/).
This is a "standard"  solution to the problem of (writing / accessing) a
(file / database / ... ) from multiple sources.
The main idea is to develop a private method for creation of a unique
ResultsTable.

Best Regards,
Fernando

On Wed, Jun 3, 2009 at 6:17 PM, Johannes Schindelin <
[hidden email]> wrote:

> Hi,
>
> On Wed, 3 Jun 2009, Michael Doube wrote:
>
> > 1. Is there a value other than 0 that represents an empty cell? At the
> >    moment, if no value is entered for a cell when another cell in the
> >    same row is updated, 0 is shown in the table.  This is not the same
> >    as 'no data' - null seems more appropriate.
>
> AFAICT no, there is no way... ResultsTable can only contain doubles, and
> there is no null double...
>
> > 2. I can create a new results table and call it "Measurements" like
> >    this:  ResultsTable rt = new ResultsTable();
> >    rt.show("Measurements");  But how do I check whether the
> >    "Measurements" table already exists, and write to it instead of
> >    overwriting it with a new instance each time? This is trivial if I
> >    use the system Results table, ResultsTable rt =
> >    ResultsTable.getResultsTable();  but I want to leave the "Results"
> >    table free for other stuff and have a dedicated table for my plugins'
> >    results.
>
> The only way I could imagine to do this is to look through
> WindowManager.getNonImageWindows().
>
> But if the table could only be constructed by _your_ code, you could make
> it a singleton... (i.e. private static ResultsTable measurements; [...] if
> (measurements == null) [...])
>
> Ciao,
> Dscho
>



--
**************************************************
Fernando José Ribeiro Sales
**************************************************
Email: [hidden email]
Tel: (11) 82020303
**************************************************
Reply | Threaded
Open this post in threaded view
|

Re: ResultsTable questions

Frederic V. Hessman
In reply to this post by Michael Doube
You're welcome to check out the MeasurementTable class in my astroj  
plugin package, which gives you that kind of functionality and is  
compatible with normal ResultsTable: http://www.astro.physik.uni-goettingen.de/~hessman/ImageJ/Astronomy/docs/

Rick

On 3 Jun 2009, at 19:52, Michael Doube wrote:

> Hi all
>
> I am writing a method that will collate results into the same row of  
> a result table when running different plugins on the same image, so  
> each image will get 1 row with results from different plugins in the  
> cells.
>
> 1. Is there a value other than 0 that represents an empty cell? At  
> the moment, if no value is entered for a cell when another cell in  
> the same row is updated, 0 is shown in the table.  This is not the  
> same as 'no data' - null seems more appropriate.
>
> 2. I can create a new results table and call it "Measurements" like  
> this:
> ResultsTable rt = new ResultsTable();
> rt.show("Measurements");
> But how do I check whether the "Measurements" table already exists,  
> and write to it instead of overwriting it with a new instance each  
> time? This is trivial if I use the system Results table,
> ResultsTable rt = ResultsTable.getResultsTable();
> but I want to leave the "Results" table free for other stuff and  
> have a dedicated table for my plugins' results.
>
> Cheers
>
> Mike
Reply | Threaded
Open this post in threaded view
|

Re: ResultsTable questions

dscho
Hi,

On Thu, 4 Jun 2009, Frederic Hessman wrote:

> You're welcome to check out the MeasurementTable class in my astroj
> plugin package, which gives you that kind of functionality and is
> compatible with normal ResultsTable:
> http://www.astro.physik.uni-goettingen.de/~hessman/ImageJ/Astronomy/docs/

On the same website you mention a wish for an Overlay class that can be
used by other plugins.  Does this meet your needs?

        http://www.masny.dk/imagej/overlay/index.php

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: ResultsTable questions

Michael Doube
In reply to this post by Fernando Sales
Thanks everyone for your suggestions overnight; I particularly liked
this from javacamp.org:

"...not only will you be smarter but will you sound a lot smarter, too".

Mike

Fernando Sales wrote:

> Michael,
>
> i was writing my reply and Johannes has just described what i was
> thinking...
> Try to use the Singleton Pattern (http://www.javacamp.org/designPattern/).
> This is a "standard"  solution to the problem of (writing / accessing) a
> (file / database / ... ) from multiple sources.
> The main idea is to develop a private method for creation of a unique
> ResultsTable.
>
> Best Regards,
> Fernando
>
> On Wed, Jun 3, 2009 at 6:17 PM, Johannes Schindelin <
> [hidden email]> wrote:
>
>> Hi,
>>
>> On Wed, 3 Jun 2009, Michael Doube wrote:
>>
>>> 1. Is there a value other than 0 that represents an empty cell? At the
>>>    moment, if no value is entered for a cell when another cell in the
>>>    same row is updated, 0 is shown in the table.  This is not the same
>>>    as 'no data' - null seems more appropriate.
>> AFAICT no, there is no way... ResultsTable can only contain doubles, and
>> there is no null double...
>>
>>> 2. I can create a new results table and call it "Measurements" like
>>>    this:  ResultsTable rt = new ResultsTable();
>>>    rt.show("Measurements");  But how do I check whether the
>>>    "Measurements" table already exists, and write to it instead of
>>>    overwriting it with a new instance each time? This is trivial if I
>>>    use the system Results table, ResultsTable rt =
>>>    ResultsTable.getResultsTable();  but I want to leave the "Results"
>>>    table free for other stuff and have a dedicated table for my plugins'
>>>    results.
>> The only way I could imagine to do this is to look through
>> WindowManager.getNonImageWindows().
>>
>> But if the table could only be constructed by _your_ code, you could make
>> it a singleton... (i.e. private static ResultsTable measurements; [...] if
>> (measurements == null) [...])
>>
>> Ciao,
>> Dscho
>>
>
>
>

--
Dr Michael Doube  BPhil BVSc PhD MRCVS
Research Associate
Department of Bioengineering
Imperial College London
South Kensington Campus
London  SW7 2AZ
United Kingdom

Phone: +44 (0)20 7594 7426
Fax: +44 (0)20 7594 9817