Skip to content

Sleep Spindles Detector toolbox analyses raw EEG signals to then extrapolate the number of sleep spindles using either the absolute or relative Sigma power (11-16Hz).

License

sjg2203/SSp_Detector

Repository files navigation

Sleep Spindles Detector

PyPI - Version Conda (channel only) PyPI pyversions License Security: bandit PyPI - Status Hit Code style: black

Sleep Spindles Detector toolbox analyses raw EEG signals to then extrapolate the number of sleep spindles using either the absolute or relative Sigma power (11-16Hz).

The toolbox is optimised for Python 3.10 and above and was tested on both Windows and macOS ARM.

Note

All dependencies are listed in requirements, Python 3.10 minimum.

Citation DOI

If you use this toolbox, please cite as followed:

Contribution Contributions Welcome

These pipelines were created and is maintained by SJG.

Contributions are more than welcome so feel free to submit a pull request!

To report a bug, please open a new issue.

Note that this program is provided with NO WARRANTY OF ANY KIND under Apache 2.0 license.

Installation of Python package

To install the toolbox, simply use:

  • Using conda Board Status
conda install -c cf-staging ssp_detector
  • Using pip Pypi package PyPI - Wheel
pip install ssp_detector

Everything worked if the following command do not return any error:

import mne
from ssp_detector import spindles_abs
from ssp_detector import spindles_rel
from tkinter import filedialog as fd

#Load an EDF file using MNE
edf=fd.askopenfilename(title='SELECT EDF FILE',filetypes=(("EDF files","*.edf"),("all files","*.*")))
raw=mne.io.read_raw_edf(edf,preload=True)
sfreq=raw.info['sfreq']

#Return sleep spindles count
spindles_abs(raw,sf=sfreq,thresh={'abs_pow':1.25})
spindles_rel(raw,sf=sfreq,thresh={'rel_pow':0.2})

Absolute Sigma power formula:

$$P_{abs\sigma}(dB)=log10(\tfrac{\int_{11}^{16}\left|x(t)\right|^{2}dt}{\int_{0.1}^{45}\left|x(t)\right|^{2}dt})$ log10(\tfrac{\int_{11}^{16}\left|x(t)\right|^{2}dt}{\int_{0.5}^{4}\left|x(t)\right|^{2}dt})$$

Relative Sigma power formula:

$$P_{rel\sigma}(dB)=log10(\tfrac{\int_{11}^{16}\left|x(t)\right|^{2}dt}{\int_{0.1}^{45}\left|x(t)\right|^{2}dt})$ log10(\tfrac{\int_{11}^{16}\left|x(t)\right|^{2}dt}{\int_{0.1}^{45}\left|x(t)\right|^{2}dt})$$

About

Sleep Spindles Detector toolbox analyses raw EEG signals to then extrapolate the number of sleep spindles using either the absolute or relative Sigma power (11-16Hz).

Resources

License

Stars

Watchers

Forks

Languages