Skip to content

Commit

Permalink
Check for duplicate triggers within trials
Browse files Browse the repository at this point in the history
  • Loading branch information
smathot committed Mar 26, 2024
1 parent f2cd15a commit 6143e40
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions eeg_eyetracking_parser/_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,15 @@ def _validate_events(events):
codes = events[:, 2]
if np.any((codes < 1) | (codes > 255)):
raise ValueError('trigger codes should be values between 1 and 255')
# Check for duplicate triggers within trials
trialid = -1
triggers = []
for code in codes:
if code >= 128:
trialid += 1
triggers = []
if code in triggers:
raise ValueError(
f'duplicate trigger {code} in trial {trialid}, label {hex(255 - 128 - trialid % 128)}')
triggers.append(code)
return events

0 comments on commit 6143e40

Please sign in to comment.