If this template helps then use it. If not then just delete and start from scratch.
OS (e.g. Win10): Win10 PsychoPy version (e.g. 1.84.x): 2020.2.4, 64bit Standard Standalone? (y/n) Y
What are you trying to achieve?:
I want two participants to do the experiment(an attention task) at the same time and start simultaneously.
What did you try to make it work?:
The task is that first a small circle appears as a fixation point in the middle of the screen and then the participant presses the Space key and after that, cue appears on one of the four sides of the screen and then four images appear on the fours sides of screen and then in one moment, the brightness of one of the images changes, and if the participant detects it, he/she presses the Right key on the keyboard (in 80% of cases, the cued image brightness changes).
Now I want the two participants to do this experiment at the same time so that in half of the cases the changes in one image happened to both (the same trial) and in half the cases the changes in different images happened.
What specifically went wrong when you tried that?:
The experiment should start when both people have pressed the Space button. Do I need to use two different keyboards and screens(window) for participants to do this experiment?
Since I am a beginner in Python, can this be done in a builder environment?
Before we go further here, can I check that you do not intend to run this online? PsychoJS/Pavlovia cannot currently accommodate ādual playerā type set ups.
If it is the case that you wish to run this locally, you will need to monitor 2 keyboard devices for keyboard events and then move on once space has been pressed on each of them. The first step here will be to distinguish between different keyboard devices, may I recommend taking a look at the documentation here Keyboard ā PsychoPy v2021.1 on getKeyboards() which might help you in the right direction.
As a further point, I notice that youa re running 2020.2.4, could I recommend an upgrade since lotās of bugs will have been ironed out since then, and that will make task creation much smoother!
Hi Becca,
thanks so much for your response.
As far as I understand unfortunately it is not possible to define two keyboards (device) in an experiment in Windows and I must use another system.
Now I have another question, I put two keyboard component by the name of a_resp and b_resp each for a subject and I used this code at the End Routine to start the task when both pressed āspaceā but it doesnāt work.
I sought similar problems which happened for others like this but all of them where about getting two correct answer from a keyboard(response component).
Do you or anyone have an idea to solve this problem?
In the past Iāve used an external USB number pad which acts like an additional mini keyboard. Could one participant be using the main keyboard and the other using something like that? Alternatively, could you simply define different keys for the participants to use on two standard keyboards?
Hi Becca,
I hope you are well.
With your help and @wakecarter , my previous problem was fortunately solved and now I can use two keyboards, so that two keys are defined to start the task(āyā and ānā), one of which is pressed by the first subject(for example, āyā) and the other by the second subject(ānā).
But the problem I have now is that, for example, when the first subject finishes its trial sooner and presses its own button quickly(āyā), while the second subject has not yet answered itself and is in the previous trial, and when it responds and Enters the new trial and presses its own button(ānā), the new trial starts for the first subject but does not start for the second subject until the start button of the first subject(āyā) is pressed again.
Can you help me solve this problem?
Hi Becca,
thanks for the quick reply.
I did everything you said, but unfortunately I still have the same problem. My problem is that when the first subject finishes its trial sooner than the second subject and hits the key(āyā). This key does not record for the second subject, which is still in the previous trial, and practically when the second subject finishes its own trial and he hits ānā, the next trial starts for the first subject but not for the second subject! How can I call the answer of the first subject that was given before the end of the second subject trial for the next trial of the second subject ?
It looks like you have two separate PsychoPy tasks that are not connected here - should both tasks not be launched from the same builder (.psyexp) file?
Hi Becca,
In fact, the content of these two tasks is almost the same. The goal of duplicating a task is that because one of the subjects may respond sooner, his or her trial will end sooner. Our main problem is that we want the two subjects to start together each trial.
Thanks,
Fazel
In that case, I am afraid that there is currently no direct way for one experiment to wait for the other experiment - as the two are not connected. You could try using python to export a .csv file as soon as something is clicked on one computer and then continuously check how many .csv files there are in a subfolder in each script, and as soon as both detect there are 2 files then they start the next routine together.
In python you can check how many .csv files there are in a folder using:
# note this will only work locally not online (glob is a python package)
import glob
filenames = glob.glob("data/*.csv")
participantCount = len(filenames)
And to export a .csv file you can use
import csv
# A list to write to csv - will have one col with header key pressed, and one row with value 1
myList = [{'key presses':1}]
keys = myList[0].keys()
# open a new csv file and write to it
with open('conditions.csv', 'w', newline='') as output_file:
dict_writer = csv.DictWriter(output_file, keys)
dict_writer.writeheader()
dict_writer.writerows(myList)
You would need to have the second snippet of code in the end routine tab of the routine where the key is pressed, then you would need to have a routine with a code component something like:
participantCount = len(glob.glob("data/*.csv"))
while participantCount < 2:
participantCount = len(glob.glob("data/*.csv"))
I havenāt tried this but hopefully it could be one solution.
Becca
Hi Becca,
Thank you for your help, but since Iām not good at Python, do you or anyone else have a different solution?
For example, can I get the answer of the first/second subject(āyā/ānā) that is hit earlier by placing the keyboard component in the task of the second/first subject and save it in a variable and move it to the next trial of the second/first subject?