Howdy, Stranger!

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

Supported by

Show backdrop image on EyeLink host with pygaze

Hi,

I am using OpenSesame with pygaze to connect with an EyeLink eyetracker and so far it's working great!

I just have a question regarding setting backdrop image. EyeLink provides a plugin with methods bitmackBackdrop:

img = PIL_Image.open(image_path)

w,h = img.size

im_pixels = img.load()

# use the list comprehension trick to convert all image pixels into a <pixel> format

# supported by the Host PC, pixels = [line1, ...lineH], line = [pix1,...pixW], pix=(R,G,B)

pixels = [[im_pixels[i, j] for i in range(w)] for j in range(h)]

# call the bitmapBackdrop() command to show backdrop image on the Host

# arguments: width, height, pixel, crop_x, crop_y, crop_width, crop_height, x, y on Host, option

pos_x = int(var.width/2.0 - w/2.0)

pos_y = int(var.height/2 - h/2.0)

exp.eyelink.bitmapBackdrop(w, h, pixels, pos, 0, w, h, pos_x, pos_y, pylink.BX_MAXCONTRAST)

and imageBackdrop:

exp.eyelink.imageBackdrop(image_path, 0, 0, scn_width, scn_height, pylink.BX_MAXCONTRAST)

to send a backdrop image to EyeLink host. I saw that this eyelink plugin was discontinued in favor of pygaze, but could not find an equivalent in pygaze documentation.

Do such methods exist in pygaze?

Thanks for your help.

Best regards,

Jessica

Comments

  • Hi Jessica,

    When you say "Eyelink provides such a functionality" do you mean the pylink library? Or the old Eyelink plugins? It looks like Pygaze hasn't implemented that option. Still, if that option exits in pylink( which I think does), you will probably be able to access it somehow and project your image to the eye tracker, but there is a chance that this will be a bit complicated, depending on how this method is implemented. I don't have access to the Pylink library at the moment, so I can't look into it unfortunately. If you can provide me with that info, I might be able to give a somewhat more informed guess on whether and how it is possible, though not having access to an eyetracker is still a problem...

    Eduard

    Buy Me A Coffee

  • edited March 2023

    Hi @eduard ,

    Thanks for your answer. Indeed, I was able to call the pylink method to send image to the eyetracker host.

    import pylink
    
    import PIL.Image as PIL_Image
    
    
    def set_backdrop(im, pos_x):
    
        starttime = exp.time()
    
        # prepare image
    
        img = PIL_Image.open(im)
    
        w,h = img.size
    
        im_pixels = img.load()
    
        # use the list comprehension trick to convert all image pixels into a <pixel> format
    
        # supported by the Host PC, pixels = [line1, ...lineH], line = [pix1,...pixW], pix=(R,G,B)
    
        pixels = [[im_pixels[i, j] for i in range(w)] for j in range(h)]
    
        pos_x = int(var.width/2 + pos_x - w/2.0)
    
        pos_y = int(var.height/2 - h/2.0)
    
        el = pylink.getEYELINK()
    
        el.bitmapBackdrop(w, h, pixels, 0, 0, w, h, pos_x, pos_y, pylink.BX_MAXCONTRAST)
    

    And I call this function doing:

    set_backdrop(image_path, pos_x)
    

    I only alter pos_x since my images are vertically centered. But for other experiments where this is not the case, a pos_y argument could be added, and pos_y could be altered in the function similarly to what is done to pos_x.

    Best,

  • Great! Good to know and good luck testing!

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.