-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlsl_emulator.py
30 lines (23 loc) · 1.05 KB
/
lsl_emulator.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
# This code is adapted from the following repository:
# https://github.com/chkothe/pylsl/blob/master/examples/SendData.py
import random
import time
from pylsl import StreamInfo, StreamOutlet
def start_lsl():
# Initialize an LSL stream by providing the stream-name ('BioSemi'),
# signal type ('EEG'), number of channels (8 for the OpenBCI Mark IV headset),
# sampling frequency (250 for the OpenBCI Mark IV headset), the data type ('float32'),
# and the user-id.
info = StreamInfo('BioSemi', 'EEG', 8, 250, 'float32', 'myuid34234')
# Create a server outlet.
outlet = StreamOutlet(info)
while True:
# Create random 8-channel sample.
mysample = [random.random(), random.random(), random.random(),
random.random(), random.random(), random.random(),
random.random(), random.random()]
# Send the signal and wait 4ms for the next data post (emulating 250 Hz sampling rate).
outlet.push_sample(mysample)
time.sleep(0.04)
if __name__ == '__main__':
start_lsl()