def connect_muse(address, device_type, host, port): muse = Muse(address=address, device_type=device_type, host=host, port=port, backend=backend, interface=None) muse.connect() print("muse connected %s" % (address)) muse.start() print("muse streaming from %s" % (address)) return muse
help="device mac address.") (options, args) = parser.parse_args() full_time = [] full_data = [] def process(data, timestamps): full_time.append(timestamps) full_data.append(data) muse = Muse(options.address, process) muse.connect() muse.start() while 1: try: sleep(1) except: break muse.stop() muse.disconnect() full_time = np.concatenate(full_time) full_data = np.concatenate(full_data, 1).T res = pd.DataFrame(data=full_data, columns=['TP9', 'AF7', 'AF8', 'TP10', 'Right AUX'])
for c in ['TP9', 'AF7', 'AF8', 'TP10', 'Right AUX']: channels.append_child("channel") \ .append_child_value("label", c) \ .append_child_value("unit", "microvolts") \ .append_child_value("type", "EEG") outlet = StreamOutlet(info, 12, 360) def process(data, timestamps): for ii in range(12): outlet.push_sample(data[:, ii], timestamps[ii]) muse = Muse(address=options.address, callback=process, backend=options.backend, time_func=local_clock, interface=options.interface, name=options.name) muse.connect() print('Connected') muse.start() print('Streaming') while 1: try: sleep(1) except: break muse.stop() muse.disconnect() print('Disonnected')