Hi, I’m a new coder to imageJ, I’m not having success printing the centroid result to file at the moment. Any suggestions would be greatly appreciated…Currently the first centroid x,y result is saved to the Results, but the remaining ones fail.
dir = getDirectory( "Choose the Directory" );
list = getFileList( dir );
for ( i=0; i<list.length; i++ ) {
open( dir + list[i] );
}
//setBatchMode(true);
count = 0;
countFiles(dir);
n = 0;
processFiles(dir);
print(count+" files processed");
function countFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
countFiles(""+dir+list[i]);
else
count++;
}
}
function processFiles(dir) {
list = getFileList(dir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/"))
processFiles(""+dir+list[i]);
else {
showProgress(n++, count);
path = dir+list[i];
processFile(path);
}
}
}
function processFile(path) {
if (endsWith(path, ".dcm")) {
open(path);
setAutoThreshold("Shanbhag");
setThreshold(0, 27310);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Analyze Particles...", "size=100-99999 circularity=0.6-1.00 exclude clear add");
run("Measure");
//roiManager("Add");
//close();
}
}
updateResults(); // Update the results table so it shows the filenames
// Show a dialog to allow user to save the results file
outputFile = File.openDialog("Save results file");
// Save the results data
saveAs("results",outputFile);