now() function does not give the timestamp when extracted in matlab

eghbal.hosseini's Avatar

eghbal.hosseini

09 Jun, 2015 02:33 AM

Hi Chris,

I am using the now() function to get the time of specific events in the task code, for example:
variable definition:
<variable tag="event_begin_trial" scope="global" logging="when_changed" default_value="0" type="float" persistant="0"></variable>
variable assignment:
 <action type="assignment" tag="Assign event_begin_trial" variable="event_begin_trial" value="now()"></action>

when I am extracting the data in MATLAB using the 'getEvents' function, I don't get the time in the data column. Instead I get numbers that don't seem to reflect time.

Please let me know how to fix this.

Thanks,
Eghbal

  1. Support Staff 1 Posted by Christopher Sta... on 09 Jun, 2015 02:42 PM

    Christopher Stawarz's Avatar

    Hi Eghbal,

    I'm not able to reproduce this problem.

    I've attached an example experiment that stores the current time in a variable 1000 times. I've also attached a MATLAB script that extracts the variable values and associated timestamps and computes the difference between them for each event. For my test run, it gives the following results:

    Min delta = 0
    Max delta = 16
    Avg delta = 1.153
    

    So the average difference between the variable's value and the timestamp is 1.153 microseconds, and the maximum difference is 16 microseconds. The difference is generally non-zero because some time elapses between when now is called and when the variable value is changed.

    Note that my experiment resets the value of the variable to zero when it's done. This makes it easy for the analysis script to filter out "announcements" of the variable's value that occur outside of the running experiment (e.g. when a data file is opened, when a MATLAB window script is started, etc.). Perhaps these extra values are throwing off your analysis?

    Cheers,
    Chris

  2. Support Staff 2 Posted by Christopher Sta... on 06 Jul, 2015 04:38 PM

    Christopher Stawarz's Avatar

    Hi Eghbal,

    Do you still need assistance with this issue, or were you able to resolve the problem?

    Cheers,
    Chris

  3. 3 Posted by eghbal.hosseini on 06 Jul, 2015 09:11 PM

    eghbal.hosseini's Avatar

    Hi Chris,
    Yes I think the code is working now. I had to remove the zero as you did.
    Thanks,
    Eghbal

  4. Christopher Stawarz closed this discussion on 07 Jul, 2015 03:14 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac