Diff of /README.md [000000] .. [e6696a]

Switch to unified view

a b/README.md
1
## DeepEEG ##
2
3
MNE/Keras/Tensorflow library for classification of EEG data
4
5
* [Kyle E. Mathewson](https://github.com/kylemath)
6
* [Kory W. Mathewson](https://github.com/korymath)
7
8
![DeepEEG Image](DeepEEGImage2.png)
9
10
DeepEEG is a Keras/Tensorflow deep learning library that processes EEG trials or raw files from the MNE toolbox as input and predicts binary trial category as output (could scale to multiclass?). 
11
12
CAN 2019 Poster presentation on DeepEEG - https://docs.google.com/presentation/d/1hO9wKwBVvfXDtUCz7kVRc0A6BsSwX-oVBsDMgrFwLlg/edit?usp=sharing
13
14
## Collab notebooks for cloud compution
15
16
Colab Notebook Example with simulated data:
17
https://colab.research.google.com/github/kylemath/DeepEEG/blob/master/notebooks/DeepEEG_Sim.ipynb
18
19
Colab Notebook Example with data from Brain Vision Recorder in google drive:
20
https://colab.research.google.com/github/kylemath/DeepEEG/blob/master/notebooks/Deep_EEG_BV.ipynb
21
22
Colab Notebook Example with muse data from [NeurotechX](https://github.com/neurotechx) eeg-notebooks:
23
https://colab.research.google.com/github/kylemath/DeepEEG/blob/master/notebooks/Deep_EEG_Muse.ipynb
24
25
## Getting Started Locally:
26
27
DeepEEG is tested on macOS 10.14 with Python3.
28
Prepare your environment the first time:
29
30
```sh
31
# using virtualenv
32
 python3 -m venv deepeeg
33
 source deepeeg/bin/activate
34
# using conda
35
#conda create -n deepeeg python=3
36
#source activate deepeeg
37
38
```
39
40
```sh
41
git clone https://github.com/kylemath/DeepEEG/
42
cd DeepEEG
43
./install.sh
44
git clone https://github.com/kylemath/eeg-notebooks_v0.1
45
46
```
47
48
You are now ready to run DeepEEG.
49
50
For example, type ```python``` and use the following:
51
This loads in some example data from eeg-notebooks
52
53
```python
54
from utils import *
55
data_dir = 'visual/cueing'
56
subs = [101,102]
57
nsesh = 2
58
event_id = {'LeftCue': 1,'RightCue': 2}
59
```
60
Load muse data, preprocess into trials,prepare for model, create model, and train and test model
61
62
```python
63
#Load Data
64
raw = LoadMuseData(subs,nsesh,data_dir)
65
```
66
67
```python
68
#Pre-Process EEG Data
69
epochs = PreProcess(raw,event_id)
70
```
71
72
```python
73
#Engineer Features for Model
74
feats = FeatureEngineer(epochs)
75
```
76
77
```python
78
#Create Model
79
model,_ = CreateModel(feats)
80
```
81
82
```python
83
#Train with validation, then Test
84
TrainTestVal(model,feats)
85
```
86
87
## Tests
88
89
You can run the unittests with the following command:
90
```
91
python -m unittest tests
92
```
93
94
## Strategy
95
* Load in Brain Products or Interaxon Muse files with mne as mne.raw,
96
* PreProcess(mne.raw) - normal ERP preprocessing to get trials by time by electrode mne.epochs
97
* FeatureEngineer(mne.epochs) - Either time domain or frequency domain feature extraction in DeepEEG.Feats class
98
* CreateModel(DeepEEG.Feats) - Customizes DeepEEG.Model for input data, pick from NN, CNN, LSTM, or AutoEncoders, splits data
99
* TrainTestVal(DeepEEG.Feats,DeepEEG.Model) - Train the model, validate it during training, and test it once complete, Plot loss during learning and at test
100
101
## Dataset example
102
* Interaxon Muse - eeg-notebooks -  https://github.com/kylemath/eeg-notebooks
103
* Brain Recorder Data
104
105
## API
106
* Input the data directory and subject numbers of any eeg-notebook experiment (https://github.com/kylemath/eeg-notebooks)
107
* Load in .vhdr brain products files by filename with mne io features
108
* FeatureEngineer can load any mne Epoch object too - https://martinos.org/mne/stable/generated/mne.Epochs.html
109
110
## Preprocessing
111
* To be moved to another repo eventually
112
* Bandpass filter
113
* Regression Eye movement correction (if eye channels)
114
  - EOG Regression example: https://cbrnr.github.io/2017/10/20/removing-eog-regression/
115
  - Original emcp paper: https://apps.dtic.mil/dtic/tr/fulltext/u2/a125699.pdf
116
  - Generalized emcp paper: http://www.kylemathewson.com/wp-content/uploads/2010/03/MillerGrattonYee-1988-GeneralizeOcularRemoval.pdf
117
  - 1988 Fortran, Gehring C code: http://gehringlab.org/emcp2001.zip
118
  - Matlab implementation: https://github.com/kylemath/MathewsonMatlabTools/blob/master/EEG_analysis/gratton_emcp.m
119
* Epoch segmentation (time limits, baseline correction)
120
* Artifact rejection
121
122
## LearningModels
123
* First try basic Neural Network (NN)
124
* Then try Convolution Neural Net (CNN)
125
* New is a 3D convolutional NN (CNN3D) in the frequency domain
126
* Then try Long-Short Term Memory Recurrant Neural Net (LSTM)
127
* Can also try using (AUTO) or (AUTODeep) to clean eeg data, or create features for other models
128
129
## DataModels
130
* Try subject specific models
131
* Then pool data over all subjects
132
* Then try multilevel models (in the works)
133
134
## Benchmarks
135
* Goal build models that can be integrated with https://github.com/NeuroTechX/moabb/
136
137
## Code References
138
* https://github.com/kylemath/eeg-notebooks
139
* https://github.com/mne-tools/mne-python
140
* https://github.com/keras-team/keras/blob/master/examples/imdb_cnn_lstm.py
141
* https://github.com/ml4a/ml4a-guides/blob/master/notebooks/keras_classification.ipynb
142
* https://github.com/tevisgehr/EEG-Classification
143
144
## Resources
145
* https://arxiv.org/pdf/1901.05498.pdf
146
* http://proceedings.mlr.press/v56/Thodoroff16.pdf
147
* https://arxiv.org/abs/1511.06448
148
* https://github.com/ml4a
149
* http://oxfordre.com/neuroscience/view/10.1093/acrefore/9780190264086.001.0001/acrefore-9780190264086-e-46
150
* https://arxiv.org/pdf/1811.10111.pdf