-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlslStreamTest.py
40 lines (32 loc) · 1.16 KB
/
lslStreamTest.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
"""Example program to show how to read a multi-channel time series from LSL."""
import time
from pylsl import StreamInlet, resolve_stream
from time import sleep
# first resolve an EEG stream on the lab network
print("looking for an EEG stream...")
streams = resolve_stream('type', 'EEG')
# create a new inlet to read from the stream
inlet = StreamInlet(streams[0])
duration = 5
sleep(1)
def testLSLSamplingRate():
start = time.time()
totalNumSamples = 0
validSamples = 0
numChunks = 0
print( "Testing Sampling Rates..." )
while time.time() <= start + duration:
# get chunks of samples
chunk, timestamp = inlet.pull_chunk()
if chunk:
numChunks += 1
#print( len(chunk) )
totalNumSamples += len(chunk)
#print(chunk)
for sample in chunk:
#print(len(sample))
validSamples += 1
print( "Number of Chunks and Samples == {} , {}".format(numChunks, totalNumSamples) )
print( "Valid Samples and Duration == {} / {}".format(validSamples, duration) )
print( "Avg Sampling Rate == {}".format(validSamples / duration) )
testLSLSamplingRate()