Showing Sequential Feedback After Motor Sequence Learning Task

Hello everyone. I made a motor sequence learning task using PsychoPy and would like to implement feedback. The experiment runs as follows: First, a sequence of 6 rectangles is shown on the screen. Each position of the rectangle is connected to a certain key response (w,a,s,z). After a whole sequence is shown, the participant has to respond with 6 key presses. I already implemented the correct answers and the variable Key_response.corr is storing with 0 or 1 if the response made was indeed correct.
After the response was made, i would like to show feedback. The feedback should appear after the all responses were made and not after each key press. What i would like is a screen that shows “key 2 wrong” and then “key 4 wrong”, if those keys were incorrect.

Here is the code that i have so far (inserted in Begin Routine):
the problem with this code is that it only shows the last correct condition. So even if my first key and sixth key were wrong, it will only show the feedback text for the sixth key.

feedback_text = ’ ’
if key_response.corr == 0 and Position == ‘Key1’:
feedback_text = “key 1 wrong”
if key_response.corr == 0 and Position == ‘Key2’:
feedback_text = “key 2 wrong”
if key_response.corr == 0 and Position == ‘Key3’:
feedback_text = “key 3 wrong”
if key_response.corr == 0 and Position == ‘Key4’:
feedback_text = “key 4 wrong”
if key_response.corr == 0 and Position == ‘Key5’:
feedback_text = “key 5 wrong”
if key_response.corr == 0 and Position == ‘Key6’:
feedback_text = “key 6 wrong”

here is a picture of my builder so you can imagine better how this looks like:

I think it might have to do something with that there is no loop made around the feedback block. But i am not sure.

I apologize if this is an easy fix, i just started with Psychopy 6 weeks ago.
I appreciate any ideas and tips! Thank you:)
test2.0.psyexp (71.9 KB)

Hello

Computers do what you tell them to do, not what you want them to do. :wink: :thinking: You told the computer to check if key1 was wrong. If it is, you set the feedback_text to “key 1 wrong”. Then you tell the computer to check if Key2, Key3, Key4, Key5 and Key6 are wrong and set the feedback_text to the corresponding feedback text over-ridding the feedback text your just set. So if Key6 is wrong, it will always display the corresponding feedback message. You will need to keep track of the correctness of each key press, probably in a list, and create your feedback message accordingly.

Best wishes Jens

Thank you for your answer Jens!
I do already store the correctness for each key press in an excel file. This is why i also have the variable “Position” with Key1, Key2 etc. So it does check whether the first or second Key was correct, unfortunately it does override if multiple conditions are correct (i.e. if more than one key press was wrong) like you said. Do you have any idea how i could stop PsychoPy from overriding the other conditions?
Kind Regards, Victoria

are you suggesting to store the corresponding feedback in the excel file as well and then drawing up the feedback that is necessary?

Hello Victoria

how many errors can a participant make in a trial, one, two, three, four, five or even six? How many combinations are possible?

How do you keep track that a response was correct?

Best wishes Jens

Hello Victoria

I have created a little toy experiment. You have to press the keys 1 to 6 of the top keyboard row. The number shown is the correct answer. This toy experiment might point you in the right direction. You will get feedback after the sixth answer.

FeedbackSix.psyexp (18.2 KB)

Best wishes Jens

Dear Jens,
thank you for this experiment i will look at it right away.
My correct response is recorded in the “response” phase. The correct answer is saved in an excel file and indicated to the key response by $corrAns, meaning i receive a variable called Key_response.corr which has 0s or 1s depending on correctness.
There are no combinations possible, the participant sees a sequence of coloured rectangles light up on the screen (6 rectangles in total), and then has to type in the sequence into the keyborad using w,a,z,s.
Since asking my question i have figured out that my feedback block cannot access the Key_response.corr variable from the response phase, which makes sense because it is not in the same loop. Do you know if there is any way to “load” or read the Key_response.corr variable from the response phase into the feedback phase?

Kind Regards, Victoria

Dear Jens,
i looked at the experiment you made and it is basically what i would like to have, so thank you! I will need some time to wrap my head around your code because for me the for loops are still very new.

The only problem i could imagine is this:
In your experiment there are 6 answer options and 6 correct answers (6 exclusive keys, 1-6). In my experiment participants only answer with 4 keys, because the key ‘a’ for example can be pressed twice. A sequence could be w,a,s,z,w,z for example. This is why i added the “position” variable which indicated Key1, Key 2 etc. to prevent mistakes.

Additionally, my sequence is changing every trial, which means that i need to work with Key_response.corr because the same order of key presses is not correct for every trial.

Hello Victoria

The code should work for randomised trials. I only tested it with the sequence 1-6 to keep it simple for myself. Uncomment the shuffle command in the Begin Experiment tab to get a randomised sequence.

Ok, I did not know which keys and how many different keys were allowed. I tried to deduce your experiment from what you wrote. You need to be more specific to get an answer that better suits your needs. Be as specific as you would be in the methods section of a manuscript.

Best wishes Jens

Hi Jens,
i will try to be as detailed as possible. Thank you so much again for taking your time to help me.

This is the interface of the experiment:

The rectangles will light up yellow six times after one another.
Here an example of one rectangle lighting up.

E.g. top, left, right, top, button, right. This would be one sequence.
For each sequence of lighting up rectangles, there is a correct way to enter the key press. On my keyboard, the w,a,s,z keys are located in a cross fashion, similar to the design of the rectangles on the picture. So, if i have the sequence top, left, right, top, button, right; the correct key sequence to respond is w,a,s,w,z,s. My allowed keys are w,a,s,z and the correct key is stored using the correct key function of PsychoPy.
I have 4 fixed sequences in total which are each their own excel file. From the excel file, psychopy reads the positioning of the yellow “indicator” based on a variable that i made with x and y coordinates.

Using a loop which is NOT trials, psychopy reads one of these sequence excel files randomly (because the order of each sequence should be random, and then executes the sequence given in the file sequentially.

Block (not trials) loop:

sequence (trials) loop (reading the sequence):

After the response, my datafile looks like this:

Recording the correct response works.
I can mange to give accurate feedback if the feedback would be in the same loop as the response phase. But then you would receive feedback after each keypress, which is not what i want.

In my feedback phase, PsychoPy does not seem to remember the Key_response.corr variable anymore from the response phase. Do you think there is any way to import the correct responses again into the feedback phase?

Kind Regards, Victoria

Hello,

The difference between my approach and yours is that you use a “long” format for the sequence, while I use a wide format for a sequence. AFAIK PsychoPy only keeps track of the last correct answer. But I am not 100% sure. PsychoPy treats each row as a separate trial while you want to treat it as one trial, am I right?

In that case, you need to check and store the correctness of each trial in a list and refer to this list in your feedback routine.

Best wishes Jens

1 Like

Hi Jens, i thought about storing each trial as a list as well. Will try this later. Do you know how i can refer back to the answers given in the feedback phase? Is there any way to “remind” PsychoPy in the feedback phase of the variables Key_response.corr or Key_response.raw that were stored during the response phase? This seems to be my only issue at the moment. Because even if i store it as a list i still need to “remind” the feedback phase of what was actually pressed during the response phase.

Kind Regards, Victoria

Hello Victoria

Another attempt. In the following toy experiment, this time with a row-wise approach, I save the position each time an error is made. In the feedback routine, I count the number of errors and present the feedback after the sixth trial, including the number of errors and their position in the sequence. Notice that the toy experiment has only six trials.

FeedbackSix.psyexp (18.3 KB)
loopTemplatesix.xlsx (8.5 KB)

Best wishes Jens

1 Like

Dear Jens,
i apologize for the late response. This is exactly what i need. I will try to implement this asap and will let you know if i manged to work it out.
Kind regards, Victoria

Dear Jens.
It worked!! i am so happy and thankful.
Big thanks to you! I appreciate it.

Kind regards, Victoria

Dear Jens, i know you have helped me a lot already. If you do not have any time anymore then please disregard this message, i titally understand. I was just wondering if it would be possible to display a message during the “trials” routine (i.e. when the stimuli are shown) if any key response occurs? Because my participants are not allowed to respond while the stimuli are shown, and i would like to display a message in case they do respond early (before they see the cue) and then start the routine again.
Capture

During the routine trial1 any key response should restart the routine and show a message shortly…

Hello Victoria

it is best to start a new topic when a new problem (feature) comes up.

Best wishes Jens

1 Like