a b/notebooks/Deep_EEG_BV.ipynb
1
{
2
  "nbformat": 4,
3
  "nbformat_minor": 0,
4
  "metadata": {
5
    "colab": {
6
      "name": "Deep_EEG_BV.ipynb",
7
      "version": "0.3.2",
8
      "provenance": [],
9
      "collapsed_sections": [],
10
      "toc_visible": true,
11
      "include_colab_link": true
12
    },
13
    "kernelspec": {
14
      "name": "python3",
15
      "display_name": "Python 3"
16
    },
17
    "accelerator": "GPU"
18
  },
19
  "cells": [
20
    {
21
      "cell_type": "markdown",
22
      "metadata": {
23
        "id": "view-in-github",
24
        "colab_type": "text"
25
      },
26
      "source": [
27
        "<a href=\"https://colab.research.google.com/github/kylemath/DeepEEG/blob/master/notebooks/Deep_EEG_BV.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
28
      ]
29
    },
30
    {
31
      "metadata": {
32
        "id": "dSd-Wr_qBirE",
33
        "colab_type": "text"
34
      },
35
      "cell_type": "markdown",
36
      "source": [
37
        "#Connect to Google Drive\n",
38
        "Save your data onto google drive in a folder called \n",
39
        "```\n",
40
        "/data\n",
41
        "```\n"
42
      ]
43
    },
44
    {
45
      "metadata": {
46
        "id": "C_4BjLLL6MJ4",
47
        "colab_type": "code",
48
        "outputId": "333aec93-0751-417e-d7d2-195f3cb6a86a",
49
        "colab": {
50
          "base_uri": "https://localhost:8080/",
51
          "height": 34
52
        }
53
      },
54
      "cell_type": "code",
55
      "source": [
56
        "#mount google drive to load own images, follow link and get code and paste in below\n",
57
        "from google.colab import drive\n",
58
        "drive.mount('/content/gdrive', force_remount=True)\n"
59
      ],
60
      "execution_count": 3,
61
      "outputs": [
62
        {
63
          "output_type": "stream",
64
          "text": [
65
            "Mounted at /content/gdrive\n"
66
          ],
67
          "name": "stdout"
68
        }
69
      ]
70
    },
71
    {
72
      "metadata": {
73
        "id": "cH7KRd8ZZPMd",
74
        "colab_type": "text"
75
      },
76
      "cell_type": "markdown",
77
      "source": [
78
        "## DeepEEG\n"
79
      ]
80
    },
81
    {
82
      "metadata": {
83
        "id": "KjZu4dFMFHJV",
84
        "colab_type": "code",
85
        "outputId": "2cb94fc8-fc42-4044-9af0-7f66bbf84903",
86
        "colab": {
87
          "base_uri": "https://localhost:8080/",
88
          "height": 683
89
        }
90
      },
91
      "cell_type": "code",
92
      "source": [
93
        "!git clone https://github.com/kylemath/DeepEEG\n",
94
        "!chmod +x ./DeepEEG/install.sh\n",
95
        "%cd DeepEEG\n",
96
        "!./install.sh\n",
97
        "from utils import *\n",
98
        "%matplotlib inline\n",
99
        "%cd .."
100
      ],
101
      "execution_count": 4,
102
      "outputs": [
103
        {
104
          "output_type": "stream",
105
          "text": [
106
            "fatal: destination path 'DeepEEG' already exists and is not an empty directory.\n",
107
            "/content/DeepEEG\n",
108
            "Requirement already up-to-date: pip in /usr/local/lib/python3.6/dist-packages (19.0.3)\n",
109
            "Requirement already satisfied: absl-py==0.7.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 1)) (0.7.0)\n",
110
            "Requirement already satisfied: astor==0.7.1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 2)) (0.7.1)\n",
111
            "Requirement already satisfied: cycler==0.10.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 3)) (0.10.0)\n",
112
            "Requirement already satisfied: gast==0.2.2 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 4)) (0.2.2)\n",
113
            "Requirement already satisfied: grpcio==1.18.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 5)) (1.18.0)\n",
114
            "Requirement already satisfied: h5py==2.9.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 6)) (2.9.0)\n",
115
            "Requirement already satisfied: Keras==2.2.4 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 7)) (2.2.4)\n",
116
            "Requirement already satisfied: Keras-Applications==1.0.7 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 8)) (1.0.7)\n",
117
            "Requirement already satisfied: Keras-Preprocessing==1.0.9 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 9)) (1.0.9)\n",
118
            "Requirement already satisfied: kiwisolver==1.0.1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 10)) (1.0.1)\n",
119
            "Requirement already satisfied: Markdown==3.0.1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 11)) (3.0.1)\n",
120
            "Requirement already satisfied: matplotlib==3.0.2 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 12)) (3.0.2)\n",
121
            "Requirement already satisfied: mne==0.17.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 13)) (0.17.0)\n",
122
            "Requirement already satisfied: numpy==1.16.1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 14)) (1.16.1)\n",
123
            "Requirement already satisfied: pandas==0.24.1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 15)) (0.24.1)\n",
124
            "Requirement already satisfied: protobuf==3.6.1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 16)) (3.6.1)\n",
125
            "Requirement already satisfied: pyparsing==2.3.1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 17)) (2.3.1)\n",
126
            "Requirement already satisfied: python-dateutil==2.8.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 18)) (2.8.0)\n",
127
            "Requirement already satisfied: pytz==2018.9 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 19)) (2018.9)\n",
128
            "Requirement already satisfied: PyYAML==4.2b1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 20)) (4.2b1)\n",
129
            "Requirement already satisfied: scikit-learn==0.20.2 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 21)) (0.20.2)\n",
130
            "Requirement already satisfied: scipy==1.2.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 22)) (1.2.0)\n",
131
            "Requirement already satisfied: six==1.12.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 23)) (1.12.0)\n",
132
            "Requirement already satisfied: sklearn==0.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 24)) (0.0)\n",
133
            "Requirement already satisfied: tensorboard==1.12.2 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 25)) (1.12.2)\n",
134
            "Requirement already satisfied: tensorflow==1.13.0rc1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 26)) (1.13.0rc1)\n",
135
            "Requirement already satisfied: termcolor==1.1.0 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 27)) (1.1.0)\n",
136
            "Requirement already satisfied: Werkzeug==0.14.1 in /usr/local/lib/python3.6/dist-packages (from -r requirements.txt (line 28)) (0.14.1)\n",
137
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.6/dist-packages (from kiwisolver==1.0.1->-r requirements.txt (line 10)) (40.8.0)\n",
138
            "Requirement already satisfied: wheel>=0.26; python_version >= \"3\" in /usr/local/lib/python3.6/dist-packages (from tensorboard==1.12.2->-r requirements.txt (line 25)) (0.33.1)\n",
139
            "Requirement already satisfied: tensorflow-estimator<1.14.0rc0,>=1.13.0rc0 in /usr/local/lib/python3.6/dist-packages (from tensorflow==1.13.0rc1->-r requirements.txt (line 26)) (1.13.0)\n",
140
            "Requirement already satisfied: mock>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow-estimator<1.14.0rc0,>=1.13.0rc0->tensorflow==1.13.0rc1->-r requirements.txt (line 26)) (2.0.0)\n",
141
            "Requirement already satisfied: pbr>=0.11 in /usr/local/lib/python3.6/dist-packages (from mock>=2.0.0->tensorflow-estimator<1.14.0rc0,>=1.13.0rc0->tensorflow==1.13.0rc1->-r requirements.txt (line 26)) (5.1.2)\n"
142
          ],
143
          "name": "stdout"
144
        },
145
        {
146
          "output_type": "stream",
147
          "text": [
148
            "Using TensorFlow backend.\n"
149
          ],
150
          "name": "stderr"
151
        },
152
        {
153
          "output_type": "stream",
154
          "text": [
155
            "/content\n"
156
          ],
157
          "name": "stdout"
158
        }
159
      ]
160
    },
161
    {
162
      "metadata": {
163
        "id": "FhkDPfIq1ewa",
164
        "colab_type": "text"
165
      },
166
      "cell_type": "markdown",
167
      "source": [
168
        "#Load Data, Preprocess, Concatenate\n"
169
      ]
170
    },
171
    {
172
      "metadata": {
173
        "id": "jhU8hlcg1e6T",
174
        "colab_type": "code",
175
        "outputId": "aa252ce9-ae9f-45db-8c18-a88e1d741a13",
176
        "colab": {
177
          "base_uri": "https://localhost:8080/",
178
          "height": 6327
179
        }
180
      },
181
      "cell_type": "code",
182
      "source": [
183
        "data_dir = 'gdrive/My Drive/data/'\n",
184
        "exp = 'P3'\n",
185
        "subs = ['001','002','004','005','006','007','008','010']\n",
186
        "#subs = ['002']\n",
187
        "sessions = ['ActiveDry','ActiveWet','PassiveWet']\n",
188
        "nsesh = len(sessions)\n",
189
        "event_id = {'Target':1, 'Standard':2}\n",
190
        "\n",
191
        "epochs = []\n",
192
        "for sub in subs:\n",
193
        "  print('Loading data for subject ' + sub)\n",
194
        "  for session in sessions:\n",
195
        "    #Load Data\n",
196
        "    raw = LoadBVData(sub,session,data_dir,exp)\n",
197
        "    #Pre-process EEG data\n",
198
        "    temp_epochs = PreProcess(raw,event_id,\n",
199
        "                             emcp_epochs=True, rereference=True,\n",
200
        "                             plot_erp=False, rej_thresh_uV=1000,\n",
201
        "                             epoch_time=(-1,2), baseline=(-.2,0),\n",
202
        "                             epoch_decim=1, filter_range=(1,20)\n",
203
        "                            )\n",
204
        "    if len(temp_epochs) > 0:\n",
205
        "      epochs.append(temp_epochs)\n",
206
        "    else:\n",
207
        "      print('Sub ' + sub + ', Cond ' + \n",
208
        "            session + 'all trials rejected')\n",
209
        "\n",
210
        "epochs = concatenate_epochs(epochs)\n"
211
      ],
212
      "execution_count": 5,
213
      "outputs": [
214
        {
215
          "output_type": "stream",
216
          "text": [
217
            "Loading data for subject 001\n",
218
            "Loading data for subject number: 001\n",
219
            "Extracting parameters from gdrive/My Drive/data/P3/001_P3_ActiveDry.vhdr...\n",
220
            "Setting channel info structure...\n",
221
            "Reading 0 ... 500209  =      0.000 ...  1000.418 secs...\n"
222
          ],
223
          "name": "stdout"
224
        },
225
        {
226
          "output_type": "stream",
227
          "text": [
228
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
229
            "  preload=True,stim_channel=stim_channel)\n"
230
          ],
231
          "name": "stderr"
232
        },
233
        {
234
          "output_type": "stream",
235
          "text": [
236
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  3', 'Stimulus/S  2', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  5']\n",
237
            "Sampling Rate = 500.0\n",
238
            "Loading Channel Locations\n",
239
            "Rerefering to average mastoid\n",
240
            "Filtering Data Between 1 and 20 Hz.\n",
241
            "751 events found\n",
242
            "Event IDs: [ 1  2  3  4  5 10]\n",
243
            "Remaining Trials: 272\n",
244
            "Epochs Eye Movement Correct\n",
245
            "Loading data for subject number: 001\n",
246
            "Extracting parameters from gdrive/My Drive/data/P3/001_P3_ActiveWet.vhdr...\n",
247
            "Setting channel info structure...\n",
248
            "Reading 0 ... 637129  =      0.000 ...  1274.258 secs...\n"
249
          ],
250
          "name": "stdout"
251
        },
252
        {
253
          "output_type": "stream",
254
          "text": [
255
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
256
            "  preload=True,stim_channel=stim_channel)\n"
257
          ],
258
          "name": "stderr"
259
        },
260
        {
261
          "output_type": "stream",
262
          "text": [
263
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
264
            "Sampling Rate = 500.0\n",
265
            "Loading Channel Locations\n",
266
            "Rerefering to average mastoid\n",
267
            "Filtering Data Between 1 and 20 Hz.\n",
268
            "751 events found\n",
269
            "Event IDs: [ 1  2  3  4  5 10]\n",
270
            "Remaining Trials: 293\n",
271
            "Epochs Eye Movement Correct\n",
272
            "Loading data for subject number: 001\n",
273
            "Extracting parameters from gdrive/My Drive/data/P3/001_P3_PassiveWet.vhdr...\n",
274
            "Setting channel info structure...\n",
275
            "Reading 0 ... 523929  =      0.000 ...  1047.858 secs...\n"
276
          ],
277
          "name": "stdout"
278
        },
279
        {
280
          "output_type": "stream",
281
          "text": [
282
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
283
            "  preload=True,stim_channel=stim_channel)\n"
284
          ],
285
          "name": "stderr"
286
        },
287
        {
288
          "output_type": "stream",
289
          "text": [
290
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  3', 'Stimulus/S  2', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  5']\n",
291
            "Sampling Rate = 500.0\n",
292
            "Loading Channel Locations\n",
293
            "Rerefering to average mastoid\n",
294
            "Filtering Data Between 1 and 20 Hz.\n",
295
            "751 events found\n",
296
            "Event IDs: [ 1  2  3  4  5 10]\n",
297
            "Remaining Trials: 281\n",
298
            "Epochs Eye Movement Correct\n",
299
            "Loading data for subject 002\n",
300
            "Loading data for subject number: 002\n",
301
            "Extracting parameters from gdrive/My Drive/data/P3/002_P3_ActiveDry.vhdr...\n",
302
            "Setting channel info structure...\n",
303
            "Reading 0 ... 490009  =      0.000 ...   980.018 secs...\n"
304
          ],
305
          "name": "stdout"
306
        },
307
        {
308
          "output_type": "stream",
309
          "text": [
310
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
311
            "  preload=True,stim_channel=stim_channel)\n"
312
          ],
313
          "name": "stderr"
314
        },
315
        {
316
          "output_type": "stream",
317
          "text": [
318
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  3', 'Stimulus/S  2', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  5']\n",
319
            "Sampling Rate = 500.0\n",
320
            "Loading Channel Locations\n",
321
            "Rerefering to average mastoid\n",
322
            "Filtering Data Between 1 and 20 Hz.\n",
323
            "751 events found\n",
324
            "Event IDs: [ 1  2  3  4  5 10]\n",
325
            "Remaining Trials: 281\n",
326
            "Epochs Eye Movement Correct\n",
327
            "Loading data for subject number: 002\n",
328
            "Extracting parameters from gdrive/My Drive/data/P3/002_P3_ActiveWet.vhdr...\n",
329
            "Setting channel info structure...\n",
330
            "Reading 0 ... 487989  =      0.000 ...   975.978 secs...\n"
331
          ],
332
          "name": "stdout"
333
        },
334
        {
335
          "output_type": "stream",
336
          "text": [
337
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
338
            "  preload=True,stim_channel=stim_channel)\n"
339
          ],
340
          "name": "stderr"
341
        },
342
        {
343
          "output_type": "stream",
344
          "text": [
345
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  3', 'Stimulus/S  2', 'Stimulus/S  4', 'Stimulus/S  5', 'Stimulus/S  1']\n",
346
            "Sampling Rate = 500.0\n",
347
            "Loading Channel Locations\n",
348
            "Rerefering to average mastoid\n",
349
            "Filtering Data Between 1 and 20 Hz.\n",
350
            "751 events found\n",
351
            "Event IDs: [ 1  2  3  4  5 10]\n",
352
            "Remaining Trials: 290\n",
353
            "Epochs Eye Movement Correct\n",
354
            "Loading data for subject number: 002\n",
355
            "Extracting parameters from gdrive/My Drive/data/P3/002_P3_PassiveWet.vhdr...\n",
356
            "Setting channel info structure...\n",
357
            "Reading 0 ... 543139  =      0.000 ...  1086.278 secs...\n"
358
          ],
359
          "name": "stdout"
360
        },
361
        {
362
          "output_type": "stream",
363
          "text": [
364
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
365
            "  preload=True,stim_channel=stim_channel)\n"
366
          ],
367
          "name": "stderr"
368
        },
369
        {
370
          "output_type": "stream",
371
          "text": [
372
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
373
            "Sampling Rate = 500.0\n",
374
            "Loading Channel Locations\n",
375
            "Rerefering to average mastoid\n",
376
            "Filtering Data Between 1 and 20 Hz.\n",
377
            "751 events found\n",
378
            "Event IDs: [ 1  2  3  4  5 10]\n",
379
            "Remaining Trials: 293\n",
380
            "Epochs Eye Movement Correct\n",
381
            "Loading data for subject 004\n",
382
            "Loading data for subject number: 004\n",
383
            "Extracting parameters from gdrive/My Drive/data/P3/004_P3_ActiveDry.vhdr...\n",
384
            "Setting channel info structure...\n",
385
            "Reading 0 ... 643389  =      0.000 ...  1286.778 secs...\n"
386
          ],
387
          "name": "stdout"
388
        },
389
        {
390
          "output_type": "stream",
391
          "text": [
392
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
393
            "  preload=True,stim_channel=stim_channel)\n"
394
          ],
395
          "name": "stderr"
396
        },
397
        {
398
          "output_type": "stream",
399
          "text": [
400
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
401
            "Sampling Rate = 500.0\n",
402
            "Loading Channel Locations\n",
403
            "Rerefering to average mastoid\n",
404
            "Filtering Data Between 1 and 20 Hz.\n",
405
            "751 events found\n",
406
            "Event IDs: [ 1  2  3  4  5 10]\n",
407
            "Remaining Trials: 293\n",
408
            "Epochs Eye Movement Correct\n",
409
            "Loading data for subject number: 004\n",
410
            "Extracting parameters from gdrive/My Drive/data/P3/004_P3_ActiveWet.vhdr...\n",
411
            "Setting channel info structure...\n",
412
            "Reading 0 ... 549039  =      0.000 ...  1098.078 secs...\n"
413
          ],
414
          "name": "stdout"
415
        },
416
        {
417
          "output_type": "stream",
418
          "text": [
419
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
420
            "  preload=True,stim_channel=stim_channel)\n"
421
          ],
422
          "name": "stderr"
423
        },
424
        {
425
          "output_type": "stream",
426
          "text": [
427
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
428
            "Sampling Rate = 500.0\n",
429
            "Loading Channel Locations\n",
430
            "Rerefering to average mastoid\n",
431
            "Filtering Data Between 1 and 20 Hz.\n",
432
            "751 events found\n",
433
            "Event IDs: [ 1  2  3  4  5 10]\n",
434
            "Remaining Trials: 293\n",
435
            "Epochs Eye Movement Correct\n",
436
            "Loading data for subject number: 004\n",
437
            "Extracting parameters from gdrive/My Drive/data/P3/004_P3_PassiveWet.vhdr...\n",
438
            "Setting channel info structure...\n",
439
            "Reading 0 ... 514149  =      0.000 ...  1028.298 secs...\n"
440
          ],
441
          "name": "stdout"
442
        },
443
        {
444
          "output_type": "stream",
445
          "text": [
446
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
447
            "  preload=True,stim_channel=stim_channel)\n"
448
          ],
449
          "name": "stderr"
450
        },
451
        {
452
          "output_type": "stream",
453
          "text": [
454
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
455
            "Sampling Rate = 500.0\n",
456
            "Loading Channel Locations\n",
457
            "Rerefering to average mastoid\n",
458
            "Filtering Data Between 1 and 20 Hz.\n",
459
            "751 events found\n",
460
            "Event IDs: [ 1  2  3  4  5 10]\n",
461
            "Remaining Trials: 293\n",
462
            "Epochs Eye Movement Correct\n",
463
            "Loading data for subject 005\n",
464
            "Loading data for subject number: 005\n",
465
            "Extracting parameters from gdrive/My Drive/data/P3/005_P3_ActiveDry.vhdr...\n",
466
            "Setting channel info structure...\n",
467
            "Reading 0 ... 489499  =      0.000 ...   978.998 secs...\n"
468
          ],
469
          "name": "stdout"
470
        },
471
        {
472
          "output_type": "stream",
473
          "text": [
474
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
475
            "  preload=True,stim_channel=stim_channel)\n"
476
          ],
477
          "name": "stderr"
478
        },
479
        {
480
          "output_type": "stream",
481
          "text": [
482
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  5', 'Stimulus/S  2', 'Stimulus/S  3', 'Stimulus/S  4']\n",
483
            "Sampling Rate = 500.0\n",
484
            "Loading Channel Locations\n",
485
            "Rerefering to average mastoid\n",
486
            "Filtering Data Between 1 and 20 Hz.\n",
487
            "751 events found\n",
488
            "Event IDs: [ 1  2  3  4  5 10]\n",
489
            "Remaining Trials: 333\n",
490
            "Epochs Eye Movement Correct\n",
491
            "Loading data for subject number: 005\n",
492
            "Extracting parameters from gdrive/My Drive/data/P3/005_P3_ActiveWet.vhdr...\n",
493
            "Setting channel info structure...\n",
494
            "Reading 0 ... 489169  =      0.000 ...   978.338 secs...\n"
495
          ],
496
          "name": "stdout"
497
        },
498
        {
499
          "output_type": "stream",
500
          "text": [
501
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
502
            "  preload=True,stim_channel=stim_channel)\n"
503
          ],
504
          "name": "stderr"
505
        },
506
        {
507
          "output_type": "stream",
508
          "text": [
509
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  5', 'Stimulus/S  3', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2']\n",
510
            "Sampling Rate = 500.0\n",
511
            "Loading Channel Locations\n",
512
            "Rerefering to average mastoid\n",
513
            "Filtering Data Between 1 and 20 Hz.\n",
514
            "751 events found\n",
515
            "Event IDs: [ 1  2  3  4  5 10]\n",
516
            "Remaining Trials: 302\n",
517
            "Epochs Eye Movement Correct\n",
518
            "Loading data for subject number: 005\n",
519
            "Extracting parameters from gdrive/My Drive/data/P3/005_P3_PassiveWet.vhdr...\n",
520
            "Setting channel info structure...\n",
521
            "Reading 0 ... 522609  =      0.000 ...  1045.218 secs...\n"
522
          ],
523
          "name": "stdout"
524
        },
525
        {
526
          "output_type": "stream",
527
          "text": [
528
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
529
            "  preload=True,stim_channel=stim_channel)\n"
530
          ],
531
          "name": "stderr"
532
        },
533
        {
534
          "output_type": "stream",
535
          "text": [
536
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  3', 'Stimulus/S  2', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  5']\n",
537
            "Sampling Rate = 500.0\n",
538
            "Loading Channel Locations\n",
539
            "Rerefering to average mastoid\n",
540
            "Filtering Data Between 1 and 20 Hz.\n",
541
            "751 events found\n",
542
            "Event IDs: [ 1  2  3  4  5 10]\n",
543
            "Remaining Trials: 281\n",
544
            "Epochs Eye Movement Correct\n",
545
            "Loading data for subject 006\n",
546
            "Loading data for subject number: 006\n",
547
            "Extracting parameters from gdrive/My Drive/data/P3/006_P3_ActiveDry.vhdr...\n",
548
            "Setting channel info structure...\n",
549
            "Reading 0 ... 574439  =      0.000 ...  1148.878 secs...\n"
550
          ],
551
          "name": "stdout"
552
        },
553
        {
554
          "output_type": "stream",
555
          "text": [
556
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
557
            "  preload=True,stim_channel=stim_channel)\n"
558
          ],
559
          "name": "stderr"
560
        },
561
        {
562
          "output_type": "stream",
563
          "text": [
564
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
565
            "Sampling Rate = 500.0\n",
566
            "Loading Channel Locations\n",
567
            "Rerefering to average mastoid\n",
568
            "Filtering Data Between 1 and 20 Hz.\n",
569
            "751 events found\n",
570
            "Event IDs: [ 1  2  3  4  5 10]\n",
571
            "Remaining Trials: 290\n",
572
            "Epochs Eye Movement Correct\n",
573
            "Loading data for subject number: 006\n",
574
            "Extracting parameters from gdrive/My Drive/data/P3/006_P3_ActiveWet.vhdr...\n",
575
            "Setting channel info structure...\n",
576
            "Reading 0 ... 493579  =      0.000 ...   987.158 secs...\n"
577
          ],
578
          "name": "stdout"
579
        },
580
        {
581
          "output_type": "stream",
582
          "text": [
583
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
584
            "  preload=True,stim_channel=stim_channel)\n"
585
          ],
586
          "name": "stderr"
587
        },
588
        {
589
          "output_type": "stream",
590
          "text": [
591
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
592
            "Sampling Rate = 500.0\n",
593
            "Loading Channel Locations\n",
594
            "Rerefering to average mastoid\n",
595
            "Filtering Data Between 1 and 20 Hz.\n",
596
            "751 events found\n",
597
            "Event IDs: [ 1  2  3  4  5 10]\n",
598
            "Remaining Trials: 293\n",
599
            "Epochs Eye Movement Correct\n",
600
            "Loading data for subject number: 006\n",
601
            "Extracting parameters from gdrive/My Drive/data/P3/006_P3_PassiveWet.vhdr...\n",
602
            "Setting channel info structure...\n",
603
            "Reading 0 ... 1977349  =      0.000 ...  3954.698 secs...\n"
604
          ],
605
          "name": "stdout"
606
        },
607
        {
608
          "output_type": "stream",
609
          "text": [
610
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
611
            "  preload=True,stim_channel=stim_channel)\n"
612
          ],
613
          "name": "stderr"
614
        },
615
        {
616
          "output_type": "stream",
617
          "text": [
618
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
619
            "Sampling Rate = 500.0\n",
620
            "Loading Channel Locations\n",
621
            "Rerefering to average mastoid\n",
622
            "Filtering Data Between 1 and 20 Hz.\n",
623
            "751 events found\n",
624
            "Event IDs: [ 1  2  3  4  5 10]\n",
625
            "Remaining Trials: 293\n",
626
            "Epochs Eye Movement Correct\n",
627
            "Loading data for subject 007\n",
628
            "Loading data for subject number: 007\n",
629
            "Extracting parameters from gdrive/My Drive/data/P3/007_P3_ActiveDry.vhdr...\n",
630
            "Setting channel info structure...\n",
631
            "Reading 0 ... 485409  =      0.000 ...   970.818 secs...\n"
632
          ],
633
          "name": "stdout"
634
        },
635
        {
636
          "output_type": "stream",
637
          "text": [
638
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
639
            "  preload=True,stim_channel=stim_channel)\n"
640
          ],
641
          "name": "stderr"
642
        },
643
        {
644
          "output_type": "stream",
645
          "text": [
646
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
647
            "Sampling Rate = 500.0\n",
648
            "Loading Channel Locations\n",
649
            "Rerefering to average mastoid\n",
650
            "Filtering Data Between 1 and 20 Hz.\n",
651
            "751 events found\n",
652
            "Event IDs: [ 1  2  3  4  5 10]\n",
653
            "Remaining Trials: 291\n",
654
            "Epochs Eye Movement Correct\n",
655
            "Loading data for subject number: 007\n",
656
            "Extracting parameters from gdrive/My Drive/data/P3/007_P3_ActiveWet.vhdr...\n",
657
            "Setting channel info structure...\n",
658
            "Reading 0 ... 493509  =      0.000 ...   987.018 secs...\n"
659
          ],
660
          "name": "stdout"
661
        },
662
        {
663
          "output_type": "stream",
664
          "text": [
665
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
666
            "  preload=True,stim_channel=stim_channel)\n"
667
          ],
668
          "name": "stderr"
669
        },
670
        {
671
          "output_type": "stream",
672
          "text": [
673
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3', 'Stimulus/S255']\n",
674
            "Sampling Rate = 500.0\n",
675
            "Loading Channel Locations\n",
676
            "Rerefering to average mastoid\n",
677
            "Filtering Data Between 1 and 20 Hz.\n",
678
            "752 events found\n",
679
            "Event IDs: [  1   2   3   4   5  10 255]\n",
680
            "Remaining Trials: 293\n",
681
            "Epochs Eye Movement Correct\n",
682
            "Loading data for subject number: 007\n",
683
            "Extracting parameters from gdrive/My Drive/data/P3/007_P3_PassiveWet.vhdr...\n",
684
            "Setting channel info structure...\n",
685
            "Reading 0 ... 489679  =      0.000 ...   979.358 secs...\n"
686
          ],
687
          "name": "stdout"
688
        },
689
        {
690
          "output_type": "stream",
691
          "text": [
692
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
693
            "  preload=True,stim_channel=stim_channel)\n"
694
          ],
695
          "name": "stderr"
696
        },
697
        {
698
          "output_type": "stream",
699
          "text": [
700
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  3', 'Stimulus/S  2', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  5']\n",
701
            "Sampling Rate = 500.0\n",
702
            "Loading Channel Locations\n",
703
            "Rerefering to average mastoid\n",
704
            "Filtering Data Between 1 and 20 Hz.\n",
705
            "751 events found\n",
706
            "Event IDs: [ 1  2  3  4  5 10]\n",
707
            "Remaining Trials: 281\n",
708
            "Epochs Eye Movement Correct\n",
709
            "Loading data for subject 008\n",
710
            "Loading data for subject number: 008\n",
711
            "Extracting parameters from gdrive/My Drive/data/P3/008_P3_ActiveDry.vhdr...\n",
712
            "Setting channel info structure...\n",
713
            "Reading 0 ... 513759  =      0.000 ...  1027.518 secs...\n"
714
          ],
715
          "name": "stdout"
716
        },
717
        {
718
          "output_type": "stream",
719
          "text": [
720
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
721
            "  preload=True,stim_channel=stim_channel)\n"
722
          ],
723
          "name": "stderr"
724
        },
725
        {
726
          "output_type": "stream",
727
          "text": [
728
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
729
            "Sampling Rate = 500.0\n",
730
            "Loading Channel Locations\n",
731
            "Rerefering to average mastoid\n",
732
            "Filtering Data Between 1 and 20 Hz.\n",
733
            "751 events found\n",
734
            "Event IDs: [ 1  2  3  4  5 10]\n",
735
            "Remaining Trials: 288\n",
736
            "Epochs Eye Movement Correct\n",
737
            "Loading data for subject number: 008\n",
738
            "Extracting parameters from gdrive/My Drive/data/P3/008_P3_ActiveWet.vhdr...\n",
739
            "Setting channel info structure...\n",
740
            "Reading 0 ... 516679  =      0.000 ...  1033.358 secs...\n"
741
          ],
742
          "name": "stdout"
743
        },
744
        {
745
          "output_type": "stream",
746
          "text": [
747
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
748
            "  preload=True,stim_channel=stim_channel)\n"
749
          ],
750
          "name": "stderr"
751
        },
752
        {
753
          "output_type": "stream",
754
          "text": [
755
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
756
            "Sampling Rate = 500.0\n",
757
            "Loading Channel Locations\n",
758
            "Rerefering to average mastoid\n",
759
            "Filtering Data Between 1 and 20 Hz.\n",
760
            "751 events found\n",
761
            "Event IDs: [ 1  2  3  4  5 10]\n",
762
            "Remaining Trials: 293\n",
763
            "Epochs Eye Movement Correct\n",
764
            "Loading data for subject number: 008\n",
765
            "Extracting parameters from gdrive/My Drive/data/P3/008_P3_PassiveWet.vhdr...\n",
766
            "Setting channel info structure...\n",
767
            "Reading 0 ... 498499  =      0.000 ...   996.998 secs...\n"
768
          ],
769
          "name": "stdout"
770
        },
771
        {
772
          "output_type": "stream",
773
          "text": [
774
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
775
            "  preload=True,stim_channel=stim_channel)\n"
776
          ],
777
          "name": "stderr"
778
        },
779
        {
780
          "output_type": "stream",
781
          "text": [
782
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
783
            "Sampling Rate = 500.0\n",
784
            "Loading Channel Locations\n",
785
            "Rerefering to average mastoid\n",
786
            "Filtering Data Between 1 and 20 Hz.\n",
787
            "751 events found\n",
788
            "Event IDs: [ 1  2  3  4  5 10]\n",
789
            "Remaining Trials: 293\n",
790
            "Epochs Eye Movement Correct\n",
791
            "Loading data for subject 010\n",
792
            "Loading data for subject number: 010\n",
793
            "Extracting parameters from gdrive/My Drive/data/P3/010_P3_ActiveDry.vhdr...\n",
794
            "Setting channel info structure...\n",
795
            "Reading 0 ... 566939  =      0.000 ...  1133.878 secs...\n"
796
          ],
797
          "name": "stdout"
798
        },
799
        {
800
          "output_type": "stream",
801
          "text": [
802
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
803
            "  preload=True,stim_channel=stim_channel)\n"
804
          ],
805
          "name": "stderr"
806
        },
807
        {
808
          "output_type": "stream",
809
          "text": [
810
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  1', 'Stimulus/S  4', 'Stimulus/S  2', 'Stimulus/S  5', 'Stimulus/S  3']\n",
811
            "Sampling Rate = 500.0\n",
812
            "Loading Channel Locations\n",
813
            "Rerefering to average mastoid\n",
814
            "Filtering Data Between 1 and 20 Hz.\n",
815
            "751 events found\n",
816
            "Event IDs: [ 1  2  3  4  5 10]\n",
817
            "Remaining Trials: 293\n",
818
            "Epochs Eye Movement Correct\n",
819
            "Loading data for subject number: 010\n",
820
            "Extracting parameters from gdrive/My Drive/data/P3/010_P3_ActiveWet.vhdr...\n",
821
            "Setting channel info structure...\n",
822
            "Reading 0 ... 499139  =      0.000 ...   998.278 secs...\n"
823
          ],
824
          "name": "stdout"
825
        },
826
        {
827
          "output_type": "stream",
828
          "text": [
829
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
830
            "  preload=True,stim_channel=stim_channel)\n"
831
          ],
832
          "name": "stderr"
833
        },
834
        {
835
          "output_type": "stream",
836
          "text": [
837
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  5', 'Stimulus/S  1', 'Stimulus/S  3', 'Stimulus/S  4', 'Stimulus/S  2']\n",
838
            "Sampling Rate = 500.0\n",
839
            "Loading Channel Locations\n",
840
            "Rerefering to average mastoid\n",
841
            "Filtering Data Between 1 and 20 Hz.\n",
842
            "751 events found\n",
843
            "Event IDs: [ 1  2  3  4  5 10]\n",
844
            "Remaining Trials: 295\n",
845
            "Epochs Eye Movement Correct\n",
846
            "Loading data for subject number: 010\n",
847
            "Extracting parameters from gdrive/My Drive/data/P3/010_P3_PassiveWet.vhdr...\n",
848
            "Setting channel info structure...\n",
849
            "Reading 0 ... 510989  =      0.000 ...  1021.978 secs...\n"
850
          ],
851
          "name": "stdout"
852
        },
853
        {
854
          "output_type": "stream",
855
          "text": [
856
            "/content/DeepEEG/utils.py:89: RuntimeWarning: Online software filter detected. Using software filter settings and ignoring hardware values\n",
857
            "  preload=True,stim_channel=stim_channel)\n"
858
          ],
859
          "name": "stderr"
860
        },
861
        {
862
          "output_type": "stream",
863
          "text": [
864
            "Used Annotations descriptions: ['Stimulus/S 10', 'Stimulus/S  2', 'Stimulus/S  3', 'Stimulus/S  1', 'Stimulus/S  5', 'Stimulus/S  4']\n",
865
            "Sampling Rate = 500.0\n",
866
            "Loading Channel Locations\n",
867
            "Rerefering to average mastoid\n",
868
            "Filtering Data Between 1 and 20 Hz.\n",
869
            "751 events found\n",
870
            "Event IDs: [ 1  2  3  4  5 10]\n",
871
            "Remaining Trials: 291\n",
872
            "Epochs Eye Movement Correct\n",
873
            "6999 matching events found\n",
874
            "Applying baseline correction (mode: mean)\n"
875
          ],
876
          "name": "stdout"
877
        }
878
      ]
879
    },
880
    {
881
      "metadata": {
882
        "id": "pwqD_voiDypa",
883
        "colab_type": "text"
884
      },
885
      "cell_type": "markdown",
886
      "source": [
887
        "#Run FeatureEngineer\n",
888
        "\n",
889
        "epochs, model_type='NN',\n",
890
        "frequency_domain=False,\n",
891
        "normalization=True, electrode_median=False,\n",
892
        "wavelet_decim=1,flims=(3,30),\n",
893
        "f_bins=20,wave_cycles=3,\n",
894
        "spect_baseline=[-1,-.5],\n",
895
        "electrodes_out=[11,12,13,14,15],\n",
896
        "test_split = 0.2, val_split = 0.2,\n",
897
        "random_seed=1017, watermark = False"
898
      ]
899
    },
900
    {
901
      "metadata": {
902
        "id": "i_jYlTW1A6sb",
903
        "colab_type": "code",
904
        "outputId": "ae19af92-ba99-4438-956c-e37ac4131b3a",
905
        "colab": {
906
          "base_uri": "https://localhost:8080/",
907
          "height": 238
908
        }
909
      },
910
      "cell_type": "code",
911
      "source": [
912
        "feats = FeatureEngineer(epochs,model_type='NN',\n",
913
        "                       electrode_median=True,\n",
914
        "                        frequency_domain=False)"
915
      ],
916
      "execution_count": 11,
917
      "outputs": [
918
        {
919
          "output_type": "stream",
920
          "text": [
921
            "Constructing Time Domain Features\n",
922
            "Computing Median over electrodes\n",
923
            "Normalizing X\n",
924
            "Combined X Shape: (6999, 1000, 1)\n",
925
            "Combined Y Shape: (6999,)\n",
926
            "Y Example (should be 1s & 0s): [1 0 0 1 0 1 1 1 0 1]\n",
927
            "X Range: -48.29169:43.34039\n",
928
            "Input Shape: (1000, 1)\n",
929
            "x_train shape: (4199, 1000, 1)\n",
930
            "4199 train samples\n",
931
            "1400 test samples\n",
932
            "1400 validation samples\n",
933
            "Class Weights: [0.95605647 1.04817773]\n"
934
          ],
935
          "name": "stdout"
936
        }
937
      ]
938
    },
939
    {
940
      "metadata": {
941
        "id": "9ChMvr-jKp8P",
942
        "colab_type": "text"
943
      },
944
      "cell_type": "markdown",
945
      "source": [
946
        "# Run CreateModel"
947
      ]
948
    },
949
    {
950
      "metadata": {
951
        "id": "HFf3rBbJKqHR",
952
        "colab_type": "code",
953
        "outputId": "dc8bdb38-ad26-46aa-fd6b-242cf3815bd1",
954
        "colab": {
955
          "base_uri": "https://localhost:8080/",
956
          "height": 1040
957
        }
958
      },
959
      "cell_type": "code",
960
      "source": [
961
        "model, _ = CreateModel(feats)"
962
      ],
963
      "execution_count": 9,
964
      "outputs": [
965
        {
966
          "output_type": "stream",
967
          "text": [
968
            "Creating LSTM Model\n",
969
            "Input shape: (1000, 1)\n",
970
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
971
            "Instructions for updating:\n",
972
            "Colocations handled automatically by placer.\n",
973
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.\n",
974
            "Instructions for updating:\n",
975
            "Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.\n",
976
            "_________________________________________________________________\n",
977
            "Layer (type)                 Output Shape              Param #   \n",
978
            "=================================================================\n",
979
            "lstm_1 (LSTM)                (None, None, 16)          1152      \n",
980
            "_________________________________________________________________\n",
981
            "batch_normalization_1 (Batch (None, None, 16)          64        \n",
982
            "_________________________________________________________________\n",
983
            "activation_1 (Activation)    (None, None, 16)          0         \n",
984
            "_________________________________________________________________\n",
985
            "dropout_1 (Dropout)          (None, None, 16)          0         \n",
986
            "_________________________________________________________________\n",
987
            "lstm_2 (LSTM)                (None, None, 8)           800       \n",
988
            "_________________________________________________________________\n",
989
            "batch_normalization_2 (Batch (None, None, 8)           32        \n",
990
            "_________________________________________________________________\n",
991
            "activation_2 (Activation)    (None, None, 8)           0         \n",
992
            "_________________________________________________________________\n",
993
            "dropout_2 (Dropout)          (None, None, 8)           0         \n",
994
            "_________________________________________________________________\n",
995
            "lstm_3 (LSTM)                (None, None, 4)           208       \n",
996
            "_________________________________________________________________\n",
997
            "batch_normalization_3 (Batch (None, None, 4)           16        \n",
998
            "_________________________________________________________________\n",
999
            "activation_3 (Activation)    (None, None, 4)           0         \n",
1000
            "_________________________________________________________________\n",
1001
            "dropout_3 (Dropout)          (None, None, 4)           0         \n",
1002
            "_________________________________________________________________\n",
1003
            "lstm_4 (LSTM)                (None, None, 8)           416       \n",
1004
            "_________________________________________________________________\n",
1005
            "batch_normalization_4 (Batch (None, None, 8)           32        \n",
1006
            "_________________________________________________________________\n",
1007
            "activation_4 (Activation)    (None, None, 8)           0         \n",
1008
            "_________________________________________________________________\n",
1009
            "dropout_4 (Dropout)          (None, None, 8)           0         \n",
1010
            "_________________________________________________________________\n",
1011
            "lstm_5 (LSTM)                (None, 16)                1600      \n",
1012
            "_________________________________________________________________\n",
1013
            "batch_normalization_5 (Batch (None, 16)                64        \n",
1014
            "_________________________________________________________________\n",
1015
            "activation_5 (Activation)    (None, 16)                0         \n",
1016
            "_________________________________________________________________\n",
1017
            "dropout_5 (Dropout)          (None, 16)                0         \n",
1018
            "_________________________________________________________________\n",
1019
            "dense_1 (Dense)              (None, 2)                 34        \n",
1020
            "_________________________________________________________________\n",
1021
            "activation_6 (Activation)    (None, 2)                 0         \n",
1022
            "=================================================================\n",
1023
            "Total params: 4,418\n",
1024
            "Trainable params: 4,314\n",
1025
            "Non-trainable params: 104\n",
1026
            "_________________________________________________________________\n"
1027
          ],
1028
          "name": "stdout"
1029
        }
1030
      ]
1031
    },
1032
    {
1033
      "metadata": {
1034
        "id": "-EKBjSapfE4O",
1035
        "colab_type": "text"
1036
      },
1037
      "cell_type": "markdown",
1038
      "source": [
1039
        "# TrainTestVal"
1040
      ]
1041
    },
1042
    {
1043
      "metadata": {
1044
        "id": "u6ize7eJfB3J",
1045
        "colab_type": "code",
1046
        "outputId": "c2486b65-91b9-47ed-dcdb-d6536159d177",
1047
        "colab": {
1048
          "base_uri": "https://localhost:8080/",
1049
          "height": 1017
1050
        }
1051
      },
1052
      "cell_type": "code",
1053
      "source": [
1054
        "TrainTestVal(model, feats)"
1055
      ],
1056
      "execution_count": 10,
1057
      "outputs": [
1058
        {
1059
          "output_type": "stream",
1060
          "text": [
1061
            "Training Model:\n",
1062
            "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n",
1063
            "Instructions for updating:\n",
1064
            "Use tf.cast instead.\n",
1065
            "Train on 4199 samples, validate on 1400 samples\n",
1066
            "Epoch 1/20\n",
1067
            "2180/4199 [==============>...............] - ETA: 36:31 - loss: 0.7567 - acc: 0.4972"
1068
          ],
1069
          "name": "stdout"
1070
        },
1071
        {
1072
          "output_type": "error",
1073
          "ename": "KeyboardInterrupt",
1074
          "evalue": "ignored",
1075
          "traceback": [
1076
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
1077
            "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
1078
            "\u001b[0;32m<ipython-input-10-6afb0c2405f4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mTrainTestVal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfeats\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
1079
            "\u001b[0;32m/content/DeepEEG/utils.py\u001b[0m in \u001b[0;36mTrainTestVal\u001b[0;34m(model, feats, batch_size, train_epochs, show_plots)\u001b[0m\n\u001b[1;32m    868\u001b[0m               \u001b[0mshuffle\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    869\u001b[0m               \u001b[0mverbose\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 870\u001b[0;31m               \u001b[0mclass_weight\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfeats\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclass_weights\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    871\u001b[0m               )\n\u001b[1;32m    872\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
1080
            "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/keras/engine/training.py\u001b[0m in \u001b[0;36mfit\u001b[0;34m(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)\u001b[0m\n\u001b[1;32m   1037\u001b[0m                                         \u001b[0minitial_epoch\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0minitial_epoch\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1038\u001b[0m                                         \u001b[0msteps_per_epoch\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msteps_per_epoch\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1039\u001b[0;31m                                         validation_steps=validation_steps)\n\u001b[0m\u001b[1;32m   1040\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1041\u001b[0m     def evaluate(self, x=None, y=None,\n",
1081
            "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/keras/engine/training_arrays.py\u001b[0m in \u001b[0;36mfit_loop\u001b[0;34m(model, f, ins, out_labels, batch_size, epochs, verbose, callbacks, val_f, val_ins, shuffle, callback_metrics, initial_epoch, steps_per_epoch, validation_steps)\u001b[0m\n\u001b[1;32m    197\u001b[0m                     \u001b[0mins_batch\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mins_batch\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtoarray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    198\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 199\u001b[0;31m                 \u001b[0mouts\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mins_batch\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    200\u001b[0m                 \u001b[0mouts\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mto_list\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mouts\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    201\u001b[0m                 \u001b[0;32mfor\u001b[0m \u001b[0ml\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mo\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mout_labels\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mouts\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1082
            "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, inputs)\u001b[0m\n\u001b[1;32m   2713\u001b[0m                 \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_legacy_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   2714\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2715\u001b[0;31m             \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   2716\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   2717\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0mpy_any\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mis_tensor\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mx\u001b[0m \u001b[0;32min\u001b[0m \u001b[0minputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1083
            "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py\u001b[0m in \u001b[0;36m_call\u001b[0;34m(self, inputs)\u001b[0m\n\u001b[1;32m   2673\u001b[0m             \u001b[0mfetched\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_callable_fn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0marray_vals\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrun_metadata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_metadata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   2674\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2675\u001b[0;31m             \u001b[0mfetched\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_callable_fn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0marray_vals\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   2676\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0mfetched\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0moutputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   2677\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
1084
            "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m   1437\u001b[0m           ret = tf_session.TF_SessionRunCallable(\n\u001b[1;32m   1438\u001b[0m               \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_session\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_session\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_handle\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstatus\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1439\u001b[0;31m               run_metadata_ptr)\n\u001b[0m\u001b[1;32m   1440\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mrun_metadata\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1441\u001b[0m           \u001b[0mproto_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtf_session\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTF_GetBuffer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrun_metadata_ptr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1085
            "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
1086
          ]
1087
        }
1088
      ]
1089
    }
1090
  ]
1091
}