-
Notifications
You must be signed in to change notification settings - Fork 60
/
tests.py
103 lines (78 loc) · 2.69 KB
/
tests.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import unittest
from utils import Feats
from utils import SimulateRaw
from utils import PreProcess
from utils import CreateModel
from utils import TrainTestVal
from utils import LoadMuseData
from utils import FeatureEngineer
class ExampleTest(unittest.TestCase):
"""
Our basic test class
"""
def test_addition(self):
"""
The actual test.
Any method which starts with ``test_`` will considered as a test case.
"""
res = 2 + 2
self.assertEqual(res, 4)
def test_feats(self):
"""
Testing utils import.
"""
feats = Feats()
self.assertEqual(feats.num_classes, 2)
def test_example_muse(self):
"""
Testing example Muse code.
"""
# Load Data
raw = LoadMuseData(subs=[101, 102], nsesh=2, data_dir='visual/cueing')
# Pre-Process EEG Data
epochs = PreProcess(raw=raw, event_id={'LeftCue': 1, 'RightCue': 2})
# Engineer Features for Model
feats = FeatureEngineer(epochs=epochs)
# Create Model
model, _ = CreateModel(feats=feats)
# Train with validation, then Test
model, data = TrainTestVal(model=model,
feats=feats,
train_epochs=1,
show_plots=False)
self.assertLess(data['acc'], 1)
def test_simulate_raw(self):
"""
Testing simulated data pipeline.
"""
# Simulate Data
raw,event_id = SimulateRaw(amp1=50, amp2=60, freq=1.)
# Pre-Process EEG Data
epochs = PreProcess(raw,event_id)
# Engineer Features for Model
feats = FeatureEngineer(epochs)
# Create Model
model, _ = CreateModel(feats, units=[16,16])
# Train with validation, then Test
model, data = TrainTestVal(model,feats,
train_epochs=1,show_plots=False)
self.assertLess(data['acc'], 1)
def test_frequencydomain_complex(self):
"""
Testing simulated data pipeline.
"""
# Simulate Data
raw,event_id = SimulateRaw(amp1=50, amp2=60, freq=1.)
# Pre-Process EEG Data
epochs = PreProcess(raw,event_id)
# Engineer Features for Model
feats = FeatureEngineer(epochs,frequency_domain=True,
include_phase=True)
# Create Model
model, _ = CreateModel(feats, units=[16,16])
# Train with validation, then Test
model, data = TrainTestVal(model,feats,
train_epochs=1,show_plots=False)
self.assertLess(data['acc'], 1)
if __name__ == '__main__':
unittest.main()