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