Skip to content

Parameter 'match' in mne.preprocessing.eyetracking.interpolate_blinks silently ignored #13880

@Cathaway

Description

@Cathaway

Description of the problem

The same bug was reported as early as Sept 2025 in https://mne.discourse.group/t/dealing-with-nans-and-missing-data-in-pupil-and-eyetracking-data/11470

interpolate_blinks() function calls tbe following function to determine start and end of periods to interpolate over

in _pupillometry.py L76, it calls

_interpolate_blinks(raw, buffer, blink_annots, interpolate_gaze)

to identify start and end of periods to interpolate over, however in L91:

        mask = np.zeros_like(raw.times, dtype=bool)
        starts, ends = _annotations_starts_stops(raw, "BAD_blink")
        starts = np.divide(starts, raw.info["sfreq"])

the function's 'match' parameter, which is default to 'BAD_blink' but should accept strings or lists of strings, is silently ignored: interpolation only happen within 'BAD_blink' period

if users need to also interpolate over NaN periods by calling mne.preprocessing.annotate_nan() - which creates 'BAD_NAN' annotations, and feeding it into the function via match=['BAD_blink', 'BAD_NAN'], the latter is not interpolated

Steps to reproduce

nan_anno = mne.preprocessing.annotate_nan(raw)
    if nan_anno:
        raw.set_annotations(raw.annotations + nan_anno)
    mne.preprocessing.eyetracking.interpolate_blinks(raw=raw, buffer=(-0.01, 0.01), interpolate_gaze=True, match=['BAD_blink','BAD_NAN'])

Link to data

any Raw Eyelink file with NaN sections not covered by 'BAD_blink' annotation

Expected results

all missing data interpolated

Actual results

only periods marked with 'BAD_blink' are interpolated

this bug also causes interpolation to fail when 'BAD_blink' periods (and its buffer) are adjacent to NaNs

Additional information

Platform Windows-11-10.0.26200-SP0
Python 3.13.5 | packaged by conda-forge | (main, Jun 16 2025, 08:20:19) [MSC v.1943 64 bit (AMD64)]
Executable C:\Users\user\AppData\Local\anaconda3\envs\mne\python.exe
CPU Intel(R) Core(TM) Ultra 5 135U (14 cores)
Memory 15.5 GiB

Core
X mne 1.11.0 (outdated, release 1.12.1 is available!)

  • numpy 2.3.1 (MKL 2023.1-Product with 12 threads)
  • scipy 1.16.0
  • matplotlib 3.10.5 (backend=module://matplotlib_inline.backend_inline)

Numerical (optional)

  • sklearn 1.7.1
  • pandas 2.3.1
  • h5io 0.2.5
  • h5py 3.14.0
  • unavailable numba, nibabel, nilearn, dipy, openmeeg, cupy

Visualization (optional)

  • qtpy 2.4.1 (PyQt5=5.15.2)
  • pyqtgraph 0.13.7
  • mne-qt-browser 0.7.2
  • ipywidgets 8.1.8
  • unavailable pyvista, pyvistaqt, vtk, ipympl, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)

  • mne-icalabel 0.7.0
  • defusedxml 0.7.1
  • unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-bids-pipeline, neo, eeglabio, edfio, curryreader, mffpy, pybv, antio

the same bug is still present in 1.12 - given its source codes linked above

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions