psychopy.org | Reference | Downloads | Github

Text stimuli not showing if an audio stimulus is set to FINISHED

In the instance that the participant made the correct response, I attempted to write code that would save various variables and put some text on the screen saying that they had got the answer correct:

if (key_resp_2.keys == str(corrAns)) or (key_resp_2.keys == corrAns):
   key_resp_2.corr = 1 # store that the answer was correct 
   how_many_correct += 1 # tally that the answer was correct
   how_many_goes +=1 # tally that 1 more go has taken place 
   AP_correctAns = songTitle # saves the current correct stimulus title for the purpose of on screen text..
   percent = int((how_many_correct/how_many_goes) * 100) # for the purpose of on screen text..
   audio_stimulus.stop() # stop playing the audio_stimulus                          
   if t >= 0.0 and correct_text.status == NOT_STARTED:
      correct_text.tStart = t
      correct_text.frameNStart = frameN  
      correct_text.setAutoDraw(True)
      incorrect_text.status = FINISHED
audio_feedback.status = FINISHED

However, whilst most of this code worked, correct_text never appeared on screen. On the other hand, incorrect_text, as called in the else part of the statement, appears just fine:

else:
    key_resp_2.corr = 0
#store that the response was incorrect within key_resp_2
    how_many_goes +=1
#Add one to the how_many_goes counter
    is_it_correct = ""
#Save “”  in the variable is_it_correct, so that nothing displays on screen
    AP_correctAns = songTitle
#Store songTitle, from the conditions file, in the variable AP_correctAns, for display on screen
    percent = int((how_many_correct/how_many_goes) * 100)
#Present the current percentage as a percentage (and an integer), for display on screen
    audio_stimulus.stop()
#Stop the audio_stimulus
    audio_feedback.tStart = t
#Store the current value of t as the audio_feedback tStart
    audio_feedback.frameNStart = frameN  
#Stores the frame?
    audio_feedback.play()
#The audio feedback plays
    if t >= 0.0 and incorrect_text.status == NOT_STARTED:
       incorrect_text.tStart = t
       incorrect_text.frameNStart = frameN 
       incorrect_text.setAutoDraw(True)
       correct_text.status = FINISHED

I’m presuming that’s because once the audio_feedback is playing, there is time for the incorrect_text to be presented, whereas when the audio_feedback is stopped there isn’t time for the correct_text to be presented? is there a good solution for this problem?

Try some debugging statements:

print(key_resp_2.keys)
print(type(key_resp_2.keys))

print(corrAns)
print(type(corrAns))

Thank you.

I’m correct in thinking that those debugging statements would just be to check if the if statement is working?

This bit of the code does just fine at collecting the data etc, as is evidenced by the accurate excel file and all of the on-screen stuff that this code accurately generates (it calculates the current percentage correct etc, which then appears on screen). As such, the if statement is definitely working.

The only thing that isn’t happening is correct_text appearing on screen. incorrect_text (in the else statement) displays just fine however. The only difference between the two that I can see is that audio_feedback.status is (deliberately) set to FINISHED in the former situation so that it doesn’t run when the answer is correct, whereas audio_feedback does play in the latter situation (thus giving incorrect_text a chance to appear on screen?). If this is the case then I guess I need to find a way of specifying how long correct_text should appear from? Or maybe I’m barking up the wrong tree with this?