Batch processing analysed particle using Bone J plugin

Hi Guys,

I want to get some statistics on pores in some images. I have saved these images in a separate folder and recorded the macro of what I intend to do from one of the image. I want to batch process the procedure and to make sure every image has an excel result saved with respect to the image. I have tried to use the macro below but I could not get the results for each image. Can anyone help me edit the macro?

 * Macro template to process multiple images in a folder

input = getDirectory("Input directory");
output = getDirectory("Output directory");

Dialog.create("File type");
Dialog.addString("File suffix: ", ".tif", 5);;
suffix = Dialog.getString();


function processFolder(input) {
	list = getFileList(input);
	for (i = 0; i < list.length; i++) {
		if(File.isDirectory(input + list[i]))
			processFolder("" + input + list[i]);
		if(endsWith(list[i], suffix))
			processFile(input, output, list[i]);

function processFile(input, output, file) {
//setThreshold(0, 41);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Median...", "radius=3");
run("Particle Analyser", "surface_area enclosed_volume moments euler thickness ellipsoids min=0.000 max=Infinity surface_resampling=2 surface=Gradient split=0.000 volume_resampling=2 labelling=Mapped slices=2");
dir = getDirectory("image"); 
   name = getTitle; 
   index = lastIndexOf(name, "."); 
   if (index!=-1) name = substring(name, 0, index); 
   name = name + ".xls";    
saveAs("Results", dir+name);

Thank you @imagejan, the code is not working. After going through process, batch, macro with the code, the popping up messages are “there are no images open” or “Binary image required”

My edit of your post was just fixing the display of the code in this forum. I didn’t change anything in your original macro code.

The template you used (from Templates > IJ1 Macro > Process Folder in the script editor, I suppose) is not meant to be run via Process > Batch > Macro. Just run the macro directly from within the script editor by clicking the run button.

Why are you closing the binary image right after creating the mask? Try to understand the commands you are recording, and I’m sure you’ll find out what’s going wrong.
I also don’t understand what you’re trying to achieve with run("Median...", "radius=3");.

Okay @imagejan. I have run the code through the script editor and multiple image processor prior to my post without success. Anyway I will still have a look again.

Thank you