def test_eeg_emotiv_direct(): # Look for emotiv usb device all_devices = get_available_devices() device_handle = all_devices[0] # in main App app = pg.mkQApp() dev = Emotiv(name='Emotiv0') dev.configure(device_handle=device_handle) dev.outputs['signals'].configure( protocol='tcp', interface='127.0.0.1', transfermode='plaindata',) dev.outputs['impedances'].configure( protocol='tcp', interface='127.0.0.1', transfermode='plaindata',) dev.outputs['gyro'].configure( protocol='tcp', interface='127.0.0.1', transfermode='plaindata',) dev.initialize() viewer = QOscilloscope() viewer.configure(with_user_dialog=True) viewer.input.connect(dev.outputs['signals']) viewer.initialize() viewer.show() dev.start() viewer.start() def terminate(): dev.stop() app.quit() # start for a while timer = QtCore.QTimer(singleShot=True, interval=3000) timer.timeout.connect(terminate) #~ timer.start() app.exec_()
def test_QTriggeredOscilloscope(): app = pg.mkQApp() dev = NumpyDeviceBuffer() dev.configure( nb_channel=nb_channel, sample_interval=1. / sample_rate, chunksize=chunksize, buffer=buffer, timeaxis=1, ) dev.output.configure(protocol='tcp', interface='127.0.0.1', transfermode='sharedarray', sharedarray_shape=(nb_channel, 2048 * 50), ring_buffer_method='double', timeaxis=1, dtype='float32') dev.initialize() viewer = QTriggeredOscilloscope() viewer.configure(with_user_dialog=True) viewer.input.connect(dev.output) viewer.initialize() viewer.show() viewer.trigger.params['threshold'] = 1. viewer.trigger.params['debounce_mode'] = 'after-stable' viewer.trigger.params['front'] = '+' viewer.trigger.params['debounce_time'] = 0.1 viewer.triggeraccumulator.params['stack_size'] = 3 viewer.triggeraccumulator.params['left_sweep'] = -.2 viewer.triggeraccumulator.params['right_sweep'] = .5 viewer2 = QOscilloscope() viewer2.configure(with_user_dialog=True) viewer2.input.connect(dev.output) viewer2.initialize() viewer2.show() def terminate(): viewer.stop() viewer2.stop() dev.stop() viewer.close() viewer2.close() dev.close() app.quit() dev.start() viewer.start() viewer2.start() # start for a while timer = QtCore.QTimer(singleShot=True, interval=2000) timer.timeout.connect(terminate) timer.start() app.exec_()
def do_filtertest(engine): app = pg.mkQApp() dev = NumpyDeviceBuffer() dev.configure(nb_channel=nb_channel, sample_interval=1. / sample_rate, chunksize=chunksize, buffer=buffer) dev.output.configure(**stream_spec) dev.initialize() f1, f2 = 40., 60. coefficients = scipy.signal.iirfilter( 7, [f1 / sample_rate * 2, f2 / sample_rate * 2], btype='bandpass', ftype='butter', output='sos') filter = OverlapFiltfilt() filter.configure(coefficients=coefficients, engine=engine, chunksize=chunksize, overlapsize=overlapsize) filter.input.connect(dev.output) filter.output.configure(**stream_spec) filter.initialize() viewer = QOscilloscope() viewer.configure(with_user_dialog=True) viewer.input.connect(filter.output) viewer.initialize() viewer.show() viewer2 = QOscilloscope() viewer2.configure(with_user_dialog=True) viewer2.input.connect(dev.output) viewer2.initialize() viewer2.show() viewer2.start() viewer.start() filter.start() dev.start() def terminate(): dev.stop() filter.stop() viewer.stop() viewer2.stop() app.quit() # start for a while timer = QtCore.QTimer(singleShot=True, interval=3000) timer.timeout.connect(terminate) timer.start() app.exec_()
def lauch_qoscilloscope(transfermode, axisorder): man = create_manager(auto_close_at_exit=False) ng = man.create_nodegroup() app = pg.mkQApp() length = int(sample_rate * 20) t = np.arange(length) / sample_rate buffer = np.random.rand(length, nb_channel) * .3 buffer += np.sin(2 * np.pi * 1.2 * t)[:, None] * .5 buffer = buffer.astype('float32') #~ dev =NumpyDeviceBuffer() dev = ng.create_node('NumpyDeviceBuffer') dev.configure(nb_channel=nb_channel, sample_interval=1. / sample_rate, chunksize=chunksize, buffer=buffer) if transfermode == 'plaindata': dev.output.configure(protocol='tcp', interface='127.0.0.1', transfermode='plaindata') elif transfermode == 'sharedmem': dev.output.configure(protocol='tcp', interface='127.0.0.1', transfermode='sharedmem', buffer_size=int(sample_rate * 62.), axisorder=axisorder, double=True) dev.initialize() viewer = QOscilloscope() viewer.configure(with_user_dialog=True) viewer.input.connect(dev.output) viewer.initialize() viewer.show() viewer.params['decimation_method'] = 'min_max' def terminate(): viewer.stop() dev.stop() viewer.close() dev.close() app.quit() dev.start() viewer.start() # start for a while timer = QtCore.QTimer(singleShot=True, interval=2000) timer.timeout.connect(terminate) timer.start() app.exec_() man.close()
def do_filtertest(engine): stream_spec = dict(protocol='tcp', interface='127.0.0.1', transfermode='sharedmem', double=True, dtype = 'float32',buffer_size=2048*50, shape=(-1,nb_channel)) app = pg.mkQApp() dev = NumpyDeviceBuffer() dev.configure(nb_channel=nb_channel, sample_interval=1./sample_rate, chunksize=chunksize, buffer=buffer) dev.output.configure( **stream_spec) dev.initialize() f1, f2 = 40., 60. coefficients = scipy.signal.iirfilter(7, [f1/sample_rate*2, f2/sample_rate*2], btype = 'bandpass', ftype = 'butter', output = 'sos') filter = SosFilter() filter.configure(coefficients = coefficients, engine=engine, chunksize=chunksize) filter.input.connect(dev.output) filter.output.configure(**stream_spec) filter.initialize() viewer = QOscilloscope() viewer.configure(with_user_dialog=True) viewer.input.connect(filter.output) viewer.initialize() viewer.show() viewer2 = QOscilloscope() viewer2.configure(with_user_dialog=True) viewer2.input.connect(dev.output) viewer2.initialize() viewer2.show() viewer2.start() viewer.start() filter.start() dev.start() def terminate(): dev.stop() filter.stop() viewer.stop() viewer2.stop() app.quit() # start for a while timer = QtCore.QTimer(singleShot=True, interval=3000) timer.timeout.connect(terminate) timer.start() app.exec_()
def lauch_qoscilloscope(transfermode, axisorder): man = create_manager(auto_close_at_exit=False) ng = man.create_nodegroup() app = pg.mkQApp() length = int(sample_rate*20) t = np.arange(length)/sample_rate buffer = np.random.rand(length, nb_channel)*.3 buffer += np.sin(2*np.pi*1.2*t)[:,None]*.5 # add offset buffer += np.random.randn(nb_channel)[None, :]*50 buffer[:, -1] = 0 buffer = buffer.astype('float32') #~ dev =NumpyDeviceBuffer() dev = ng.create_node('NumpyDeviceBuffer') dev.configure(nb_channel=nb_channel, sample_interval=1./sample_rate, chunksize=chunksize, buffer=buffer) if transfermode== 'plaindata': dev.output.configure(protocol='tcp', interface='127.0.0.1', transfermode='plaindata') elif transfermode== 'sharedmem': dev.output.configure(protocol='tcp', interface='127.0.0.1', transfermode='sharedmem', buffer_size=int(sample_rate*62.), axisorder=axisorder, double=True) dev.initialize() viewer = QOscilloscope() viewer.configure(with_user_dialog=True) viewer.input.connect(dev.output) viewer.initialize() viewer.show() viewer.params['decimation_method'] = 'min_max' #~ viewer.params['scale_mode'] = 'by_channel' def terminate(): viewer.stop() dev.stop() viewer.close() dev.close() app.quit() dev.start() viewer.start() # start for a while timer = QtCore.QTimer(singleShot=True, interval=2000) timer.timeout.connect(terminate) timer.start() app.exec_() man.close()
def do_filtertest(engine): app = pg.mkQApp() dev = NumpyDeviceBuffer() dev.configure(nb_channel=nb_channel, sample_interval=1./sample_rate, chunksize=chunksize, buffer=buffer) dev.output.configure(**stream_spec) dev.initialize() f1, f2 = 40., 60. coefficients = scipy.signal.iirfilter(7, [f1/sample_rate*2, f2/sample_rate*2], btype = 'bandpass', ftype = 'butter', output = 'sos') filter = OverlapFiltfilt() filter.configure(coefficients = coefficients, engine=engine, chunksize=chunksize, overlapsize=overlapsize) filter.input.connect(dev.output) filter.output.configure(**stream_spec) filter.initialize() viewer = QOscilloscope() viewer.configure(with_user_dialog=True) viewer.input.connect(filter.output) viewer.initialize() viewer.show() viewer2 = QOscilloscope() viewer2.configure(with_user_dialog=True) viewer2.input.connect(dev.output) viewer2.initialize() viewer2.show() viewer2.start() viewer.start() filter.start() dev.start() def terminate(): dev.stop() filter.stop() viewer.stop() viewer2.stop() app.quit() # start for a while timer = QtCore.QTimer(singleShot=True, interval=3000) timer.timeout.connect(terminate) timer.start() app.exec_()
def test_QTriggeredOscilloscope(): app = pg.mkQApp() dev = NumpyDeviceBuffer() dev.configure(nb_channel=nb_channel, sample_interval=1./sample_rate, chunksize=chunksize, buffer=buffer, timeaxis=1,) dev.output.configure(protocol='tcp', interface='127.0.0.1', transfermode='sharedarray', sharedarray_shape=(nb_channel, 2048*50), ring_buffer_method = 'double', timeaxis = 1, dtype = 'float32') dev.initialize() viewer = QTriggeredOscilloscope() viewer.configure(with_user_dialog=True) viewer.input.connect(dev.output) viewer.initialize() viewer.show() viewer.trigger.params['threshold'] = 1. viewer.trigger.params['debounce_mode'] = 'after-stable' viewer.trigger.params['front'] = '+' viewer.trigger.params['debounce_time'] = 0.1 viewer.triggeraccumulator.params['stack_size'] = 3 viewer.triggeraccumulator.params['left_sweep'] = -.2 viewer.triggeraccumulator.params['right_sweep'] = .5 viewer2 = QOscilloscope() viewer2.configure(with_user_dialog=True) viewer2.input.connect(dev.output) viewer2.initialize() viewer2.show() def terminate(): viewer.stop() viewer2.stop() dev.stop() viewer.close() viewer2.close() dev.close() app.quit() dev.start() viewer.start() viewer2.start() # start for a while timer = QtCore.QTimer(singleShot=True, interval=2000) timer.timeout.connect(terminate) timer.start() app.exec_()
def test_eeg_emotiv_direct(): # Look for emotiv usb device all_devices = get_available_devices() device_handle = all_devices[0] # in main App app = pg.mkQApp() dev = Emotiv(name='Emotiv0') dev.configure(device_handle=device_handle) dev.outputs['signals'].configure( protocol='tcp', interface='127.0.0.1', transfermode='plaindata', ) dev.outputs['impedances'].configure( protocol='tcp', interface='127.0.0.1', transfermode='plaindata', ) dev.outputs['gyro'].configure( protocol='tcp', interface='127.0.0.1', transfermode='plaindata', ) dev.initialize() viewer = QOscilloscope() viewer.configure(with_user_dialog=True) viewer.input.connect(dev.outputs['signals']) viewer.initialize() viewer.show() dev.start() viewer.start() def terminate(): dev.stop() app.quit() # start for a while timer = QtCore.QTimer(singleShot=True, interval=3000) timer.timeout.connect(terminate) #~ timer.start() app.exec_()