psychopy.org | Reference | Downloads | Github

Creation a conditional response for a remember/know task

Hello everyone,
I am trying to programme a remember/ know task. In this task, the participant is asked if the word displayed on the screen has been seen before. If it has already been seen, the participant must press the “p” button. On the contrary, if he does not, he must press “a”. After responding, I want a second “Remember / Know” screen, but only if it presses the “p” button. If he presses “a”, I want him to continue the task.


I’m trying to code this conditional option in “each frame” but it doesn’t work… The programme often told me that ‘p’ buttom is not recognize.

I try this : print(clavier.keys)
print(type(response.keys))
if clavier.keys.lower() !=[‘p’]:
continueRoutine = False

Thanks a lot for your help

HI @Claire_Ballot, how the response.keys attribute works will depend on your keyboard settings. If you are storing all key presses, then response.keys returns a list, if you storing the last key, then it returns a string. So, if storing last key pressed, you would want something like:

if clavier.keys !=  'p':
    continueRoutine = False

Thanks a lot, I write your code but it still doesn’t work. Now, experiment run but the R/K screen does not appear every 5 trials whatever the previous Buttom Pushed(a or p)
I don’t inderstand

Ok, I am unsure about your design. You have a loop with a set of trials that the person responds seen/not seen. Then after this loop of n trials has finished, you have a remember/know routine. What is supposed to happen in the remember know routine?

The R/K routine is just a remember/Know screen with 2 buttoms (r/k) to precise the response given during the first routine. The screen must appear immediatly after the p buttom has Been pushed in the fist routine thanks for your help

Ok, you need to include your “Essai” and “RK” routines in the “trials” loop. This way, the RK routine will follow from every trial, not just every 5 trials. However, you only want the RK routine to be presented if ‘p’ is pressed, and the participant has seen the word. In this case, you need a code component in your RK routine. IT would help if you have defined the correct answer for each trial in your condition file and fed that into the keyboard. Are you doing this? If so, you can add the following to the code component in the tab “Start Routine”

if not response.corr:  # If not correct, do not continue the RK routine
    continueRoutine = False

The alternative is to not define your correct answer in the keyboard, and instead use the following code in the “Begin Routine” tab in the RK routine.

if not response.keys == 'p':  # If not correct, do not continue the RK routine
    continueRoutine = False

EDIT: Actually, you will want the RK routine to be based on the participants decision, not whether or not the stim has actually been seen, therefore you would opt for the second coding option in this post.

Yes i have. After doing what you told me, it say me That “response” is not defined.
Moreover, i want the R/N screen only when the participant is Right but when he pushed the buttom p (even if it’s a mistake)

Do you have a keyboard component called “response” in your “Essai” routine?

No, I have clavier (=keyboard), mot (=Word) and fixation cross

Ok, instead of response.keys use clavier.keys. If that does not work, I have an example to show you that does work.

It still doesn’t work. Sorry

Ok, it would be helpful for you to describe how it doesnt work, otherwise I cannot understand. Look at the attached example, it is a simplified version of your task. Text is shown on screen, and then after a button is pushed, either ‘a’ or ‘p’, the routine ends. A second routine called “feedback” is in the loop. The text in the feedback routine will only be presented if ‘p’ is pushed.

RKTask.psyexp (9.1 KB)

It continue to have a problem to define “response” even after changes.
I’m going to try with this script ! Thanks a lot

Ok, that means that “response” is being used as a variable somewhere, even though it has not been defined - i.e., no components are called “response”. It is probably being used in a code component somewhere. So, find where response is being used, and either delete it, or change it to clavier.

Hello again,
from your codes I got to run the task!
Thank you very much for your help!