Login  Register

Re: ) expected in line 20 but all parentheses are there in the code. Pls help!

Posted by Herbie on Nov 13, 2019; 6:55pm
URL: http://imagej.273.s1.nabble.com/expected-in-line-20-but-all-parentheses-are-there-in-the-code-Pls-help-tp5022674p5022677.html

Here is the code that works for me:

/////////////////////////
run("Open...");
title=getTitle()
run("Split Channels");
close(title+" (blue)");
close(title+" (green)");
title+=" (red)";
run("16-bit"); // not sure if this is reasonable
run("Duplicate..."," ");
selectImage(title+"-1");
setThreshold(51, 254);
setOption("BlackBackground", true);
run("Convert to Mask");
run("Watershed");
run("Set Measurements...", "area mean standard min limit
redirect=[title] decimal=3");
run("Analyze Particles...", "pixel show=Outlines display clear summarize");
close(title);
close(title+"-1");
exit();
/////////////////////////

"Is there a better way of doing that using automatic thresholding?"

Yes!

Run the first part of the macro, i.e.:

/////////////////////////
run("Open...");
title=getTitle()
run("Split Channels");
close(title+" (blue)");
close(title+" (green)");
title+=" (red)";
run("16-bit"); // not sure if this is reasonable
run("Duplicate..."," ");
selectImage(title+"-1");
/////////////////////////

Then go to "Image >> Adjust >> Threshold...", check "Dark background"
and choose a scheme from the left drop-down menu and look if the
threshold suits your needs. If you've found an automatic threshold that
is adequate, then exchange the macro code-line

setThreshold(51, 254);

by this line

setAutoThreshold("XXXXX dark");

where XXXXX is the name of the automatic threshold-scheme.

I'm not sure if you really need the code line:

run("16-bit");

Finally, please try to understand what your macro is doing!

Regards

Herbie

::::::::::::::::::::::::::::::::::::
Am 13.11.19 um 19:24 schrieb nhasan:

> Thank you Herbie!
>
> Just to clarify, where would i put the title+=" (red)"; ? should that be
> right above line 20?
>
> Also, thanks for the tip on the thresholding - the reason why I set the
> threshold was to be able to get a quantitative estimate of particles across
> images that fall within the thresholded area. Is there a better way of doing
> that using automatic thresholding?
>
>
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html