IJ1 Macro can be run from editor, but crashes when run from FIJI Plugins menu

Hi all,
I made my first ImageJ1 Macro to process some files. Today when I wanted to apply it to some new files, I realized a peculiar error: I can run the script just fine from the script editor, but when I try to run it from the FIJI Menu → Plugins → Macros → Run, I get an error.
First, the code:

// @int(label = “DAPI Contrast Min”, min = 0, max = 20000, style = “scroll bar”) DAPIminCon
// @int(label = “DAPI Contrast Max”, min = 0, max = 20000, style = “scroll bar”) DAPImaxCon
// @int(label = “BC Contrast Min”, min = 0, max = 20000, style = “scroll bar”) BCminCon
// @int(label = “BC Contrast Max”, min = 0, max = 20000, style = “scroll bar”) BCmaxCon
// @int(label = “BG removal rolling ball radius”, value=30) RBradius

// @File (label = “Input directory”, style = “directory”) input
// @File (label = “Output directory”, style = “directory”) output
// @String (label = “File suffix”, value = “.nd2”) suffix

processFolder(input);

//to give correct count at end message:
//numFiles = 0;

// 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]);
//numFiles++;
}
}

//Works for images with 2 channels. Channel 1 = DAPI, Channel 2 = BCs (Atto565).

function processFile(input, output, file) {
// Do the processing here by adding your own code.
// Leave the print statements until things work, then remove them.

setBatchMode(true);

//this was suggested by the youtube tutorial but fucks up my LUTs: Scripting with Fiji - YouTube
//run(“Bio-Formats”, “open=[” + input + “/” + file +"] autoscale color_mode=Colorized view=Hyperstack stack_order=XYCZT");

//This variation on opening actually opens the bio-format importer, and you have to click OK after every image… so no :slight_smile:
//open(input + “/” + file);

run(“Bio-Formats”, “open=[” + input + “/” + file +"] autoscale color_mode=Default view=Hyperstack");

//save as .tif in output folder with “(BG removed)” prefix
saveAs(“Tiff”, output + “/” + " (BG removed) " +BCminCon+"-"+BCmaxCon+ file);
//Subtract background & save
run(“Subtract Background…”, “rolling=RBradius sliding stack”);
run(“Save”);

//run(“Brightness/Contrast…”);
Stack.setPosition(1, 9, 1);
setMinAndMax(DAPIminCon, DAPImaxCon);
//run(“Brightness/Contrast…”);
Stack.setPosition(2, 9, 1);
setMinAndMax(BCminCon, BCmaxCon);

// Then, create a max intensity z-projection using Images → Stacks → Z-project. Use slices 5-12 out of 17.
run(“Z Project…”, “start=5 stop=12 projection=[Max Intensity]”);

// INSERT: Save under MAX folder
File.makeDirectory(output + “/MAX/”);
saveAs(“Tiff”, output + “/MAX/” + "MAX "+ file);

// Then, set the display mode to a composite of channels 1 and 2 and create an RGB of that.
Stack.setDisplayMode(“composite”);
run(“Stack to RGB”);

//INSERT: Save under MAX/RGB foler.
File.makeDirectory(output + “/MAX/RGB/”);
saveAs(“Tiff”, output + “/MAX/RGB/” + "MAX " + "(RGB) " + file);

print("Processing: " + input + File.separator + file);
print("Saving to: " + output);
}

//print(“Done processing “+numFiles+” files!”);
print(“Done!”);
Dialog.create(“The End”);
Dialog.addMessage(“Done!”);
Dialog.show();

Here’s the error message:

Error: Undefined variable in line 12:
(called from line 12)

  processFolder ( <input> ) ; 

Please help! Thank you :slight_smile:

Cheers, Christina