| Reference | Downloads | Github

Displaying analysed results to participants

OS (e.g. Win10): Mac
PsychoPy version (e.g. 1.84.x): 1.90.3

Hi there!
This is my first attempt on PsychoPy. I would like to show two set of images (set A and set B) and register the reaction time. Participants are told to press “space” only if the image belongs to the set A. I already did this. Now, my problem is that I would like to display the results to the participants at the end of the experiment. I found how to display the number of correct answer (when they did press ‘space’ for an image of set A) and the mean of the reaction time. However, the mean of reaction time is calculated on both sets (mean of reaction for set A (correct answer) and set B (wrong answer)).

In the Code Component (Begin Routine) of my Routine I wrote :
nCorr =[‘response.corr’].sum()
meanRt =[‘response.rt’].mean()
msg = "Vous avez fait %i reponses correctes (rt=%.2f), " %(nCorr,meanRt)

I am a beginner also in python coding, but I am pretty sure the solution would be to set a condition there… (meaning : calculate the mean of reaction time if ‘response.corr’ = 1).

What would be the best solution to display the mean of reaction time for the correct answers.

Thank you for your help!

@Kmi, at the end of the routine for your final trial, you could use list comprehension to store RTs if their corresponding entry in the data file is 1 for correct, then take their mean and present in a code component in the next routine. In a code component, in the “End Routine” tab:

if trials.nRemaining == 0:
    rts = [rt for idx, rt in enumerate(['response.rt'][0]) if['response.corr'][0][idx] == 1]
    meanRT = np.mean(rts)

Hi @dvbridges,
Thank you for your answer
I copy-pasted this in the “End Routine” tab of the “final routine” (the routine following the trials), but unfortunately, the mean is still taking to account both sets (A and B) when checking via Excel… Did I miss something?

@Kmi, have you defined the correct answer in the conditions file and passed this to the keyboard component? e.g., you may have a single column, which contains both Set A and Set B stim, then you have another column called “correctAns” (or something else) and in that column, you have “space” for all Set A stim, and nothing for all Set B stim. correctAns would be the variable used for correct answer in the Keyboard component.

@dvbridges, yes I did defined the correct answer (I named it corrAns) with “space” for set A. In keyboard component of the trials I checked “store correct” ($corrAns)

I realise now that you will get a correct response even if there is no response, since no response to Set B is correct. So we need to create an extra column in your spreadsheet that only records correct responses for Set A stim. At the end of every routine i.e., trial, try:

if response.corr == 1 and corrAns == 'space':  # On correct responses where space is correct e.g., Set A stim
    thisExp.addData('setA.corr', 1)

Now, you can try:

if trials.nRemaining == 0:
    rts = [rt for idx, rt in enumerate(['response.rt'][0]) if['setA.corr'][0][idx] == 1]
    meanRT = np.mean(rts)

Yes indeed! I didn’t mention it but I defined a “fake” correct answer for set B (random keyboard, I choose “a”, so that participants will never have a correct answer)
But I will try your script

However, if I did use two keyboards, your first script should have worked, right?

If I want to create an extra column for “setA.corr”, where should I put exactly:
if response.corr == 1 and corrAns == ‘space’: # On correct responses where space is correct e.g., Set A stim
thisExp.addData(‘setA.corr’, 1)

You would put it at the end of the routine, so that after every trial, an entry is written for “setA.corr”. Please can you post your conditions file, and an example of a datafile?

Hi @dvbridges,
here is an Excel file with the conditions and the data ProtocolHumainAnimal.xlsx (12.5 KB)