def disconnect(self): '''Close the interface to the NSP (or nPlay).''' if not self._init: raise ValueError("Please open the interface to Central/nPlay first.") print 'calling cbpy.close in cerelink.disconnect()' result = cbpy.close() print 'result:', result print '' self._init = False
conn_params = cbpy.defaultConParams() cbpy.open(parameter=conn_params) print("Creating LSL Outlet") outlet_info = pylsl.StreamInfo(name=STREAM_NAME, type=TYPE, channel_count=len(CHANNEL_NAMES), nominal_srate=pylsl.IRREGULAR_RATE, channel_format=CHAN_FORMAT, source_id=SOURCE_ID) outlet_info.desc().append_child_value("manufacturer", "Blackrock") channels = outlet_info.desc().append_child("channels") for c in CHANNEL_NAMES: channels.append_child("channel").append_child_value("label", c) outlet = pylsl.StreamOutlet(outlet_info) print("Sending timestamps...") try: start_time = pylsl.local_clock() n_samples = 0 target_isi = 1 / SYNC_RATE while True: while (pylsl.local_clock() - start_time) < (n_samples * target_isi): time.sleep(0.1/SYNC_RATE) cbpy.trial_config(reset=True, noevent=True, nocontinuous=True, nocomment=True) res, ts = cbpy.time() lsl_stamp = pylsl.local_clock() outlet.push_sample([int(ts)], timestamp=lsl_stamp) n_samples += 1 except KeyboardInterrupt: print("Terminating...") del outlet cbpy.close()
def stop(self): """Tell the device to stop streaming data.""" self.running_ = False result = cbpy.close() err_msg = "Connection to NSP/Central not closed successfully." self._check_result(result, ConnectionError, err_msg)
data[inds, 2] = unit idx += len(unit_ts) # print 'trial_event result:', trial_event_result print '' print 'trial data:\n' if data.shape[0] > 0: data = data[np.argsort(data[:,0]), :] headers = ['timestamp', 'channel', 'unit'] print tabulate.tabulate(data, headers=headers) print '' # print 'time result:', time_result print 'NSP time:', int(nsp_time) print '' last_nsp_time = nsp_time t_elapsed = time.time() - t_start if t_elapsed < loop_time: time.sleep(loop_time - t_elapsed) # print 't_elapsed: %3.3f secs, loop time: %3.3f secs' % (t_elapsed, time.time()-t_start) result = cbpy.close() # print 'result:', result # print ''
print '\nitr %d of %d:' % (itr + 1, n_itrs) # print 'calling cbpy.trial_event()' # result, trial = cbpy.trial_event(reset=True) # result, nsp_time = cbpy.time() print 'calling cbpy.trial_continuous()' result, trial = cbpy.trial_continuous(reset=True) result, nsp_time = cbpy.time() for i in range(len(trial)): print '# samples:', len(trial[i][1]) print 'result:', result print 'trial:', trial print '' # print 'calling cbpy.time()' result, nsp_time = cbpy.time() print 'result:', result print 'time:', nsp_time print '' t_elapsed = time.time() - t_start if t_elapsed < loop_time: time.sleep(loop_time - t_elapsed) print 't_elapsed: %3.3f secs, loop time: %3.3f secs' % ( t_elapsed, time.time() - t_start) result = cbpy.close() print 'result:', result print ''
def disconnect(self): # Close the interface to the NSP (or nPlay). # cbpy.close() self.is_connected = False
def __del__(self): res = cbpy.close(instance=0)