def _stream_debug(self):
        info = pylsl.stream_info('Debug', 'EEG', self.channel_count,
                                 self.nominal_srate, pylsl.cf_float32,
                                 'dsffwerwer')
        outlet = pylsl.stream_outlet(info)
        print('DebudStream: Streaming start...')
        path_rest = 'C:/Workspace/SpeechMapping/SpeechMappingv0_3/data/Sysoeva/10_10_19/data_rest/experiment_data.h5'
        path_actions = 'C:/Workspace/SpeechMapping/SpeechMappingv0_3/data/Sysoeva/10_10_19/data_actions/experiment_data.h5'
        path_objects = 'C:/Workspace/SpeechMappingv0_3/data/Sysoeva/10_10_19/data_objects/experiment_data.h5'
        paths = [path_rest, path_actions, path_objects]
        time.sleep(3)
        for i in range(len(paths)):
            with h5py.File(paths[i], "r") as file:
                data = file['protocol1']['raw_data']
                data_length = data.shape[0]
                index = 0
                start_time = time.time()
                current_time = time.time()
                while (time.time() - start_time <
                       self.stream_time) and index < data_length:
                    if time.time() - current_time > 1 / 2048:
                        current_time = time.time()
                        sample = data[index, :68]
                        outlet.push_sample(sample)
                        index += 1
                        if index % 100 == 0:
                            print('Index: ', index)
                    time.sleep(0.0001)
        time.sleep(3)

        print('DebudStream: Streaming stop...')
Пример #2
0
def Ni_data_collection():
    streams = pylsl.resolve_stream()
    info = pylsl.stream_info('Force', 'Data', 1, 1000, 'float32')
    outlet = pylsl.stream_outlet(info)

    with nidaqmx.Task() as task:
        task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
        while True:
            sample = pylsl.vectorf([task.read()])
            outlet.push_sample(sample)
            time.sleep(0.01)
Пример #3
0
    def handle_config(self, timestamp, data_obj):

        # Configure the LSL streams
        eeg_info = pylsl.stream_info("Interaxon","EEG", data_obj.eeg_channel_count,
                                     data_obj.eeg_sample_frequency_hz, pylsl.cf_float32,
                                     "Muse-EEG-" + data_obj.mac_addr)
        eeg_info.desc().append_child_value("manufacturer", "Interaxon")
        channels = eeg_info.desc().append_child("channels")
        for c in data_obj.eeg_channel_layout.split():
            channels.append_child("channel").append_child_value("label",c).append_child_value("unit","microvolts").append_child_value("type","EEG")

        # outgoing buffer size to 360 seconds (max.) and the transmission chunk size to 32 samples
        self.__outlets["EEG"] = pylsl.stream_outlet(eeg_info, 360, 32)


        acc_info = pylsl.stream_info("Interaxon","Accelerometer", 3, 50, pylsl.cf_int32,
                                     "Muse-AC-" + data_obj.mac_addr)
        acc_info.desc().append_child_value("manufacturer", "Interaxon")
        channels = acc_info.desc().append_child("channels")
        for c in ['x', 'y', 'z']:
            channels.append_child("channel").append_child_value("label",c).append_child_value("unit","4/1023g").append_child_value("type","Accelerometer")

        # outgoing buffer size to 360 seconds (max.) and the transmission chunk size to 32 samples
        self.__outlets["ACC"] = pylsl.stream_outlet(acc_info, 360, 32)
    def _stream(self):
        info = pylsl.stream_info('Debug', 'EEG', self.channel_count,
                                 self.nominal_srate, pylsl.cf_float32,
                                 'dsffwerwer')
        outlet = pylsl.stream_outlet(info)
        print('DebudStream: Streaming start...')

        start_time = time.time()
        current_time = time.time()
        while (time.time() - start_time < self.stream_time):
            if time.time() - current_time > self.seconnds_per_sample:
                current_time = time.time()
                sample = [random.random() for i in range(self.channel_count)]
                outlet.push_sample(sample)
                #time.sleep(0.0002)
            time.sleep(0.0001)

        print('DebudStream: Streaming stop...')
Пример #5
0
    def startReadAndProcess(self):
        if self.stream is None:
            print("No stream to read... aborting")
            return
        # create a new inlet to read from the stream
        self.inlet = StreamInlet(self.stream)
        self.outlet = pylsl.stream_outlet(self.outputInfo)
        mustStop = False
        outputEveryNSample = self.inputRate / self.outputRate
        samp = 0
        while not mustStop:
            samp += 1
            np.roll(self.buff, -1, 0)
            self.buff[self.bufferSize -
                      1, :], timestamp = self.inlet.pull_sample()
            if samp % outputEveryNSample == 0:
                #pdb.set_trace()
                values = self.processBuffer(self.freqBand)
                self.outlet.push_sample(
                    pylsl.vectorf(self.processBuffer(self.freqBand)))

        self.inlet = None
Пример #6
0
        "EEG",
        len(headset.channel_mask),
        headset.sampling_rate,
        pylsl.cf_int16,
        str(headset.serial_number),
    )

    info_desc = info.desc()
    info_desc.append_child_value("manufacturer", "Emotiv")
    channels = info_desc.append_child("channels")

    for ch in headset.channel_mask:
        channels.append_child("channel").append_child_value("label", ch).append_child_value(
            "unit", "microvolts"
        ).append_child_value("type", "EEG")

    # Outgoing buffer size = 360 seconds, transmission chunk size = 32 samples
    outlet = pylsl.stream_outlet(info, 1, 32)

    while True:
        try:
            s = headset.get_sample()
        except epoc.EPOCTurnedOffError, e:
            print "Headset is turned off, waiting..."
            time.sleep(0.02)
        else:
            if s:
                outlet.push_sample(pylsl.vectori(s), pylsl.local_clock())

    headset.disconnect()
Пример #7
0
'''
Created on Jul 10, 2012

@author: SCCN
'''

from pylink import *
import pylsl, socket, time

if __name__ == '__main__':

    outlet = None
    try:
        info = pylsl.stream_info("EyeLink", "Gaze", 9, 100, pylsl.cf_float32,
                                 "eyelink-" + socket.gethostname())
        outlet = pylsl.stream_outlet(info)
        print "Established LSL outlet."
    except:
        print "Could not create LSL outlet."

    while True:
        try:
            print "Trying to connect to EyeLink tracker..."
            try:
                tracker = EyeLink("255.255.255.255")
                print "Established a passive connection with the eye tracker."
            except:
                tracker = EyeLink("100.1.1.1")
                print "Established a primary connection with the eye tracker."
            beginRealTimeMode(100)
            getEYELINK().startRecording(1, 1, 1, 1)
# TEST SCRIPT 
# NOT FINAL


import nidaqmx.system
import time
import pylsl

info = pylsl.stream_info('BioSemi', 'fnir', 1, 100, pylsl.cf_float32, 'myuid34234') #'float32'

# next make an outlet
outlet = None
outlet = pylsl.stream_outlet(info)
task = nidaqmx.Task()

for num in range(1,17):
    task.ai_channels.add_ai_voltage_chan('{0}{1}'.format('Dev1/ai',num-1))

   
print("now sending data...")
while True:
    datarec = task.read(number_of_samples_per_channel=1)
    #outlet.push_sample(data)
    stamp = time.time() #100 #local_clock()-0.125
    #values=[datarec[1], datarec[2]]
    outlet.push_sample(pylsl.vectord(datarec[1]), stamp)

    print "Found headset with serial number: ", headset.serial_number

    info = pylsl.stream_info('Emotiv EEG', 'EEG', len(headset.channel_mask),
                             headset.sampling_rate, pylsl.cf_int16,
                             str(headset.serial_number))

    info_desc = info.desc()
    info_desc.append_child_value("manufacturer", "Emotiv")
    channels = info_desc.append_child("channels")

    for ch in headset.channel_mask:
        channels.append_child("channel").append_child_value(
            "label", ch).append_child_value("unit",
                                            "microvolts").append_child_value(
                                                "type", "EEG")

    # Outgoing buffer size = 360 seconds, transmission chunk size = 32 samples
    outlet = pylsl.stream_outlet(info, 1, 32)

    while True:
        try:
            s = headset.get_sample()
        except epoc.EPOCTurnedOffError, e:
            print "Headset is turned off, waiting..."
            time.sleep(0.02)
        else:
            if s:
                outlet.push_sample(pylsl.vectori(s), pylsl.local_clock())

    headset.disconnect()
Пример #10
0
def CreateMrkStream():
    info = pylsl.stream_info('P300_Markers', 'Markers', 1, 0, pylsl.cf_string, 'unsampledStream');
    outlet = pylsl.stream_outlet(info, 1, 1)
    return outlet;
Пример #11
0
    outlet = pylsl.stream_outlet(info)

    with nidaqmx.Task() as task:
        task.ai_channels.add_ai_voltage_chan("Dev1/ai0")
        while True:
            sample = pylsl.vectorf([task.read()])
            outlet.push_sample(sample)
            time.sleep(0.01)


Ni_collect_proccess = multiprocessing.Process(target=Ni_data_collection)
#experiment_proccess= multiprocessing.Process(target=start_experiment)

if __name__ == '__main__':
    trigg_info = pylsl.stream_info('Markers', 'Markers', 1, 0, 'string')
    trigg_outlet = pylsl.stream_outlet(trigg_info)
    app = App(LabRecorder_path, EEG_module_path, impedence_path,
              Ni_collect_proccess)
    app.root.mainloop()
    # message if EEG is not activated
    if app.EEG_var == 0:
        root2 = tk.Tk()
        root2.withdraw()
        result = tk.messagebox.askokcancel(
            title=None,
            message='No EEG Signal. \nWould you like to procceed?',
        )
        if result == False:
            quit()

    if app.Ni_var == 0:
Пример #12
0
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 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 = pylsl.stream_info('BioSemi','EEG',8,100,pylsl.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 outgoing buffer size to 360 seconds (max.) and the transmission chunk size to 32 samples
outlet = pylsl.stream_outlet(info,360,32)

print("now sending data...")
while True:
	# make a new random 8-channel sample; this is converted into a pylsl.vectorf (the data type that is expected by push_sample)
	mysample = pylsl.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)
	now = pylsl.local_clock()
	# now send it and wait for a bit
	outlet.push_sample(mysample,now)
	time.sleep(0.01)
Пример #13
0
# 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 = pylsl.stream_info('BioSemi', 'EEG', 8, 100, pylsl.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 outgoing buffer size to 360 seconds (max.) and the transmission chunk size to 32 samples
outlet = pylsl.stream_outlet(info, 360, 32)

print("now sending data...")
while True:
    # make a new random 8-channel sample; this is converted into a pylsl.vectorf (the data type that is expected by push_sample)
    mysample = pylsl.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)
Пример #14
0
def CreateMrkStream():
    info = pylsl.stream_info('SegSpeller_Markers', 'Markers', 1, 0,
                             pylsl.cf_string, 'segspeller')
    return pylsl.stream_outlet(info)
Пример #15
0
from Tkinter import *
import random, pylsl
from pylsl import stream_inlet, stream_outlet, stream_info
info = stream_info('RandomData', 'EEG', 4, 50, pylsl.cf_int32, 'RandomDev123')
outlet = stream_outlet(info)
inlet = stream_inlet(info)
inlet.open_stream()

WIDTH = 800
HEIGHT = 600
SEG_SIZE = 20
IN_GAME = True


def create_block():
    global BLOCK
    posx = SEG_SIZE * random.randint(1, (WIDTH-SEG_SIZE) / SEG_SIZE)
    posy = SEG_SIZE * random.randint(1, (HEIGHT-SEG_SIZE) / SEG_SIZE)
    BLOCK = c.create_oval(posx, posy, posx+SEG_SIZE, posy+SEG_SIZE, fill="red")

    
def main():
    global IN_GAME
    if IN_GAME:
        s.move()
        head_coords = c.coords(s.segments[-1].instance)
        x1, y1, x2, y2 = head_coords
        insample = pylsl.vectorf()
        inlet_list = []
        while inlet.samples_available():
            inlet.pull_sample(insample)
Пример #16
0
    if (len(sys.argv) < 3):
        print("ERROR: Incorrect use of the script")
        print(
            "Use: python incoming_trigger_test.py <numberoftriggers> <interval in seconds>"
        )
        sys.exit()

    print("LSL INCOMING TRIGGERS TEST\n")

    name = "stream_trigger2"

    si = lsl.StreamInfo(name=name,
                        type='Markers',
                        source_id='testing_dep',
                        channel_format=lsl.cf_string)
    so = lsl.stream_outlet(si)

    print("It will take 5 seconds to start sending triggers...")
    time.sleep(
        5
    )  # Make sure that eego got the news of the new stram and subcribes to it. Not needed from the python side

    triggers = int(sys.argv[1])  #number of triggers
    sleeping_time = float(sys.argv[2])  #time in seconds

    cont = 1

    while (cont <= triggers or triggers is -1):

        string = "%i -> %s" % (cont, datetime.datetime.now().time())