Three pipelines for automatic epileptic spikes detection
All pipelines imply simple preprocessing, such as resampling to 250 Hz and filtering from 2 to 35 Hz.
Naive pipeline (naive
):
Operates only on the channel with the highest variance. Applies standardization to this channel and make classification by variance thresholding.
Yields the highest rate of false positives.
RECOMMENDED: Simple SVM (var1_svm
):
Operates only on the channel with the highest variance. Applies standardization to this channel.
Computes 44 features for each epoch and uses Support Vector Machines for classification.
Simple AdaBoost (var1_abdt
):
Operates only on the channel with the highest variance. Applies standardization to this channel.
Computes 44 features for each epoch and uses AdaBoost for classification.
Yields the best detection of spikes within seizures, however, can lead to increased false positives.
- conda
- python==3.7
Python libraries:
- mne == 0.22.0
- scikit-learn == 0.24.1
- scipy == 1.4.1
- joblib == 0.15.1
- numpy == 1.18.2
- imbalanced-learn == 0.8.0
- antropy == 0.1.4
- PyWavelets == 1.1.1
- coloredlogs == 14.0
To satisfy all the requirements:
- Install conda
- Open a Conda Terminal and clone the following repository using command:
git clone https://github.com/NataliiaMolch/spikes_detection_fcbg.git
- Finally, go to
spikes_detection/
directory and make a setup with one of two options:
Automatic setup (Linux):
cd spikes_detection_fcbg/
python setup.py
OR
Manual setup (Linux):
cd spikes_detection_fcbg/
conda env create -f environment.yml
echo 'export PATH=$(pwd):$PATH' >> ~/.bashrc
source ~/.bashrc
chmod u+x spikes_detection
First, make sure that all the requirements are satisfied (use the instructions above).
Before running program for spikes detection add configurations to config.ini
file (can be opened with any text editor).
Make sure that MAIN and DATA configurations are up to date.
If there are bad channels they need to interpolated for correct work of the algorithms. One can use a build-in interpolation of bad channels performed via linear splines. To indicate for each recording what channels should be interpolated create a "<recording_name>_bads.txt" file where in the first line all the bad channels are listed, separated by a comma and a space.
For example, for a recording "M9_epi2_LH.sef" with 1st and 13th channels broken create a file "M9_epi2_LH_bads.txt" with content:
e1, e13
Note that, "<recording_name>_bads.txt" file should be at the same location as "<recording_name>.sef" file.
Presence of movement artefacts can negatively affect the quality of predictions. Detection of spikes during seizures is not perfect with presented algorithms, however, presence of seizures should not affect the quality of predictions.
To exclude seizures and artefacts, create a separate .mrk file at the same location as "<recording_name>.sef" and name it: "<recording_name>_exclude.mrk". Mark artefacts/seizures beginning and ending with "Art"/"Sz" and "Art.end"/"Sz.end" correspondingly.
For example, for a recording "M9_epi2_LH.sef" create a "M9_epi2_LH_exclude.mrk" file with possible content:
TL02
2020000 2020000 Art
2056000 2056000 Art.end
2104000 2104000 Art
2112000 2112000 Art.end
2184000 2184000 Sz
2496000 2496000 Sz.end
...
Use terminal to run the program by either ways (prior modification of configuration file is needed):
Easy run:
cd spikes_detection_fcbg/
spikes_detection
Note spikes_detection
cmd has two optional options: [-p] [-e]
Option -p
: full path to configuration file with .ini extension.
If -p
option is not given, then searches for config.ini file in current working directory.
Option -e
: the name of the conda environment.
If -e
option is not given, then uses spikes_detection conda environment by default.
OR
The other way
cd spikes_detection_fcbg/
conda activate spikes_detection
python make_predictions.py
Note make_predictions.py
has one argument [--config_file]
- path to configuration file.
If not given, searches for config.ini
file in current working directory.