bridge¶
Cross-paper bridge — analytic bounds between sample- and alarm-based metrics under a declared AlarmPolicy.
Useful when comparing a published paper that reported only sample-based AUC against a paper that reported only alarm-based sensitivity + FP/hr.
Symbols¶
\(s\) — per-window sample sensitivity, \(\Pr(\hat{y} = 1 \mid y = 1)\).
\(\alpha\) — per-window false-positive rate, \(1 - \text{specificity} = \Pr(\hat{y} = 1 \mid y = 0)\).
\(\pi\) — pre-ictal-window prevalence, \(\Pr(y = 1)\).
\(\Delta\) —
cadence_seconds(seconds between prediction windows).\(\text{SOP}\) — Seizure Occurrence Period (seconds).
\(R\) —
refractory_seconds(minimum gap between alarms).
Effective K¶
The number of independent prediction windows whose “above-threshold” event would catch a seizure under the alarm semantics:
Prevalence-adjusted effective K (very-low-prevalence streams may not contain \(K\) pre-ictal-labelled windows inside one SOP):
Alarm sensitivity (per-seizure detection probability)¶
Upper bound (independent errors — optimistic envelope):
Lower bound (fully-clustered errors — if any one of the \(K_{\text{eff}}\) windows is correctly above threshold, all are; pessimistic envelope):
FP/hr (alarms per hour)¶
Naive (no refractory, independent errors):
Refractory cap (no two alarms within \(R\) seconds, regardless of \(\alpha\)):
Upper bound:
Lower bound: 0.0 by convention. Under maximal positive correlation
the alarm count collapses; a calibrated non-trivial lower bound requires
an autocorrelation-proxy parameter that sample-only metrics do not
identify.
References
Andrade et al. 2024 — sample- vs alarm-based perspectives.
Mormann et al. 2007 — definition of false-prediction rate.
docs/math/sample_to_alarm.md— paper-ready derivation including the inverse direction (alarm → sample) and a worked example.
- class scitex_seizure_metrics.bridge.SampleToAlarmBounds(alarm_sensitivity_upper, alarm_sensitivity_lower, fp_per_hour_lower, fp_per_hour_upper, K_effective=1, notes=())[source]¶
Bases:
objectAnalytic bounds on alarm-based metrics derived from sample-based.
- Attrs:
alarm_sensitivity_upper: 1 - (1 - s) ** K_eff alarm_sensitivity_lower: s (worst-case clustering) fp_per_hour_lower: 0.0 by convention (correlation-dependent) fp_per_hour_upper: min(α * preds_per_hour * (1 - π), 3600 / R) K_effective: number of independent chances actually used notes: free-form list of pertinent caveats
- Parameters:
- scitex_seizure_metrics.bridge.alarm_to_sample(*, alarm_sensitivity, fp_per_hour, sop_seconds, cadence_seconds, refractory_seconds=0.0, prevalence=0.5)[source]¶
Reverse-bound: feasible sample-metric ranges from alarm metrics.
Returns dict with sample_sensitivity_lower / upper and sample_specificity_lower / upper.
- scitex_seizure_metrics.bridge.sample_to_alarm(*, sample_sensitivity, sample_specificity, sop_seconds, cadence_seconds, refractory_seconds=0.0, prevalence=0.5)[source]¶
Bound alarm-based metrics from sample-based metrics + AlarmPolicy.
- Parameters:
sample_sensitivity (float) – per-window sensitivity (true-positive rate).
sample_specificity (float) – per-window specificity (1 - FPR).
sop_seconds (float) – Seizure Occurrence Period.
cadence_seconds (float) – time step between predictions.
refractory_seconds (float) – minimum gap between alarms.
prevalence (float) – per-window prior probability of pre-ictal class. Lower prevalence reduces K_effective (the number of independent chances to detect each seizure) AND reduces FP/hr (because the per-hour count of negative windows scales with 1-π).
- Returns:
SampleToAlarmBounds with four numbers and K_effective.
- Return type: