Trial feedback for double response

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:!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

Thanks @jon

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.

Hi @jon

I should have responded addressing your questions:

  • some of the keys are correct? Is that OK? - no, both keys need to be pressed to be deemed correct
  • what if all the answers are there but in wrong order, does that matter? - yes, they have to be in the correct order
  • what if all the answers are there, and in right order, but more added as well? - this is fine

I’ve tried addressing this issue further by having a $corrAns1 and a $corrAns2 but this didn’t seem to work.

If you have anything you could point me towards I’d be very grateful.

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
    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]:

Thanks so much Jon - that has worked perfectly!

Hi Jon,

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
    DualResponse.corr = 0

And this code into the ‘End Routine’ section:

dual_trials.addData('DualResponse.corr', DualResponse.corr)

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.

Dual task routine and keyboard settings:

Never mind! I moved all the code to ‘End Routine’ and it works perfectly :slight_smile:

Hi Jon,

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.

Hope you can help me and thank you in advance.