-
Notifications
You must be signed in to change notification settings - Fork 7
FFT
Previous research in seizure prediction has found that certain frequency bands of EEG data carry important information about imminent seizures. A Fast Fourier Transform (or FFT for short) gives the amplitude of a signal at each frequency. Using this we can take the amplitude at certain frequencies (in our case 8-30 Hz) and use these as the inputs to our convolutional neural network. This preprocessing technique allows us to strip away some noise from the raw EEG and reduce the amount of inputs to our neural network allowing it to run and train more effectively.
One problem with an FFT, however, is that it assumes that the input signal repeats itself and that the input signal is a repetitive unit. Since EEGs are not perfectly repetitive, this assumption of the FFT functions causes the amplitude of one frequency to leak into others. A window function minimizes the effect of this leakage by multiplying the input signal function by a window which smoothly brings the amplitude of the edges of the input signal to zero. Right now we use a short rectangular window function for our FFT. This isn't perfect, but we did find that including it improved model performance, as measured by AUROC.
This is handled by the preprocessing/fourier-transform/fft.py
script. This script assumes that the input files are laid out in a folder structure like this:
- root
- test
- positive
- negative
- training
- positive
- negative
- test
You can use the script like this:
python3 fft.py --min-freq 8 --max-freq 30 ROOT/*/*/*.raw32
where ROOT is the folder you're using to store the files.
We hardcoded the assumption that the recording was at 500 Hz. If not, change the 500s on lines 14 and 15 to the correct recording frequency.
This will produce a folder called "out" in the working directory of fft.py
(probably the same folder as fft.py
), with the same internal structure (described above) as the input directory.
The files with extensions .freq32
will then have the Fourier-transformed outputs that you can feed to the next stage.