Skip to content

Commit bed90d0

Browse files
FIX, STY: More informative messages on warnings and errors
- explicitly check that the sfreq didnt change during recording - tell the user the implications of channel dropout Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
1 parent 9d0ab84 commit bed90d0

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

mne/io/eyelink/_utils.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ def _parse_eyelink_ascii(
5959
for block in data_blocks:
6060
del block["samples"] # remove samples from block to save memory
6161

62-
# TODO: We still assume that sfreq and units are static across all blocks.
63-
# But we should probably check this with SR Research...
6462
first_block = data_blocks[0]
6563
raw_extras["pos_unit"] = first_block["info"]["unit"]
6664
raw_extras["sfreq"] = first_block["info"]["sfreq"]
@@ -175,10 +173,12 @@ def _validate_data(data_blocks: list):
175173
pupil_units = []
176174
modes = []
177175
eyes = []
176+
sfreqs = []
178177
for block in data_blocks:
179178
units.append(block["info"]["unit"])
180179
modes.append(block["info"]["tracking_mode"])
181180
eyes.append(block["info"]["eye"])
181+
sfreqs.append(block["info"]["sfreq"])
182182
pupil_units.append(block["info"]["pupil_unit"])
183183
if "GAZE" in units:
184184
logger.info(
@@ -197,12 +197,29 @@ def _validate_data(data_blocks: list):
197197

198198
if len(set(modes)) > 1:
199199
warn(
200-
"Acquisition changed between monocular and binocular "
201-
"tracking during the recording."
200+
"This recording switched between monocular and binocular tracking. "
201+
f"In order of acquisition blocks, tracking modes were {modes}. Data "
202+
"for the missing eye during monocular tracking will be filled with NaN."
202203
)
203204
# Monocular tracking but switched between left/right eye
204205
elif len(set(eyes)) > 1:
205-
warn("The eye being tracked changed during the recording.")
206+
warn(
207+
"The eye being tracked changed during the recording. "
208+
f"In order of acquisition blocks, they were {eyes}. "
209+
"Missing data for each eye will be filled with NaN."
210+
)
211+
if len(set(sfreqs)) > 1:
212+
raise RuntimeError(
213+
"The sampling frequency changed during the recording. "
214+
f"In order of acquisition blocks, they were {sfreqs}. "
215+
"please notify MNE-Python developers"
216+
) # pragma: no cover
217+
if len(set(units)) > 1:
218+
raise RuntimeError(
219+
"The unit of measurement for x/y coordinates changed during the recording. "
220+
f"In order of acquisition blocks, they were {units}. "
221+
"please notify MNE-Python developers"
222+
) # pragma: no cover
206223

207224

208225
def _get_recording_datetime(fname):

0 commit comments

Comments
 (0)