I’m using Psychopy 3.03 standalone on windows10.
I would like to write a feedback routine which tells the participant, whether they responded correctly in a 2back-experiment (different positions are shown sequentially and one should hit space if the position is the same as two pictures before).
Something like if space was hit and corr=1: "Correct!; if space was hit and corr=0: “incorrect”; if space wasn’t hit and corr=1: “should have hit space”; if space wasn’t hit and corr=0: nothing
I already realized that I have to change my “corr” column in the excel file to empty instead of 0 und to ‘space’ instead of 1. Still I have problems programming the feedback routine.
Thanks for any help.
as I understand the thread you mention is about coding what the correct response ist (y/n if a 2-back occured or not) and about feedback in a 1-back experiment.
I don’t need code for the correct responce as I have it in my trials file (sequential presentation). I just don’t know how to call on this information (variable corr is either ‘space’ or ’ ') and how to implement in the code component. I think the idea of what I want to do is clear and it’s simply a matter of transforming it into correct python code…
OK, yes, that code is for the general case where stimuli are randomised and so the n-back values need to be calculated. If you have sequential conditions and your own “correct” variable, then your problem is indeed simpler.
Part of the reason why your code above is failing is that you are referring to the keyboard component itself (key_resp_4) and not one of its specific attributes (like key_resp_4.corr or key_resp_4.keys), etc. At the moment you’re kind of asking “is my keyboard the space bar?”
If you don’t have any luck, please provide a screenshot of your keyboard component settings, and the text of your code (i.e. it’s easier to suggest changes to code if you paste in the code itself, rather than a screenshot, which can’t be copied from), and please:
if key_resp_4.keys == '' and corr == 'space'
msg = 'Das wäre ein Treffer gewesen!'
if key_resp_4.keys == 'space' and corr == 'space'
msg = 'Richtig! Die vorletzte Position war gleich.'
if key_resp_4.keys == 'space' and corr == ''
msg = 'Leider falsch. Die Position ist nicht gleich wie die vorletzte.'
else msg = ''
I’m getting a feedback now (although not specific enough), but it’s always delayed by one trial i.e. if I make a mistake it gets reported one trial later, at the wrong time. That doesn’t make sense to me as I collect the information at the beginning of the feedback routine…AG-Test.psyexp (73.1 KB) trials_34.xlsx (10.5 KB) trials_probe.xlsx (8.8 KB)
Can you work with this or do you need the images?
Thanks again for your help!
This is likely simply due to the ordering of your components. They are executed in order from top to bottom. So if the code component is below the text component, it will be setting the msg variable after it has already been drawn, using the previous value for msg. You need to shift your code component to be above the text components (by right-clicking on the icon), so that the text components get immediate access to the new value of msg.