Error with Script Editor Template

Hi everyone! I’m relatively new to FIJI and having some issues with utilizing the “Process Folder” IJ1 Macro template in Script Editor (see image below).
image

Essentially, I’m trying to create an IJ1 Macro script to process multiple images in a folder. I know that Batch Process will perform the same function, however I wanted to add some additional functions to this script later on. When I try to input some previously recorded Macro code into this template to process, I keep getting a “No Image” error box that pops up that states that there are no images open in line 29. Can anyone help me with this?

image

Here is the full IJ1 Macro code for reference:

/*
 * Macro template to process multiple images in a folder
 */

#@ File (label = "Input directory", style = "directory") input
#@ File (label = "Output directory", style = "directory") output
#@ String (label = "File suffix", value = ".tif") suffix

// See also Process_Folder.py for a version of this code
// in the Python scripting language.

processFolder(input);

// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
	list = getFileList(input);
	list = Array.sort(list);
	for (i = 0; i < list.length; i++) {
		if(File.isDirectory(input + File.separator + list[i]))
			processFolder(input + File.separator + list[i]);
		if(endsWith(list[i], suffix))
			processFile(input, output, list[i]);
	}
}

function processFile(input, output, file) {
	// Do the processing here by adding your own code.
	setOption("BlackBackground", false);
	run("Make Binary");
	run("Analyze Particles...", "size=10-Infinity display summarize");
	// Leave the print statements until things work, then remove them.
	print("Processing: " + input + File.separator + file);
	print("Saving to: " + output);
}

Hey @Angu312,

you need to open an image. You could for example try to run

open(input + File.separator + file);

as first in your processFile() function.

Let us know if this helps.

Cheers,
Robert

Hey @haesleinhuepf,

This works perfectly! It’s so simple that I can’t believe I overlooked it. Thank you!

Best,
Andrew

1 Like