-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add buttons #13287
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
base: main
Are you sure you want to change the base?
Add buttons #13287
Changes from all commits
bf5b980
1dca05d
5b9e385
9ded82d
8178b0f
41a12cb
a6624c0
7671ed4
f7a54d1
0d5f6ce
5ad0f0e
4e87100
80e929f
96043cd
b50a29a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -201,6 +201,19 @@ def _simulate_eye_tracking_data(in_file, out_file): | |||||||||||||||||||||||||||||||||||||||||
"SAMPLES\tPUPIL\tLEFT\tVEL\tRES\tHTARGET\tRATE\t1000.00" | ||||||||||||||||||||||||||||||||||||||||||
"\tTRACKING\tCR\tFILTER\t2\tINPUT" | ||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
# Define your known BUTTON events | ||||||||||||||||||||||||||||||||||||||||||
button_events = [ | ||||||||||||||||||||||||||||||||||||||||||
(5488529, 1, 0), | ||||||||||||||||||||||||||||||||||||||||||
(5488532, 1, 1), | ||||||||||||||||||||||||||||||||||||||||||
(5488540, 1, 0), | ||||||||||||||||||||||||||||||||||||||||||
(5488543, 1, 1), | ||||||||||||||||||||||||||||||||||||||||||
(5488550, 1, 0), | ||||||||||||||||||||||||||||||||||||||||||
(5488553, 1, 1), | ||||||||||||||||||||||||||||||||||||||||||
(5488571, 1, 0), | ||||||||||||||||||||||||||||||||||||||||||
] | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+205
to
+214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am just making sure that the timestamps here line up with the adjustments I made below. |
||||||||||||||||||||||||||||||||||||||||||
button_idx = 0 | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
with out_file.open("w") as fp: | ||||||||||||||||||||||||||||||||||||||||||
in_recording_block = False | ||||||||||||||||||||||||||||||||||||||||||
events = [] | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -214,7 +227,7 @@ def _simulate_eye_tracking_data(in_file, out_file): | |||||||||||||||||||||||||||||||||||||||||
if event_type.isnumeric(): # samples | ||||||||||||||||||||||||||||||||||||||||||
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"): | ||||||||||||||||||||||||||||||||||||||||||
elif event_type in ("EFIX", "ESACC", "BUTTON"): | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
if event_type == "ESACC": | ||||||||||||||||||||||||||||||||||||||||||
tokens[5:7] = [".", "."] # pretend start pos is unknown | ||||||||||||||||||||||||||||||||||||||||||
tokens.extend(["45", "45"]) # resolution | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -224,6 +237,15 @@ def _simulate_eye_tracking_data(in_file, out_file): | |||||||||||||||||||||||||||||||||||||||||
tokens.append("INPUT") | ||||||||||||||||||||||||||||||||||||||||||
elif event_type == "EBLINK": | ||||||||||||||||||||||||||||||||||||||||||
continue # simulate no blink events | ||||||||||||||||||||||||||||||||||||||||||
elif event_type == "BUTTON": | ||||||||||||||||||||||||||||||||||||||||||
# simulate a button event | ||||||||||||||||||||||||||||||||||||||||||
tokens[1] = "BUTTON" # simulate button press | ||||||||||||||||||||||||||||||||||||||||||
tokens[2] = "1" # simulate button 1 | ||||||||||||||||||||||||||||||||||||||||||
tokens[3] = "1" # simulate button pressed | ||||||||||||||||||||||||||||||||||||||||||
tokens[4:4] = ["100", "20", "45", "45", "127.0"] | ||||||||||||||||||||||||||||||||||||||||||
tokens.extend(["1497.0", "5189.0", "512.5", "............."]) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
continue | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+240
to
+248
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Hint: This simulated eyetracking data is built off the actual eyetracking test file ~/mne_data/MNE-testing-data/eyetrack/test_eyelink_HREF.asc, which doesn't have any button events! So the code you added there will never actually be hit : ) |
||||||||||||||||||||||||||||||||||||||||||
elif event_type == "END": | ||||||||||||||||||||||||||||||||||||||||||
pass | ||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -246,6 +268,22 @@ def _simulate_eye_tracking_data(in_file, out_file): | |||||||||||||||||||||||||||||||||||||||||
"...\t1497\t5189\t512.5\t.............\n" | ||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
for timestamp in np.arange(5488500, 5488600): # 100 samples | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
So these new lines you appended to the end of the simulated file, actually had earlier timestamps than the previous lines, which breaks things. So I'm just making sure the timestamps are increasing. |
||||||||||||||||||||||||||||||||||||||||||
fp.write( | ||||||||||||||||||||||||||||||||||||||||||
f"{timestamp}\t-2434.0\t-1760.0\t840.0\t100\t20\t45\t45\t127.0\t" | ||||||||||||||||||||||||||||||||||||||||||
"...\t1497\t5189\t512.5\t.............\n" | ||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||
# Check and insert button events at this timestamp | ||||||||||||||||||||||||||||||||||||||||||
while ( | ||||||||||||||||||||||||||||||||||||||||||
button_idx < len(button_events) | ||||||||||||||||||||||||||||||||||||||||||
and button_events[button_idx][0] == timestamp | ||||||||||||||||||||||||||||||||||||||||||
): | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+277
to
+280
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
t, btn_id, state = button_events[button_idx] | ||||||||||||||||||||||||||||||||||||||||||
fp.write( | ||||||||||||||||||||||||||||||||||||||||||
f"BUTTON\t{t}\t{btn_id}\t{state}\t100\t20\t45\t45\t127.0\t" | ||||||||||||||||||||||||||||||||||||||||||
"1497.0\t5189.0\t512.5\t.............\n" | ||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||
button_idx += 1 | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like reasonable modifications, but later I'd expect some assertions about the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WouterKroot do you need more guidance on this part specifically? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes please, not sure that I follow. What do you mean by assertions, as in tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if you look later in the file you see stuff like mne-python/mne/io/eyelink/tests/test_eyelink.py Lines 318 to 319 in b50a29a
I would expect similar
make sense? And you can add to the test and test locally with
to make sure it passes before pushing |
||||||||||||||||||||||||||||||||||||||||||
fp.write("END\t7453390\tRIGHT\tSAMPLES\tEVENTS\n") | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this
_pl
function was supposed to add ans
character in the case of multiple button events (because_pl
is not defined), but I think the logging message below is good enough?