eeglib


Nameeeglib JSON
Version 0.4.1.1 PyPI version JSON
download
home_pagehttps://github.com/Xiul109/eeglib
SummaryA library with some tools and functions for EEG signal analysis
upload_time2023-12-28 15:53:35
maintainer
docs_urlNone
authorLuis Cabañero Gómez
requires_python
licenseMIT
keywords lib eeg signal analysis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # eeglib

The module *eeglib* is 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. *eeglib* provides a friendly interface that allows data scientists who work with EEG signals to extract lots of features with just a few lines.

## Main features
* Different types of processings
    * FFT
    * Band Power
    * Synchronization Likelihood
    * Petrosian and Higuchi Fractal Dimensions
    * Hjorth Parameters
    * Detrended Fluctuation Analysis
    * Sample Entropy
    * Lempel-Ziv Complexity
    * Cross Correlation Coeficient
* Load data from
    * CSV files
    * EDF files
    * numpy arrays
* Feature extraction oriented
* Sliding window oriented
* Flexible and easy

## Installation

Installation using pip:

`$ pip install eeglib`

## Dependencies

* numpy
* numba
* scipy
* scikit-learn
* pandas
* pyedflib
* fastdtw

# Getting started

Bellow there is a Quickstart Guide to eeglib. If you are interested in the API, you can find it [here](https://eeglib.readthedocs.io/en/latest/index.html).

## Basic example

The 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.

```python
from eeglib.helpers import CSVHelper

helper= CSVHelper("fake_EEG_signal.csv")

for eeg in helper:
    print(eeg.PFD())
```

This will show this:

```python
[ 1.03089233  1.03229887  1.03181488  1.03123267  1.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 windows

The 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:

```python
helper= CSVHelper("fake_EEG_signal.csv",windowSize=256)

for eeg in helper:
    print(eeg.PFD())
```

This will show this:

```python
[ 1.03922468  1.03897773  1.03971798  1.03674636  1.03873059]
[ 1.03848326  1.04168343  1.04094783  1.04168343  1.03699509]
[ 1.03996434  1.04045647  1.03996434  1.03774006  1.03947143]
[ 1.03749194  1.04045647  1.03897773  1.0402105   1.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 iterators

Now you may want to move the windows in another ways, like the ones that are shown in the next image:
![windows](/Examples/slidingWindow.png)

So, if you want to make the windows overlap between them you can do it this way:

```python
helper= CSVHelper("fake_EEG_signal.csv",windowSize=256)

for eeg in helper[::128]:
    print(eeg.PFD())
```

## Preprocessing

Maybe you want to preprocess the signals stored in the window before extracting features from them. Currently this library allows the next Preprocessings:
* Bandpass filtering
* Z-Scores normalization
* Independent Component Analysis

These preprocessings can be applied at the load of the data by the Helpers:
```python
helper = CSVHelper("fake_EEG_signal.csv",
        lowpass=30, highpass=1, normalize=True, ICA=True)
```

## Using wrappers

A 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:

```python
from eeglib import wrapper, helpers

helper = 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:
1. Create the Helper object.
2. Create the wrapper object.
3. Select the desired features to compute. They can be parameterized by adding the parameters just behind the name.
4. 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.

# Citing
If eeglib has been useful in your research, please, consider citing the next article.

[eeglib: A Python module for EEG feature extraction](https://www.sciencedirect.com/science/article/pii/S2352711021000753)


# Documents related
This 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)](https://ruidera.uclm.es/xmlui/handle/10578/15441)

Later it was extented as part of a Master's thesis that can be found in the next link:

[Master's thesis (Spanish)](https://ruidera.uclm.es/xmlui/handle/10578/19062)


## Scientific papers

There are also some papers related to this library that can be seen bellow:

### Open Access

* [Computational EEG Analysis Techniques When Playing Video Games: A Systematic Review](https://www.mdpi.com/2504-3900/2/19/483)
* [Analysis of Cognitive Load Using EEG when Interacting with Mobile Devices](https://www.mdpi.com/2504-3900/31/1/70)
* [eeglib: A Python module for EEG feature extraction](https://www.sciencedirect.com/science/article/pii/S2352711021000753)

### Not open access

* [Characterisation of mobile-device tasks by their associated cognitive load through EEG data processing](https://www.sciencedirect.com/science/article/abs/pii/S0167739X20305112)
* [eeglib: computational analysis of cognitive performance during the use of video games](https://link.springer.com/article/10.1007%2Fs12652-019-01592-9)
* [Studying the generalisability of cognitive load measured 7with EEG](https://www.sciencedirect.com/science/article/pii/S1746809421006297)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Xiul109/eeglib",
    "name": "eeglib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "lib EEG signal analysis",
    "author": "Luis Caba\u00f1ero G\u00f3mez",
    "author_email": "Luis.Cabanero@uclm.es",
    "download_url": "https://files.pythonhosted.org/packages/c5/02/1e1ed40cff2bb2174292f7846014d7325765c01fc76f65f00adbce07e42e/eeglib-0.4.1.1.tar.gz",
    "platform": null,
    "description": "# eeglib\n\nThe module *eeglib* is 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. *eeglib* provides a friendly interface that allows data scientists who work with EEG signals to extract lots of features with just a few lines.\n\n## Main features\n* Different types of processings\n    * FFT\n    * Band Power\n    * Synchronization Likelihood\n    * Petrosian and Higuchi Fractal Dimensions\n    * Hjorth Parameters\n    * Detrended Fluctuation Analysis\n    * Sample Entropy\n    * Lempel-Ziv Complexity\n    * Cross Correlation Coeficient\n* Load data from\n    * CSV files\n    * EDF files\n    * numpy arrays\n* Feature extraction oriented\n* Sliding window oriented\n* Flexible and easy\n\n## Installation\n\nInstallation using pip:\n\n`$ pip install eeglib`\n\n## Dependencies\n\n* numpy\n* numba\n* scipy\n* scikit-learn\n* pandas\n* pyedflib\n* fastdtw\n\n# Getting started\n\nBellow there is a Quickstart Guide to eeglib. If you are interested in the API, you can find it [here](https://eeglib.readthedocs.io/en/latest/index.html).\n\n## Basic example\n\nThe 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.\n\n```python\nfrom eeglib.helpers import CSVHelper\n\nhelper= CSVHelper(\"fake_EEG_signal.csv\")\n\nfor eeg in helper:\n    print(eeg.PFD())\n```\n\nThis will show this:\n\n```python\n[ 1.03089233  1.03229887  1.03181488  1.03123267  1.03069761]\n```\nThis returns an array of the same size of the channels of the data (5) and each position of the array correspond with each channel.\n\n## Using windows\n\nThe 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:\n\n```python\nhelper= CSVHelper(\"fake_EEG_signal.csv\",windowSize=256)\n\nfor eeg in helper:\n    print(eeg.PFD())\n```\n\nThis will show this:\n\n```python\n[ 1.03922468  1.03897773  1.03971798  1.03674636  1.03873059]\n[ 1.03848326  1.04168343  1.04094783  1.04168343  1.03699509]\n[ 1.03996434  1.04045647  1.03996434  1.03774006  1.03947143]\n[ 1.03749194  1.04045647  1.03897773  1.0402105   1.03873059]\n```\n\nNow 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.\n\n## Using iterators\n\nNow you may want to move the windows in another ways, like the ones that are shown in the next image:\n![windows](/Examples/slidingWindow.png)\n\nSo, if you want to make the windows overlap between them you can do it this way:\n\n```python\nhelper= CSVHelper(\"fake_EEG_signal.csv\",windowSize=256)\n\nfor eeg in helper[::128]:\n    print(eeg.PFD())\n```\n\n## Preprocessing\n\nMaybe you want to preprocess the signals stored in the window before extracting features from them. Currently this library allows the next Preprocessings:\n* Bandpass filtering\n* Z-Scores normalization\n* Independent Component Analysis\n\nThese preprocessings can be applied at the load of the data by the Helpers:\n```python\nhelper = CSVHelper(\"fake_EEG_signal.csv\",\n        lowpass=30, highpass=1, normalize=True, ICA=True)\n```\n\n## Using wrappers\n\nA 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:\n\n```python\nfrom eeglib import wrapper, helpers\n\nhelper = helpers.CSVHelper(\"fake_EEG_signal.csv\", windowSize=128)\n\nwrap = wrapper.Wrapper(helper)\n\nwrap.addFeature.HFD()\nwrap.addFeature.DFT()\nwrap.addFeature.synchronizationLikelihood()\n\nfeatures=wrap.getAllFeatures()\n```\nSo, the scheme to follow with wrappers is the next:\n1. Create the Helper object.\n2. Create the wrapper object.\n3. Select the desired features to compute. They can be parameterized by adding the parameters just behind the name.\n4. 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.\n\n# Citing\nIf eeglib has been useful in your research, please, consider citing the next article.\n\n[eeglib: A Python module for EEG feature extraction](https://www.sciencedirect.com/science/article/pii/S2352711021000753)\n\n\n# Documents related\nThis library was initialy a Final Degree Project and you can find the documentation of the development in the next link:\n\n[Final Degree Project Documentation (Spanish)](https://ruidera.uclm.es/xmlui/handle/10578/15441)\n\nLater it was extented as part of a Master's thesis that can be found in the next link:\n\n[Master's thesis (Spanish)](https://ruidera.uclm.es/xmlui/handle/10578/19062)\n\n\n## Scientific papers\n\nThere are also some papers related to this library that can be seen bellow:\n\n### Open Access\n\n* [Computational EEG Analysis Techniques When Playing Video Games: A Systematic Review](https://www.mdpi.com/2504-3900/2/19/483)\n* [Analysis of Cognitive Load Using EEG when Interacting with Mobile Devices](https://www.mdpi.com/2504-3900/31/1/70)\n* [eeglib: A Python module for EEG feature extraction](https://www.sciencedirect.com/science/article/pii/S2352711021000753)\n\n### Not open access\n\n* [Characterisation of mobile-device tasks by their associated cognitive load through EEG data processing](https://www.sciencedirect.com/science/article/abs/pii/S0167739X20305112)\n* [eeglib: computational analysis of cognitive performance during the use of video games](https://link.springer.com/article/10.1007%2Fs12652-019-01592-9)\n* [Studying the generalisability of cognitive load measured 7with EEG](https://www.sciencedirect.com/science/article/pii/S1746809421006297)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A library with some tools and functions for EEG signal analysis",
    "version": "0.4.1.1",
    "project_urls": {
        "Homepage": "https://github.com/Xiul109/eeglib"
    },
    "split_keywords": [
        "lib",
        "eeg",
        "signal",
        "analysis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e125aad43bb62d3652f567629c754568839e48ab2177a22465a1272df1990b26",
                "md5": "4436b2f80e9b1a9fed5d6b7a255ccfff",
                "sha256": "a4cadaac911a5a8aea4f0c7bb1282db3e5bbebed398ae33af3299ac27a43da87"
            },
            "downloads": -1,
            "filename": "eeglib-0.4.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4436b2f80e9b1a9fed5d6b7a255ccfff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 25559,
            "upload_time": "2023-12-28T15:53:33",
            "upload_time_iso_8601": "2023-12-28T15:53:33.389221Z",
            "url": "https://files.pythonhosted.org/packages/e1/25/aad43bb62d3652f567629c754568839e48ab2177a22465a1272df1990b26/eeglib-0.4.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c5021e1ed40cff2bb2174292f7846014d7325765c01fc76f65f00adbce07e42e",
                "md5": "98d79eaf6f6aa8942216c41b7ae5bea3",
                "sha256": "831b7cab0f7eb2ce933f645e0c0c9a0406377c7a0a8b089f3e0a991031ba34a4"
            },
            "downloads": -1,
            "filename": "eeglib-0.4.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "98d79eaf6f6aa8942216c41b7ae5bea3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 25389,
            "upload_time": "2023-12-28T15:53:35",
            "upload_time_iso_8601": "2023-12-28T15:53:35.545793Z",
            "url": "https://files.pythonhosted.org/packages/c5/02/1e1ed40cff2bb2174292f7846014d7325765c01fc76f65f00adbce07e42e/eeglib-0.4.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-28 15:53:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Xiul109",
    "github_project": "eeglib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "eeglib"
}
        
Elapsed time: 0.20501s