setting results table column headings

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

setting results table column headings

Tony Collins-4
Hi,

This is a problem I've had crop up a few times. I've a few plugins that output several columns to the Results window. I've been using: IJ.setColumnHeadings(headerString) to set the column headers.

However, this results in the results table being 'reset' and cleared each time the pluing is run and I lose the data from the previous analysis. To avoid this, I have used a 'static boolean headingsSet' variable and put the setColumnHeadings in an if-statement.

if(!headingsSet)
                        {
                        IJ.setColumnHeadings(headerString);
                        headingsSet= true;
                        }


This works so long as the Results window is closed. When it is closed and the plugin run again, the column headers are not reset to what I want because the headingSet Boolean is true.

A better way for me would be to compare the existing headers in the results table with the ones I want to use. I've tried:

String currHeaders = Analyzer.getResultsTable().getColumnHeadings());

..but it returns a blank string.

Any help appreciated.

Thanks,
Tony


 
Tony J. Collins, Ph.D.
McMaster Biophotonics Facility
Dept. Biochemistry and Biomedical Sciences HSC 4H21A
McMaster University, Hamilton, ON, L8N 3Z5
[hidden email]     www.macbiophotonics.ca
Reply | Threaded
Open this post in threaded view
|

Setting results table column headings - repost

Tony Collins-4
Hi Folks,

I'm just reposting this in case it was missed over the vacation - or I wasn't very clear about the problem.

Any suggestions or clarifications? Or is there no solution!

Thanks,

Tony



> Hi,
>
> This is a problem I've had crop up a few times. I've a few plugins that
> output several columns to the Results window. I've been using:
> IJ.setColumnHeadings(headerString) to set the column headers.
>
> However, this results in the results table being 'reset' and cleared
> each time the pluing is run and I lose the data from the previous
> analysis. To avoid this, I have used a 'static boolean headingsSet'
> variable and put the setColumnHeadings in an if-statement.
>
> if(!headingsSet)
> {
> IJ.setColumnHeadings(headerString);
> headingsSet= true;
> }
>
>
> This works so long as the Results window is closed. When it is closed
> and the plugin run again, the column headers are not reset to what I
> want because the headingSet Boolean is true.
>
> A better way for me would be to compare the existing headers in the
> results table with the ones I want to use. I've tried:
>
> String currHeaders = Analyzer.getResultsTable().getColumnHeadings());
>
> ..but it returns a blank string.
>
> Any help appreciated.
>
> Thanks,
> Tony
>
>
>
> Tony J. Collins, Ph.D.
> McMaster Biophotonics Facility
> Dept. Biochemistry and Biomedical Sciences HSC 4H21A
> McMaster University, Hamilton, ON, L8N 3Z5
> [hidden email]     www.macbiophotonics.ca
Reply | Threaded
Open this post in threaded view
|

Re: Setting results table column headings - repost

Justin McGrath-2
No one has replied, so I'll take a shot at it.

I believe that your currHeaders solution should actually work.  Once the
Results window is closed, the data and headers are lost.  The string is
blank because there are no headers.  Therefore, if you check that
currHeaders == desiredHeaders, it will be false, and you need to set the
headers.

Justin





On Tue, Jan 20, 2009 at 7:43 AM, Tony Collins
<[hidden email]>wrote:

> Hi Folks,
>
> I'm just reposting this in case it was missed over the vacation - or I
> wasn't very clear about the problem.
>
> Any suggestions or clarifications? Or is there no solution!
>
> Thanks,
>
> Tony
>
>
>
> > Hi,
> >
> > This is a problem I've had crop up a few times. I've a few plugins that
> > output several columns to the Results window. I've been using:
> > IJ.setColumnHeadings(headerString) to set the column headers.
> >
> > However, this results in the results table being 'reset' and cleared
> > each time the pluing is run and I lose the data from the previous
> > analysis. To avoid this, I have used a 'static boolean headingsSet'
> > variable and put the setColumnHeadings in an if-statement.
> >
> > if(!headingsSet)
> >                       {
> >                       IJ.setColumnHeadings(headerString);
> >                       headingsSet= true;
> >                       }
> >
> >
> > This works so long as the Results window is closed. When it is closed
> > and the plugin run again, the column headers are not reset to what I
> > want because the headingSet Boolean is true.
> >
> > A better way for me would be to compare the existing headers in the
> > results table with the ones I want to use. I've tried:
> >
> > String currHeaders = Analyzer.getResultsTable().getColumnHeadings());
> >
> > ..but it returns a blank string.
> >
> > Any help appreciated.
> >
> > Thanks,
> > Tony
> >
> >
> >
> > Tony J. Collins, Ph.D.
> > McMaster Biophotonics Facility
> > Dept. Biochemistry and Biomedical Sciences HSC 4H21A
> > McMaster University, Hamilton, ON, L8N 3Z5
> > [hidden email]     www.macbiophotonics.ca
>
Reply | Threaded
Open this post in threaded view
|

Re: Setting results table column headings - repost

Tony Collins-4
Hi Justin,

That's what I figured but:
Analyzer.getResultsTable().getColumnHeadings());

returns the correct heading string if I've used the menu 'measure' command, e.g.
 " Area Mean StdDev"

But returns a blank string if I've set the headings in the results window using my plugin with:
IJ.setColumnHeadings(headerString);

...even though the results window is open and has column headers set correctly.

Is this the wrong code to get the column headers of the results window?

Cheers,
Tony

 
Tony J. Collins, Ph.D.
McMaster Biophotonics Facility
Dept. Biochemistry and Biomedical Sciences HSC 4H21A
McMaster University, Hamilton, ON, L8N 3Z5
[hidden email]     www.macbiophotonics.ca


> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Justin McGrath
> Sent: Wednesday, January 21, 2009 11:33 AM
> To: [hidden email]
> Subject: Re: Setting results table column headings - repost
>
> No one has replied, so I'll take a shot at it.
>
> I believe that your currHeaders solution should actually work.  Once
> the
> Results window is closed, the data and headers are lost.  The string is
> blank because there are no headers.  Therefore, if you check that
> currHeaders == desiredHeaders, it will be false, and you need to set
> the
> headers.
>
> Justin
>
>
>
>
>
> On Tue, Jan 20, 2009 at 7:43 AM, Tony Collins
> <[hidden email]>wrote:
>
> > Hi Folks,
> >
> > I'm just reposting this in case it was missed over the vacation - or
> I
> > wasn't very clear about the problem.
> >
> > Any suggestions or clarifications? Or is there no solution!
> >
> > Thanks,
> >
> > Tony
> >
> >
> >
> > > Hi,
> > >
> > > This is a problem I've had crop up a few times. I've a few plugins
> that
> > > output several columns to the Results window. I've been using:
> > > IJ.setColumnHeadings(headerString) to set the column headers.
> > >
> > > However, this results in the results table being 'reset' and
> cleared
> > > each time the pluing is run and I lose the data from the previous
> > > analysis. To avoid this, I have used a 'static boolean headingsSet'
> > > variable and put the setColumnHeadings in an if-statement.
> > >
> > > if(!headingsSet)
> > >                       {
> > >                       IJ.setColumnHeadings(headerString);
> > >                       headingsSet= true;
> > >                       }
> > >
> > >
> > > This works so long as the Results window is closed. When it is
> closed
> > > and the plugin run again, the column headers are not reset to what
> I
> > > want because the headingSet Boolean is true.
> > >
> > > A better way for me would be to compare the existing headers in the
> > > results table with the ones I want to use. I've tried:
> > >
> > > String currHeaders =
> Analyzer.getResultsTable().getColumnHeadings());
> > >
> > > ..but it returns a blank string.
> > >
> > > Any help appreciated.
> > >
> > > Thanks,
> > > Tony
> > >
> > >
> > >
> > > Tony J. Collins, Ph.D.
> > > McMaster Biophotonics Facility
> > > Dept. Biochemistry and Biomedical Sciences HSC 4H21A
> > > McMaster University, Hamilton, ON, L8N 3Z5
> > > [hidden email]     www.macbiophotonics.ca
> >
Reply | Threaded
Open this post in threaded view
|

Re: Setting results table column headings - repost

Gabriel Landini
On Friday 23 January 2009, Tony Collins wrote:

> Hi Justin,
>
> That's what I figured but:
> Analyzer.getResultsTable().getColumnHeadings());
>
> returns the correct heading string if I've used the menu 'measure' command,
> e.g. " Area Mean StdDev"
>
> But returns a blank string if I've set the headings in the results window
> using my plugin with: IJ.setColumnHeadings(headerString);
>
> ...even though the results window is open and has column headers set
> correctly.
>
> Is this the wrong code to get the column headers of the results window?

Tony, why don't you just use:

rt.setValue(ColumnName, row, value);

If the column does not exist, it will be created.
This way you are guaranteed that the headers are created correctly.
I hope it helps.

G.