| Reference | Downloads | Github

Iohub + eye tracker trials identification in iohub data tables

I’m sorry for fairly basic question but I can not find an answer in iohub nor psychopy documentation. That is the last thing stopping me starting my first experiment with iohub and eye tracker.

Is there a way to add a trial identification column (with custom unique names, e.g. stimuli picture) to the iohub events / eyetracking data tables?


You need to connect your ioHubConnection (let’s call it io below) to the TrialHandler for the relevant loop (let’s call it trials below:

# only do this once:
if trials.thisN == 0: # on the first trial,
    # connect the ioHub data store to our TrialHandler 
    # (i.e. to the loop called 'trials'): 

At this point, the conditions table in the HDF file only contains the names of the variables. At the end of each trial, you should call this function actually fill in the row of values for each variable on this particular trial:


If you want to save data that wasn’t in the original conditions file, that file needs to contain a column with the relevant header name, even though there is no data in its cells. Problem with IoHub datastore while using ioHubExperimentRuntime class

Do test this stuff out very carefully:

  • I’m not sure how ioHub figures out the correspondence between the values and their respective columns in the data table.
  • I think there might currently be an issue where a new session’s TrialHandlerRecordTable overwrites the previous one, rather than being added again and tagged to a new data set. If so, you might need to create a separate HDF file for each session (which negates some of the advantage of having a hierarchical file store.

If you want custom time-stamped information to be stored, this can be done simply like this:


Which ensures that the message will be stored in a table with a time stamp that matches your gaze data.

Thank you Michael a lot.
It works in the sense that I can create the TrialHandler table with trial IDs in it.
However the problem persists.

I’ll try to be as clear as I can:
The eye tracking data are stored in the e.g. events.eyetracker.MonocularEyeSampleEvents table.
These are the only data which I am interesting in BUT any analyses fails if there is no TrialID column.
I believe there should be an easy way to add such a column to this particular table since that is so basic. (BTW why it is not adding by default since there are ExperimentID and SessionID columns?).
When I record events I need to know to which trials they belong.

You need to read up on the HDF data format. NB this a is a widely-used format originally created by the NCSA (National Center for Supercomputing Applications): it isn’t something created by the PsychoPy developers. Instead, it was chosen by @sol because it is so well suited to streaming and storing last amounts of data.

Unlike simple tabular data formats like .csv, it is inherently hierarchical (that is what the H in HDF stands for). So like in a relational database, different data types are separated into different tables, and need to be joined up as required at the analysis stage. For example, periodic or constant values like trial and subject IDs shouldn’t be stored in the middle of streaming data like gaze data, which is sampled at many times per second. But messages can be time stamped so that they can be linked up as required at the analysis stage.