// ******************************************************************************** // Length measurement - Fabrice Duprat august 2011 - LAST MODIFICATION: 3/2/2014 // Macro for multiple length measurements // INPUT: images with extension .tif, // BEWARE the scale calculation is made for the Leica DMD 108 histology microscope (you can change the values of myscale) // OUTPUT: .txt file with the file name, the mean value and all the values for the measured lengths // // ******************************************************************************** macro "histo_length" { run("Line Width...", "line=3"); print("File name \t Mean \t Length1 \t Length2 \t Length3 \t Length4 \t Length5 \t Length6 \t Length7 \t Length8 \t Length9 \t Length10 \t More... "); mainwhile=1; while (mainwhile == 1) { run("Close All"); // ADJUST THE RIGHT SCALE zoom = newArray("x4","x10","x20","x40","x63"); Dialog.create("Choose objective "); Dialog.addChoice("Objective", zoom, "x20") Dialog.addMessage("WARNING, close the Log window if starting a new serie."); Dialog.show(); choice = Dialog.getChoice(); myscale=0; run("Set Measurements...", "display redirect=None decimal=3"); run("Clear Results"); if (choice=="x4") {myscale=630;} else if (choice=="x10") {myscale=1580;} else if (choice=="x20") {myscale=3180;} else if (choice=="x40") {myscale=6360;} else if (choice=="x63") {myscale=10042;} // START LOOPING FOR EACH IMAGE while (myscale!=0) { run("Clear Results"); image1 = File.openDialog("CHOOSE image to analyse"); open(image1); titre_image = getTitle(); mypath = getDirectory("image"); nb = indexOf(image1, ".tif"); nom_image = substring( image1, 0, nb ); //Get rid of .tif extension in the name run("Set Scale...", "distance="+myscale+" known=1000 pixel=1 unit=µm global"); setTool("line"); waitForUser("To measure, DRAW LINE then CTRL+M\n \nChange zoom with Magnifying glass tool...\n... back to measurement with Straight line tool"); mylength= newArray(nResults); mytotal = 0; mytemp = ""; for (i=0; i1) { myprint = getResultLabel(0) + "\t" + toString(mymean) + "\t" + mytemp; print (myprint); } selectWindow(titre_image); close(); Dialog.create("NEXT IMAGE"); Dialog.addMessage("Measurements have been added to Log window."); Dialog.addMessage(" "); Dialog.addMessage("CONTINUE ANALYSIS ?"); Dialog.addCheckbox("NO, save the results", false); Dialog.show() saveresult = Dialog.getCheckbox(); if (saveresult == true) {myscale = 0; mainwhile = 0;} } // end while myscale // SAVE THE RESULTS } // end main while namefile = "analyse"; myfile = mypath + namefile +".txt"; overwrite = false; filexist = File.exists(myfile); // Check if file name already exist while ( (filexist== 1) && (overwrite == false) ) { // This name already exist for analyse file Dialog.create("ANALYSE FILE"); Dialog.addString(namefile + ".txt file already exists, other name : ", namefile ); Dialog.addCheckbox("Or overwrite file ? ", false); Dialog.show(); namefile = Dialog.getString(); overwrite = Dialog.getCheckbox(); myfile = mypath + namefile + ".txt"; filexist = File.exists(myfile); } selectWindow("Log"); saveAs("Text", myfile); waitForUser("The formatted results have been saved in < " + myfile + " >"); }