JIPipe Help

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 button next to the parameter and select Make parameter adaptive.

Screenshot

The parameter editor will be changed to an expression editor:

Screenshot

Removing adaptive parameters

To make a parameter static again, click the Button button next to the parameter and select Make parameter static.

Screenshot

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

default

, 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.

Parameter explorer

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.

Screenshot

The parameter explorer reveals that the parameter is complex due to the JSON code involving objects or lists.

Screenshot

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.

{"content":"THIS WILL BE CHANGED", "enabled": true}

The JIPipe expression code that generates this text will fill the content with the value of an annotation MyAnnotation:

"{"content\":\"" + MyAnnotation + "\", \"enabled\": true}"

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:

TO_JSON( MAP( PAIR("content", MyAnnotation), PAIR("enabled", true)) )

This will create a Java dictionary (map) that contains two key-value pairs (entries) content and enabled. Those are then converted into JSON code.

Last modified: 09 October 2024