import liblsl
import random
import time

# first create a new stream info (here we set the name to MyMarkerStream, the content-type to Markers, 1 channel, irregular sampling rate, and string-valued data)
# The last value would be the  locally unique identifier for the stream as far as available, e.g. program-scriptname-subjectnumber (you could also omit it but interrupted connections wouldn't auto-recover).
# The important part is that the content-type is set to 'Markers', because then other programs will know how to interpret the content
info = liblsl.stream_info('MyMarkerStream','Markers',1,0,liblsl.cf_string,'dgeyurtutu567sdf');

# next make an outlet
outlet = liblsl.stream_outlet(info)

print("now sending markers...")
markernames = ['Test', 'Blah', 'Marker', 'XXX', 'Testtest', 'Test-1-2-3']
while True:
	# choose a marker string randomly and store it as a liblsl.vectorstr (note that this is actually a list since there can be multiple channels in the sample, even though it is of little use for markers)
	mysample = liblsl.vectorstr([ random.choice(markernames) ])
	# now send it and wait for a bit
	outlet.push_sample(mysample)
	time.sleep(random.random()*3)
import liblsl
import random
import time

# first create a new stream info (here we set the name to BioSemi, the content-type to EEG, 8 channels, 100 Hz, and float-valued data)
# The last value would be the serial number of the device or some other more or less locally unique identifier for the stream as far as available (you could also omit it but interrupted connections wouldn't auto-recover).
info = liblsl.stream_info('BioSemi','EEG',8,100,liblsl.cf_float32,'dsffwerwer');

# append some meta-data
info.desc().append_child_value("manufacturer","BioSemi")
channels = info.desc().append_child("channels")
for c in ["C3","C4","Cz","FPz","POz","CPz","O1","O2"]:
	channels.append_child("channel").append_child_value("name",c).append_child_value("unit","microvolts").append_child_value("type","EEG")

# next make an outlet; we set the transmission chunk size to 32 samples and the outgoing buffer size to 360 seconds (max.)
outlet = liblsl.stream_outlet(info,32,360)

print("now sending data...")
while True:
	# make a new random 8-channel sample; this is converted into a liblsl.vectorf (the data type that is expected by push_sample)
	mysample = liblsl.vectorf([random.random(),random.random(),random.random(),random.random(),random.random(),random.random(),random.random(),random.random()])
    # get a time stamp in seconds (we might modify this time stamp based on the true age of the sample, e.g. if it came from a measurement device, in case we can determine it)
	stamp = liblsl.local_clock()
	# now send it and wait for a bit
	outlet.push_sample(mysample,stamp)
	time.sleep(0.01)
Example #3
0
info = liblsl.stream_info("MetaTester", "EEG", 8, 100, liblsl.cf_float32,
                          "myuid56872")
chns = info.desc().append_child("channels")
for label in ["C3", "C4", "Cz", "FPz", "POz", "CPz", "O1", "O2"]:
    ch = chns.append_child("channel")
    ch.append_child_value("label", label)
    ch.append_child_value("unit", "microvolts")
    ch.append_child_value("type", "EEG")
info.desc().append_child_value("manufacturer", "SCCN")
cap = info.desc().append_child("cap")
cap.append_child_value("name", "EasyCap")
cap.append_child_value("size", "54")
cap.append_child_value("labelscheme", "10-20")

# create outlet for the stream
outlet = liblsl.stream_outlet(info)

# === the following could run on another computer ===

# resolve the stream and open an inlet
results = liblsl.resolve_stream("name", "MetaTester")
inlet = liblsl.stream_inlet(results[0])
# get the full stream info (including custom meta-data) and dissect it
inf = inlet.info()
print "The stream's XML meta-data is: "
print inf.as_xml()
print "The manufacturer is: " + inf.desc().child_value("manufacturer")
print "The cap circumference is: " + inf.desc().child("cap").child_value(
    "size")
print "The channel labels are as follows:"
ch = inf.desc().child("channels").child("channel")
Example #4
0
import liblsl
import random
import time

# first create a new stream info (here we set the name to BioSemi, the content-type to EEG, 8 channels, 100 Hz, and float-valued data)
# The last value would be the serial number of the device or some other more or less locally unique identifier for the stream as far as available (you could also omit it but interrupted connections wouldn't auto-recover).
info = liblsl.stream_info('BioSemi','EEG',8,100,liblsl.cf_float32,'dsffwerwer');

# append some meta-data
info.desc().append_child_value("manufacturer","BioSemi")
channels = info.desc().append_child("channels")
for c in ["C3","C4","Cz","FPz","POz","CPz","O1","O2"]:
	channels.append_child("channel").append_child_value("name",c).append_child_value("unit","microvolts").append_child_value("type","EEG")

# next make an outlet; we set the transmission chunk size to 32 samples and the outgoing buffer size to 360 seconds (max.)
outlet = liblsl.stream_outlet(info,32,360)

print("now sending data...")
while True:
	# make a new random 8-channel sample; this is converted into a liblsl.vectorf (the data type that is expected by push_sample)
	mysample = liblsl.vectorf([random.random(),random.random(),random.random(),random.random(),random.random(),random.random(),random.random(),random.random()])
    # get a time stamp in seconds (we might modify this time stamp based on the true age of the sample, e.g. if it came from a measurement device, in case we can determine it)
	stamp = liblsl.local_clock()
	# now send it and wait for a bit
	outlet.push_sample(mysample,stamp)
	time.sleep(0.01)