Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Setup an experiment and save data

sarmad.msarmad.m Posts: 12

Hi

I'm new to eye tracking and pygaze . my requirement is to build an experiment to display an image or video file then record eye gaze points and fixations . I have started with pygaze temple in opensesame . I have these questions :

  1. How can I add video file or image to the experiment , I have added using sketchpad , but for video how to make it as long as the video plays ?

  2. After the video file is finished , how the experiment should end and save the data ?

Thanks for help

Comments

  • eduardeduard Posts: 977

    1.How can I add video file or image to the experiment , I have added using sketchpad , but for video how to make it as long as the video plays ?

    Yes, with sketchpads you can add images. And with the video plugin, you can present videos. Unless you specify something else, the video will run as long as its duration.

    2.After the video file is finished , how the experiment should end and save the data ?

    Nothing needs to be done. The experiment will stop once no further items needs to be executed. For the data to be written to file you need to add a loggeritem to the experimental sequence. Then every time this logger item is executed, the current trials will be written to the file.

    When eye-tracking, the eyetracker software usually writes a seperate logfile with all the eye position samples. You can either opt for combining these two files after you recorded the data. Or you can send Opensesame variables to the eyetracker and it will be added to the eye logfile right away (at least it does so with the Eyelink eyetrackers)

    Eduard

  • sarmad.msarmad.m Posts: 12
    edited February 1

    Hi, I i'm using this code below to recored data from eyetribe using pygaze .

    when I run the .bat file it just shows ( press space to start calibration ) when I press space just shows a

    white calibration dot and stops the program . what could be the problem ?

    import os
    from constants import *
    from pygaze.display import Display
    from pygaze.screen import Screen
    from pygaze.keyboard import Keyboard
    from pygaze.eyetracker import EyeTracker
    import pygaze.libtime as timer
    
     # Initialise a Display to interact with the monitor
     disp = Display()
    
    # Initialise a Keyboard to collect key presses
    kb = Keyboard(keylist=None, timeout=None)
    
    # Create a Screen for the image task instructions
    inscr = Screen()
    inscr.draw_text(text='Please look at the images. \
    \n\n(Press any key to begin)', fontsize=24)
    
     # Create a Screen with a central fixation cross
     fixscr = Screen()
     fixscr.draw_fixation(fixtype='cross', diameter=8)
    
    # Create a Screen to draw images on later
     imgscr = Screen()
    
    # Initialise a new EyeTracker
     tracker = EyeTracker(disp)
    
    # Calibrate the eye tracker
    tracker.calibrate()
    
    # Feed the instructions to the Display
    disp.fill(inscr)
    # Show the instructions
    disp.show()
    # Wait until the participant presses any key
    # (Allowing them to read the instructions at their own pace)
    kb.get_key()
    
    # Loop through all image names
    for imgname in IMGNAMES:
    
    # Construct the path to the image
    imgpath = os.path.join(IMGDIR, imgname)
    
    # Draw the image on imgscr
    # (clear imgscr first, to be sure it's clean)
    imgscr.clear()
    imgscr.draw_image(imgpath)
    
    # Start recording gaze data
    tracker.start_recording()
    
    # Display a status message on the EyeLink computer
    # (EyeLink only; doesn't do anything for other brands)
    tracker.status_msg('Trial with %s image' % (imgname))
    
    # Log trial start
    tracker.log('TRIALSTART')
    
    # Feed the fixation Screen to the Display
    disp.fill(fixscr)
    # Update the monitor to show the fixation mark
    disp.show()
    # Log the fixation onset to the gaze data file
    tracker.log('fixation_onset')
    # Wait for the right duration
    timer.pause(FIXTIME)
    
    # Feed the image Screen to the Display
    disp.fill(imgscr)
    # Update the monitor to show the image
    disp.show()
    # Log the image onset to the gaze data file
    # Include the image name in the message!
    tracker.log('image_onset, imgname=%s' % (imgname))
    # Wait for the right duration
    timer.pause(IMGTIME)
    
    # Clear the Display
    disp.fill()
    # Update the monitor to show a blank screen
    disp.show()
    # Log the image offset
    tracker.log('image_offset')
    
    # Log the end of the trial
    tracker.log('TRIALEND')
    # Pause recording
    tracker.stop_recording()
    
    # Clear the instructions Screen
    inscr.clear()
    # Write a new message
    inscr.draw_text(text='All done!', fontsize=24)
    # Feed the new message to the Display
    disp.fill(inscr)
    # Show the message
    disp.show()
    # Wait until the participant presses any key
    # (Allowing them to read at their own pace)
    kb.get_key()
    
    # Close the connection to the eye tracker
    # (This will also close the log file!)
    tracker.close()
    
    # Close the Display
    disp.close()
    
  • eduardeduard Posts: 977

    Hi,

    I'm not sure why but your line, kb.get_key(), is not responding to key presses. For testing purposes, try using a timeout (e.g. 2000 ms), this solved it for me. However, on the long run, you should find out how to initialize a keyboard the proper way. I don't use the pygaze functions myself, so I can't really help there.

    So, use this to check if your experimental sequence is alright: kb.get_key(timeout=2000)

    Eduard

Sign In or Register to comment.