Correct Responses reset at the end of the routine

OS Win7
PsychoPy version 1.84)
Standard Standalone? y

In the attached exp, in the component Test within the routine trials_3 the keyboard responses are getting reset to 0 (as it appears in the data file). In other words, the key_resp_8.corr appears always as zero even when the correct responses are given.

In the attached script of the same exp in lines 1082 - 1084 the responses key_resp_8.corr appear to be recorded just fine (using print) but then at lines 1114-1117 they get reset to 0.
I have a vague understanding of what the following code does (it inserts itself in my exp) but I have no idea why it resets the responses.

        key_resp_8.keys=None
        # was no response the correct answer?!
        if str(correctAns).lower() == 'none':
           key_resp_8.corr = 1  # correct non-response
        else:
           key_resp_8.corr = 0```

I was able to circumvent the problem by saving the  responses to a new variable and add it to my data but still I don't think this is how it should work.

Can anybody advise/help?

Thanks in advance

<a class="attachment" href="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/psychopy/original/1X/60dd3d7722677b29b675b267097428058680aeb5.psyexp">Session1.psyexp</a> (42.6 KB)
<a class="attachment" href="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/business7/uploads/psychopy/original/1X/9388f6430bfcad0b865827f98b575b249ba6f6cc.py">Session1.py</a> (46.6 KB)

Hi Yiannis,

This is good troubleshooting so far, although things are still puzzling. The problem is, the code you posted above shouldn’t get executed if a valid key press has been made. i.e. if either z or m was pressed, then by definition

key_resp_8.keys is not in ['', [], None]

You should be able to verify this by inserting a print statement within that check, e.g.

if key_resp_8.keys in ['', [], None]: # No response was made
    print('no key was pressed')
    key_resp_8.keys=None
    # was no response the correct answer?!
    if str(correctAns).lower() == 'none':
        key_resp_8.corr = 1 # correct non-response
    else:
        key_resp_8.corr = 0

Re-insert your other print statement near line 1082. One, and only one, of those statements should be printed on every trial. Hopefully that will help you narrow things down further.

Hi Michael,

I have upgraded psychopy from 1.84.1 to 1.84.2 and it seems that it has fixed the problem for now (I should have done this first before posting). Many thanks for your time and your suggestion, it’s appreciated.