Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Missing Saccade information in Eyelink File #11877

Merged
merged 3 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions mne/io/eyelink/eyelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 2 additions & 0 deletions mne/io/eyelink/tests/test_eyelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down