Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

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 or inline_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 of time_<item_name>.

    If you present everything in an inline_script, every time you show a canvas, 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

    Buy Me A Coffee

  • 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 datetime package.

    For example, say that you want to log the system time after showing my_canvas, you could do so as follows:

    from datetime import datetime
    
    my_canvas.show()
    var.my_system_time = datetime.now().strftime('%d-%m-%y %H:%M:%f')
    

    This will set my_system_time to something like 27-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

  • 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 sketchpad that you want to timestamp, you can insert a short inline_script with just this:

    from datetime import datetime
    var.my_system_time = datetime.now().strftime('%d-%m-%y %H:%M:%f')
    

    If you do this, make sure that the duration of the sketchpad is set to 0, so that the experiment moves on to the timestamp script immediately. If necessary, you can then insert an advanced_delay again after the inline_script. Does that make sense?

  • 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.

  • Here is the script in pastebin. http://pastebin.com/R2LvMHEH

    Thanks in advance.

  • edited August 2016

    Right, the problem is that you're not setting the time as an experimental variable, that is, not as a property of the var object.

    You're doing:

    from datetime import datetime
    my_sysytem_time =datetime.now().strftime('%d-%m-%y %H:%M:%f')
    

    Whereas you should be doing:

    from datetime import datetime
    var.my_system_time = datetime.now().strftime('%d-%m-%y %H:%M:%f')
    

    See also:

  • 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

  • shouldn't it be like this: '%d-%m-%y %H:%M:%S:%f' instead?

    Absolutely!

  • S_HS_H
    edited July 2021

    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() from time library?

    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() from time library?

    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

    Buy Me A Coffee

  • 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

    Buy Me A Coffee

  • 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

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games