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_eventsare merged, then events longer thanmax_event_durationare split into pieces that count as separate events. A reference event is detected (true positive) when the hypothesis overlaps it, extended bytolerance_startseconds before andtolerance_endseconds after, by more thanmin_overlapof 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 matchestimescoring0.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 intimescoring.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,tpandfp(integers, after merging and splitting),sensitivity,precision,f1,fp_per_hourandfp_per_day.sensitivityis NaN without reference events,precisionis NaN without any hypothesis event or detection, andf1is NaN when there is neither a reference event nor a false positive. To score a subject, sumtp,n_ref_events,fpand the durations of its recordings; SzCORE reports a dataset as the mean of its subjects’ scores.- Return type:
Examples
Convert
mne.Annotationsto events withnp.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