braindecode.training.szcore_event_scores#

braindecode.training.szcore_event_scores(reference, hypothesis, recording_duration, *, tolerance_start=30.0, tolerance_end=60.0, min_overlap=0.0, max_event_duration=300.0, min_duration_between_events=90.0)[source]#

SzCORE event-based seizure scoring of one recording.

Events closer than min_duration_between_events are merged, then events longer than max_event_duration are split into pieces that count as separate events. A reference event is detected (true positive) when the hypothesis overlaps it, extended by tolerance_start seconds before and tolerance_end seconds after, by more than min_overlap of that window. A hypothesis event that touches no detected window is a false positive. The defaults are those of the SzCORE framework [1], and the result matches timescoring 0.0.7, its reference implementation, for sorted, non-overlapping events. Time is sampled at 10 Hz.

Parameters:
  • reference (array-like of shape (n_events, 2)) – Annotated seizures as (onset, offset) in seconds. May be empty.

  • hypothesis (array-like of shape (n_events, 2)) – Predicted seizures as (onset, offset) in seconds. May be empty.

  • recording_duration (float) – Length of the recording in seconds, the time base of the false-alarm rates. Events are clipped to it; a hypothesis event that starts after it still counts as a false positive, as in timescoring.

  • tolerance_start (float) – Seconds before a reference event in which a detection still counts.

  • tolerance_end (float) – Seconds after a reference event in which a detection still counts.

  • min_overlap (float) – Fraction of the tolerance window the hypothesis must cover, in [0, 1).

  • max_event_duration (float) – Events longer than this many seconds are split.

  • min_duration_between_events (float) – Events less than this many seconds apart are merged.

Returns:

n_ref_events, tp and fp (integers, after merging and splitting), sensitivity, precision, f1, fp_per_hour and fp_per_day. sensitivity is NaN without reference events, precision is NaN without any hypothesis event or detection, and f1 is NaN when there is neither a reference event nor a false positive. To score a subject, sum tp, n_ref_events, fp and the durations of its recordings; SzCORE reports a dataset as the mean of its subjects’ scores.

Return type:

dict[str, float]

Examples

Convert mne.Annotations to events with np.c_[ann.onset, ann.onset + ann.duration].

>>> from braindecode.training import szcore_event_scores
>>> scores = szcore_event_scores([(1800, 1860)], [(1790, 1800)], 3600)
>>> scores["tp"], scores["fp"]
(1, 0)

References

Examples using braindecode.training.szcore_event_scores#

Seizure alarm on CHB-MIT, scored with SzCORE

Seizure alarm on CHB-MIT, scored with SzCORE