Selection Variable Issue

Hello Chris,

I have an mwel script where I need to generate a variable [signal_pool_indicies] from a range of integers. I am doing so by using the selection variable.
However, I want my range of integers to be adjustable throughout the duration of the task, so I assigned a [low_pool] variable and a [high_pool] variable.

I used the low and high variables in the values parameter of my selection variable [signal_pool_indicies] hoping that I could change the range of integers that was being drawn in real time as the program was running. However I noticed that that was not the case and integers outside of the [low_pool] and [high_pool] range were being drawn. Eg. [low_pool = 7] and [high_pool = 14], however numbers less than 7 are still being drawn.

I have included a screenshot of the portion of code I am referring to.
Does the values parameter not allow for variables in the range expression?

Best,
Tiffany
Screen Shot 2023-12-20 at 3.11.20 PM

Hi Tiffany,

A selection variable’s set of values is fixed when the experiment loads, so changes made to low_pool and high_pool while the experiment is running won’t change the values used by signal_pool_indicies.

If you know all the ranges you want to use ahead of time, you could create a separate selection variable for each range. Alternatively, if you fix the maximum range at experiment load time, you can manually reject values that lie outside the dynamic range when invoking next_selection, e.g.

next_selection (signal_pool_indicies)
while (signal_pool_indicies < low_pool or signal_pool_indicies > high_pool) {
    next_selection (signal_pool_indicies)
}

If you want to get fancy, you could drop the selection variable and use Python actions to generate and draw from the list of values.

Cheers,
Chris

1 Like