How to close ROI Manager and Results Table programmatically using Python

Hi,

I have this script, which I run on FIJI/ImageJ script editor:

import os
from ij import IJ, Prefs
PATH="/mypath/channel3/crop_level2/"
tiffile="04_709_channel-3_R1_C3.tif"
infile = os.path.join(PATH,tiffile)
print infile
imp = IJ.openImage(infile)
IJ.setAutoThreshold(imp, "Moments dark");
imp.show()
IJ.run(imp, "Analyze Particles...", "  display summarize add")
IJ.saveAs(imp, "Jpeg", "/mypath/Desktop/01_718_channel-3_R1_C1.jpg")
IJ.run("Close")

Every time this code finish. It creates the ROI Manager and Result box that looks like this:

How can I programmatically close and clear this two boxes at then end of my script?

The reason I ask this because, I’de like to test this script many times by changing tiffile without closing the two windows
will affect the result of next execution.

Dear @Peverall_Dubois,

you can close the Results window using

IJ.selectWindow("Results"); 
IJ.run("Close");

and the ROI Manager

roiManager = RoiManager.getRoiManager();
roiManager.close();

Best,
Stefan

5 Likes