// ********************************************************************** // declare global variable //var mypath="c:/"; // ********************************************************************** // "0intensity_objects" // Macro to measure mean intensity and count many objects. // Fabrice Duprat november 2012 //Macro for multiple objects measurements. // INPUT: Structure of the data to be analysed: Serie of Images. // TODO: in INITIAL SETTINGS: Modify the threshold limits and minimum size of particle to be analysed // Modify the name of results file // OUTPUT: "Results" window for each object: file name, area, mean value, Integrated density, and all the values for the measured lengths. // OUTPUT : "Summary" window : file name, number of objects, Total aea, Average size of each object, % area, Mean intensity, Integrated density. // // ******************************************************************************** // // If you are using this script for a research article, please cite this web page: https://www.ipmc.cnrs.fr/~duprat/scripts/ // macro "Intensity_objects" { // INITIAL SETTINGS // Set the threshold min and max values Tmin=40; Tmax=255; // Set the size of minimal particle to analyse Spart=500; // Set the name of saved results file (.txt) namefile = "0results"; // SHOW A WINDOW WITH CHOOSEN PARAMETERS showMessage( "Parameters","" +"" +"Threshold : "+Tmin+" - "+Tmax +"
Analysed particle over : "+Spart +"
Results file name : "+namefile ); run("Clear Results"); mainwhile=1; run("Close All Without Saving"); // Close all images (the plugin needs to be installed) while (roiManager("count")!= 0) // Empty the ROI manager list {roiManager("Delete");} // START LOOPING FOR EACH IMAGE while (mainwhile ==1) { // Open Image image1 = File.openDialog("CHOOSE image to analyse"); open(image1); titre_image1 = getTitle(); mypath = getDirectory("image"); setLocation(10, 10); // ANALYSE IMAGE run("8-bit"); run("Threshold..."); //setAutoThreshold("Default dark"); setThreshold(Tmin, Tmax); waitForUser("Adjust threshold"); run("Analyze Particles...", "size="+Spart+"-Infinity circularity=0.00-1.00 show=[Overlay Outlines] display summarize"); resetThreshold(); Dialog.create("Continue ?"); Dialog.addCheckbox("NO, save the results", false); Dialog.show() saveresult = Dialog.getCheckbox(); if (saveresult == true) {mainwhile= 0;} } // end mainwhile // SAVE THE RESULTS myfile = mypath + namefile +".txt"; overwrite = false; namefile2 = ""; while ( File.exists(myfile) ) { Dialog.create("ANALYSE FILE"); Dialog.addString(namefile+".txt file already exists, other name : ", namefile ); Dialog.addCheckbox("Or overwrite file ? ", false); Dialog.show(); namefile2 = Dialog.getString(); overwrite = Dialog.getCheckbox(); if (overwrite == true) {myfile = "";} else {myfile = mypath + namefile2 + ".txt";} } if (overwrite == true) {myfile = mypath + namefile +".txt";} selectWindow("Results"); saveAs("Results", myfile); }