Hi Yasmine,
My apologies. The “no more items left to draw” message was due to an error on my part in the original example experiment. To resolve the issue, you need to make two changes.
First, in the definition of image_index
, add the parameter advance_on_accept with value YES
:
selection image_index (
values = 0 : image_set_size - 1
selection = random_without_replacement
advance_on_accept = YES // This is the line to add
)
Second, in the state “Stim on”, replace
next_selection (image_index)
with
if (images_shown > 0) {
next_selection (image_index)
}
I’ve attached a copy of your experiment file that includes these changes. With this version, you should no longer see the error message.
As for why these changes are necessary: Selection variables are confusing (even to me), because sometimes they advance automatically to the next selection, and sometimes they don’t. Specifically:
-
reset_selections does not automatically make a next selection. Immediately after being reset, a selection variable is in the “no selection” state. To make an initial selection, you have to either (1) invoke next_selection explicitly or (2) just use the variable, as asking for the value of a selection variable in the “no selection” state causes a selection to be made automatically for you. Personally, while I think (1) is totally reasonable and expected, (2) is not so expected and a little unnerving. However, it doesn’t really matter in practice, because in both cases, you end up making one, initial selection.
-
By default, accept_selections also does not make a next selection. However, unlike reset_selections, accept_selections doesn’t cause the selection variable to enter the “no selection” state. Rather, it leaves the current, just-accepted selection in place. You can alter this behavior by setting advance_on_accept to YES
, in which case accept_selections does make a next selection.
-
Finally, reject_selections always makes a next selection.
When writing the example for you, I forgot that reject_selections makes a next selection. This meant that, when a trial failed before the current image set repetition was complete, the selection variable was advanced twice when it should have been advanced only once: implicitly by reject_selections, and explicitly by the next_selection invocation in state “Stim on”. This resulted in the first of those two selections (i.e. images) never being used, and it caused the next trial to “consume” more than images_per_trial
images, which in turn led to later trials running out, hence the “no more items left to draw” error. The changes I outlined above fix the problem by
- making both accept_selections and reject_selections automatically make a next selection and
- explicitly invoking next_selection only when not at the beginning of a trial.
If you think this all sounds ridiculous and highly conducive to errors, I agree! I didn’t implement selection variables, and if I could re-make them from scratch, they would never implicitly make a next selection. However, I can’t change their behavior now, because doing so would break the many, many experiments that are designed around and depend on the existing behavior. I suppose I could make a new, alternative selection variable that behaves in ways that I find sensible, but that might just muddy the waters further.
If you have any suggestions for how to improve this situation, please let me know! In the meantime, the changes I described should make the selection-variable bits of your experiment work correctly.
Cheers,
Chris