Skip to content

Commit 6b5e011

Browse files
committed
ENH: Read and store "START" and "END" events from EDF file
These events indicate when the Eyetracking started and stopped recording, respectively. There can be multiple of these events, meaning that the eyetracker started and paused (e.g. during a calibration sequence or between trials). The pyeparse authors appeared to know about "START" and "END events in EDF files, but they just used python's `pass` to skip handling these events. I adjusted our event handlers to give both start and end events an entry in `EDF["discrete"]. It's important to store this info because for some recordings (read: users) there is a time gap between an end event and the subsequent start event. In other words, there is a pause/gap in the recording that the user might want to know about.
1 parent 1d57c07 commit 6b5e011

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/eyelinkio/edf/read.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ def __exit__(self, type_, value, traceback):
151151
BUTTONEVENT="buttons",
152152
INPUTEVENT="inputs",
153153
MESSAGEEVENT="messages",
154+
STARTEVENTS="starts",
155+
ENDEVENTS="ends",
154156
)
155157

156158

@@ -209,7 +211,16 @@ def _read_raw_edf(fname):
209211
#
210212
discrete = res["discrete"]
211213
info = res["info"]
212-
event_types = ("saccades", "fixations", "blinks", "buttons", "inputs", "messages")
214+
event_types = (
215+
"saccades",
216+
"fixations",
217+
"blinks",
218+
"buttons",
219+
"inputs",
220+
"messages",
221+
"starts",
222+
"ends",
223+
)
213224
info["sample_fields"] = info["sample_fields"][1:] # omit time
214225

215226
#
@@ -541,6 +552,10 @@ def _handle_end(edf, res, name):
541552
f = ["sttime", "buttons"]
542553
elif name == "inputs":
543554
f = ["sttime", "input"]
555+
elif name == "starts":
556+
f = ["sttime"]
557+
elif name == "ends":
558+
f = ["sttime"]
544559
else:
545560
raise KeyError(f"Unknown name {name}")
546561
res["edf_fields"][name] = f
@@ -592,7 +607,7 @@ def _handle_version(res):
592607
BREAKPARSE=_handle_pass,
593608
STARTSAMPLES=_handle_pass,
594609
ENDSAMPLES=_handle_pass,
595-
STARTEVENTS=_handle_pass,
596-
ENDEVENTS=_handle_pass,
610+
STARTEVENTS=partial(_handle_end, name="starts"),
611+
ENDEVENTS=partial(_handle_end, name="ends"),
597612
VERSION=_handle_version,
598613
)

0 commit comments

Comments
 (0)