Hi. I am totally new to Psychopy and I am struggling to build an experiment on the Builder. I have two loops in my experiment. In the first loop three sound files are played followed by a video component. In the second loop the same three sound files are played without the video file. I would like the participants to be randomly assigned to only one of these loops. Every participant should complete only one of the loops. I don’t know any coding and I would like to do this using the features of the Builder. The experiment is not going to be online. I would be really grateful if you could help me solve the problem.
Somebody please help It is very urgent. I need help with the above problem. Thanks.
If you have two loops and you want to present one at random you could add the following in a Begin Experiment code component.
order = [0,1]
shuffle(order)
Then set the nReps for the first loop to order[0] and the second to order[1]
Thank you very much. One more question, what should my excel files look like and how many of them do I need with this solution?
One Excel file should do with a column called soundFile and a column called videoFile. The routine in one of your loops will ignore the videoFile column.
Thanks a lot. I proceeded accordingly. But on every run of the experiment only one identical loop is run. The other one is not run for any of the participants. And I keep receiving this warning: “Duplicate variable names”.
Can you share a screenshot of the code component and the two loop setting dialogues?
Sure. The following is the code component
The following are the first routine and loop.
The following are the second routine and its loop.
And finally, the following is my excel sheet (this is atrial so only three stimuli are included).
Great, thanks for the detaild post!
In the loop settings for Group_A
you set the nReps to 1 and for Group_B
to 0.
So loop Group_A
is always run once and loop Group_B
always zero times.
To fix it:
Put order[0]
in nReps for Group_A
and order[1]
for Group_B
.
Thanks. This time no one of the loops was run and the experiment :(((
sorry … and the experiment ended.
Was there any error message?
Did the experiment start or did it crash right before the start?
The experiment started and showed the first two text components (the welcome page and the instructions). It crashed just before starting the loops. There was a warning “Duplicate variable names”.
So the contents of the routine called “thanks” were not displayed?
Can you copy the entire error message? “Duplicate variable names” shouldn’t be a problem. It’s just because you import the xlsx in two loops (but that’s not an issue in this case).
Thanks. It seems there was a mismatch in my excel file. I corrected it and it worked. However, I have one more question. The loops are now shuffled and randomized but they do not appear in equal number of times. I want an equal number of participants to do each loop (e.g. 25 participants do loop 1 and 25 participants do loop 2). How do I do that?
That’s not an easy thing to do in PsychoPy internally as you would need to write to a file.
What you could do however is the following. Manually choose a group for every participant before the experiment starts. You would need to keep track of the group sizes yourself (eg. flip a coin with block randomization).
The automatic randomization is gone, though.
If this is acceptable:
Delete the code component, you don’t need it for this.
Go to experiment settings add a new field for “Experiment Info” and call it whichGroup
. As the default enter ["A", "B"]
Go to your loop settings for Group_A and for nReps enter the following: int(expInfo["whichGroup"] == "A")
. Hit Ok.
Go to your loop settings for Group_B and for nReps enter the following: int(expInfo["whichGroup"] == "B")
. Hit Ok.
Eg:
Now, when you run the Experiment you can choose the condition (loop A or loop B) yourself: