Howdy, Stranger!

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

Supported by

[solved] Record continous timestamps

edited June 2013 in OpenSesame

Hi everybody,

for various implementations i would like to ask if there is a possibilty to record continous timestamps to the .csv file, e.g. if you add an external serial device to sync with a video for example or when to see when the video file started/ended. I did not find anything equivalent in the documentation.

Thanks in advance,
Daniel

Comments

  • edited June 2013

    ok, got it. sorry for not searching enough.

    i modified this original tracker:

    http://forum.cogsci.nl/index.php?p=/discussion/351/open-mousetracking-and-visual-world-paradigm/p1

    for my purposes, so to log system time for synchronization as well.
    tracker prepare phase:

    #original scripts from hunterh, see
    #http://forum.cogsci.nl/index.php?p=/discussion/351/open-mousetracking-and-visual-world-paradigm/p1
    
    xList, yList, tList, stList = [], [], [], []
    global xList, yList, tList, stList
    
    global myLog
    
    #initialise sampler
    #from openexp.sampler import sampler
    #src = exp.get_file(self.get("sent") + ".wav")
    #my_sampler = sampler(exp,src)
    #global my_sampler
    

    tracker run phase:

    #original scripts from hunterh, see
    #http://forum.cogsci.nl/index.php?p=/discussion/351/open-mousetracking-and-visual-world-paradigm/p1
    
    #initialise
    start = self.time()
    my_mouse.set_visible()
    
    #initialise logging variables; not necessary, but makes the write command cleaner.
    part = self.get('subject_nr')
    seq = self.get('count_sequence')
    #condition = self.get('cond')
    #snumber = self.get('sent_num')
    
    #set a tracking loop
    tracking = True
    
    while tracking:
        position, timestamp = my_mouse.get_pos()
        x, y = position
        t = timestamp - start
        #system time for synchronization
        st = timestamp
        #uncomment this to print to the debug window.
        #print str(t)+', ' + str(st) + ', ' +str(x)+', '+str(y)
        #write to myLog
        myLog.write(str(x) + ',' + str(y) + ',' + str(t) + ',' + str(st) + ',' + str(seq) + ',' + str(part) + ',' + chr(10))
        #assemble to write trajectories to OS logger (duplicate data and could be removed)
        xList.append(x)
        yList.append(y)
        tList.append(t)
        stList.append(st)
        #set up mouse click
        lclick, mclick, rclick =  get_pressed()
        get()
        #three defined areas, one for each picture
        if x > tr_left and y < tr_below and lclick == 1:
            resp = 1
            mouse_rt = timestamp - start
            print 'Clicked'
            my_canvas.clear()
            tracking = False
            break
        if x > br_left and y > br_above and lclick == 1:
            resp = 2
            mouse_rt = timestamp - start
            print 'Clicked'        
            my_canvas.clear()
            tracking = False
            break
        if x < bl_right and y > bl_above and lclick == 1:
            resp = 3
            print 'Clicked'
            mouse_rt = timestamp - start        
            my_canvas.clear()
            tracking = False
            break
        #This dictates sampling rate. 50 hertz is more than enough
        self.sleep(20)
    my_canvas.clear()
    
    self.experiment.set("Mouse_RT", mouse_rt)
    self.experiment.set("xTrajectory", str(xList))
    self.experiment.set("yTrajectory", str(yList))
    self.experiment.set("tTrajectory", str(tList))
    self.experiment.set("stTrajectory", str(stList))
    self.experiment.set("position", position)
    
  • edited 12:53PM

    Hi Daniel,

    Thanks for sharing your script here! :)

    Best,

    Lotje

Sign In or Register to comment.