hsogo / psychopy_tobii_controller

A module to use tobii_research package with PsychoPy.
GNU General Public License v3.0
34 stars 11 forks source link

a negative number in TimeStamp when record Event #2

Closed agoodStu closed 5 years ago

agoodStu commented 5 years ago

When I record the data of eye movement in Psychopy, I got a negative value in TimeStamp column at the the beginning of each trial. I think there's some missing data. At your convenience, would you please tell me how to fix it. Thank you for your assistance. image My Psychopy version is 1.85.6 in win10, eye tracker is Tobii-Tx 300. Here is some of the relevant code. `

    # ------Prepare to start Routine "trial"-------
    t = 0
    trialClock.reset()  # clock
    frameN = -1
    continueRoutine = True
    # update component parameters for each repeat
    ptc_controller_tobii_controller.subscribe()
    ptc_controller_tobii_controller.record_event('Start Recording')
    main_sound.setSound('sounds/' + str(sound), secs=-1)
    main_image.setPos([picposition, 0])
    main_image.setImage('images/' + str(image))
    sec_image.setPos((picposition, 0))
    main_target.setPos([dotposition, 0])
    main_resp = event.BuilderKeyResponse()
    sec_resp = event.BuilderKeyResponse()

    # keep track of which components have finished
    trialComponents = [main_fix, main_sound, main_image, sec_image, main_target, main_resp, sec_resp]
    for thisComponent in trialComponents:
        if hasattr(thisComponent, 'status'):
            thisComponent.status = NOT_STARTED

    # -------Start Routine "trial"-------
    while continueRoutine:
        # get current time
        t = trialClock.getTime()
        frameN = frameN + 1  # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame

        # *main_fix* updates
        if frameN >= 0.0 and main_fix.status == NOT_STARTED:
            # keep track of start time/frame for later
            main_fix.tStart = t
            main_fix.frameNStart = frameN  # exact frame index
            main_fix.setAutoDraw(True)
            ptc_controller_tobii_controller.record_event(int(str(trigger) + '0'))`
hsogo commented 5 years ago

Hi agoodStu,

I'm sorry for my late response, I had a vacation.

tobii_controller.subscribe() internally calls tobii_research.EyeTracker.subscribe_to() of Tobii PRO SDK, which sends your tobii eyetracker a request to start recording. There is a time lag between sending a request and the beginning of recording on tobii eyetracker. This time lag cannot be eliminated in principle.

I guess that recording had not been started when record_event('Start Recording') was executed. An easy solution to this problem is to insert psychopy.core.wait() immediately after tobii_controller.subscribe(). If the time lag is not longer than 120 ms on your system, psychopy.core.wait(0.12) would work (note that unit of the argument of psychopy.core.wait() is second).

agoodStu commented 5 years ago

Hi hsogo, Thank you for your response. I'm sorry for the late reply, I have been doing experiments for the past few days. I'm glad I see eye to eye with you on this question. So I inserted a blank screen (150ms) in psychopy after tobii_controller.subscribe(). It worked fine. But I think your solution is simpler and more convenient. Thank you for developing this software. My classmates and I have benefited a lot from it. Best wishes