From bf5b98097160ea76f0eaa50d10062b1f07f1cfd3 Mon Sep 17 00:00:00 2001 From: Wouter Kroot Date: Mon, 19 May 2025 12:20:18 +0200 Subject: [PATCH 01/14] Added button event parsing in _utils.py --- mne/io/eyelink/_utils.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index 7ac03e088fd..457785c7a68 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -324,7 +324,20 @@ def _create_dataframes(raw_extras, apply_offsets): cols = ["time", "end_time", "block"] df_dict["recording_blocks"] = pd.DataFrame(blocks, columns=cols) - # TODO: Make dataframes for other eyelink events (Buttons) + # make dataframes for other button events + if raw_extras["event_lines"]["BUTTON"]: + button_events = raw_extras["event_lines"]["BUTTON"] + parsed = [] + for entry in button_events: + parsed.append({ + "onset": float(entry[0]), + "button_id": int(entry[1]), + "button_pressed": int(entry[2]) # 1 = press, 0 = release + }) + df_dict["buttons"] = pd.DataFrame(parsed) + else: + logger.info("No button events found in this file.") + return df_dict @@ -416,6 +429,10 @@ def _assign_col_names(col_names, df_dict): elif key == "messages": cols = ["time", "offset", "event_msg"] df.columns = cols + #added for buttons + elif key == "buttons": + cols = ["time", "button_id", "button_pressed"] + df.columns = cols return df_dict @@ -677,7 +694,7 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets): "pupil_right", ), } - valid_descs = ["blinks", "saccades", "fixations", "messages"] + valid_descs = ["blinks", "saccades", "fixations", "buttons", "messages" ] msg = ( "create_annotations must be True or a list containing one or" f" more of {valid_descs}." @@ -720,9 +737,17 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets): descriptions = df["event_msg"] this_annot = Annotations( onset=onsets, duration=durations, description=descriptions - ) + ) + elif (key in ["buttons"]) and (key in descs): + onsets = df["time"] + durations = np.zeros_like(onsets) + descriptions = df.apply( + lambda row: f"button_{int(row['button_id'])}_{'press' if row['button_pressed'] == 1 else 'release'}", axis=1) + this_annot = Annotations( + onset=onsets, duration= durations, description=descriptions + ) else: - continue # TODO make df and annotations for Buttons + continue if not annots: annots = this_annot elif annots: From 1dca05d75fe57115e0c739e116a2aab935035019 Mon Sep 17 00:00:00 2001 From: Wouter Kroot Date: Mon, 16 Jun 2025 14:05:54 +0200 Subject: [PATCH 02/14] Added Button events in eyelink test --- mne/io/eyelink/tests/test_eyelink.py | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/mne/io/eyelink/tests/test_eyelink.py b/mne/io/eyelink/tests/test_eyelink.py index b5239c7fe14..243a4a75433 100644 --- a/mne/io/eyelink/tests/test_eyelink.py +++ b/mne/io/eyelink/tests/test_eyelink.py @@ -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), + ] + 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"): 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 elif event_type == "END": pass else: @@ -245,6 +267,18 @@ def _simulate_eye_tracking_data(in_file, out_file): f"{timestamp}\t-2434.0\t-1760.0\t840.0\t100\t20\t45\t45\t127.0\t" "...\t1497\t5189\t512.5\t.............\n" ) + + for timestamp in np.arange(5488500, 5488600): # 100 samples + # Write sample line + 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: + t, btn_id, state = button_events[button_idx] + fp.write(f"BUTTON\t{t}\t{btn_id}\t{state}\n") + button_idx += 1 fp.write("END\t7453390\tRIGHT\tSAMPLES\tEVENTS\n") From 9ded82d42686055d8d8e6b49898905ccb10edf74 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 14:52:26 +0000 Subject: [PATCH 03/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/io/eyelink/_utils.py | 34 ++++++++++++++++------------ mne/io/eyelink/tests/test_eyelink.py | 13 +++++++---- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index 457785c7a68..75c89a25c50 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -325,19 +325,21 @@ def _create_dataframes(raw_extras, apply_offsets): df_dict["recording_blocks"] = pd.DataFrame(blocks, columns=cols) # make dataframes for other button events - if raw_extras["event_lines"]["BUTTON"]: + if raw_extras["event_lines"]["BUTTON"]: button_events = raw_extras["event_lines"]["BUTTON"] parsed = [] for entry in button_events: - parsed.append({ - "onset": float(entry[0]), - "button_id": int(entry[1]), - "button_pressed": int(entry[2]) # 1 = press, 0 = release - }) + parsed.append( + { + "onset": float(entry[0]), + "button_id": int(entry[1]), + "button_pressed": int(entry[2]), # 1 = press, 0 = release + } + ) df_dict["buttons"] = pd.DataFrame(parsed) else: logger.info("No button events found in this file.") - + return df_dict @@ -429,7 +431,7 @@ def _assign_col_names(col_names, df_dict): elif key == "messages": cols = ["time", "offset", "event_msg"] df.columns = cols - #added for buttons + # added for buttons elif key == "buttons": cols = ["time", "button_id", "button_pressed"] df.columns = cols @@ -694,7 +696,7 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets): "pupil_right", ), } - valid_descs = ["blinks", "saccades", "fixations", "buttons", "messages" ] + valid_descs = ["blinks", "saccades", "fixations", "buttons", "messages"] msg = ( "create_annotations must be True or a list containing one or" f" more of {valid_descs}." @@ -737,17 +739,19 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets): descriptions = df["event_msg"] this_annot = Annotations( onset=onsets, duration=durations, description=descriptions - ) - elif (key in ["buttons"]) and (key in descs): + ) + elif (key in ["buttons"]) and (key in descs): onsets = df["time"] durations = np.zeros_like(onsets) descriptions = df.apply( - lambda row: f"button_{int(row['button_id'])}_{'press' if row['button_pressed'] == 1 else 'release'}", axis=1) + lambda row: f"button_{int(row['button_id'])}_{'press' if row['button_pressed'] == 1 else 'release'}", + axis=1, + ) this_annot = Annotations( - onset=onsets, duration= durations, description=descriptions - ) + onset=onsets, duration=durations, description=descriptions + ) else: - continue + continue if not annots: annots = this_annot elif annots: diff --git a/mne/io/eyelink/tests/test_eyelink.py b/mne/io/eyelink/tests/test_eyelink.py index 243a4a75433..cad1e277d99 100644 --- a/mne/io/eyelink/tests/test_eyelink.py +++ b/mne/io/eyelink/tests/test_eyelink.py @@ -201,7 +201,7 @@ 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), @@ -213,7 +213,7 @@ def _simulate_eye_tracking_data(in_file, out_file): (5488571, 1, 0), ] button_idx = 0 - + with out_file.open("w") as fp: in_recording_block = False events = [] @@ -244,7 +244,7 @@ def _simulate_eye_tracking_data(in_file, out_file): tokens[3] = "1" # simulate button pressed tokens[4:4] = ["100", "20", "45", "45", "127.0"] tokens.extend(["1497.0", "5189.0", "512.5", "............."]) - + continue elif event_type == "END": pass @@ -267,7 +267,7 @@ def _simulate_eye_tracking_data(in_file, out_file): f"{timestamp}\t-2434.0\t-1760.0\t840.0\t100\t20\t45\t45\t127.0\t" "...\t1497\t5189\t512.5\t.............\n" ) - + for timestamp in np.arange(5488500, 5488600): # 100 samples # Write sample line fp.write( @@ -275,7 +275,10 @@ def _simulate_eye_tracking_data(in_file, out_file): "...\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: + while ( + button_idx < len(button_events) + and button_events[button_idx][0] == timestamp + ): t, btn_id, state = button_events[button_idx] fp.write(f"BUTTON\t{t}\t{btn_id}\t{state}\n") button_idx += 1 From 8178b0ff195c11a71a52f19cb9fe909a132e9c04 Mon Sep 17 00:00:00 2001 From: Wouter Kroot Date: Mon, 16 Jun 2025 20:17:18 +0200 Subject: [PATCH 04/14] formatting --- mne/io/eyelink/_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index 75c89a25c50..495fe45230b 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -744,7 +744,10 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets): onsets = df["time"] durations = np.zeros_like(onsets) descriptions = df.apply( - lambda row: f"button_{int(row['button_id'])}_{'press' if row['button_pressed'] == 1 else 'release'}", + lambda row: ( + f"button_{int(row['button_id'])}_" + f"{'press' if row['button_pressed'] == 1 else 'release'}" + ), axis=1, ) this_annot = Annotations( From 41a12cb201b3767017664a7adcccb4238ff6dbd0 Mon Sep 17 00:00:00 2001 From: Wouter Kroot Date: Tue, 17 Jun 2025 09:21:05 +0200 Subject: [PATCH 05/14] Formatting time sort _utils for buttons --- mne/io/eyelink/_utils.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index 495fe45230b..802b33c877f 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -740,16 +740,23 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets): this_annot = Annotations( onset=onsets, duration=durations, description=descriptions ) - elif (key in ["buttons"]) and (key in descs): + elif (key == "buttons") and (key in descs): + required_cols = {"time", "button_id", "button_pressed"} + if not required_cols.issubset(df.columns): + raise ValueError(f"Missing required columns for 'buttons': {required_cols - set(df.columns)}") + + def get_button_description(row): + try: + button_id = int(row["button_id"]) + action = "press" if row["button_pressed"] == 1 else "release" + return f"button_{button_id}_{action}" + except Exception as e: + raise ValueError(f"Invalid row for button description: {row}") from e + df = df.sort_values("time") # Add this line onsets = df["time"] durations = np.zeros_like(onsets) - descriptions = df.apply( - lambda row: ( - f"button_{int(row['button_id'])}_" - f"{'press' if row['button_pressed'] == 1 else 'release'}" - ), - axis=1, - ) + descriptions = df.apply(get_button_description, axis=1) + this_annot = Annotations( onset=onsets, duration=durations, description=descriptions ) From a6624c0461c7afdd9692f187182001ab1ac7e58a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 07:21:35 +0000 Subject: [PATCH 06/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/io/eyelink/_utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index 802b33c877f..3618821afed 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -743,7 +743,9 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets): elif (key == "buttons") and (key in descs): required_cols = {"time", "button_id", "button_pressed"} if not required_cols.issubset(df.columns): - raise ValueError(f"Missing required columns for 'buttons': {required_cols - set(df.columns)}") + raise ValueError( + f"Missing required columns for 'buttons': {required_cols - set(df.columns)}" + ) def get_button_description(row): try: @@ -751,8 +753,11 @@ def get_button_description(row): action = "press" if row["button_pressed"] == 1 else "release" return f"button_{button_id}_{action}" except Exception as e: - raise ValueError(f"Invalid row for button description: {row}") from e - df = df.sort_values("time") # Add this line + raise ValueError( + f"Invalid row for button description: {row}" + ) from e + + df = df.sort_values("time") # Add this line onsets = df["time"] durations = np.zeros_like(onsets) descriptions = df.apply(get_button_description, axis=1) From 7671ed4d4b999bdcfb693fff5d58d5a820591923 Mon Sep 17 00:00:00 2001 From: Wouter Kroot Date: Tue, 17 Jun 2025 09:24:32 +0200 Subject: [PATCH 07/14] shorten some strings for tests --- mne/io/eyelink/_utils.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index 3618821afed..7f5b01c6aed 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -743,9 +743,7 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets): elif (key == "buttons") and (key in descs): required_cols = {"time", "button_id", "button_pressed"} if not required_cols.issubset(df.columns): - raise ValueError( - f"Missing required columns for 'buttons': {required_cols - set(df.columns)}" - ) + raise ValueError(f"Missing column: {required_cols - set(df.columns)}") def get_button_description(row): try: @@ -753,11 +751,9 @@ def get_button_description(row): action = "press" if row["button_pressed"] == 1 else "release" return f"button_{button_id}_{action}" except Exception as e: - raise ValueError( - f"Invalid row for button description: {row}" - ) from e - - df = df.sort_values("time") # Add this line + raise ValueError(f"Invalid row for button: {row}") from e + + df = df.sort_values("time") onsets = df["time"] durations = np.zeros_like(onsets) descriptions = df.apply(get_button_description, axis=1) From f7a54d1e3b7f2581820e731faf06e3cbd417ecea Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 07:31:38 +0000 Subject: [PATCH 08/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/io/eyelink/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index 7f5b01c6aed..cc3c2183f36 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -752,7 +752,7 @@ def get_button_description(row): return f"button_{button_id}_{action}" except Exception as e: raise ValueError(f"Invalid row for button: {row}") from e - + df = df.sort_values("time") onsets = df["time"] durations = np.zeros_like(onsets) From 0d5f6ce67579f2f2ef55fd40a5a57798361ad6a3 Mon Sep 17 00:00:00 2001 From: Wouter Kroot Date: Tue, 17 Jun 2025 11:51:24 +0200 Subject: [PATCH 09/14] change button write syntax --- mne/io/eyelink/tests/test_eyelink.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mne/io/eyelink/tests/test_eyelink.py b/mne/io/eyelink/tests/test_eyelink.py index cad1e277d99..8605d772e3c 100644 --- a/mne/io/eyelink/tests/test_eyelink.py +++ b/mne/io/eyelink/tests/test_eyelink.py @@ -280,7 +280,8 @@ def _simulate_eye_tracking_data(in_file, out_file): and button_events[button_idx][0] == timestamp ): t, btn_id, state = button_events[button_idx] - fp.write(f"BUTTON\t{t}\t{btn_id}\t{state}\n") + 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 fp.write("END\t7453390\tRIGHT\tSAMPLES\tEVENTS\n") From 5ad0f0ee4dfdf5a4efc7924a1c11bd2583a07208 Mon Sep 17 00:00:00 2001 From: Wouter Kroot Date: Tue, 17 Jun 2025 11:53:23 +0200 Subject: [PATCH 10/14] change button write syntax --- mne/io/eyelink/tests/test_eyelink.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mne/io/eyelink/tests/test_eyelink.py b/mne/io/eyelink/tests/test_eyelink.py index 8605d772e3c..7733090f6a0 100644 --- a/mne/io/eyelink/tests/test_eyelink.py +++ b/mne/io/eyelink/tests/test_eyelink.py @@ -269,7 +269,6 @@ def _simulate_eye_tracking_data(in_file, out_file): ) for timestamp in np.arange(5488500, 5488600): # 100 samples - # Write sample line 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" @@ -283,7 +282,6 @@ def _simulate_eye_tracking_data(in_file, out_file): 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 - fp.write("END\t7453390\tRIGHT\tSAMPLES\tEVENTS\n") From 4e87100723279bf6ebf3386971068901f2a5b203 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 09:53:53 +0000 Subject: [PATCH 11/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/io/eyelink/tests/test_eyelink.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mne/io/eyelink/tests/test_eyelink.py b/mne/io/eyelink/tests/test_eyelink.py index 7733090f6a0..08ed52f98dc 100644 --- a/mne/io/eyelink/tests/test_eyelink.py +++ b/mne/io/eyelink/tests/test_eyelink.py @@ -279,8 +279,10 @@ def _simulate_eye_tracking_data(in_file, out_file): and button_events[button_idx][0] == timestamp ): 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") + 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 fp.write("END\t7453390\tRIGHT\tSAMPLES\tEVENTS\n") From 80e929f0ba22d0b57650d8c10a7845d9ea18dcf5 Mon Sep 17 00:00:00 2001 From: Wouter Kroot <120388146+WouterKroot@users.noreply.github.com> Date: Tue, 17 Jun 2025 16:38:55 +0200 Subject: [PATCH 12/14] Update mne/io/eyelink/_utils.py Co-authored-by: Eric Larson --- mne/io/eyelink/_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index cc3c2183f36..db5cc9b2676 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -337,8 +337,8 @@ def _create_dataframes(raw_extras, apply_offsets): } ) df_dict["buttons"] = pd.DataFrame(parsed) - else: - logger.info("No button events found in this file.") + n_button = len(df_dict.get('buttons', [])) + logger.info(f"Found {n_button} button event{_pl(n_button)} in this file.") return df_dict From 96043cd7749d9e1c69d4ab20ca0030ddfcc893ee Mon Sep 17 00:00:00 2001 From: Wouter Kroot <120388146+WouterKroot@users.noreply.github.com> Date: Tue, 17 Jun 2025 16:39:19 +0200 Subject: [PATCH 13/14] Update mne/io/eyelink/_utils.py Co-authored-by: Eric Larson --- mne/io/eyelink/_utils.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index db5cc9b2676..9fdd3376cf0 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -746,12 +746,9 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets): raise ValueError(f"Missing column: {required_cols - set(df.columns)}") def get_button_description(row): - try: - button_id = int(row["button_id"]) - action = "press" if row["button_pressed"] == 1 else "release" - return f"button_{button_id}_{action}" - except Exception as e: - raise ValueError(f"Invalid row for button: {row}") from e + button_id = int(row["button_id"]) + action = "press" if row["button_pressed"] == 1 else "release" + return f"button_{button_id}_{action}" df = df.sort_values("time") onsets = df["time"] From b50a29af46b05f2b231985ac620f69f6f08cbcc2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 14:40:25 +0000 Subject: [PATCH 14/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/io/eyelink/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne/io/eyelink/_utils.py b/mne/io/eyelink/_utils.py index 9fdd3376cf0..a4d5f5bf16d 100644 --- a/mne/io/eyelink/_utils.py +++ b/mne/io/eyelink/_utils.py @@ -337,7 +337,7 @@ def _create_dataframes(raw_extras, apply_offsets): } ) df_dict["buttons"] = pd.DataFrame(parsed) - n_button = len(df_dict.get('buttons', [])) + n_button = len(df_dict.get("buttons", [])) logger.info(f"Found {n_button} button event{_pl(n_button)} in this file.") return df_dict