-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulate_sender.py
More file actions
45 lines (32 loc) · 1.15 KB
/
Copy pathsimulate_sender.py
File metadata and controls
45 lines (32 loc) · 1.15 KB
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
"""Simple LSL marker sender for testing the debugger.
Simulates a PsychoPy-like experiment that sends integer trigger codes
on a Markers stream at random intervals.
Usage:
uv run python simulate_sender.py
"""
import random
import time
from pylsl import StreamInfo, StreamOutlet
STREAM_NAME = "test_experiment"
SOURCE_ID = "test_experiment_participant01"
# Typical trigger codes you might see in an EEG experiment
TRIGGER_CODES = [1, 2, 3, 4, 10, 20, 99, 100, 255]
def main():
print(f"Creating LSL stream: {STREAM_NAME}")
info = StreamInfo(STREAM_NAME, "Markers", 1, 0, "int32", SOURCE_ID)
outlet = StreamOutlet(info)
print("Sending triggers (Ctrl+C to stop)...")
print()
count = 0
try:
while True:
trigger = random.choice(TRIGGER_CODES)
outlet.push_sample([trigger])
count += 1
print(f" [{count:4d}] trigger = {trigger}")
# Random interval between 0.5 and 3 seconds (like real stimulus timing)
time.sleep(random.uniform(0.5, 3.0))
except KeyboardInterrupt:
print(f"\nStopped after {count} triggers.")
if __name__ == "__main__":
main()