Problem reading binocular data with mne.io.read_raw_eyelink()

Hello,

I am having trouble reading eyelink data using mne.io.read_raw_eyelink() and SR Research’s edf2asc converter from python (running terminal commands).

In order to convert the eyelink .edf file to .asc, I use the following python command:

os.system(('%s %s %s -failsafe -input -y')%(EDF2ASC, edfFile, ascFile))

To read the .asc file:

eye_raw = mne.io.read_raw_eyelink(ascFile)
  • MNE version: 1.6.1
  • operating system: macOS-14.2.1-arm64-arm-64bit
  • Python version: 3.12.0

I get the following error:

Pixel coordinate data detected.Pass `scalings=dict(eyegaze=1e3)` when using plot method to make traces more legible.
Pupil-size diameter detected.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/inespontsanc/Documents/eyetracking/preprocessing/raw_preprocessing.py", line 68, in <module>
    raw = prepro_utils.prepare_eyelink_from_source(sub,DATA_DIR_HOME)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/inespontsanc/Documents/eyetracking/preprocessing/prepro_utils.py", line 241, in prepare_eyelink_from_source
    eye_raw = mne.io.read_raw_eyelink(fname)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/inespontsanc/miniconda3/envs/MemorEEG/lib/python3.12/site-packages/mne/io/eyelink/eyelink.py", line 62, in read_raw_eyelink
    raw_eyelink = RawEyelink(
                  ^^^^^^^^^^^
  File "<decorator-gen-181>", line 12, in __init__
  File "/Users/inespontsanc/miniconda3/envs/MemorEEG/lib/python3.12/site-packages/mne/io/eyelink/eyelink.py", line 107, in __init__
    eye_ch_data, info, raw_extras = _parse_eyelink_ascii(
                                    ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/inespontsanc/miniconda3/envs/MemorEEG/lib/python3.12/site-packages/mne/io/eyelink/_utils.py", line 59, in _parse_eyelink_ascii
    raw_extras["dfs"] = _assign_col_names(col_names, raw_extras["dfs"])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/inespontsanc/miniconda3/envs/MemorEEG/lib/python3.12/site-packages/mne/io/eyelink/_utils.py", line 405, in _assign_col_names
    df.columns = col_names[key]
    ^^^^^^^^^^
  File "/Users/inespontsanc/miniconda3/envs/MemorEEG/lib/python3.12/site-packages/pandas/core/generic.py", line 6218, in __setattr__
    return object.__setattr__(self, name, value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "properties.pyx", line 69, in pandas._libs.properties.AxisProperty.__set__
  File "/Users/inespontsanc/miniconda3/envs/MemorEEG/lib/python3.12/site-packages/pandas/core/generic.py", line 767, in _set_axis
    self._mgr.set_axis(axis, labels)
  File "/Users/inespontsanc/miniconda3/envs/MemorEEG/lib/python3.12/site-packages/pandas/core/internals/managers.py", line 227, in set_axis
    self._validate_set_axis(axis, new_labels)
  File "/Users/inespontsanc/miniconda3/envs/MemorEEG/lib/python3.12/site-packages/pandas/core/internals/base.py", line 85, in _validate_set_axis
    raise ValueError(
ValueError: Length mismatch: Expected axis has 8 elements, new values have 11 elements

This may be related to this post ?

When using the exact same commands on a monocular dataset, my code runs without a glitch. My new binocular data would naturally have 3 additional channels (hence 11 and not 8), however I’m not sure why this should be a problem when reading the file into mne.

Has anyone encountered this error before?

Link to example asc file

Many thanks in advance!

Ines Pont Sanchis

Hi @inespontsanc, thanks for reporting. This looks like a bug in our Eyelink reader. I’ve opened up a ticket at our issue tracker:

Hi @scott-huberty , thank you for responding to this so quickly.

I see from the bug you opened that while this might be an mne bug, it could also be an issue with the edf2asc conversion. I’m not very familiar with it, do you know if I may have used the wrong arguments, causing it to skip the data that is missing (ie the head position)? I removed the date time from my file as a precaution when sharing data as this is a subject file from a study - I did not realise this would trigger another issue!

Ah, ok! In that case we might not have to worry about that part.

Maybe but I don’t think so. Are you able to share the EDF file with me so that I can test this out? And What experiment software are you using (Psychopy, Experiment Builder, etc)?