System time for each sketchpad
Hi,
Need some assistance to create system timestamps in the logger associated with each image I present on Opensesame.
To give a little context, I am running Opensesame along with an facial emotion detection software. The emotion software give me the system time followed by emotion intensity at each frame taken henceforth. I want to analyze the emotions elicited by the images shown in Opensesame. For this I will need to make sure that I know the timepoints at which each image is displayed in Opensesame so that I can use the data from emotion detection software. I do not have access to any serial/parallel port to send triggers. So I believe that timestamping might work best for me. Any other suggestions are welcome too.
Thanks in advance,
Asma
Comments
Hi Asma,
How is your experiment structured? Do you present your images via
sketchpads orinline_scripts? Normally, OpenSesame logs automatically the time when each of its elements are called. Check out the log file and you should see many variables in the style oftime_<item_name>.If you present everything in an
inline_script, every time you show acanvas, you can save the time of this call to a variable, e.g.,var.time_c1 = canvas1.show(). In doing so, you also get your time stamps.Good luck.
Eduard
Hi guys,
Just to avoid confusion: The timestamps that OpenSesame uses are not the system time, but some relative time measure that depends on the backend. (Such as the number of milliseconds since PyGame was initialized.)
If you want to get the system time, you can do so with Python's
datetimepackage.For example, say that you want to log the system time after showing
my_canvas, you could do so as follows:This will set
my_system_timeto something like27-07-16 09:53:387064, where the last value corresponds to microseconds.Important: If you must rely on the system time, the two programs (the emotion detection software and OpenSesame) should run on the same computer, so that they use the same system clock. You should not assume that the system clock's of two different computer are perfectly in sync.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks for the reply Sebastiaan and Eduaard,
I am running both the programs on the same system so system time is what I need. I tried the time_ but it gives the relative time as Sebastiaan suggested. I will try the script suggested by you. But where do I place this code? Do I need to program the whole experiment in Python? Or could I use it in OS inline script?
Best wishes,
Asma
After the
sketchpadthat you want to timestamp, you can insert a shortinline_scriptwith just this:If you do this, make sure that the duration of the
sketchpadis set to 0, so that the experiment moves on to the timestamp script immediately. If necessary, you can then insert anadvanced_delayagain after theinline_script. Does that make sense?Check out SigmundAI.eu for our OpenSesame AI assistant!
Dear Sebastiaan,
Thanks very much for your detailed response. I have made changes as you described and added a custom variable my_system_time in the logger, but still getting NA and not system timestamp.
Could you upload the experiment?
Check out SigmundAI.eu for our OpenSesame AI assistant!
Here is the script in pastebin. http://pastebin.com/R2LvMHEH
Thanks in advance.
Right, the problem is that you're not setting the time as an experimental variable, that is, not as a property of the
varobject.You're doing:
Whereas you should be doing:
See also:
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan.
Thanks for your help here.
I just noticed something, aren't we missing the "Seconds" in the code here?
having microseconds without having seconds seems to be not useful.
shouldn't it be like this: '%d-%m-%y %H:%M:%S:%f' instead?
please correct me if I misunderstood the calculation.
Best,
Kian
Absolutely!
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan,
Just to avoid confusion: The timestamps that OpenSesame uses are not the system time, but some relative time measure that depends on the backend. (Such as the number of milliseconds since PyGame was initialized.)
I tried my best but I couldn't find a documentation for how psychopy/legacy backends record their time that is shown on time_[item]. I'd be grateful for any guidance.
Also, is there a way to disentangle the time_[item] recording from the backend configuration and change it into
time.time()fromtimelibrary?Thanks a lot,
SH
Hi,
You want to check this part of Opensesame, and dig from there to find what the backends are doing. For example, for legacy, you will find that, the clock is returning the time since pygame.init() was called, which occurs here I think.
Also, is there a way to disentangle the time_[item] recording from the backend configuration and change it into
time.time()fromtimelibrary?I think the easiest would be to initialize your own clock, and measure the time difference to Opensesame's default clock. This time difference will most likely be consistent, so you can use it to transform the variables to your liking.
Hope this helps,
Eduard
Hi @sebastiaan,
thank you for the useful response, this is exactly what I need:
from datetime import datetime var.my_system_time = datetime.now().strftime('%d-%m-%y %H:%M:%S:%f')Unfortunately, I have not inserted that script in my experiment during data collection. So my question now is whether there is a way to implement something similar already in the data file, when all data have already been collected to get this global time stamp, given that OS gives a system time of the beginning of the experiment?
Thanks in advance,
Esli
Hi Esli,
Unfortunately, I don't think this is possible. If it is not in your data file, that the system information time at the beginning of the experiment is lost.
Eduard
Hi Eduard,
thanks for the comment - I solved the issue in the following way: since the data contain the time stamp for the moment when the script was initialized, I wrote the R script which calculated time stamps for each trial by adding the relative time provided for each trial onset to the experiment initialization time stamp.
Esli