// ZIRULAB particle-analysis macro (ImageJ 1.x macro language; runs in Fiji or plain ImageJ) // Argument string: "||" // Fixed rules for EVERY method: size >= 20 px^2, circularity 0-1, exclude edge particles, include holes. // Image: dark particles on a light background -> no "dark" flag in setAutoThreshold. args = getArgument(); p = split(args, "|"); imgPath = p[0]; method = p[1]; outDir = p[2]; open(imgPath); base = File.nameWithoutExtension; tag = base + "__" + method; // Set Scale: synthetic nominal calibration 1 px = 0.5 um (known distance 0.5 um per 1 px) run("Set Scale...", "distance=1 known=0.5 pixel=1 unit=um"); run("Set Measurements...", "area centroid shape redirect=None decimal=4"); setAutoThreshold(method); // e.g. "Otsu", "Huang", "Triangle"... getThreshold(lo, hi); run("Analyze Particles...", "size=20-Infinity pixel circularity=0.00-1.00 show=[Count Masks] display exclude clear include"); n = nResults; saveAs("Results", outDir + "/" + tag + "_results.csv"); selectWindow("Count Masks of " + base + ".tif"); saveAs("Tiff", outDir + "/" + tag + "_countmask.tif"); info = "image=" + base + "\nmethod=" + method + "\nthreshold_lower=" + lo + "\nthreshold_upper=" + hi + "\ncount=" + n + "\nimagej_version=" + getVersion() + "\n"; File.saveString(info, outDir + "/" + tag + "_run.txt"); run("Close All");