psychopy.org | Reference | Downloads | Github

Reward based on criterion and RT

Hello,

I am building a Visual Search task and want participants to get reward (receive a specific number of points) and visually see feedback on every trial only if:

a) they reply with a correct response. This is something i have already done using the following code:

if trial_resp_2.corr:
msg = “Correct!”
msgColor = “green”
else:
msg = “Oops! That was wrong.”
msgColor = “red”

b) but also reply within 0.8 seconds of the stimuli presentation. So how can I add this element in the above code?

BOTH of these conditions need to be met so that participants will receive the reward and be provided with the “Correct!” screen.

thank you

You can embed a second if loop for RT inside the if correct loop:

if trial_resp_2.corr:
    if trial_resp_2.time <= .8: #this is if they're responding with a mouse. If it's a key, it would be trial_resp_2.rt
        msg = “Correct!”
        msgColor = “green”
    else:
        msg = “Oops! That was wrong.”
        msgColor = “red”
else:
    msg = “Oops! That was wrong.”
    msgColor = “red”

great thank you! it works perfectly. Now I want to give points to participants depending on which trial they are at. So for example if they are correct (i.e. rt below 0.8seconds and correctly identify the target) in a high reward trial they will get 7 points, if they are correct in a middle reward trial they will get 2 points and if they are correct in a low reward trial they will get 1 point. And the different trials are difined in an excel file as follows: Screen Shot 2021-09-03 at 09.57.44

How can i do that?
Thank you again for your help.

The points each participant received need to be stored in a variable which I can then both print in my output file but also use to to present to the participants their total number of points earned at the end of each block.

You would just have to make an if statement that checks for the trial type. I did something similar in this experiment, where I gave a different number of points depending on which of two tasks they answered correct. So it’s not exactly what you’re trying to do, but it will help you with the general format to give a certain amount of points for different conditions. I also have a variable trialScore that shows the number of points for that trial and grandScore that sums the scores as you go along, and I print them to the data sheet at the end of each trial… You can download the PsychoPy experiment and look at the code in the ‘resultsPage’ routine. Let me know if you have questions!

Thank you for your reply. I tried to press the link you sent and I get this notification:

No information available for this experiment: it may not exist or you may not have access to it.

it seems like I am not able to access it. Can you send me the parts of the code instead or if there is a way to give me access?

Thanks again

Sorry, try again

Sorry but I still get the same notification :confused:

I have created a for loop for each trial type but it does does not seem to work properly:


Screen Shot 2021-09-03 at 17.12.19

This is added in the ‘begin routine’ of the feedback routine.

You have to be logged in to GitLab to see it. Also note that all of my code components are written in javascript, so it will look slightly different but the general format is the same. What issue are you having?

I think I have fixed that. But now i want instead of presenting text messages if participants are rewarded, to present images. I have those images saved in the path of the experiment. how can I insert an image in a for loop?

Thank you