Adaptive parameters
Adaptive parameters allow to dynamically calculate the parameter values using an expression, even if the parameter itself is not expression-based. The feature is for example useful, if you want to set the radius of a median filter based on a precalculated value stored within annotations.
Creating an adaptive parameter
To make a parameter adaptive, click the button next to the parameter and select Make parameter adaptive.
The parameter editor will be changed to an expression editor:
Removing adaptive parameters
To make a parameter static again, click the button next to the parameter and select Make parameter static.
Editing adaptive parameters
Adaptive parameters are parameters that are generated just before the workload is executed. They are generated after external parameters are obtained, meaning that you can override/modify those. Adaptive parameters are also applied per iteration step and thus can be generated from annotations.
By default, the expression provided by the adaptive parameter editor is
, where default
is always assigned to the current static parameter value or the value obtained from external parameters.
For simple parameter types, including booleans, numbers, and text, you can just type in or generate the value:
Parameter type | Examples |
---|---|
Text |
"This is a text"
#LoadTextFromAnnotation
#FirstAnnotationValue + "_" + #OtherAnnotationValue
|
Numbers |
42
NUM(SomeAnnotation)
MAX(NUM(SomeAnnotation), 42)
|
Booleans |
true
#SomeAnnotation == "the value"
#SomeAnnotation == "the value" OR OtherAnnotation == "other value"
|
The JIPipe parameter system supports a wide variety of different parameter types that cannot always be represented as simple numbers, text, or booleans. To generate an appropriate adaptive parameter value for more complex types, you will need to generate JSON code in the format expected by the parameter type.
To learn about the required JSON syntax for a parameter, we recommend to use the Parameter explorer window that can be opened by right-clicking the node and selecting Explore parameters. Here you can select the parameter of interest and use the Value tester to find out which JSON code corresponds to which value.
Based on the knowledge gained from the parameter explorer, adapt the adaptive parameter expression to generate anb appropriate JSON string.
Example
In this example, we want to make the parameter Threshold annotation of the Auto threshold 2D node adaptive.
The parameter explorer reveals that the parameter is complex due to the JSON code involving objects or lists.
In this example, we want to determine the written annotation name via an adaptive parameter. Additionally, we enable the generation of a threshold annotation by setting the value of enabled
to true
.
The JIPipe expression code that generates this text will fill the content
with the value of an annotation MyAnnotation
:
As you can see, the code may be hard to read due to the required escaping of quotation marks. Thus, it may be more convenient to instead use the expression language's functions for creating JSON data:
This will create a Java dictionary (map) that contains two key-value pairs (entries) content
and enabled
. Those are then converted into JSON code.