Pebble Version – Seizure Detection Algorithm

Seizure Detection Algorithm

The programme that runs on the Pebble Smart Watch does the seizure detection.

It works as follows:

    1. Collect accelerometer data (at 100 Hz sample rate) for 5 seconds.
    2. Perform a Fast Fourier Transform (FFT) to convert the acceleration time series into the frequency domain.
    3. Calculate the average power over the spectrum Region Of Interest (ROI) frequency range (5-10 Hz), and the whole spectrum.
    4. Calculate the ratio of the ROI power to the spectrum power.
    5. A seizure is detected if the ROI power is above a threshold AND the ratio of ROI power to spectrum power is above another threshold.
    6. A warning is raised if a seizure is detected for 5 seconds.
    7. An alarm is raised if a seizure is detected for a further 5 seconds.
    8. Noting that each measurement takes 5 seconds, means seizure like shaking is required for over 10 seconds for a warning and a further 5 or 10 seconds for an alarm.

Detection_algorithmMost of the settings are adjustable from the Android phone.  See the  Settings page for more information.

Alternative Multiple ROI Seizure Detection Algorithm

The above approach is trying to be very general, because we do not know the frequency of movement for a specific seizure – it could be anywhere in the 3-8 Hz range.    I have experienced an issue with a 4 Hz seizure being right on the limit of detection of the normal agorithm (Real Test of OpenSeizureDetector).

An alternative that I will try is that we will split the ROI into two halves, and do four seizure detection calculations:

  1. Full ROI (As for main algorithm above)
  2. Low frequency half of ROI
  3. High frequency half of ROI
  4. Middle half of ROI (that is overlapping the two regions above)

This should give us improved sensitivity to a particular range of movement.  I am not sure what it will do for false alarm rate though.  I will give this a try in a Beta test version 2.5 this weekend….

Fall Detection Algorithm

Version 1.3 of the pebble watch app introduced a simple fall detection algorithm and alarm function, which works as follows:

  1. Analyse 1.5 sec of acceleration data
  2. A fall is detected if there is a period of freefall (very low acceleration) and a period of high acceleration in the 1.5 sec period.

This algorithm is very crude so may well result in excessive spurious alarms so we may have to develop something more sophisticated.

The other thing to note is that a fall is a one-off event so the alarm will only initiate once.

To overcome this an option to ‘latch’ alarms has been added to the Android App this means the alarm will annunciate until the user accepts the alarm by pressing a button on the phone.

Most of the settings are adjustable from the Android phone.  See the  Settings page for more information.

Sampling System Design

What are we trying to detect

To detect a tonic-clonic seizure, we are looking for movement in the 5-10 Hz frequency range for several seconds.
We do not know the axis of the movement, so will have to just combine the 3 acceleration readings into a single value. A secondary objective could be to detect breathing related movements, which will probably be in the 0.1-0.2 Hz range (this is not implemented in the current version).

Sampling System

The Pebble watch has a 3 axis accelerometer, which we can sample at 10, 25 or 100 Hz. The accelerometer detects the acceleration due to gravity, so one value is always around 980 mg, even with the device stationary.

FFT Design

Based on a handy FFT summary by National Instruments.

Frequency Resolution

The frequency resolution (frequency range covered by each fft output data point) is 1/T, where T is the sample acquisition time.

This means if we collect samples for 1 sec, our output will be in 1Hz steps. If we collect for 10 sec we will have 0.1Hz steps.  For this application, to collect seizure type movements, 1Hz is probably enough, but if we want to detect breathing movements too, we probably want higher resolution so that we can detect sub 1Hz frequency movements.

We collect 5 seconds worth of data into a buffer then analyse it, so we get one spectrum every 5 seconds and our frequency resolution will be 0.2 Hz.

Maximum Frequency

The maximum frequency detectable by FFT f_max is 1/fs, where fs is the sampling frequency. On the pebble we have three frequencies to choose from:

  • 10 Hz – this would give f_max = 5 Hz. I suspect this is not good enough – I think a tonic-clonic seizure will give us movement in the 5-10 Hz range.
  • 25 Hz – would give f_max = 12.5 Hz – this will probably be good enough for us, but if some human movement is over 12.5 Hz, we will get artifacts appearing in the lower frequency bins, which may confuse us.
  • 100 Hz – would give f_max = 50 Hz – definitely more than the sort of frequencies I am looking for, so little risk of getting artifacts in the lower frequency bins, but 5 sec of data at 100 Hz = 500 data points so quite a lot of data to deal with on a low powered device like the Pebble watch.

Design Summary

Collect data for 5 seconds using 100 Hz sampling frequency.   If we have problems with memory limits on the Pebble, fall back to 25 Hz sampling.

Expected Results

At 100 Hz sample frequency, collecting data for 5 seconds (=500 samples), the frequency resolution will be 0.1 Hz. This means that the expected 5-10 Hz movement due to a seizure will occur in output bins 25-50. Breathing related movements at say 0.1-0.2 Hz will be in output bin 1.

We expect to have a very high DC signal (=output bin 0) because the accelerometer detects the acceleration due to gravity which is a constant significant signal upon which the movement is imposed. Given a small amount of noise, the DC signal will be smeared over several bins, which means that the breathing related movement will be swamped. To detect that we will need to sample for a longer period (but we will not need to sample at 100 Hz).

<< Back to How It Works

Leave a Reply