// ********************************************************************** // declare global variable //var mypath="c:/"; // ********************************************************************** // "0histo_surfaces" // Macro for calculating empty surfaces on histological slices // Fabrice Duprat august 2010 // // If you are using this script for a research article, please cite this web page: https://www.ipmc.cnrs.fr/~duprat/scripts/ // macro "histo_surface" { while (1 == 1) { run("Close All Without Saving"); changezoom = false; // ADJUST THE RIGHT SCALE zoom = newArray("macro","x4","x10","x20","x40"); Dialog.create("Choose objective"); Dialog.addChoice("Objective", zoom, "x10") Dialog.show(); choice = Dialog.getChoice(); myscale=0; mysize="40"; if (choice=="macro") {myscale=100;} else if (choice=="x4") {myscale=400;} else if (choice=="x10") {myscale=1600;} else if (choice=="x20") {myscale=3200;} else if (choice=="x40") {myscale=6400;} else if (choice=="x63") {myscale=10000;} // START LOOPING FOR EACH IMAGE while (myscale!=0) { mysize="40"; image1 = File.openDialog("Choose image to analyse"); open(image1); titre_image = getTitle(); nb = indexOf(image1, ".tif"); nom_image = substring( image1, 0, nb ); //Get rid of .tif extension in the name run("Duplicate...", "title=ORIGINAL_"+titre_image); // Create a duplicate called ORIGINAL for visual check run("Set Scale...", "distance="+myscale+" known=1000 pixel=1 unit=µm global"); selectWindow(titre_image); run("RGB Split"); selectWindow(titre_image+" (red)"); close(); selectWindow(titre_image+" (blue)"); close(); selectWindow(titre_image+" (green)"); run("In"); // Crop image setTool(0); selectWindow(titre_image+" (green)"); waitForUser("Make ROIs for croping (surface of interest MUST be the larger"); type = selectionType(); if (type!=-1) {run("Crop");} // Clean the image run("Color Picker..."); setForegroundColor(255, 255, 255); setBackgroundColor(0,0,0); close(); setTool(15); waitForUser("Delete bad pixels"); // Adjust threshold and convert to binary run("Threshold..."); setThreshold(0, 200); waitForUser("Adjust threshold"); run("Convert to Mask"); run("Erode"); run("Dilate"); run("Median...", "radius=2"); run("Make Binary"); // If zoom is macro if (choice=="macro") { mysize="100000"; // Analysis of whole kidney run("Duplicate...", "title=temp"); run("Fill Holes"); run("Analyze Particles...", "size=1000-Infinity circularity=0.00-1.00 show=Nothing display exclude clear add"); waitForUser("Note total area"); selectWindow("temp"); close(); // draw a line to close the volume selectWindow(titre_image+" (green)"); run("Color Picker..."); setForegroundColor(0,0,0); setBackgroundColor(255, 255, 255); close(); setTool(20); selectWindow(titre_image+" (green)"); waitForUser("Make a line"); // Select one or multiple ROI setTool(0); selectWindow(titre_image+" (green)"); waitForUser("Make ROIs for analysing"); // Analysis of contour run("Analyze Particles...", "size="+mysize+"-Infinity circularity=0.00-1.00 show=Outlines display summarize"); rename("contour"); // Analysis of pelvis selectWindow(titre_image+" (green)"); run("Invert"); run("Analyze Particles...", "size="+mysize+"-Infinity circularity=0.00-1.00 show=Outlines display summarize"); rename("pelvis"); imageCalculator("AND", "contour","pelvis"); selectWindow("contour"); nom_image = nom_image + "_ANAL.tif"; saveAs("Tiff", nom_image); selectWindow(titre_image+" (green)"); close(); selectWindow("pelvis"); close(); } else { // Select one or multiple ROI setTool(0); selectWindow(titre_image+" (green)"); waitForUser("Make ROIs for analysing"); run("Analyze Particles...", "size="+mysize+"-Infinity circularity=0.00-1.00 show=Outlines display clear summarize"); selectWindow("Drawing of "+titre_image+" (green)"); nom_image = nom_image + "_ANAL.tif"; saveAs("Tiff", nom_image); } selectWindow("ORIGINAL_"+titre_image); // Delete the duplicate called ORIGINAL close(); Dialog.create("Continue ?"); Dialog.addCheckbox("Change zoom ", false); Dialog.show() changezoom = Dialog.getCheckbox(); if (changezoom == true) {myscale = 0;} } // end while myscale } // end main while