0
votes

I turn to you all after many hours and visiting lots of websites and tutorials. I need to apply a radial polynomial function to a circular roi. The parameters for the polynomial are calculated for each image elsewhere in my imagej macro.

I have tried process>math>macro and the plugin "Expression" by Ditmer, but I cannot get the syntax correct to pass the variables. Clearly, I am not finding something about passing parameters, despite using & and even full concatenation. In particular, I cannot find an example of Expression being used in macro mode to get the syntax of its arguments.

Here is a sample of code that runs on a single open image:

run("32-bit");
rename("working");
//setTool("oval");
makeOval(30, 37, 444, 444);
p0=1.31061     
p1=-0.0023456;
p2=-0.000017459;
selectWindow("working");
//run("Macro...", "code=v=v*(1.31061-0.0023456*d-0.00001745*pow(d,2))");
//run("Macro...", "code=v=v*(&p0+&p1*d+&p2*pow(d,2))");
//run("Expression ", "preset='Radial_cutdown'");
//run("Expression ", "preset='Radial_cutdown_parampass'");

The first run command works. The second does not.

The third uses Ditmer's Expression plugin with the preset code as follows:

i*(1.31061-0.0023456*d-0.00001745*d*d)
0
0
0
maxval
0
0
0
w
h
0
100

This also works. However a preset containing the macro parameters instead of numbers does not:

Radial_cutdown_parampass
i*(&p0+&p1*d+&p2*d*d)
0
0
0
maxval
0
0
0
w
h
0
100

I apologize for asking what should be a simple question, but I admit to being stumped.

1
If you've spent hours searching, I'm sure you also have come across the ImageJ mailing list, which is usually the best place to ask and also to report bugs (since if something doesn't work as you expect it to work from tutorials, that might also be a bug..). - Jan Eglinger

1 Answers

1
votes

Use String concatenation syntax:

run("Macro...", "code=v=v*(" + p0 + "+" + p1 + "*d+" + p2 + "*pow(d,2))");