Code for Fixation cross

I need help for writing a code to change Fixation cross color for flanker experiment. I am trying to do change the color of cross based on the answer (until the answer it should be white) for ex. when participant press a key, if participant gives correct answer it should turn out green, then turn white again but if the answer wrong it should be turn red then again white. But I have an issue here because it is staying red all the time. I’m missing out somethings. any ideas?

Hello,
Can you please provide what you have been trying to do so far?

Thanks,
Chen

Well, I’m trying to do change a fixation cross’ color. I added fix.cross by using polygon component and I want to write a code for changing the color of this cross. This cross should be white at the first while waiting for the answer. When answer comes it should turn red or green based on the answer if its wrong it would be red, if its correct it would be green. And I have a problem right here. Do you have any suggestions?

Hello yongbok

the easiest way is probably to have two routines. One for the flanker stimulus and the response and one for the feedback with the fixation-cross that turns green or red depending on the correctness of the answer.

Best wishes Jens

Create two objects with different timings so the feedback one starts and the white one ends upon response (or whatever your trigger is). And you can set the color using a code block checking the response outcome (e.g. If respect.corr: color=green etc)

Thanks for your reply. I actually did your idea but the problem here is with code I cannot write that necessary code for change the color. Firstly I need a code like while true or something like that like a loop (apologies for that because i’m lack of information about coding) but when I tried that the app didn’t work. the code should provide the fixcross should be white until the answer is given, then it should change color based on answer like true is green color, wrong is red color. But I couldn’t write that code. Do you have any suggestions for that?

Thanks for your reply. If I understood correctly what you said, I did that and the problem here is the code I explained the problem in another reply. If you read that reply and you have any ideas, I would like to hear because I’m literally desperate right now because of this code.

Hi @yongbok,

PsychoPy has a page on setting up feedback, which can help get started. Note: the page gives advice for text feedback. You will need to make adjustments for colour feedback.

If you are still having trouble, you could share a copy of your experiment here. Then people can see what you have so far and give more detailed advice.

Hope that helps,
-shabkr

Hello @yongbok

plenty solutions have been posted to this forum regarding feedback. So, it might be worth searching for a solution before asking a question :stuck_out_tongue_winking_eye: :wink:.

But here a short explanation.

  1. You need to define a variable in your Excel-file that contains the correct answer. So, corrAns is the correct answer in the example below. Stim is the stimulus being presented.
    grafik

  2. You need to tell PsychoPy that it should monitor the correctness of the answer in the Property tab Data of your response device. In the following example it is a keyboard.

  3. Next, insert a code-component in the feedback routine that follows your stimulus/reaction-routine. The code-component should be in the top row.

  1. Define the variable feedColor (or whatever name you want) in the Begin Experiment tab . If you run the experiment locally, you can skip this step.
feedColor = "white"
  1. insert the following code in the Begin Routine tab of the code-component.
if key_resp.corr:
    feedColor = "green"
else:
    feedColor = "red" 
  1. Next, go to the Appearance tab of your polygon-component. Insert $feedColor in the field fill Color and the field Border Color if you don’t want a white border. Set set every repeat for both, the Fill Color and the Border Color.

Your are set.

Best wishes Jens

2 Likes

Thank you so much it’s working… I’m really thankful for your help I was trying so much complex codes.