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)
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)#
Apply attenuation filters to remove specific frequencies (e.g., stimulation artifacts).
- design_filters()#
Design FIR bandpass filters for each frequency band.
- property extraction_functions#
Get the list of feature extraction functions.
- prefilter(x)#
Apply low and high pass filters to the signal.
- process_signal(x)#
- Parameters:
x