Fiji Macro error Ext.Manager3D_AddImage() when no objects

Hi,
I am trying to write a macro to analyse tiff stack dual channel files in a same folder.
From one channel I would like to get the number of objects (stainned cells); from the other one the total volume of all the objects (all cells stainned with generic stainning)
I am trying to use “3d simple segmentation”. The loop is working fine exepted when no GFP cells are found in the image (and that can happen…). It stop working when there are no objects found and teh command Ext.Manager3D_AddImage() is run

I have then this error and that in the log:

Adding image : min-max 2147483647 0

and in the console i have this exeption:

Exception in thread "Thread-82" java.lang.NegativeArraySizeException
	at mcib_plugins.tools.RoiManager3D_2.addImage(RoiManager3D_2.java:1516)
	at mcib_plugins.tools.RoiManager3D_2.lambda$buttonAddImageActionPerformed$3(RoiManager3D_2.java:1281)
	at java.lang.Thread.run(Thread.java:748)

I hope somebody knows how to manage this kind of error. (like if no image then nb=0)
Thanks in advance for your help
cheers

Here is a part of my code

dir=getDirectory("Choose a Directory");
print(dir);
list = getFileList(dir);
// select measurments in Manager3D Options, select Plugins/Record to record
run("3D Manager Options", "volume integrated_density distance_between_centers=10 distance_max_contact=1.80 drawing=Contour");
// run the manager 3D
run("3D Manager");
for (i=0; i<list.length; i++) {
     if (endsWith(list[i], ".tif")){
               print(i + ": " + dir+list[i]);
             open(dir+list[i]);
             imgName=getTitle();
         baseNameEnd=indexOf(imgName, ".tif");
         baseName=substring(imgName, 0, baseNameEnd);
       
         run("Split Channels");
         //count GFP cells
         selectWindow("C1-"+imgName);
         run("3D Simple Segmentation", "low_threshold=30 min_size=50 max_size=-1");
             //add image to 3D roi manager
         Ext.Manager3D_SelectAll();
		Ext.Manager3D_Delete();
		  Ext.Manager3D_AddImage();
          // if list is not visible please refresh list by using Deselect
		Ext.Manager3D_Select(0);
		Ext.Manager3D_DeselectAll();
         // number of results, and arrays to store results
		Ext.Manager3D_Count(nb);

     }}

Hi @neolilous,

Sorry there was a bug in 3DManager, this should be corrected in today update.

Best

Thomas

Hi Thomas.
thanks a lot for the fast answer! it gonna be an automatic update of the 3d roi manager pluggin? or do i have to modify my self. i have seen on github that you already out the revised code.

best
ismael

Hi @neolilous,

The update should be automatic, however it seems I have some problems doing the upload to the 3D Suite update site in Fiji, but I hope to be able to update it by end of this week.

Best,

Thomas

Hi @ThomasBoudier,
No problem; for now i “bypass” the bug with this if/else statement

 //segmentation of the objects
run("3D Simple Segmentation", "low_threshold=CCT min_size=CCsize max_size=-1");
selectWindow("Log");  //select Log-window
saveAs("Text",  dir + "log");
test= File.openAsString(dir + "log.txt");
//if state until 3d manager not updated (bypass the bug)
if (indexOf(test, "size =0") >= 0)
{nb="0";}
else
{Ext.Manager3D_SelectAll();
Ext.Manager3D_Delete();
Ext.Manager3D_AddImage();
Ext.Manager3D_Save(dirC1 + imgName + "C1" + ".zip");

// if list is not visible please refresh list by using Deselect
Ext.Manager3D_Select(0);
Ext.Manager3D_DeselectAll();
// number of results, and arrays to store results
Ext.Manager3D_Count(nb);}

thanks again
Best
Ismael