How to interpret no response and distiguish them from a wrong response for triggers

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Ubuntu 20.04
PsychoPy version (e.g. 1.84.x): PsychoPy 2022.2.4
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:

have an experiment where possible response to provide are:

1) correct
2) not correct
3) no response

and encode them as a specific triggers

What did you try to make it work?:

I have used the following code to encode specific responses:

if responded == 1:
    if(trial_resp.keys == str(corrAns)) or (trial_resp.keys == corrAns):
           trial_resp.corr = 1
    elif (trial_resp.keys != str(corrAns)) or (trial_resp.keys != corrAns): 
           trial_resp.corr = 0

and the following chunk of for encoding triggers

if responded == 1 and trial_resp.corr == 1:
   ccc = 'corr'
   port.writeRegister(FIO1,65280+ int(block_nr)+4)

elif responded == 1 and trial_resp.corr == 0:        
   ccc = 'inco'
   port.writeRegister(FIO1,65280+ int(block_nr)+5)  

elif responded == 0:   
    ccc = 'noresp'
    port.writeRegister(FIO1,65280+ int(block_nr)+6)

What specifically went wrong when you tried that?:

with this code I am able to distinguish only correct response while incorrect and no response are coded as the same.

Does anyone have any suggestion? Thanks
Include pasted full error message if possible. “That didn’t work” is not enough information.

Hello Airt78

did you define the correct answer somewhere? I guess so because you use corrAns in our if-construction. In this case you could simplify your if-construction. trial_resp.corr contains 1 or 0 for correct or incorrect answers. It evaluates to true or false in an if-construction depending on your corrAns.

if trials_resp.corr:
 ....

You can also check key_resp.keys. If your participants did not answer, key_resp.keys evaluates in an if-construction to false. So combing everything it boils down to

if key_resp.keys:
    if key_resp.corr:
        msg = "correct"
    else:
        msg = "wrong"
else:
    msg = "no answer"

You could add your triggers and code to the appropriate branch of the if-construction.

In the example I used the “standard” name PsychoPy comes up with when using the keyboard-component. You need to adapt that to your component-names.

Bets wishes Jens

1 Like

I was going to ask a similar question. Your issue might be with the value of responded.

You can check with print(‘responded’,responded)

Also, you are using elif with no else conditions. If responded is supposed to be 1 or 0 then you can use else: instead of elif responded == 0: (which would mean that your code would work if responded was, for example, switching between 1 and undefined)

@JensBoelte Thank you. Possibly I will think to readapt your code to the one I am using.

@wakecarter Thanbk you. I guess I’’ try a the way that you suggested too. I was also wondering whether by specifying better the difference from correct responses conditions (!= corrAns) - possibly by adding an and statement such as and trial_resp.keys == None in one of the statements of the if-loop, this might make work everything.

Thanks

Hello,

I would use

trial_resp.keys is None

Best wishes Jens