Data from summary window

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

Data from summary window

davek604
Hello
I'm trying to get the %Area value from the summary table using a plugin. It's a straightforward task to get results from the Results Table but there doesn't seem to be any plugin commands to achieve this for the Summary table. I've had a look on Nabble and it can be done using macro's and the getInfo command but it doesn't work for plugins. Any help appreciated as I'm completely stuck.

I need this because the images I'm analysing require thresholding of the top 0.1% of the histogram and I thought this would be an easy way to figure out when I'd thresholded the top 0.1%, but its not proving to be quite as straightforward as I thought.

Regards

David
Reply | Threaded
Open this post in threaded view
|

Re: Data from summary window

Tiago Ferreira-2
Hi David,

On Nov 27, 2014, at 09:00, davek604 <[hidden email]> wrote:
> It's a straightforward task to get results from the Results Table but there
> doesn't seem to be any plugin commands to achieve this for the Summary
> table.

The following should work:

import ij.IJ;
import ij.WindowManager;
import ij.measure.ResultsTable;
import ij.text.TextWindow;

TextWindow tw = (TextWindow)WindowManager.getFrame("Summary");
if (tw!=null) {
    ResultsTable st = tw.getTextPanel().getResultsTable();
    IJ.log("1st row of Summary:\n"+ st.getRowAsString(0));
} else {
    IJ.log("Summary window not found");
}


-tiago

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Data from summary window

davek604
Hello Tiago
Thanks for replying but unfortunately it doesn't work

I changed the following code
TextWindow tw = (TextWindow)WindowManager.getFrame("Summary");
to
TextWindow tw = (TextWindow)WindowManager.getFrame("Summary of "+GreenZ.getTitle());
this gets the correct name of the summary window and prevents tw from being null.
 When I debug it, st always comes out as null so it doesn't appear to be picking up anything from the summary window or the results window. I'm wondering if its actually possible to access the data in the summary window via a plugin as the API has no commands that I can find for it.

Regards

David
Reply | Threaded
Open this post in threaded view
|

Re: Data from summary window

Tiago Ferreira-2
Hi David,

It is hard to help without knowing exactly what you have.
It would be best if you could share what you have so far.


> I'm wondering if its actually possible to access the data in the summary window
It is. Find below a more detailed BeanShell example. It works every time I run it on IJ 1.9m2.
It is derived from the ParticleAnalyzer[1], that you should have a look at.

// Start
import ij.IJ;
import ij.ImagePlus;
import ij.Prefs;
import ij.WindowManager;
import ij.measure.ResultsTable;
import ij.text.TextWindow;
import ij.plugin.filter.ParticleAnalyzer;
import java.awt.Frame;


imp = IJ.openImage(Prefs.getImagesURL()+"bat-cochlea-volume.zip");
imp.show();
pa = new ParticleAnalyzer(ParticleAnalyzer.DISPLAY_SUMMARY,0,new ResultsTable(),0,100);
pa.analyze(imp);

frame = WindowManager.getFrame("Summary of "+imp.getTitle());
if (frame!=null && (frame instanceof TextWindow)) {
    tw = (TextWindow)frame;
    table = tw.getTextPanel().getResultsTable();
    if (table!= null) {
        st = tw.getTextPanel().getResultsTable();
        IJ.log("Table found! Here is 1st row:\n"+ st.getRowAsString(0));
    } else {
        IJ.log("Summary Table not found");
    }
}

// End

[1] https://github.com/imagej/imagej1/blob/master/ij/plugin/filter/ParticleAnalyzer.java#L612-L615

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Data from summary window

davek604
Hello Tiago

I'm trying to use a set threshold percentage, eg I want to use 0.1% of the histogram to threshold my cells and I noticed that the summary %area gave me the percentage I was looking for. So I thought that would be simpler than calculating it from the getHistogram command and counting pixels in bins.

So what you posted is exactly what I want to do but it unfortunately still doesn't work. I'm debugging it in Eclipse and it wouldn't start until I declared the variables. The problem seems to be the table variable which Eclipse insists is a ResultsTable variable type, it is always null so the summary table cannot be found. However what I've noticed is that you say you run it on 1.9m2  what is that, as the highest version I can download of ImageJ is 1.48 are you using ImageJ2. I've put the code with my slight modifications below (also made sure all imports are in place). I really appreciate your help on this because I'm really stuck.

ImagePlus imp = null;
                imp = IJ.openImage(Prefs.getImagesURL()+"bat-cochlea-volume.zip");
                imp.show();
                ParticleAnalyzer pa = new ParticleAnalyzer(ParticleAnalyzer.DISPLAY_SUMMARY,0,new ResultsTable(),0,100);
                pa.analyze(imp);

                Frame frame = WindowManager.getFrame("Summary of "+imp.getTitle());
                if (frame!=null && (frame instanceof TextWindow)) {
                    TextWindow tw = (TextWindow)frame;
                    ResultsTable table = tw.getTextPanel().getResultsTable();
                    if (table!= null) {
                        ResultsTable st = tw.getTextPanel().getResultsTable();
                        IJ.log("Table found! Here is 1st row:\n"+ st.getRowAsString(0));
                    } else {
                        IJ.log("Summary Table not found");
                    }
                }
Reply | Threaded
Open this post in threaded view
|

Re: Data from summary window

davek604
Hello
Tiago has been working on this off the list and it seems the code only works in ImageJ 1.49h and above. Wayne Rasband has also contacted me with the same info. So thank you Tiago and Wayne, problem solved.

Regards

David