Outcome of trial routine won't show

OS (e.g. Win10): Windows 10
PsychoPy version (e.g. 2024.2.4 Py 3.8): Py v2023.2.3
Standard Standalone Installation? (y/n) Y
To note: This study will not only be run locally in the lab and not online.

What are you trying to achieve?:

I have a routine called show_feedback which I want to be able to show either the message ‘congrautlations’ or ‘bad luck’ depending on how the participant has performed in the trial.

What did you try to make it work?:

I have a trial routine set up which has a dynamic rectangle component in it. This acts as a gauge so as someon makes effort in the trial it records the amount of effort made. I have a polygon set up (and working well) to dynamically adjust to the effort made. I can also see in the data output that correct is being stored as 0/1 correctly. So the issue is how I get the next routine to show based on the correct outcome.

Here is the code from Each Frame:

rectangle_color = ''

if latest_raw_value != '':
    effort_level_txt.text = latest_raw_value
    effort_percent = float(latest_raw_value.strip('%'))

    #scale the height of the rectangle 
    rect_height = 0.2 * (effort_percent / 100)

    #change the colour of the rectangle based on the effort
    if effort_percent < 80:
        correct = 0
        rectangle_colour = 'red'
    else:
        rectangle_colour = 'grreen'
        correct = 1

else:
    #show a default reference value and treat as incorrect
    effort_level_txt.text = 'Waiting for effort...'
    rectangle_colour = 'red'
    rect_height = 0
    correct = 0

thisExp.addData('correct', correct)
thisExp.addData('effort_percent', effort_percent)

In my End Routine tab I have:

final_outcome = correct
print(final_outcome)
thisExp.addData('final_outcome', final_outcome)

Then in my next routine where I want to show the outcome (congratulations or bad luck message) I have.

Begin Experiment tab

msg =''

Begin Routine tab

show_rate = 0 
if condition == 'Money' and correct == 1:
    message = 'Congratulations'
    text_color = 'lime'

elif condition == 'Trivia' and correct == 1:
    show_rate = 1
    msg = 'Congratulations'
    text_colour = 'lime'
    message = msg + '\n' + this_answer

else:
    message = 'Bad luck!'
    text_colour = 'red'

I think the issue might be something to do with the final_outcome = correct variable at the end of the trial i.e., it’s not enabling the next routine to show the reward. At the moment the rectangle displays as needed, the trials loop through as needed but the reward outcome (congrats or bad luck) do not display at all so something is making this routine effectively be skipped over.

Grateful for any thoughts!

Hello @Charlotte1

So, you don’t even see “Bad Luck” in red? Did you set the text of the text-component to update on every repeat?

Best wishes Jens

Hi @JensBoelte ,

Yes that is correct. The routine does not show at all. I wonder if it is something to do with the correct variable being declared as a local variable and therefore not available to be used in the following show_reward routine.

I’ve been playing around with that idea to try and get the variable to be global without breaking my dynamic gauge but so far no luck.

Thanks for taking the time to read and ponder this!

Charlotte

Hi there - I’ve resolved this. I have a 2.0 second ‘core.wait’ command in my script which essentially meant that the routine was waiting rather than presenting. All now resolved. :slight_smile: