Multiple results tables


so I’m currently optimizing a macro which returns two custom results tables during the course. The first part runs super stable so I always get the first results saved using

saveAs("Results", dirimg + imgName + "_" + rName + "_Filopodia.csv");

In the second part I measure something else and my results table is repopulated with different measures and I can again save it using saveAs("Results"....).

The second part however still crashes sometimes for certain shapes of cells. I already found a way to detect the crash and stop the macro using error() but at that point, the first results have already been saved and I don’t want to only create half of the results.

So is there a way store a custom results tabe in a variable or basically have two results tables so I can just save them after successfully finishing the full macro?


One option in IJ1 Macro is to create a different table.
It is not THE result table so you cannot use the built in functions on it. Since these only work on the one and only result table:

new_table_name1 = "NewTable";
new_table_name2 = "[" + new_table_name1 + "]";
run("New... ", "name=" + new_table_name2  + " type=Table width=800 height=600");
print(new_table_name2 , "\\Headings:Well\tSeries\tCell");

well = 0;
series = 1;
cell = 2;

print(new_table_name2, well + "\t" + series + "\t" + cell );

saveAs("Text", "path/to/Result/resultName.csv");

This is a bit hacky and this table you cannot really store in a variable or hide. For more advanced hidden tables you need to look into proper scripting languages which support this. Or some people suggest to write information into images: Multidimensional arrays

If I were you I would find a way to prevent the macro to stall at all using if else statements. Maybe there is something that you can use to recognize that this specific cell can give you an error and skip it.

1 Like

A more flexible approach to using multiple (result) tables in IJ1 macros is to use the Table.* macro functions. You will find them documented here:


ah perfect, this was what I was looking for! I don’t really depend on any specific results-table functionality anyways, wonderful :slight_smile:

But you are right @schmiedc, I should probably anyways find a better way of handling the weird cells.
Thanks to you both!

1 Like

Yes the Table.* functions are easy to use when you want to read and/or write a table column-wise, using arrays. If you have a pre-determined layout and write the table row-wise, using the print("[tablename]", tab_delimited_string) approach, which @schmiedc gave an example of, may be faster and easier.