from ij import IJ; from ij.plugin.frame import RoiManager; from java.awt import Color from ij.gui import PolygonRoi, WaitForUserDialog; from ij.gui import Roi; from java.awt import FileDialog import os EXCLUDE_ON_EDGES = True NUCLEI_GROUP = 2 CYTOPLASM_GROUP = 1 COLORS = [Color.cyan, Color.magenta] DISTANCE_TO_BORDER = 5 Roi.setGroupName(NUCLEI_GROUP, "nuclei") Roi.setGroupName(CYTOPLASM_GROUP, "cytoplasm") Roi.saveGroupNames() folder = IJ.getDirectory("") files=[[], [], [], []] for c in range(0, 4): files[c] = [os.path.join(folder, image) for image in os.listdir(folder) if image.lower().endswith("_c"+str(c)+"_cp_outlines.txt")] if(not files[0] and not files[1] and not files[2] and not files[3]): files[0] = [os.path.join(folder, image) for image in os.listdir(folder) if image.lower().endswith("_cp_outlines.txt")] images = [os.path.join(folder, image) for image in os.listdir(folder) if (image.lower().endswith(".tif") or image.lower().endswith(".jpg") or image.lower().endswith(".png")) and not image.lower().endswith("_cp_masks.png")] ext = images[0].split(".")[1] RM = RoiManager()