Problem with saving results from 3D object counter in headless mode


I need to run 3D Object counter in headless mode to analyze the stack of images in Fiji. The problem is that there is no saved table of results to be appeared in output directory folder.
This is my macro:

run("Image Sequence...", "open=/path/nofib00010.tif number=20 starting=5 increment=1 scale=100 convert sort"); 
setMinAndMax(8, 65); 
run("Apply LUT", "stack");
run("Labeling 2D 3D", "lower=186 upper=255 background=NaN color entire labeling=Volumetric");
setMinAndMax(0, 0); 
run("Apply LUT", "stack");
run("3D OC Options", "volume surface centre_of_mass bounding_box dots_size=5 font_size=50 show_numbers white_numbers redirect_to=none");
run("3D Objects Counter", "threshold=255 slice=20 min.=0 max.=125000000 statistics");

Does anyone have ideas, how to solve this problem?


Welcome to the Forum!

So… I was playing a bit… and maybe have some solutions? I am not sure why you make the updateResults(); call… but if you replace that line with:


… it appears to run smoothly. You can name the Results table anything you want by just changing that String - but that allows you to reliably select the Results table to then save it.

Another option is to include setBatchMode(true); in your script (you can still delete the updateResults(); call) - that prevents all the intermediary image windows from popping up and your script should also work.

These might not be the most elegant solutions - but try them out yourself and see.


Thank you for your reply and ideas!

I’ve tried setBatchMode(true); already and it didn’t work.

This command unfortunately also not working:

The thing is, that everything is working well, when I am running this with opened user interface. However it is not running in headless mode through terminal in Linux.

It seems to me that in headless mode the results table from 3D Object Manager is not appearing at all. Do you have any thoughts about this? What could be the reason?


Sorry @antonoa1 !!! I totally misled you… I forgot you are running headless !!! That’s why it’s not working - I was just playing via the Script Editor. Sorry about that! Silly me!