How to randomize the stimulus position across the trials


WIndow 10, PsychoPy version 1.82.01


Hi everyone,

I’m trying to design an experiment in which participants are asked to choose the answer after seeing a statement like a multiple choice task. A stimulus is present until they press the key corresponding to the answer.

There are three options as possible answers for each question, and I want to shuffle the position of items in each trial. The three items correspond to the three columns in condition file (ansA, ansB, ansC)

For doing this, I specified the position and the button to be pressed by using Text and Code component. Here is the screenshot for your understanding:

image

In each Text component, I put the position as positions.pop () in the location field and the variable $ansA in the text field, all by set every repeat.

And for the Code component, I insert some codes like:
In Begin Experiment,

key_to_x = {‘z’:-0.6, ‘v’:0, ‘m’:0.6}

In Begin Routine,

positions = [[-0.6,0],[0,0],[0.6,0]]
shuffle(positions)    # randomize the order on each trial

#Store the x coordinate of each stimulus:
thisExp.addData('text_trial_ansA_x', text_trial_ansA.pos[0])
thisExp.addData('text_trial_ansB_x', text_trial_ansB.pos[0])
thisExp.addData('text_trial_ansC_x', text_trial_ansC.pos[0])

# Indicate the x coordinate of the chosen stimulus:
thisExp.addData('chosen_x', key_to_x[Choice.keys[0])

The problem is that the builder doesn’t run; even any error message is not generated.

I’m not pretty sure, but is it because there is a crash between code components (one of them is used for a cumulative presentation of items across trials, but there is no string used in Begin Experiment field)? or maybe because of other problems that I haven’t thought of…?

Thank you all in advance for your help!

That makes it very difficult for us to speculate what the issue might be. If problems with code were preventing the experiment from running, they would generate error messages.

Since we can’t speculate what the problem is, you’ll need to try and narrow it down. e.g. save a copy of your experiment and remove elements that might be causing the issue until you can get it to run.