Package: eeglib
eeglibThe moduleeeglibis a library for Python that provides tools to analyse electroencephalography (EEG) signals. This library is mainly a feature extraction tool that includes lots of frequently used algorithms in EEG processing with using a sliding window approach.eeglibprovides a friendly interface that allows data scientists who work with EEG signals to extract lots of features with just a few lines.Main featuresDifferent types of processingsFFTBand PowerSynchronization LikelihoodPetrosian and Higuchi Fractal DimensionsHjorth ParametersDetrended Fluctuation AnalysisSample EntropyLempel-Ziv ComplexityCross Correlation CoeficientLoad data fromCSV filesEDF filesnumpy arraysFeature extraction orientedSliding window orientedFlexible and easyInstallationInstallation using pip:$ pip install eeglibDependenciesnumpynumbascipyscikit-learnpandaspyedflibfastdtwGetting startedBellow there is a Quickstart Guide to eeglib. If you are interested in the API, you can find ithere.Basic exampleThe next example shows a basic usage of the library. In it is shown how to load a file and apply a processing (Petrosian Fractal Dimension) to the data in windows of all the data.fromeeglib.helpersimportCSVHelperhelper=CSVHelper("fake_EEG_signal.csv")foreeginhelper:print(eeg.PFD())This will show this:[1.030892331.032298871.031814881.031232671.03069761]This returns an array of the same size of the channels of the data (5) and each position of the array correspond with each channel.Using windowsThe previous example applies the PFD to all the data in the file, but you may want to segment the data in different windows and that can be done in the next way:helper=CSVHelper("fake_EEG_signal.csv",windowSize=256)foreeginhelper:print(eeg.PFD())This will show this:[1.039224681.038977731.039717981.036746361.03873059][1.038483261.041683431.040947831.041683431.03699509][1.039964341.040456471.039964341.037740061.03947143][1.037491941.040456471.038977731.04021051.03873059]Now the function has been called 4 times, this is because of the data has a lenght of 1024 samples and the window selected has a size of 256, so the windows contained in the data are 1024/256=4.Using iteratorsNow you may want to move the windows in another ways, like the ones that are shown in the next image:So, if you want to make the windows overlap between them you can do it this way:helper=CSVHelper("fake_EEG_signal.csv",windowSize=256)foreeginhelper[::128]:print(eeg.PFD())PreprocessingMaybe you want to preprocess the signals stored in the window before extracting features from them. Currently this library allows the next Preprocessings:Bandpass filteringZ-Scores normalizationIndependent Component AnalysisThese preprocessings can be applied at the load of the data by the Helpers:helper=CSVHelper("fake_EEG_signal.csv",lowpass=30,highpass=1,normalize=True,ICA=True)Using wrappersA Wrapper is an object that envelops a helper and simplifies the proccess of computing features that can be later be used, for example, in machine learning algorithms. The next example shows an example of how wrappers can be used:fromeeglibimportwrapper,helpershelper=helpers.CSVHelper("fake_EEG_signal.csv",windowSize=128)wrap=wrapper.Wrapper(helper)wrap.addFeature.HFD()wrap.addFeature.DFT()wrap.addFeature.synchronizationLikelihood()features=wrap.getAllFeatures()So, the scheme to follow with wrappers is the next:Create the Helper object.Create the wrapper object.Select the desired features to compute. They can be parameterized by adding the parameters just behind the name.Call the method "getAllFeatures()" in order to compute every feature from every window at once or iterate over the Wrapper object for obtaining the features of each window. They are returned as a pandas.DataFrame or a pandas.Series.CitingIf eeglib has been useful in your research, please, consider citing the next article.eeglib: A Python module for EEG feature extractionDocuments relatedThis library was initialy a Final Degree Project and you can find the documentation of the development in the next link:Final Degree Project Documentation (Spanish)Later it was extented as part of a Master's thesis that can be found in the next link:Master's thesis (Spanish)Scientific papersThere are also some papers related to this library that can be seen bellow:Open AccessComputational EEG Analysis Techniques When Playing Video Games: A Systematic ReviewAnalysis of Cognitive Load Using EEG when Interacting with Mobile Deviceseeglib: A Python module for EEG feature extractionNot open accessCharacterisation of mobile-device tasks by their associated cognitive load through EEG data processingeeglib: computational analysis of cognitive performance during the use of video gamesStudying the generalisability of cognitive load measured 7with EEG