|
a |
|
b/BV_P3example.py |
|
|
1 |
#conda create -n deepeeg |
|
|
2 |
#source activate deepeeg |
|
|
3 |
#chomd +x install.sh |
|
|
4 |
#bash install.sh |
|
|
5 |
#!git clone https://github.com/kylemath/eeg-notebooks_v0.1 |
|
|
6 |
#python |
|
|
7 |
from utils import * |
|
|
8 |
data_dir = '/Users/kylemathewson/Desktop/data/' |
|
|
9 |
exp = 'P3' |
|
|
10 |
subs = ['001','002','004','005','006','007','008','010'] |
|
|
11 |
subs = [ '008'] |
|
|
12 |
|
|
|
13 |
sessions = ['ActiveDry','ActiveWet','PassiveWet'] |
|
|
14 |
|
|
|
15 |
nsesh = len(sessions) |
|
|
16 |
event_id = {'Target': 1, 'Standard': 2} |
|
|
17 |
|
|
|
18 |
epochs = [] |
|
|
19 |
for sub in subs: |
|
|
20 |
print('Loading data for subject ' + sub) |
|
|
21 |
for session in sessions: |
|
|
22 |
#Load Data |
|
|
23 |
raw = LoadBVData(sub,session,data_dir,exp) |
|
|
24 |
#Pre-Process EEG Data |
|
|
25 |
temp_epochs = PreProcess(raw,event_id, |
|
|
26 |
emcp_epochs=True, rereference=True, |
|
|
27 |
plot_erp=False, rej_thresh_uV=1000, |
|
|
28 |
epoch_time=(-1,2), baseline=(-.2,0), |
|
|
29 |
epoch_decim=1,filter_range=(1,20)) |
|
|
30 |
if len(temp_epochs) > 0: |
|
|
31 |
epochs.append(temp_epochs) |
|
|
32 |
else: |
|
|
33 |
print('Sub ' + sub + ', Cond ' |
|
|
34 |
+ session + 'all trials rejected') |
|
|
35 |
|
|
|
36 |
epochs = concatenate_epochs(epochs) |
|
|
37 |
|
|
|
38 |
#Engineer Features for Model |
|
|
39 |
feats = FeatureEngineer(epochs,model_type='CNN',electrode_median=False, |
|
|
40 |
normalization=False, frequency_domain=True, |
|
|
41 |
wavelet_decim=10) |
|
|
42 |
#Create Model |
|
|
43 |
model,_ = CreateModel(feats, units=[256,256,256,256]) |
|
|
44 |
#Train with validation, then Test |
|
|
45 |
TrainTestVal(model,feats) |
|
|
46 |
|
|
|
47 |
|