Communicating with EyeLink
Communication with the EyeLink is possible from a number of different platforms. The following sections will detail various aspects of this communication.
Adding Additional Data to the EDF File
Due to the flexibility of the EyeLink and the EDF file format, it is possible to add additional data to be directly recorded into the EDF file with the eyetracking data. This is extremely useful, as it allows you to include such things as target/distractor locations, subject responses, etc. There is no real practical limit on the number of the items you can record in the EDF file, but try to include only what is necessary for scoring eyetracking data. Each additional variable (target loc/responses/etc) you track will add an addional entire channel when the EDF file is converted to Grapes compatible format.
As an overview, adding data to the EDF file works as follows. The experiment sends a message to the eyetracker which contains a header, variable, and value. The header is simply there for the conversion process, such that all variables which need to be tracked should have their messages start with '3rdI'. Next comes the name of the variable, which can be anything, so long as it is connected (i.e. no spaces). Finally, comes the value, which needs to be a number of any format (i.e. integer, float, etc). After a message is sent, a channel is created for that variable, and it is set at the value sent until another message is sent changing the value.
So any number of variables can be used, with a message sent anytime their values change.
Adding data with MGL
To add a variable with MGL, simply send a messages as follows:
Eyelink('Message','3rdI XDAT %i',3);
Note that the message string acts as a sprintf string, so that the value is substitued in, creating the message string '3rdI XDAT 3'. Here are some more examples:
Eyelink('Message','3rdI TarX %i',stimulus.target.X);
Eyelink('Message','3rdI TarY %i',stimulus.target.Y);
Eyelink('Message','3rdI XDAT %i',4);
When this file is converted to grapes format, in addition to the x,y,pupil, and trial channels, it will have XDAT, TarX, and TarY channels.
Addition data with Experiment Builder
To add a variable with Experiment builder, simply have your action send a Message with the string in the appropriate format:
3rdI XDAT 3
Converting the EDF to Grapes format
Once you have collected EDF data, you can convert it to Grapes compatible format with the command line command edf2thirdI. There are several ways to call this command, detailed below. Which ever method you use when executing the command, the output will be a grapes compatible file as well as a header file which gives the channel/datatype/# of samples information which is needed when loading the data into grapes.
Option 1 for running edf2thirdI is to simply supply the name of the EDF file as an argument. This will output a grapes file with the same name as the orginal EDF file, but with an .eye extension and a header text file.
edf2thirdI example.edf
Option 2 for running edf2thirdI is to pass both the name of the EDF file, and the name of an output file. This allows you to both rename the file, and to give it an alternative extension, which comes in handy when usings Grapes association files for loading.
edf2thirdI example.edf example.sre
The final option for running edf2third is to pass the EDF file, a new name, and a range of trials to extract. This allows you to pull out a subset of the data, and can come in handy when you collect long runs, as Grapes can only handle so much information.
edf2thirdI example.edf example1-20.sre 1 20
In addition to the actual data file, the conversion also creates a header file, which gives you details about the conversion and the data itself. This is extremely important when opening the data in Grapes or creating Grapes association files. An example header file, example1-20-header.txt, from the conversion above, is shown below:
** Converted from example.edf, extracted trials 1 to 20 (of 40) **
Samples: 16742
Datatype: Double
# of Channels: 7
Channels: X,Y,Pupil,Trial,XDAT,TarX,TarY
When you open the data file in Grapes, you need to make sure these parameters are entered correctly. Change the datatype to Double, enter the number of channels and the channel names. Finally, delete whatever value is in samples and press 'Enter'. It should automatically fill in the number of samples it finds in the file, which should match the value in the extracted header file. If it does not you have entered something incorrectly. Make sure you are looking at the correct data file/header file pair.
To ease file opening in the future, you can create a custom association file for the data from a specific study. This will allow you to open the data without having to enter the pertinent data each time. To do this, open grapes and select File > Associate... This will open the Associate Dialog where you can create a new association. Scroll down on the list until you reach a blank row. Enter a unique three character extension value for this particular association in the 'Ext' column. This will be the extension you give the output file, as shown in Option 2 above. Be sure to wrap the extension in quotes. Next enter a simple description in the "Type". Enter the number of channels in the "#Chan" column, enter an empty pair of quotes for "ChanSize", and set the "DataType" column "Double". Finally enter the SampRate and Channel Labels, being sure to wrap any values you enter in quotes. Click 'Ok'.
Now whenever you open a file with the unique extention Grapes will automatically fill in the appropriate values, simplifying file opening considerably.
