-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathLSL_sender_sine.py
More file actions
29 lines (24 loc) · 918 Bytes
/
LSL_sender_sine.py
File metadata and controls
29 lines (24 loc) · 918 Bytes
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
import time
import math
from random import random as rand
from pylsl import StreamInfo, StreamOutlet
# 스트림 정보 생성 (채널 수 8, 샘플링 주파수 100Hz, 데이터 형식 float32)
info = StreamInfo('8ch_sine', 'EEG', 8, 100, 'float32', 'myuid34235')
# 채널 이름 추가
desc = info.desc()
channels = desc.append_child("channels")
channel_names = ["Fp1", "Fp2", "F7", "F8", "C3", "C4", "O1", "O2"]
for name in channel_names:
channel = channels.append_child("channel")
channel.append_child_value("label", name)
channel.append_child_value("unit", "microvolts")
channel.append_child_value("type", "EEG")
# 스트림 아웃렛 생성
outlet = StreamOutlet(info)
print("now sending data...")
while True:
t = time.time()
mysample = [math.sin(2 * math.pi * f * t) for f in [5, 10, 15, 20, 25, 30, 35, 40]]
print(mysample)
outlet.push_sample(mysample)
time.sleep(0.01)