EEGraph is a Python library to model electroencephalograms (EEGs) as graphs, so the connectivity between different brain areas could be analyzed. It has applications in the study of neurologic diseases like Parkinson or epilepsy. The graph can be exported as a NetworkX graph-like object or it can also be graphically visualized.
What libraries does EEGraph use.
- Numpy
- Pandas
- Mne
- Matplotlib
- NetworkX
- Plotly
- Scipy
- Scot
- Antropy
To install the latest stable version of EEGraph, you can use pip in a terminal:
pip install EEGRAPH
EEGraph documentation is available online. Examples of usage are also available.
The different supported EEG file formats by EEGraph.
- Brainvision | .vhdr
- Neuroscan CNT | .cnt
- European data format | .edf
- Biosemi data format | .bdf
- General data format | .gdf
- EGI simple binary | .egi
- EGI MFF format | .mff
- eXimia | .nxe
The different available connectivity measures in EEGraph. Visit documentation for more info.
- Cross Correlation
- Pearson Correlation
- Squared Coherence
- Imaginary Coherence
- Corrected Cross Correlation
- Weighted Phase Lag Index (WPLI)
- Phase Locking Value (PLV)
- Phase Lag Index (PLI)
- Directed Transfer Function (DTF)
- Power Spectrum
- Spectral Entropy
- Shannon Entropy
Example usage of the library with Pearson Correlation.
import eegraph
G = eegraph.Graph()
G.load_data(path = 'eeg_sample_1.edf', exclude = ['EEG TAntI1-TAntI', 'EEG TAntD1-TAntD', 'EEG EKG1-EKG2'])
An electrode montage file can be specified for channels names while loading EEG data. Visit documentation for more info.
import eegraph
G = eegraph.Graph()
G.load_data(path = 'eeg_sample_1.edf', electrode_montage_path = 'electrodemontage.set.ced')
graphs, connectivity_matrix = G.modelate(window_size = 2, connectivity = 'pearson_correlation')
graphs, connectivity_matrix = G.modelate(window_size = 2, connectivity = 'squared_coherence', bands = ['delta','theta','alpha'])
A custom threshold can be specified as a parameter in modelate. Default threshold values can be found in the documentation.
graphs, connectivity_matrix = G.modelate(window_size = 2, connectivity = 'pearson_correlation', threshold = 0.8)
The window size can be defined as an int or list.
int: The set window size in seconds, e.g.(2). All the time intervals will be 2 seconds long.
list: The specific time intervals in seconds, e.g.[0, 3, 8]. The time intervalls will be the same as specified in the input.
In order to visualize graphs, EEG channel names must be in one of the following formats:
- Standard: 'Fp1', 'Fp2', 'C3', 'Cz'...
- Dash separated: 'Fp1-EEG', 'Fp2-EEG', 'C3-EEG', 'Cz-EEG'...
- Space separated: 'EEG Fp1', 'EEG Fp2', 'EEG C3', 'EEG Cz'...
For the Space separtor the information on the left side of the separator will be ignored, the standard electrode name must be on the right side.
For the Dash separtor the information on the right side of the separator will be ignored, the standard electrode name must be on the left side.
G.visualize(graphs[0], 'graph_1')
See Contribution guidelines for more information.
See CHANGELOG.txt for major/breaking updates and version history.
Centro de Estudios e Innovación en Gestión del Conocimiento (CEIEC), Universidad Francisco de Vitoria.
- Responsible: Alberto Nogales ([email protected])
- Supervisor: Ana María Maitín
- Main developer: Pedro Chazarra
- There is a known issue with DTF connectivity, sometimes the error 'math domain error' is shown, it is part of an external library.
This project is licensed under the GPL-3.0 License.