@@ -325,19 +325,21 @@ def _create_dataframes(raw_extras, apply_offsets):
325
325
df_dict ["recording_blocks" ] = pd .DataFrame (blocks , columns = cols )
326
326
327
327
# make dataframes for other button events
328
- if raw_extras ["event_lines" ]["BUTTON" ]:
328
+ if raw_extras ["event_lines" ]["BUTTON" ]:
329
329
button_events = raw_extras ["event_lines" ]["BUTTON" ]
330
330
parsed = []
331
331
for entry in button_events :
332
- parsed .append ({
333
- "onset" : float (entry [0 ]),
334
- "button_id" : int (entry [1 ]),
335
- "button_pressed" : int (entry [2 ]) # 1 = press, 0 = release
336
- })
332
+ parsed .append (
333
+ {
334
+ "onset" : float (entry [0 ]),
335
+ "button_id" : int (entry [1 ]),
336
+ "button_pressed" : int (entry [2 ]), # 1 = press, 0 = release
337
+ }
338
+ )
337
339
df_dict ["buttons" ] = pd .DataFrame (parsed )
338
340
else :
339
341
logger .info ("No button events found in this file." )
340
-
342
+
341
343
return df_dict
342
344
343
345
@@ -429,7 +431,7 @@ def _assign_col_names(col_names, df_dict):
429
431
elif key == "messages" :
430
432
cols = ["time" , "offset" , "event_msg" ]
431
433
df .columns = cols
432
- #added for buttons
434
+ # added for buttons
433
435
elif key == "buttons" :
434
436
cols = ["time" , "button_id" , "button_pressed" ]
435
437
df .columns = cols
@@ -694,7 +696,7 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets):
694
696
"pupil_right" ,
695
697
),
696
698
}
697
- valid_descs = ["blinks" , "saccades" , "fixations" , "buttons" , "messages" ]
699
+ valid_descs = ["blinks" , "saccades" , "fixations" , "buttons" , "messages" ]
698
700
msg = (
699
701
"create_annotations must be True or a list containing one or"
700
702
f" more of { valid_descs } ."
@@ -737,17 +739,19 @@ def _make_eyelink_annots(df_dict, create_annots, apply_offsets):
737
739
descriptions = df ["event_msg" ]
738
740
this_annot = Annotations (
739
741
onset = onsets , duration = durations , description = descriptions
740
- )
741
- elif (key in ["buttons" ]) and (key in descs ):
742
+ )
743
+ elif (key in ["buttons" ]) and (key in descs ):
742
744
onsets = df ["time" ]
743
745
durations = np .zeros_like (onsets )
744
746
descriptions = df .apply (
745
- lambda row : f"button_{ int (row ['button_id' ])} _{ 'press' if row ['button_pressed' ] == 1 else 'release' } " , axis = 1 )
747
+ lambda row : f"button_{ int (row ['button_id' ])} _{ 'press' if row ['button_pressed' ] == 1 else 'release' } " ,
748
+ axis = 1 ,
749
+ )
746
750
this_annot = Annotations (
747
- onset = onsets , duration = durations , description = descriptions
748
- )
751
+ onset = onsets , duration = durations , description = descriptions
752
+ )
749
753
else :
750
- continue
754
+ continue
751
755
if not annots :
752
756
annots = this_annot
753
757
elif annots :
0 commit comments