Window pop-up after ending macro

Hi,
Every time a macro ends and it runs “close” on all windows (tables, images, Roi Manager, etc.), a blank table window always pops-up and I have to close it manually. The table is usually named after a table which has been opened, processed, and closed at some point of the macro.
I used all macro commands to close windows and it just pops-up again.

Any suggestions for this issue?

Thanks!

Lee

Please provide a minimal macro that reproduces the problem.

I tried to scale the macro down a bit. Here’s an example where it shows a Result table after pressing the “Done!” message. The macro usually opens three files and edits them: a “.csv” file, a “.zip” file with all the ROIs, and a “.tiff” image, as I show below.

Path = "C:/Users/Documents/TEST_FILES/"; //
CruiseName = "TESTCRUISE18/"; //
Input = Path + CruiseName + "/" + "Images_raw" + "/";
Output_data = Path + CruiseName +"/" + "Data" + "/";
Output_ROIs = Path + CruiseName +"/" + "ROIs" + "/";
Output_images = Path + CruiseName + "/" + "Images_treated" + "/";
OutputFile = "TESTCRUISE18_T1_315_1";
Ex0 = ".csv";
ReflTransImage = OutputFile + "_GR" + ".tif";
scale = 0.0463;

open(Output_ROIs + OutputFile + ".zip");
open(Output_data + OutputFile + Ex0);
open(Input + ReflTransImage);

ImageName = getInfo("image.filename");
setLocation(0, 0);

run("Set Scale...", "distance="+scale+" known=1 pixel=1 unit=um global");

count1 = roiManager("count");
roiManager("UseNames", "false");
roiManager("Show All with labels");
circ = newArray(count1);
feret = newArray(count1);
minferet = newArray(count1);
AR = newArray(count1);

for (i = 0; i<count1; i++) {
	roiManager("Select", i);
	run("To Selection");
	run("Out [-]");
	run("Out [-]"); 
	run("Out [-]"); 
	run("Out [-]");  
	getSelectionBounds(x, y, width, height);
	makeRectangle(x, y, width, height);
	run("Copy");
	run("Internal Clipboard");
	run("Maximize");
	setLocation(screenWidth*0.50, 0); 
	run("Scale Bar...", "width=500 height="+height/60+" font="+height/20+" color=Black background=None location=[Lower Right] overlay"); 
	selectWindow(ImageName);
	selectWindow("Clipboard");
	Dialog.createNonBlocking("Select");
	items = newArray("a", "b", "h", "c", "d", "e", "f", "g");
	Dialog.addRadioButtonGroup("Category*: ", items, 4, 2, "a");
	Dialog.addMessage("*Some options may be suggested");
	Dialog.addMessage("Progress: " + i + "/" + count1 + " " + "(" + (i/count1)*100 + "%" + ")");
	Dialog.show();
	close("Clipboard");
	Type = Dialog.getRadioButton();
	if(Type == "a"){Type1 = "1";}
	if(Type == "b"){Type1 = "2";}
	if(Type == "c"){Type1 = "3";}
	if(Type == "d"){Type1 = "4";}
	if(Type == "e"){Type1 = "5";}
	if(Type == "f"){Type1 = "6";}
	if(Type == "g"){Type1 = "7";}
	if(Type == "h"){Type1 = "8";}
	roiManager("Select", i);
	Roi.setGroup(Type1);
	Table.set("Group", i, Type1);
	run("Original Scale");
}

selectWindow(ImageName);
roiManager("Show All with labels");
run("Scale Bar...", "width=5000 height=25 font=100 color=White background=None location=[Lower Right] overlay");
run("Flatten");
saveAs("Jpeg", Output_images + OutputFile + "_Category.jpg");
selectWindow(OutputFile + Ex0);
saveAs("Results", Output_data + OutputFile + ".csv");
close(OutputFile + ".csv");
close("Results"); 
close("*");
selectWindow("ROI Manager");
run("Close All");
showMessage("Done!");

I forgot to mention that the minimal macro needs to be runnable. It should create images using newImage() or open one or more of the sample images listed in the File>Open Samples menu.

Of course.

newImage("ReflTransImage", "16-bit white", 1000, 1000, 1);
makeRectangle(42, 78, 144, 104);
setForegroundColor(0, 0, 255);
run("Fill", "slice");
makeRectangle(274, 146, 110, 28);
run("Fill", "slice");
makeRectangle(526, 164, 86, 72);
run("Fill", "slice");
makeOval(238, 308, 102, 94);
run("Fill", "slice");
makeOval(494, 420, 254, 232);
run("Fill", "slice");
makeOval(226, 520, 120, 128);
run("Fill", "slice");
run("Select None");
run("Threshold...");
run("Analyze Particles...", "exclude add");
run("Set Measurements...", "area perimeter shape feret's median redirect=None decimal=3");
roiManager("Measure All");

ImageName = "ReflTransImage";
setLocation(0, 0);

scale = 0.0463;
run("Set Scale...", "distance="+scale+" known=1 pixel=1 unit=um global");

count1 = roiManager("count");
roiManager("UseNames", "false");
roiManager("Show All with labels");
circ = newArray(count1);
feret = newArray(count1);
minferet = newArray(count1);
AR = newArray(count1);

for (i = 0; i<count1; i++) {
	roiManager("Select", i);
	run("To Selection");
	run("Out [-]");
	run("Out [-]"); 
	run("Out [-]"); 
	run("Out [-]");  
	getSelectionBounds(x, y, width, height);
	makeRectangle(x, y, width, height);
	run("Copy");
	run("Internal Clipboard");
	run("Maximize");
	setLocation(screenWidth*0.50, 0); 
	run("Scale Bar...", "width=500 height="+height/60+" font="+height/20+" color=Black background=None location=[Lower Right] overlay"); 
	selectWindow(ImageName);
	selectWindow("Clipboard");
	Dialog.createNonBlocking("Select");
	items = newArray("a", "b", "h", "c", "d", "e", "f", "g");
	Dialog.addRadioButtonGroup("Category*: ", items, 4, 2, "a");
	Dialog.addMessage("*Some options may be suggested");
	Dialog.addMessage("Progress: " + i + "/" + count1 + " " + "(" + (i/count1)*100 + "%" + ")");
	Dialog.show();
	close("Clipboard");
	Type = Dialog.getRadioButton();
	if(Type == "a"){Type1 = "1";}
	if(Type == "b"){Type1 = "2";}
	if(Type == "c"){Type1 = "3";}
	if(Type == "d"){Type1 = "4";}
	if(Type == "e"){Type1 = "5";}
	if(Type == "f"){Type1 = "6";}
	if(Type == "g"){Type1 = "7";}
	if(Type == "h"){Type1 = "8";}
	roiManager("Select", i);
	Roi.setGroup(Type1);
	Table.set("Group", i, Type1);
	run("Original Scale");
}

selectWindow(ImageName);
roiManager("Show All with labels");
run("Scale Bar...", "width=5000 height=25 font=100 color=White background=None location=[Lower Right] overlay");
run("Flatten");
close("Results"); 
close("*");
selectWindow("ROI Manager");
run("Close All");
showMessage("Done!");

This bug is fixed in the latest ImageJ daily build (1.52v21) and in the 1.52v release candidate. Add

   close("Threshold"); 
   close("ROI Manager");

to the end of the macro to have all windows closed when the macro ends.