Update a personalized ResultsTable

Hi to all,
I wrote a very simple python plugin that analyze a DAPI staining and get some parameters.
One of them the C.V. (std/mean intensity) is not one of the standard parameters in Set Measurements menu.
So I create a result table that calculate also this parameter.
I don’t get how to update this Results Table without clear it.
Essentially, I would like that works like that:

  1. open an Image-1
  2. then launch my plugin
  3. Results Table with parameters relative at Image-1
    4)open Image-2
  4. launch my plugin
    6)append the results to the already present Results Table.

In few word, how can I check if there is already a generic Results Table and the use it?
I know that I could use analyzer.getResultsTable() but that returns the default ResultsTable.

Thank you
Emanuele Martini

Maybe this post is helpful:

In addition eventually you can dervive the Jython commands from the ImageJ macro examples and the ResultsTable API, see, e.g.:





Hi @Bio7,
thank you for the suggested pages, I will read and try them, then I will let you know.

Dear @Bio7,
I found a way to do that.
I write here since isn’t present in the link that you suggested me, so it could be useful for someone other.
I did in jython, passing by getTextPanel()

rt_exist = WindowManager.getWindow("Personalized_Results")
if rt_exist==None:
    rt= ResultsTable()
    rt = rt_exist.getTextPanel().getOrCreateResultsTable()

Essentially, it supposes that your ResultsTable has as name “Personalized_Results”: the name is assigned by rt.show(“Personalized_Results”)

Now, using WindowManager.getWindow(“Personalized_Results”) you can test if it is already existing (i.e. if you have a already used your script and analyzed something); if not (None case) it will create a new ResultsTable, if yes passing by getTextPanel().getOrCreateResultsTable() you obtain a new ResultsTable with the personalized data already analyzed.

Hoping to be helpful also to other users,
have a nice day


This will fail if there’s an image window named “Personalized_Results”. To be safe, you should check whether rt_exist actually is a TextWindow instance:

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

rt_exist = WindowManager.getWindow("Personalized_Results")
if rt_exist==None or not isinstance(rt_exist, TextWindow):
    rt= ResultsTable()
    rt = rt_exist.getTextPanel().getOrCreateResultsTable()

For java developers this is my helper function

     * This function returns the result table with given title, if it doesn't
     * exist then it creates a new one
     * @param Title The title of the result table
     * @return the result table with given title
    public static ResultsTable getOrCreateResultsTable(String Title) {
        Window we = WindowManager.getWindow(Title);
        if (we instanceof TextWindow) {
            TextWindow rt_exist = (TextWindow) we;
            return rt_exist.getTextPanel().getOrCreateResultsTable();
        return new ResultsTable();

For ImageJ1 Macro lovers, this is my take on the question :smile_cat:

 * Prepare a new table or an existing table to receive results. 
function prepareTable(tableName) { 
		if(isOpen("Results")) { IJ.renameResults("Results","Temp"); updateResults();} 
		if(isOpen(tableName)) { IJ.renameResults(tableName,"Results"); updateResults();} 
 * Once we are done updating the results, close the results table 
 and give it its final name 
function closeTable(tableName) { 
		if(isOpen("Results")){ IJ.renameResults("Results",tableName); updateResults();} 
		if(isOpen("Temp")) { IJ.renameResults("Temp","Results"); updateResults();} 

That way when you want to write something to the ‘Personalized_Results’ table you first run
prepareTable("Personalized_Results") then you can use setResult, getResult, nResults as you like. And when you are done working on it, call closeTable("Personalized_Results")

NOTE: The ‘Personalized_Results’ table will be exactly behind the ‘Results’ table at the end of this, so make sure to move the Results window a bit to see it.