Howdy, Stranger!

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

Supported by

[open] Re-calibrate Eye Tribe

edited November 2015 in PyGaze

Hi,

I am running an experiment using the Eye-Tribe.

As the eye-tracker is portable and new, and as my experiment is quite long (72 trials), I want to insert a few breaks and re-calibrate the tracker. I am now drift-correcting before every trial, but I would like to repeat a full calibration.

I created a conditional break half-way through and inserted another Pygaze_init. I get the error message
"You should have only one instance of pygaze_init in your experiment"

I can understand that Pygaze_init is not only calibrating, but also initializing the tracker, so it shouldn't appear twice. But I need to insert a new calibration.

How can I get this done?
Unfortunately, I am not a programmer and I am using OpenSesame from the GUI interface.

Any help would be hugely appreciated
Thanks

h.

Comments

  • edited 9:51AM

    Hi Harold,

    You can simply insert an inline_script with:

    eyetracker.calibrate()
    

    As described here:

    (In 2.9 or earlier, you need to call exp.pygaze_eyetracker.calibrate().)

    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 November 2015

    Thank you Sebastiaan!!

    *** edit (I always think there is more into coding than there really is)

    it works fabulously, thanks.

    h.

  • edited November 2015

    :)

  • edited 9:51AM

    Unfortunately, it seems I still have a problem.
    I introduced two breaks and two re-calibration in my script.
    The second re-calibration makes the experiment end prematurely.
    I do not get an error message, but the message 'the experiment is finished'. One third of the trials, though, did not run.

    Any suggestions?

    Thank you

    harold

  • edited November 2015

    I created a different pilot experiment to see what the problem could be with the recalibration killing it.
    This simpler one runs ok 2/3 of the times, but occasionally gives me a Runtime Error:

    Microsoft Visual C++ Runtime Library
    Program... opensesame.exe
    This application has requested the Runtime to terminate it in an unusual way.

    I have seen some other users are having problems with Runtime errors
    http://www.cogsci.nl/forum/index.php?p=/discussion/1675/open-runtime-error-while-adjusting-script-of-form-plug-in#Item_8
    but that description doesn't apply to my case.

    Thank you

  • edited November 2015

    I took a look at the debug window, and I found a message after the premature end:

    *Exception AttributeError: " ' LaminaPanelSurface' object has no attribute '_txtr' in bound method _LaminaPanelSurface.__del__of
    expyriment.stimuli._visual._LaminaPanelSurface object at 0x158C3C70 ignored*
    

    I don't know if this is relevant to my problem.

  • edited 9:51AM

    Hi Harold,

    It seems like something goes wrong in Expyriment, the library used by OpenSesame. I cannot really say much more about it, because I've never seen this issue myself, and these kind of 'hard' crashes are very difficult to debug.

    But, since the problem seems to be in the xpyriment backend, you could simply try a different backend. You can change this in the General properties tab. For example, does everything work smoothly if you use the legacy backend?

    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 9:51AM

    Hi Sebastiaan,
    Thank you for your answer.

    I worked on the script to identify the problem, and I finally fixed it.
    In my experimental sequence, I had various elements (a sentences, some pictures, and a question) and then a logger. When I added a break sketchpad and the recalibration, I had put it between these elements and the logger. By changing the place of the logger and putting it closer to those elements, everything now works fine. It seems that these elements were intervening between the response and the logger and were creating a conflict.

    Thank you for your assistance and for the development of these open source tools.

    best
    h

  • edited 9:51AM

    Hi

    I am still having some crashes if I restart the calibration. I updated to version 3. It does not all the times, but it can happen in the initialization as well as in my in-line script.
    The debug window reports the error as "calibration is already in progress", identifies it in calibration.start() and it tags it as error 403.

    Is there anything I could do about it?
    Thank you

    h

  • edited 9:51AM

    Hi,

    Could you post the full stacktrace? You can find that in the debug window.

    And is there any regularity behind the crash. For example, can you take certain steps to reliably reproduce it?

    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 November 2015

    Hi Sebastiaan,

    here's the problem:

    Recalibrating sometimes leads to a crash. I updated Opensesame to version 3 and I am using Legacy. I introduced an inline script for recalibrating every 1/3 of trials, using the function eyetracker.calibrate()

    If calibration is unsuccessful and I press R to restart, it crashes and I get this message (while I don’t seem to have this problem if I restart a successful calibration)

    *Error while executing inline script
    
    item-stack: experiment[run].experiment_loop[run].recalibration_inline_script[run]
    exception type: Exception
    exception message: Error in calibration.start: Calibration already in progress (code 403)
    item: recalibration_inline_script
    time: Tue Nov 10 13:51:18 2015
    phase: run
    
    Traceback:
      File "dist\libopensesame\inline_script.py", line 96, in run
      File "dist\libopensesame\python_workspace.py", line 160, in _exec
      File "<string>", line 2, in <module>
      File "dist\pygaze\_eyetracker\libeyetribe.py", line 193, in calibrate
      File "dist\pygaze\_eyetracker\pytribe.py", line 1127, in start
    Exception: Error in calibration.start: Calibration already in progress (code 403)*
    

    Thanks for any suggestion
    h

  • edited 9:51AM

    It's not ideal, but for now this can be fixed with a monkeypatch to the pytribe.calibration class. This simply aborts any current calibration and retries, if necessary.

    import pygaze._eyetracker.pytribe
    
    def start_new(self, pointcount=9):
    
        """Starts the calibration, using the passed number of calibration
        points
    
        keyword arguments
    
        pointcount  --  integer value indicating the amount of
                        calibration points that should be used, which
                        should be at least 7 (default = 9)
        """
    
        attempts = 0
        max_attempts = 3
        while attempts < max_attempts:
            # send the request
            response = self.connection.request('calibration', 'start', {'pointcount':pointcount})
            # return value or error
            if response['statuscode'] == 200:
                return True
            self.abort()
            attempts += 1
    
        raise Exception("Error in calibration.start: %s (code %d)" % (response['values']['statusmessage'],response['statuscode']))
    
    pygaze._eyetracker.pytribe.calibration.start = start_new
    
  • edited 9:51AM

    p.s. I should have said, for this fix to work the code above should be in an inline code item right at the start of the experiment (before any use of pygaze_init).

  • edited 9:51AM

    This solution seems to work fine. I'll pilot more and update in case.

    Thanks

  • edited 9:51AM

    @alisdt That's great, thank you. Since you seem to known what you're doing, would you be interested in submitting a pull request with this fix through GitHub? If so, please submit it to the os3 branch of my fork, which currently has the most up-to-date code.

    If not, no problem, and I'll push a fix myself.

    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:51AM

    Hi @alisdt and @harold_mb,

    I added a variation of this fix to PyGaze, which is newly packaged in the 3.0.3 prerelease. Would you mind trying out the latest prerelease (not 3.0.3a3) to see if this resolves the recalibration issue?

    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

Sign In or Register to comment.