Skip to content

Commit fe3fb6f

Browse files
committed
fix: check 'states' length before inferring event durations
1 parent 0199770 commit fe3fb6f

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

neo/rawio/openephysbinaryrawio.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,18 @@ def _parse_header(self):
211211
labels = d["labels"]
212212
rising = np.where(states > 0)[0]
213213
falling = np.where(states < 0)[0]
214-
# make sure first event is rising and last is falling
215-
if states[0] < 0:
216-
falling = falling[1:]
217-
if states[-1] > 0:
218-
rising = rising[:-1]
219-
220-
if len(rising) == len(falling):
221-
durations = timestamps[falling] - timestamps[rising]
222-
else:
223-
# something wrong if we get here
224-
durations = None
214+
215+
# infer durations
216+
durations = None
217+
if len(states) > 0:
218+
# make sure first event is rising and last is falling
219+
if states[0] < 0:
220+
falling = falling[1:]
221+
if states[-1] > 0:
222+
rising = rising[:-1]
223+
224+
if len(rising) == len(falling):
225+
durations = timestamps[falling] - timestamps[rising]
225226

226227
d["rising"] = rising
227228
d["timestamps"] = timestamps[rising]

0 commit comments

Comments
 (0)