Skip to content

Commit

Permalink
Merge branch 'main' into refactor-epochs-splits-naming-test
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner authored Aug 14, 2023
2 parents ef716f2 + 2e357a6 commit 030f5f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
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

0 comments on commit 030f5f0

Please sign in to comment.