-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream_eog.py
41 lines (31 loc) · 946 Bytes
/
stream_eog.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
#!/usr/bin/env Python 3
# Copyright 2014 Jari Torniainen <[email protected]>
# Finnish Institute of Occupational Health
#
# This code is released under the MIT License
# http://opensource.org/licenses/mit-license.php
#
# Please see the file LICENSE for details.
import scipy.io as io
from midas.node import lsl
import time
def start_streaming():
data = io.loadmat('full_set.mat')
eog_h = data['EOGh'][0]
eog_v = data['EOGv'][0]
info = lsl.StreamInfo('EOG', 'EOG', 2, 500, 'float32', '001')
outlet = lsl.StreamOutlet(info)
fs = 500.0
idx = 0
print('Starting stream (Ctrl+c to stop)...')
try:
while True:
outlet.push_sample([eog_h[idx], eog_v[idx]])
idx += 1
if idx == len(eog_h):
idx = 0
time.sleep(1.0 / fs)
except KeyboardInterrupt:
print('\nStopping stream.')
if __name__ == '__main__':
start_streaming()