How to put a predefined value into an analyze particle macro?

Hi,

I’m building a macro in wich I defined a value using a dialbox. I want this value to be used in the analyse particle function as one or both size asked by this function.

run("Analyze Particles...", "size=0.00005-Infinity circularity=0.50-1.00 display exclude clear include summarize add in_situ");

In this case the size is 0.00005-Infinity and I want the 0.00005 value to be replaced by a term, for exemple called “Tvalue”.

I tried :
run("Analyse Particles...", "size-"Tvalue"-Infinity circularity=0.50-1.00 display excluse clear include summarize add in_situ");
But it did not work.

I also can provide you the full macro :

Seuil=0.00005;
couleur1="Yellow"
couleur2="Red"
Dialog.create("Configuration");
Dialog.addString("Couleur 6nm:", couleur1);
Dialog.addString("Couleur 10nm:", couleur2);
Dialog.addNumber("Seuil", Seuil)
 Dialog.show();
couleur1 = Dialog.getString()
couleur2 = Dialog.getString()
Seuil = Dialog.getNumber()

run("Grays");//Lut en cas de mauvaise Lut
titleA=getTitle()
setOption("ScaleConversions", true);
run("8-bit");//Compatibilité
run("Duplicate...", " ");
run("Subtract Background...", "rolling=10 light");
run("Auto Threshold", "method=RenyiEntropy white");//Treshold
run("Duplicate...", " ");
run("Invert");//Préparation du watershed
run("Watershed");
titleB=getTitle()
run("Analyze Particles...", "size=0.00005-Infinity circularity=0.50-1.00 display exclude clear include summarize add in_situ");
roiManager("Set Fill Color", couleur2);//Couleurs des ROI
roiManager("Show None");
roiManager("Show All");
selectWindow(titleA);
roiManager("Show None");
roiManager("Show All");//Affiche les ROI sur l'image originale
roiManager("Show All without labels");//Fin de processus billes bleues.
run("Flatten");//Merge l'overlay et l'image originale
titleC=getTitle()
selectWindow(titleB);
run("Analyze Particles...", "size=0.00001-0.00005 circularity=0.50-1.00 display exclude clear include summarize add in_situ");
roiManager("Set Fill Color", couleur1 );
roiManager("Show All without labels");
selectWindow(titleC);
roiManager("Show None");
roiManager("Show All");//Affiche les 2eme ROI sur l'image originale
saveAs("Tiff")//Sauvegarde

The ImageJ macro language does not work that way. “Analyze Particles…” requires a second string in the format specified by the macro recorder.

Below is a reproducible example that uses a string script parameter to let you construct that string. String script parameters need to be at the top of your macro. More information is available here. Note the use of the style="" second parameter. If you leave that out, the script will crash…

@String(label="Lower Area [px]", style="") str_min_area
run("Close All");
run("Blobs (25K)");
setAutoThreshold("Default");
//setThreshold(126, 255);
run("Convert to Mask");
run("Set Measurements...", "area mean modal min center perimeter bounding fit shape feret's display redirect=None decimal=3");
run("Analyze Particles...", "size="+ str_min_area +"-Infinity display exclude clear include add");

Hope this helps.
John Minter

Thanks a lot John Minter, as a beginner I appreciate your explanation.

Have a great day.