Post-error slowing script in Opensesame
Hi everyone!
I am designing a mental arithmetic task consisting of additions and subtractions, with 7 blocks of ascending difficulty (each block containing both additions and subtractions). As I am trying to examine the emergence of post-error slowing, I want to write an inline script into the experiment to automatically create the post-error and post-correct RT averages for me. So, my script needs to do the following: If a trial's accuracy is 0 or 1 and the accuracy of the previous trial (needs to be in the same block) is 0, this is a post-error trial. If a trial's accuracy is 0 or 1 and the accuracy of the previous trial (needs to be in the same block) is 1, then this is a post-correct trial. Make an average of the RTs of all post-error and post-correct trials for each block (so, one average post-error and one average post-correct for every block). Then, subtract the post-correct average RT from the post-error average RT for every block. This score is the post-error slowing score for each block.".
I know, it's a mouthful! I have tried to do it with this script (photos below), and although it runs correctly with no error messages and the experiment finishes, it doesn't create for me the variables I need.
Any help is much appreciated!
Thank you!
Tryfonas
Comments
Hi Tryfonas,
I am a bit confused about your code. It looks like you are computing the slowing after the experiment has completed (you read the data file). If so, I wonder why you use Opensesame for the computation and not regular python. If you do it during the experiment it is a bit weird that you don't just live update the variables you need on every trial. The principle is pretty much the same as you do, but without the loops (essentially adding relevant information to lists that you initialize every block).
The reason that your variables don't appear in the logfile could be that you don't include them in the logger. Do you make those computations before or after the logger? If this is not the case, what version of Opensesame do you use? If it is slightly outdated (<4), you would need to add
var.
before the variables that you want to be logged.If none of this is the case, I would need more information on your experiment. Perhaps you could share it?
Eduard
ps. You can make your code much more efficient using Pandas operation. This here does essentially the same as your code:
Hi Eduard! Thanks for the quick and informative response!
I thought it would be easier for me to collect the data after the experiment was finished; it didn't occur to me I could do it live. If I understand correctly, I could do it live by incorporating an in-line script into the trial sequence executing the code you showed, minus line 2 and the df prefix in every line (just by introducing the variable I want to create, e.g., prev_correct). Is my assumption correct?
As for data logging, I am logging all variables but have put my inline script after the logger, so this could be the reason I am having an issue. I am using OpenSeame 4.0.24
Thanks again for the input!
I have uploaded my experiment with tirals only for the practice block and block 1, because otherwise it was too large. I am uploading it purely as an experiment structure aid.
Thanks!
Hey,
As for data logging, I am logging all variables but have put my inline script after the logger, so this could be the reason I am having an issue
So, is this it? Does your script work if you move back the logger?
If you want to keep track of information on trial n-1. You need to start those lists before a block start
Then, during the trial, as soon as you have your response, you can do:
Eduard