Howdy, Stranger!

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

Supported by

[solved] Set the duration of a sketchpad according to the length of the current sequence

edited October 2013 in OpenSesame

Hello,
I am actually making an OpenSesame version of the ANT (original by Fan et al., 2002).
I have two main problems.

  1. Each trial must last 4150ms. To get this length, i have: a 1st sketchpad (random duration between 400 and 1600ms) ; 1 sampler + 2 sketchpads (total = 650 ms) ; a keyboard response ; and a last sketchpad.
    So, i have to find a way to set the last sketchpad in order to make it last :
    4150ms - 650ms - 1st sketchpad duration - response time.
    I have tried Sebastiaan's solution from http://forum.cogsci.nl/discussion/505#Item_8 but it looks like i still don't have a "calibrated" time for each trials. When i try to read the logs, the length of each trial is around 5000ms but never the same time.

  2. I want to get the exact time (UTC) at the beginning of each trial in the logger. But i don't know how to do it.

Did someone have the same issue?
I hope i have been clear, ask me if you need more informations.

Thank you in advance.

Franck.

Comments

  • edited 9:07PM

    Hi Franck,

    it looks like i still don't have a "calibrated" time for each trials. When i try to read the logs, the length of each trial is around 5000ms but never the same time.

    The jitter that you're seeing is presumably due to variation during the prepare phase that precedes each trial. That is, the timing within the trial should be very constant (when implemented properly, of course), but the timing between trials can vary a bit. This is described here:

    If you want to ensure that the start of each trial is separated by a fixed interval (i.e. non-slip timing), you can do this with an inline_script. See for example here:

    I want to get the exact time (UTC) at the beginning of each trial in the logger. But i don't know how to do it.

    If you want, you can set any kind of timestamp at the beginning of the trial with an inline_script. For example:

    import time # See http://docs.python.org/2/library/time.html
    exp.set('trial_utc', time.gmtime()) # Second accuracy
    

    For most cases it will suffice to look at the timestamp of the trial_sequence item, though. This variable is called time_trial_sequence:

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited October 2013

    Hi Sebastiaan,

    Thank you for your fast answer.

    I tried to use the time_trial_sequence but in my excel file, all y get is "NA" for that column (named time_essai_entrainement in my experiment). so, in order to calculate the exact length of my trial, i use to substract the time of the last item (of the current trial) from the time of the last item (from previous trial).

    In order to set the length of the trials and avoid inter-trials slips, i tried your script from http://forum.cogsci.nl/index.php?p=/discussion/298/open-timing-issue/p1.
    I set the trial_duration = 4150.
    Now i have better trial durations, but it still move between 3800 and 4500ms (mean=4153ms). I was wondering wether those different trial times can be due to my computer's calculation time for my random factors?

    To get the exact UTC time, your exp.set('trial_utc', time.gmtime()) works perfectly but what i wanted was the time with a millisecond accuracy. So, i found this script and i think it works the way i need it :

    t = datetime.datetime.now()
    print t
    print t.hour, t.minute, t.second, t.microsecond
    self.experiment.set("temps", t)"
    

    Thank you for your time,

    Franck.

  • edited 9:07PM

    Re,

    I managed to get the exact length combining both of your examples :
    http://forum.cogsci.nl/index.php?p=/discussion/298/open-timing-issue/p1
    and
    http://forum.cogsci.nl/discussion/505#Item_8
    Now i think that part is good. I get 4150ms for each trial (sometimes 4151ms but it's not a problem)

    All i need now is to get the GMT time (in milliseconds) at the beginning of each trial. The problem with my script is that in my excel file, the "time" is given in minutes, seconds, microsecond. Or i would like to have it only in ms.
    Do you have an idea?

    Thanks,
    Franck.

  • edited 9:07PM

    The problem with my script is that in my excel file, the "time" is given in minutes, seconds, microsecond. Or i would like to have it only in ms. Do you have an idea?

    Well, that boils down to stripping off the last three digits, right? So you can simply convert the datetime object to a str (which was already silently done by exp.set()) , and slice off the last three characters, like so:

    import datetime
    now = datetime.datetime.now() # Get datetime object
    s = str(now) # Convert to str
    s = s[:-3] # Strip off last three decimals
    exp.set('temps', s)
    

    For advanced formatting, you can also take a look at date.strftime(), but I'm not sure whether it can deal with sub-second values.

    Cheers!

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 9:07PM

    Hi Sebastiaan,

    Thank you for your answers and ideas to solve my problem.
    My duration problem is now solved. I tried to run my experiment on a better computer and it worked perfectly to 4150ms per trial with no variations.
    :-\"
    For the GMT time, your solution worked, so i took both functions. Now i have a column only with ms, and a column with full datetime.datetime.now(), and it's perfect like this !

    Thank you a lot for your fast answers !

    Best,
    Franck.

Sign In or Register to comment.