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 time # create a new StreamInfo and declare some meta-data (in accordance with XDF format) 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")
import liblsl import time # create a new StreamInfo and declare some meta-data (in accordance with XDF format) 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")
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'); # next make an outlet outlet = liblsl.stream_outlet(info) 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()]) # now send it and wait for a bit outlet.push_sample(mysample) time.sleep(0.01)
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') # next make an outlet outlet = liblsl.stream_outlet(info) 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() ]) # now send it and wait for a bit outlet.push_sample(mysample) time.sleep(0.01)
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)