Setting conditions file via an if statement

URL of experiment: Pavlovia


In my experiment, the participants see two present boxes. They have to click one of the present boxes as soon as the response cue (’?’) is visible. The correct box that they should have chosen is then shown in the centre of the screen after a brief delay. The first 20 trials form a stable condition. During those trials, there is a fixed 75% chance of one of the present box colours being the correct choice. After that, the volatile condition begins. In the volatile condition, two changes happen. First, the probabilities change to 80% and 20%. Second, the probability that each box colour is the correct choice switches every 20 trials. So for example, on trials 21-41, red box could have an 80% chance of being correct (blue=20% chance). Then, on the next 20 trials, blue box would have a 80% chance of being correct (red=20% chance).

The problem

This is a video of the experiment running online (no issues offline). Trials 17-20 run as intended. However, after trial 20 (0:28 on video), the screen goes black. After trial 21 (0:43), a grey screen is seen. Then on trial 22 (and every subsequent trial), the fixation cross, response cue, mask stimuli (‘XX’) are not visible. Also, a warning message should show when the participant doesn’t respond within 4 seconds of the response cue onset. I didn’t respond on trial 23, to see if the message was still working, and as you can see by the black screen (1:01) between trial 23 and trial 24, the warning message is also not visible!

The flow, code and builder components

Screenshot 2020-09-17 at 11.28.19

I use a different excel file to make each probability. For example, one excel file will have a 75% probability of red box being correct. Then when the condition changes, I use a different excel file to make the probabilities change to (for example) 80%=blue, 20%=red. The code to set the conditions file is in ‘condSelecter’. This routine only contains the one code component used to set the conditions file.
The name of ‘stable’ is misleading. This routine is actually my main trial routine and is used for all the conditions, not just the stable condition.

Screenshot 2020-09-17 at 11.28.45

In the trials_2 loop, no conditions file is set, instead, I ask it to loop 5 times as to make it pick an excel file 5 times (switch probabilities 5 times).

Screenshot 2020-09-17 at 11.28.53

In the trials loop, the conditions file is set via a variable (the value of this variable is set in the condSelecter routine). Each excel file has 20 trials, so I only set this loop to loop once.

This is the code component within the condSelecter routine. In the Begin Experiment tab, I use a line of code to randomly set the stableShape to be 1 or 2. The purpose of this is to randomly set either blue box to = 75% chance in the stable condition (given by the excel file, ‘stableImagesB.xlsx’) or red = 75% (‘stableImagesR.xlsx’). The other conditions files (e.g. ‘volatileRed’) are used in the volatile condition and refer to instances where the named colour has an 80% chance of being correct (so in volatileRed, red -80% chance). trialsDone is a variable that’s value increases by one at the End of every main trial (stable routine).

I suspect the issue is to do with the conditions file changing between blocks/switches?
It’s really odd that the fixation cross, etc just isn’t showing up, even though the image files are! (The image files are set by the conditions file, so the files are definitely being read in properly).

Thank you for reading and for any help that you can give!

1 Like

As I recall, for online experiments, all condition files are loaded once at the start of the experiment, so attempting to change them mid-experiment just doesn’t work on Pavlovia. I suspect if you look at the JS console during your experiment (command-option-J on Chrome for Mac), you will see that it’s throwing an error about not being able to load the condition file. If you want it to change responsively like this, you may need to have it manually set the relevant variables in your code rather than referencing a condition file.