Script_parameters

Hi ImageJ-ists,

Recently I tried to use the Script_parameters and I have two questions :

  • regarding the use of “choices” :
    // @String(label="string",choices={}) varChoice
    I would like to use the list returned by getList(), for example getList("threshold.methods") or getList("LUTS").
    the only workaround I found is to create a list of some threshold
    // @String(label="What Threshold to use?",choices={"Default","Huang","IsoData","Triangle"}) thresholdChoiceCh
    but it’s definitely not ideal.

  • could it be compatible with macro installation and using shortcuts:

// @String(label="a string", value=test) string
// @Integer(label="a number",value=1) nbr
print(string+","+nbr);

but neither

// @String(label="a string", value=test) string
// @Integer(label="a number",value=1) nbr
macro "Macro to test Parameters [F1]"{
   print(string+","+nbr);
}

nor

macro "Macro to test Parameters [F1]"{
// @String(label="a string", value=test) string
// @Integer(label="a number",value=1) nbr
print(string+","+nbr);
}

works !

Thank you for your inputs,

Cheers,

Romain

1 Like

Hi Romain,

regarding you first question: The script parameters are evaluated in Java, before the script runs. Therefore it is not possible to use functions from inside the script. Using Parameters in Java gives you more options (e.g. callbacks), but I don’t know if it’s possible to fill the choices by a function. If I found the correct implementation it does only support String[].

Hi all,

Would this not call for the Script Parameters themselves to be able to handle this particular case through a new @Notation for them?
Something like:
// @Threshold(label="What Threshold to use?")

Asking for a threshold method from ImageJ is a very common need, and getList("threshold.methods") is very useful for populating that kind of list.

3 Likes

That’s a neat idea! I have opened a GitHub issue on the topic! This was, by the way, possible in pre-Ops versions of ImageJ2.

2 Likes