From 30254cef3789530c7f321a7840a6a7128d8f42bd Mon Sep 17 00:00:00 2001 From: Scott Huberty Date: Thu, 12 Sep 2024 12:20:46 -0700 Subject: [PATCH 1/2] TST: Make it break --- mne/io/eyelink/tests/test_eyelink.py | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/mne/io/eyelink/tests/test_eyelink.py b/mne/io/eyelink/tests/test_eyelink.py index e270b8cbbe5..53aef4b7874 100644 --- a/mne/io/eyelink/tests/test_eyelink.py +++ b/mne/io/eyelink/tests/test_eyelink.py @@ -193,6 +193,43 @@ def test_find_overlaps(): assert overlap_df["eye"].iloc[0] == "both" +@requires_testing_data +@pytest.mark.parametrize("fname", [fname]) +def test_bino_to_mono(tmp_path, fname): + """Test a file that switched from binocular to monocular mid-recording.""" + out_file = tmp_path / "tmp_eyelink.asc" + in_file = Path(fname) + + with in_file.open() as file: + lines = file.readlines() + end_line = lines[-2] + end_ts = int(end_line.split("\t")[1]) + # Now only left eye data + second_block = [] + new_ts = end_ts + 1 + info = ["GAZE", "LEFT", "RATE", "500.00", "TRACKING", "CR", "FILTER", "2"] + start = ["START", f"{new_ts}", "LEFT", "SAMPLES", "EVENTS"] + samples = ["SAMPLES"] + info + events = ["EVENTS"] + info + second_block.append("\t".join(start) + "\n") + second_block.append("\t".join(samples) + "\n") + second_block.append("\t".join(events) + "\n") + # Some fake data + left = ["960", "540", "0.0", "..."] # x, y, pupil, status + NUM_FAKE_SAMPLES = 10 + for ii in range(NUM_FAKE_SAMPLES): + ts = new_ts + ii + tokens = [f"{ts}"] + left + second_block.append("\t".join(tokens) + "\n") + end_ts = ts + 1 + end_block = ["END", f"{end_ts}", "SAMPLES", "EVENTS", "RES", "45", "45"] + second_block.append("\t".join(end_block)) + lines += second_block + with out_file.open("w") as file: + file.writelines(lines) + assert read_raw_eyelink(out_file) + + def _simulate_eye_tracking_data(in_file, out_file): out_file = Path(out_file) From 863ff752565fccfa0b1357c511953cb68e82f37f Mon Sep 17 00:00:00 2001 From: Scott Huberty Date: Thu, 12 Sep 2024 12:52:40 -0700 Subject: [PATCH 2/2] Changelog [ci skip] --- doc/changes/devel/12847.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/devel/12847.bugfix.rst diff --git a/doc/changes/devel/12847.bugfix.rst b/doc/changes/devel/12847.bugfix.rst new file mode 100644 index 00000000000..26301853842 --- /dev/null +++ b/doc/changes/devel/12847.bugfix.rst @@ -0,0 +1 @@ +Handle scenario where an Eyelink recording switched from binocular to monocular mode during a trial by `Scott Huberty`_ \ No newline at end of file