Macro Help ; expected ')' in line

Hello everyone !

I’m kind of a beginner for creatinf macro.

I’m currently creating one with FIJI to count the number of nuclei, and the mean intensity of each nucleus. So far it was ok, but when I redirect the data (set mesurement) an error message saying “expected ‘)’ in line 24” appear and I cannot find what is wrong.

If annyone can figure this out it will be great !

Here my current macro :


//================Get image information=================//

getDimensions(width, height, channels, slices, frames);

path = getDirectory(“image”);
t = getTitle;

//=============Filter, Threshold and SPLIT===============//

run(“Median…”, “radius=1 stack”);
setOption(“BlackBackground”, false);
run(“Convert to Mask”, “method=Minimum background=Light only”);
run(“Watershed”, “slice”);
run(“Split Channels”);


run(“Set Measurements…”, “area mean min redirect=[“C2-”+t], decimal=3”);

selectWindow(“C1-”+ t);
run(“Analyze Particles…”, “size=50-Infinity display summarize slice”)

Thank you so much in advance.

Below a screenshot of the parsed source. You see at line 23 that you included wrong string concatenation of a variable.

If you want to include the variable prefix you have to concatenate it ,e.g., like this:

run("Set Measurements…", "area mean min redirect=[C2-"+t+"], decimal=3");

1 Like

It’s working, Thanks a lot !

But I don’t understand ont thing; if in the line 23 “C2-”+t isn’t working, why did it work in line 25 with :
selectedWindow( “C1-”+t);

In both method calls strings are expected. In the run method the second argument has to be a string, too which needs to be concatenated with the variable ‘t’ and then with the rest to be parsed as one string.