Hopefully, no stupid mistakes this time. I’m trying to give RT feedback at the end of a block. I have a detection task in different conditions so have more than one response component I want to average RTs and present to participants at the end of the block. But, so far I’m struggling to average RTs from one component and present that. I have tried to follow: Builder - providing feedback — PsychoPy v2022.2.5
but I get
meanRT = trials.data[‘long_detect.rt’].mean
KeyError: ‘respOne.rt’
################ Experiment ended with exit code 1
Not sure why. Any ideas would be helpful. Once solved, I then need a mean of multiple responses to present back to participants, but one step at a time.
when you surround code with triple ` your code gets formatted and it is easier to spot errors. When auto-translation (Auto → JS) is set in your code-component and the Python-code does not translate to JS, there is probably an error in your Python-code.
in the code you post you still have intelligent instead of dumb quotation marks. But it might be that the forum replaces dumb quotation marks with “intelligent” ones. Please surround your code with triple `.
Is this issue happening because the participant always responds during short_detect? Why do you have separate keyboard components? Won’t that mess up your mean RT anyway?
No - the participant will respond, depending on the condition at either short_detect or long_detect. I’ve used separate keyboard responses for two reasons - 1. So I can easily calculate response time to either short_target or long_target depending on the trial 2. So I can view data easily by correct response - if a response is recorded in short_detect on a long_target trial this would be incorrect… or maybe this is a hangover from moving recently from e-prime(?)
Thanks!
The two components are active at different times so that should be fine. Personally I’m more familiar with appending RTs to lists and calculating means from that than interrogating the trials.data.
Insert a code-component following the keyboard-component in the end-routine tab. The first print-command will print the current RT, the second the RT-list.
That error means that trials.data doesn’t contain a field called detect.rt.
As I said before, I am unfamiliar with whether you can use trials.data (or indeed whether that is how you are supposed to use it). I would instead have something like rtList = in Begin Experiment and rtList.append(detect.rt) in End Routine. Then meanRT = rtList.mean() should work.