Free, Open Source tools to Alert Carers if someone suffers an Epileptic Seizure
The Original OSD algorithm looks for seizure-like rhythmic motion in accelerometer data. It uses a frequency analysis approach and has been part of OpenSeizureDetector since the early versions.
At a high level:
flowchart LR
A[Acceleration samples] --> B[FFT]
B --> C[ROI power between AlarmFreqMin and AlarmFreqMax]
B --> D[Total spectral power up to cutoff]
C --> E[Check 1: ROI power > AlarmThresh]
C --> F[Check 2: 10 x ROI power / spectrum power > AlarmRatioThresh]
D --> F
E --> G{Both checks true?}
F --> G
G -->|Yes| H[OSD algorithm alarm]
G -->|No| I[OSD algorithm OK]
These are the key settings you can tune in current Android app versions:
| Setting | What it changes |
|---|---|
| OsdAlarmActive | Enables or disables the Original OSD algorithm. |
| AlarmFreqMin | Lower edge of the target frequency band. Lower values make it more sensitive to slower rhythmic movement. |
| AlarmFreqMax | Upper edge of the target frequency band. Higher values include faster rhythmic movement. |
| AlarmThresh | Minimum movement power needed before OSD can trigger. Increasing it usually reduces sensitivity and false alarms. |
| AlarmRatioThresh | How concentrated movement must be in the target band. Higher values require a cleaner seizure-like frequency signature. |
flowchart TD
A[Increase AlarmThresh] --> B[Harder to trigger]
C[Decrease AlarmThresh] --> D[Easier to trigger]
E[Increase AlarmRatioThresh] --> F[Needs clearer rhythmic pattern]
G[Widen AlarmFreqMin or AlarmFreqMax range] --> H[Detects broader movement patterns]
For context and history of the frequency method, see the project notes at: https://www.openseizuredetector.org.uk/?page_id=455
This section provides the detailed technical description of the OSD algorithm and design rationale.
The original OSD acceleration algorithm is described as:
Detection diagram:
Conceptually, the ROI check is:
flowchart LR
A[FFT spectrum 0 to Nyquist] --> B[ROI band AlarmFreqMin to AlarmFreqMax]
A --> C[Reference spectrum power]
B --> D[ROI power]
C --> E[Spectrum power]
D --> F[Power threshold check]
D --> G[Ratio check with spectrum power]
E --> G
The sampling rationale compares watch sampling choices 10, 25, and 100 Hz.
With a 5 second analysis window:
This is why the design summary selected 25 Hz sampling with 5 second windows.
The design targets sustained rhythmic movement typical of tonic-clonic seizure phases, with energy often concentrated in approximately the 5-10 Hz region.
Important assumptions:
The practical trade-off is between sampling frequency, maximum detectable frequency, and compute/data load.
| Sampling frequency | Nyquist (f_s/2) | Interpretation |
|---|---|---|
| 10 Hz | 5 Hz | Considered borderline/too low for seizure motion around 5-10 Hz |
| 25 Hz | 12.5 Hz | Chosen compromise: covers target band with manageable processing |
| 100 Hz | 50 Hz | Plenty of bandwidth, but much higher data and compute load |
For a 5 second analysis window:
This means the detector updates in discrete analysis windows (every 5 seconds), each with 0.2 Hz spectral bin spacing.
Timing can be interpreted as:
In current app architecture, final app-level WARNING/ALARM timing is additionally controlled by Algorithm Voting timing settings (WarnTime and AlarmTime), so effective user-visible timing depends on both algorithm output persistence and global state-machine settings.
flowchart LR
A[5 s analysis window] --> B[OSD alarm/no alarm result]
B --> C[Consecutive positive windows accumulate]
C --> D[Global warning and alarm timers]
D --> E[User-visible OK/WARNING/ALARM state]
Expected FFT-derived behavior:
| Observation | Why it happens | Practical implication |
|---|---|---|
| Strong DC or very low-frequency component | Accelerometer includes gravity offset | Low-frequency bins can dominate unless normalized/ratio-based checks are used |
| ROI band rises during rhythmic shaking | Seizure-like rhythmic motion concentrates energy in ROI | ROI power threshold is a primary detector gate |
| Ratio check improves specificity | Compares ROI concentration to broader spectrum | Helps reject broad-spectrum movement that is not seizure-like |
The documentation also describes an alternative detector variant using more than one Region Of Interest (for example standard 3-8 Hz plus an additional lower-frequency band) to improve sensitivity for some partial or lower-frequency patterns.
This is presented as an experimental extension rather than the baseline default path.
flowchart TD
A[FFT spectrum] --> B[ROI 1: standard seizure band]
A --> C[ROI 2: lower-frequency auxiliary band]
B --> D[Compute band powers and ratios]
C --> D
D --> E[Combine criteria for detection decision]
The algorithm write-up was created in 2015 and updated in 2024 to better match Garmin/PineTime implementation while retaining the original sampling and FFT rationale.