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

BUG: read raw eyelink file that switches from binocular to monocular mode #12847

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions doc/changes/devel/12847.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle scenario where an Eyelink recording switched from binocular to monocular mode during a trial by `Scott Huberty`_
37 changes: 37 additions & 0 deletions mne/io/eyelink/tests/test_eyelink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down