Feature Extraction#

Sleep Feature Extractor#

The Feature Extractor package contains SleepSpectralFeatureExtractor for spectral feature extraction from designed for hypnogram classification from a raw EEG signal.

The extractor can return data rate which gives a relative ratio of valid values in the input signal based on a number of NaN values. The extractor requires information about frequency bands at which parameters will be calculated. Please see an example bellow.

Example

import sys
import numpy as np
from best.feature_extraction.Feature_Extractor import SleepSpectralFeatureExtractor

# Example synthetic signal generator
fs = 500 # sampling frequency
f = 10 # sin frequency
a = 1 # amplitude
b = 0 # bias
t = np.arange(0, 1000, 1/fs)
x = a * np.sin(2*np.pi*f*t) + b

# Spectral Feature  Extraction
fs = 500 # sampling frequency of an analysed signal
segm_size = 30 # time length of a segment which is used for extraction of each feature
fbands = [[1, 4],
 [4, 8],
 [8, 12],
 [12, 14],
 [14, 20],
 [20, 30]] # frequency bands at which you want to extract features

from sleep_classification.FeatureExtractor.SpectralFeatures import mean_bands, relative_bands

Extractor = SleepSpectralFeatureExtractor(
    fs=fs,
    segm_size=segm_size,
    fbands=fbands,
    datarate=True
)


Extractor_MeanBand._extraction_functions =         [
        mean_bands,
        mean_frequency,
        relative_bands,
    ]

feature_values, feature_names = Extractor(x)

Sources#

This Feature Extractor implementation is based on the following papers (when use whole, parts, or are inspired by, we appreciate you acknowledge and refer these journal papers)

Kremen, V., Duque, J. J., Brinkmann, B. H., Berry, B. M., Kucewicz, M. T., Khadjevand, F., G.A. Worrell, G. A. (2017). Behavioral state classification in epileptic brain using intracranial electrophysiology. Journal of Neural Engineering, 14(2), 026001. https://doi.org/10.1088/1741-2552/aa5688
Kremen, V., Brinkmann, B. H., Van Gompel, J. J., Stead, S. (Matt) M., St Louis, E. K., & Worrell, G. A. (2018). Automated Unsupervised Behavioral State Classification using Intracranial Electrophysiology. Journal of Neural Engineering. https://doi.org/10.1088/1741-2552/aae5ab
Gerla, V., Kremen, V., Macas, M., Dudysova, D., Mladek, A., Sos, P., & Lhotska, L. (2019). Iterative expert-in-the-loop classification of hypnogram PSG recordings using a hierarchical clustering. Journal of Neuroscience Methods, 317(February), 61?70. https://doi.org/10.1016/j.jneumeth.2019.01.013

and on repository Semi Automated Sleep Classifier, see details in the original repository.

class brainmaze_eeg.features.feature_extraction.SleepSpectralFeatureExtractor(fs: float = None, segm_size: float = None, fbands: list = None, sperwelchseg: float = None, soverlapwelchseg: float = 0.0, nfft: int = None, filters_attenuate: list = [], repeat_attenuate: int = 1, ignore_bands: list = [], datarate: bool = False, n_processes: int = 1)#
attenuate(x)#
design_filters()#
property extraction_functions#
prefilter(x)#
process_signal(x)#
Parameters:

x