esdalmaijer / PyGaze

an open-source, cross-platform toolbox for minimal-effort programming of eye tracking experiments
www.pygaze.org
GNU General Public License v3.0
670 stars 211 forks source link

How to produce eye data file #156

Closed procton closed 2 years ago

procton commented 3 years ago

I have initialized the tracker as follows

disp = Display()
tracker = EyeTracker(disp, eyedatafile='C:/temp/datafile.log', logfile='./log.txt')
tracker.calibrate()

in my working PoC. I am able to run my PoC and see that eye tracking is fine, but at the end of the execution, no data is collected as per eyedatafileparameter. What I am missing ? Thank you

esdalmaijer commented 3 years ago

Hi Paolo,

It would help if you specified what tracker you are using.

It would also help if you clarify what you mean by "PoC".

As for your code snippet, the eyedatafile keyword is not an actual keyword. The logfile keyword does use (although, oops, it's data_file in EyeLink). The best way to set this, is to create a constants.py file that you then import in your script. This constants.py file could have the following content:

import os

# Back-end for the display. Choose either "psychopy" or "pygame".
DISPTYPE = "psychopy"
# Display resolution in pixels as (width,height). Needs to be integers!
DISPSIZE = (1280,1024)

# TODO: Change the TRACKERTYPE to your own.
# Tracker type. Choose from: "alea", "eyelink", "eyelogic", "eyetribe", "opengaze",
# "smi", "tobii", "tobii-legacy", "dummy", or "dumbdummy". (Note: if DUMMYMODE==True,
# TRACKERTYPE will be set to "dummy" automatically.)
TRACKERTYPE = "eyelink"

# Ask the user for a file name.
user_defined_name = input("Please provide a file name: ")

# EyeLink does not allow for names over 8 characters.
if TRACKERTYPE == "eyelink":
    while len(user_defined_name) > 8:
        print("EyeLink names should have fewer than 8 characters!")
        user_defined_name = input("Please provide a file name: ")

# Auto-detect the current directory.
this_dir = os.path.dirname(os.path.abspath(__file__))

# Name of the log file, without path or extension.
LOGFILENAME = user_defined_name
# Path to the log file.
LOGFILE = os.path.join(this_dir, LOGFILENAME)

Cheers, Edwin

procton commented 3 years ago

@esdalmaijer thank you for your effort. PoC stands for Proof of concept, basically I am trying one of the provided samples (pygaze_trackertest) setting the dummy tracker. I followed your advice and I implemented my constants.py as follows:

import os
# Back-end for the display. Choose either "psychopy" or "pygame".
DISPTYPE = "pygame"
# Display resolution in pixels as (width,height). Needs to be integers!
DISPSIZE = 1920, 1080
# TODO: Change the TRACKERTYPE to your own.
# Tracker type. Choose from: "alea", "eyelink", "eyelogic", "eyetribe", "opengaze",
# "smi", "tobii", "tobii-legacy", "dummy", or "dumbdummy". (Note: if DUMMYMODE==True,
# TRACKERTYPE will be set to "dummy" automatically.)
TRACKERTYPE = "dummy"
user_defined_name = 'out.log'
# Auto-detect the current directory.
this_dir = os.path.dirname(os.path.abspath(__file__))
# Name of the log file, without path or extension.
LOGFILENAME = user_defined_name
# Path to the log file.
LOGFILE = os.path.join(this_dir, LOGFILENAME)

then I use EyeTracker as follows

disp = Display()
tracker = EyeTracker(disp)
tracker.calibrate()

The sample works fine, but no data is collected (I cannot find any out.log data file).

esdalmaijer commented 3 years ago

Ah, I see. The "dummy" trackertype does not produce a data file, as there is no gaze to record.

procton commented 3 years ago

So without any phisycal device I cannot collect data, correct ? If true, it would help me a lot to have a sample log file, just to understand what kind of data are collected and to better evaluate if PyGaze fits with our project needs. Thank you in advance (and happy Easter)

esdalmaijer commented 3 years ago

Yes. You'd be very welcome to write some functionality into the Dummy class, but keep in mind that different trackers produce different files. Each manufacturer has their own standard, and while there is considerable overlap, there are important differences too.