From 2e357a6f9131208a0e5f69f6ca161f76dbf20f54 Mon Sep 17 00:00:00 2001 From: Scott Huberty <52462026+scott-huberty@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:08:59 -0400 Subject: [PATCH] FIX: Missing Saccade information in Eyelink File (#11877) --- mne/io/eyelink/eyelink.py | 12 ++++++------ mne/io/eyelink/tests/test_eyelink.py | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mne/io/eyelink/eyelink.py b/mne/io/eyelink/eyelink.py index 1d64e5c7d9b..72fa5567814 100644 --- a/mne/io/eyelink/eyelink.py +++ b/mne/io/eyelink/eyelink.py @@ -590,20 +590,20 @@ def _set_df_dtypes(self): for key, df in self.dataframes.items(): if key in ["samples", "DINS"]: # convert missing position values to NaN - self._set_missing_values(df) + self._set_missing_values(df, df.columns[1:]) _set_pandas_dtype(df, df.columns, float, verbose="warning") elif key in ["blinks", "fixations", "saccades"]: + self._set_missing_values(df, df.columns[1:]) _set_pandas_dtype(df, df.columns[1:], float, verbose="warning") elif key == "messages": _set_pandas_dtype(df, ["time"], float, verbose="warning") # timestamp - def _set_missing_values(self, df): + def _set_missing_values(self, df, columns): """Set missing values to NaN. operates in-place.""" missing_vals = (".", "MISSING_DATA") - for col in df.columns: - if col.startswith(("xpos", "ypos")): - # we explicitly use numpy instead of pd.replace because it is faster - df[col] = np.where(df[col].isin(missing_vals), np.nan, df[col]) + for col in columns: + # we explicitly use numpy instead of pd.replace because it is faster + df[col] = np.where(df[col].isin(missing_vals), np.nan, df[col]) def _create_info(self, ch_names, sfreq): """Create info object for RawEyelink.""" diff --git a/mne/io/eyelink/tests/test_eyelink.py b/mne/io/eyelink/tests/test_eyelink.py index 690d930c913..6341ab25014 100644 --- a/mne/io/eyelink/tests/test_eyelink.py +++ b/mne/io/eyelink/tests/test_eyelink.py @@ -209,6 +209,8 @@ def _simulate_eye_tracking_data(in_file, out_file): tokens[4:4] = ["100", "20", "45", "45", "127.0"] # vel, res, DIN tokens.extend(["1497.0", "5189.0", "512.5", "............."]) elif event_type in ("EFIX", "ESACC"): + if event_type == "ESACC": + tokens[5:7] = [".", "."] # pretend start pos is unknown tokens.extend(["45", "45"]) # resolution elif event_type == "SAMPLES": tokens[1] = "PUPIL" # simulate raw coordinate data