Saving "Summary" table using jython script

Hello!

This is just a simple thing but somehow does not seem to work at all. I am running the plugin ComDet (a very cool tool, btw!) on some of my images for spot colocalization measures. The plugin provides a nice “Results” table and a “Summary” table as output. I would like to save just the summary table and discard the results table. The latter worked out quite easily. But when I try to get the summary table, I always get None.

A code snippet to try:

from ij import WindowManager
from ij.measure import ResultsTable
from ij.text import TextWindow

wm = WindowManager

win = wm.getWindow("Summary")
if win is not None:
    rt = win.getTextPanel().getResultsTable()
    print rt 	                #always returns None even if win is not None

Then I thought maybe I just rename the summary window to “Results” and get results table. So I closed the results table generated by ComDet and tried to rename summary as “Results”. This also does not work.

res = wm.getWindow("Results")
if res is not None:
    res.setVisible(False)

rt = ResultsTable()
win = wm.getWindow("Summary")
if win is not None:
    win.setTitle("Results")
    text_window = rt.getResultsWindow()             # is not None
    results_table = text_window.getResultsTable()
    print results_table                             # returns None

I am using the latest version of FIJI/ ImageJ. Any help is appreciated!

2 Likes

Hey @gayaJ,

these tables are sometimes a bit tricky. Just guessing a potential solution: Have you tried IJ.renameResults(); ?

image

Have a nice weekend!

Cheers,
Robert

Hey @haesleinhuepf,

Sorry for the late response. IJ.renameResults was the first thing I tried after seeing an old post where you had mentioned this but it did not help :frowning: Somehow “Summary” is still called the same. That is why I switched to setTitle(). Also I find strange when I do getTitle() it says Results and not Summary as I had expected. I did not know that name and title are two different things.

Thanks and best,
Gayathri

1 Like

The very first code snippet you proposed works fine for me on a Summary table produced e.g. by the Analyze Particles command.

The problem here is that ComDet uses a non-standard way to display its summary, i.e. it doesn’t internally use ResultsTable and therefore makes it unnecessarily difficult to access its contents. See here in the source code:

I’d consider this a flaw (or poor design choice) of the ComDet plugin. You might want to ask @ekatrukha to change this, or submit a pull request to the ComDet repository yourself.

3 Likes

Hello again @imagejan! You are right, it indeed uses some non-standard way of results table because I could easily run these snippets without any issues on tables generated by some other plugins like MorpholibJ for example. For now, I managed to find some workaround for ComDet tables. I don’t feel so comfortable making the changes myself but hope @ekatrukha takes this into consideration during the next update. :upside_down_face:

Hello everybody,

I see your struggle, I will take a look at it and try to correct it quickly.

3 Likes

I’ve updated the plugin and uploaded the new version (can be downloaded or through “Update” site), try it, please.

Now the code snippet from the first message should work.

Cheers,
Eugene

3 Likes

Hi Eugene, I updated the plugin and gave it a try and it works :smile: Thanks a lot for the prompt action!
Best,
Gayathri

1 Like