Created
February 11, 2015 15:15
-
-
Save jlouros/a6b2ec9d6185c99e9cef to your computer and use it in GitHub Desktop.
ImageJ macro to perform a batch cell count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ImageJ macro to perform a batch cell count for a given directory (with images) | |
// ImageJ can be downloaded from http://rsb.info.nih.gov/ij/ | |
requires("1.48g"); | |
dir = getDirectory("Choose a Directory"); | |
list = getFileList(dir); | |
Dialog.create("User selection"); | |
Dialog.addNumber("Select size:", 250); | |
Dialog.show(); | |
selSize = Dialog.getNumber(); | |
sizeFullSetting = "size="+selSize+"-Infinity display"; | |
count = 1; | |
for (i=0; i<list.length; i++) | |
{ | |
if(endsWith(list[i], ".tif")) | |
{ | |
open(list[i]); | |
CellCounter(); | |
close(); | |
} | |
} | |
function CellCounter() { | |
xlsFileName = replace(getInfo("image.filename"),".tif",".xls"); | |
fullFilePath = getDirectory("image") + xlsFileName; | |
run("32-bit"); | |
run("Find Edges"); | |
setOption("BlackBackground", false); | |
run("Convert to Mask"); | |
run("Fill Holes"); | |
run("Analyze Particles...", sizeFullSetting); | |
currDialog = getInfo("window.type"); | |
if(currDialog != "ResultsTable") { | |
close("Particle*"); | |
} else { | |
saveAs("Results", fullFilePath); | |
run("Close"); | |
} | |
} | |
Dialog.create("Status"); | |
Dialog.addMessage("Operation complete!"); | |
Dialog.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment