psychopy.org | Reference | Downloads | Github

How to save additional data during experiment and use for feedback after loop?

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2021.2.3
Standard Standalone? (y/n) y
What are you trying to achieve?:
Hi
I have created an experiment testing reactions to subliminal input with an initial middle target that will in some trials change for 1 frame to 1 of 8 surrounding targets, all presented in a 3x3 grid. After the loop I want to provide feedback on not just if the correct target was chosen, but instead I want to separate it out into 4 different conditions:

  • How many times did participant correctly change from middle target to newly presented target?
  • How many times did participant correctly choose the middle target (when no new target was presented)?
  • How many times did participant incorrectly move to another target when they should have chosen original middle target?
  • How many times did participant incorrectly choose middle target when they should have moved to a newly presented target?

What did you try to make it work?:
I have provided feedback after every trial (within loop) with the following code: (I use the numpad to input target in a 3x3 grid, “num_5” being the middle/original target)

if key_response.corr:
…if key_response.keys == “num_5”:
…msg=“Correct! Target remained. RT=%.3f” %(key_response.rt)
…else:
…msg=“Correct! Target moved. RT=%.3f” %(key_response.rt)
else:
…msg=“Oops! That was wrong.”

I am thinking it should be possible to tell Psychopy to save an additional list of 1’s and 0’s similar to what is built in with key_response.corr, and insert that command into in relevant if/else statements above, but I don’t know how I might do that.
I am very new to python and psychopy, so I might be missing some obvious solution.
Any ideas? :slight_smile:

thisExp.addData('Score',1)

Thanks a lot!

Hi
again thanks! that seems to do exactly what I want, but for some reason I’m having trouble accesing the data for feedback. I am using the following code to retrieve it after the loop and I am gettign a KeyError for “Score”.

trials.data[‘Score’].sum()

I have checked and “Score” shows up in the csv file correctly after the experiment, with the expected values. Based on this I do not understand why I would be getting a KeyError?

It might be thisExp.data but personally I would use a separate variable to keep score .

score += 1