def Paradigm(): global refresh_rate global win global photosensor global fixation global triangle global mrkstream global bg_color # Compute sequence of stimuli sequence = CreateSequence(120, 30) # Iterate through sequence and perform: # 250ms bold fixation # 500ms normal fixation # 500ms stimulus presentation # 1000ms black screen for i, s in enumerate(sequence): # 250ms Bold fixation cross fixation.lineWidth = 1 fixation.lineColor = [1, 1, 1] SetStimulus(fixation, 'on') for frame in range(MsToFrames(250, refresh_rate)): fixation.draw() win.flip() # 500ms Normal fixation cross fixation.lineColor = bg_color for frame in range(MsToFrames(500, refresh_rate)): fixation.draw() win.flip() # 500ms Stimulus presentation (w/ fixation) RotateTriangle(triangle, 180) # <-- Standard (S) mrk = pylsl.vectorstr(['0']) if s == 'T': RotateTriangle(triangle, 0) # <-- Target (T) mrk = pylsl.vectorstr(['1']) SetStimulus(photosensor, 'on') for frame in range(MsToFrames(500, refresh_rate)): # Send LSL marker on first frame if frame == 0: mrkstream.push_sample(mrk); photosensor.draw() triangle.draw() fixation.draw() win.flip() # 1000ms darkness for frame in range(MsToFrames(1000, refresh_rate)): win.flip()
import sys; sys.path.append('..') # make sure that pylsl is found (note: in a normal program you would bundle pylsl with the program) import pylsl # first resolve a marker stream on the lab network print("looking for a marker stream...") streams = pylsl.resolve_stream('type','Markers') # create a new inlet to read from the stream inlet = pylsl.stream_inlet(streams[0]) sample = pylsl.vectorstr() while True: # get a new sample (you can also omit the timestamp part if you're not interested in it) timestamp = inlet.pull_sample(sample) print("got ",sample[0]," at time ",timestamp)
import sys; sys.path.append('..') # make sure that pylsl is found (note: in a normal program you would bundle pylsl with the program) import pylsl 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 = pylsl.stream_info('MyMarkerStream','Markers',1,0,pylsl.cf_string,'dgeyurtutu567sdf'); # next make an outlet outlet = pylsl.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 pylsl.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 = pylsl.vectorstr([ random.choice(markernames) ]) # now send it and wait for a bit outlet.push_sample(mysample) time.sleep(random.random()*3)
outlet = pylsl.stream_outlet(info) print("looking for video frame stream...") streams = pylsl.resolve_stream('type','VideoRaw') # create a new inlet to read from the stream inlet = pylsl.stream_inlet(streams[0]) print("now sending markers...") flatFrame = pylsl.vectori() i=0 while True: # choose a marker string randomly and store it as a pylsl.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 = pylsl.vectorstr([ 'Request Image' ]) # now send it and wait for a bit outlet.push_sample(mysample) if(inlet.pull_sample(flatFrame,1)): print 'got frame' buf = struct.pack('b'*len(flatFrame), *flatFrame) #It is possible to load the width and height from the stream header, but not implemented here. img = Image.frombuffer('RGB', (640,480), buf) if i==0: #this opens your default graphics program to show the image. Not wonderful. img.show() time.sleep(1)
import sys sys.path.append( '..' ) # make sure that pylsl is found (note: in a normal program you would bundle pylsl with the program) import pylsl 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 = pylsl.stream_info('MyMarkerStream', 'Markers', 1, 0, pylsl.cf_string, 'dgeyurtutu567sdf') # next make an outlet outlet = pylsl.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 pylsl.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 = pylsl.vectorstr([random.choice(markernames)]) # now send it and wait for a bit outlet.push_sample(mysample) time.sleep(random.random() * 3)
def SendStimMrk(stim): mrk = pylsl.vectorstr([str(stim)]) mrkstream.push_sample(mrk)
import sys sys.path.append( '..' ) # make sure that pylsl is found (note: in a normal program you would bundle pylsl with the program) import pylsl # first resolve a marker stream on the lab network print("looking for a marker stream...") streams = pylsl.resolve_stream('type', 'Markers') # create a new inlet to read from the stream inlet = pylsl.stream_inlet(streams[0]) sample = pylsl.vectorstr() while True: # get a new sample (you can also omit the timestamp part if you're not interested in it) timestamp = inlet.pull_sample(sample) print("got ", sample[0], " at time ", timestamp)