Access variable's history
Hi,
Although it is a similar question as the one I've previously asked, I opened an new discussion because it may be interesting for others too.
I found the following page on accessing previous responses: https://osdoc.cogsci.nl/3.1/manual/python/responses/. However, I wanted to know whether there is a way to access another variable's history in a similar fashion.
Imagine that you have a binary variable that can either have the values 0 or 1. How could I access the history of this variable via an inline script?
I tried to define a variable and access it in a similar fashion as described in the link above:
example = var.binaryvariable[:10]
However, this only led to the following error message: 'int' object has no attribute 'getitem'.
Thank you so much in advance!
Best,
Christian

Comments
Hi Christian,
That's an interesting question. The
varobject has no memory (unlike theresponsesobject). You could give it memory by overriding the way it sets variables, and by adding a function to retrieve a variable's history. Adding the following script to the Prepare phase at the very start of the experiment should do this.Note: This hacks into the OpenSesame internals and may break in future versions. And test your experiment to make sure that there are no unwanted side-effects (I don't think there are, but still).
Once you've done this, you get a list of all values that a variable every had with the
var.history()function:Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
Thank you very much! Meanwhile I thought of a similar workaround, created a list and added the wanted variable at the end of each trial to the list:
if self.get('my_variable') == 1: my_list.append(1) else: my_list.append(0)Then I could just access the last few trials via:
But thank you again, I for sure have to try your approach!
Best,
Christian