What are you trying to achieve?:
I have 3 trial types:
Single - participants make 1 key response
Double - participants make 2 key responses
Stop - participants withhold all key responses
For each trial type I want to give participants feedback during practice.
I have managed to do this for the single and stop trials, but it is not working for the double trials.
What did you try to make it work?:
For the double trials I couldn’t find any guidance so just tried typing 2 keys on the .csv file but I feel like this may need to be done in code?
I did find the following but it confused me a little as I don’t want my key presses to force the end of the routine: https://groups.google.com/forum/#!topic/psychopy-users/eZfR77Bn8vA
Yes, the first step is not to force end routine on a keypress. The second step is to compare with what you consider the right answer. The issue is that this is ambiguous. If there are several answers what happens if:
some of the keys are correct? Is that OK?
what if all the answers are there but in wrong order, does that matter?
what if all the answers are there, and in right order, but more added as well?
You’d need a code component (like the components in the feedback routine of extended stroop) to test yoru conditions
I already have code for the single and stop trials based on what is stored as $corrAns in my .csv files, and they work perfectly because there is only 1 correct button press.
The issue I’m having here is that for the double trials, participants have to press 2 keys, and they need to press both (no exceptions as it’s a very simple response) in order to receive correct feedback.
So while I have the code in place, I can’t seem to find a way of storing both the keys in the $corrAns section.
If you have two columns key1 and key2 then you could have a code component that says:
if nameOfKeyboard.keys and nameOfKeyboard.keys==[key1, key2]:
nameOfKeyboard.corr = True
else:
nameOfKeyboard.corr = False
The issue I was pointing to earlier is just that the simple graphical rule isn’t applied here because it’s ambiguous what should be considered ‘correct’. The rule above is a strict version of ‘correct’ in that participants adding additional keys would be considered wrong
.
A slight change to the if statement would allow you to base the decision just on the first 2 key presses ( so further presses didn’t matter):
if nameOfKeyboard.keys and nameOfKeyboard.keys[:2] == [key1, key2]:
...
My experiment involves dual task trials, where participants respond to two stimuli at the same time using two different response keys. My conditions file has two columns for the correct responses, labelled CorrectAns1 and CorrectAns2. In my case, the order the keys are pressed doesn’t matter as long as they are both correct. I have inserted this code into the ‘Begin Routine’ section:
if DualResponse.keys and DualResponse.keys[:2] == [CorrectAns1, CorrectAns2] or DualResponse.keys[:2] == [CorrectAns2, CorrectAns1]: # order keys pressed doesn't matter
DualResponse.corr = 1
else:
DualResponse.corr = 0
However, all responses are logged as 0, even if they are correct. Is there an issue with the code or the placement of the code? If you could point me in the right direction it would be much appreciated.
if I wanted to transform this code into java script how would it look like? I just started to learn python but need java script for an online experiment.