本文整理匯總了Python中recorder.Recorder.stop_recording方法的典型用法代碼示例。如果您正苦於以下問題:Python Recorder.stop_recording方法的具體用法?Python Recorder.stop_recording怎麽用?Python Recorder.stop_recording使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類recorder.Recorder
的用法示例。
在下文中一共展示了Recorder.stop_recording方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: start
# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import stop_recording [as 別名]
def start(self):
# Init the amp
print 'Initializing the amp...'
recorder = Recorder('lslamp', params.FREQ_S, params.LEN_REC_BUF_SEC, params.NUM_CHANNELS)
thread_rec = threading.Thread(target=recorder.record)
thread_rec.start()
# Start plotting
plt.show()
#thread_plot = threading.Thread(target=self.plot_live)
#thread_plot.start()
# Get and display data from the amp
counter = 0
while not is_terminate_requested:
data_last_chunk = recorder.get_new_data(params.LEN_DATA_CHUNK_READ, params.AMP_WAIT_SEC)
recorder.acknowledge_new_data()
print 'recorder.new_data_counter:', recorder.new_data_counter
#print 'data_last_chunk.shape: ', data_last_chunk.shape
# Position the older data to the beginning of the buffer
self.X_buf[0:(self.len_buf - params.LEN_DATA_CHUNK_READ)]\
= self.X_buf[params.LEN_DATA_CHUNK_READ:]
# Insert the new data into the buffer
self.X_buf[(self.len_buf - params.LEN_DATA_CHUNK_READ):]\
= data_last_chunk
#i_row_from = int((counter*params.LEN_DATA_CHUNK_READ) % self.len_buf)
#i_row_to = int(((counter+1)*params.LEN_DATA_CHUNK_READ) % self.len_buf)
#if i_row_to == 0:
# i_row_to = self.len_buf
#print 'i_row_from, i_row_to:', i_row_from, i_row_to
#self.X_buf[i_row_from: i_row_to] = data_last_chunk
#print 'X_buf[i_row_from: i_row_to]:\n', self.X_buf[i_row_from: i_row_to]
if counter % 2 == 0:
self.plot_live()
counter += 1
# End of while
# Stop the amp
recorder.stop_recording()
示例2: cursor_func
# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import stop_recording [as 別名]
#.........這裏部分代碼省略.........
# Initialize the amplifier
if not is_simulation_mode:
print 'Initializing the amp...'
recorder = Recorder('lslamp', freq_sampling, params.LEN_REC_BUF_SEC, num_signal_channels)
thread_rec = threading.Thread(target=recorder.record)
thread_rec.start()
# Cursor control loop
X_raw_buf_live = np.zeros((int(freq_sampling*params.LEN_REC_BUF_SEC), num_signal_channels))
label_buf_live = np.zeros((int(freq_sampling*params.LEN_REC_BUF_SEC), num_event_types))
counter = 0
#while True:
while counter < (params.LEN_REC_SEC * freq_sampling / params.LEN_DATA_CHUNK_READ):
print 'counter: ', counter
# Clear the canvas
win.delete('all')
if not is_simulation_mode:
# Wait for new data and get it
data_last_chunk = recorder.get_new_data(params.LEN_DATA_CHUNK_READ, params.AMP_WAIT_SEC)
recorder.acknowledge_new_data()
print 'recorder.new_data_counter:', recorder.new_data_counter
else:
time.sleep(1.0 / (freq_sampling/params.LEN_DATA_CHUNK_READ))
data_last_chunk = 1000.0 * np.random.rand(int(params.LEN_DATA_CHUNK_READ), num_signal_channels)
#print 'Random data_last_chunk size:', data_last_chunk
# Insert the new sample into our time series
i_row_lb = int((counter+len_padding)*params.LEN_DATA_CHUNK_READ)
i_row_ub = int((counter+len_padding+1)*params.LEN_DATA_CHUNK_READ)
X_raw_buf_live[i_row_lb:i_row_ub, :] = data_last_chunk
#print 'data_last_chunk:', data_last_chunk
label_buf_live[i_row_lb:i_row_ub, :]\
= cursor_event_list[counter % int(params.LEN_PERIOD_SEC * freq_sampling / params.LEN_DATA_CHUNK_READ)]
# Calculating cursor step
i_row_ub = int((counter+len_padding+1)*params.LEN_DATA_CHUNK_READ)
i_row_lb = i_row_ub - int(window_size_in_samples)
if i_row_lb >= 0:
#print 'i_row_lb, i_row_ub:', i_row_lb, i_row_ub
#print 'X_raw_buf_live[i_row_lb:i_row_ub, :].shape:', X_raw_buf_live[i_row_lb:i_row_ub, :].shape
if is_control_mode:
X_window = utils.preprocess(X_raw_buf_live[i_row_lb:i_row_ub, :], scaler)
X_in = TimeSeriesBatchIterator.create_X_instance(X_window, conv_dim=1)
X_in = X_in.reshape(1, X_in.shape[0], X_in.shape[1])
#print 'X_window.shape:', X_window.shape
#print 'X_in.shape:', X_in.shape
cursor_step = calc_cursor_step(nnet, X_in.astype(np.float32))
else:
#X_window = X_raw_buf_live[i_row_lb:i_row_ub, :]
cursor_step = 0
cursor_pos = cursor_pos_prev + np.array([cursor_step, 0])
#print 'cursor_pos: ', cursor_pos
else:
cursor_pos = cursor_pos_prev
cursor_pos_point = graphics.Point(cursor_pos[0], cursor_pos[1])
cursor_pos_prev = cursor_pos
cursor = graphics.Circle(cursor_pos_point, cursor_radius)
color_temp = cursor_color_arr_final[counter % int(params.LEN_PERIOD_SEC * freq_sampling / params.LEN_DATA_CHUNK_READ)]
cursor.setFill(graphics.color_rgb(color_temp[0], color_temp[1], color_temp[2]))
cursor.setOutline(graphics.color_rgb(color_temp[0], color_temp[1], color_temp[2]))
cursor.draw(win)
counter += 1
# End of if
# End of while
# Stop recording
recorder.stop_recording()
# Close the window
win.close()
# Cut the padding from the data
i_row_lb = int(len_padding * params.LEN_DATA_CHUNK_READ)
i_row_ub = int((counter+len_padding)*params.LEN_DATA_CHUNK_READ)
X_raw_buf_cut = X_raw_buf_live[i_row_lb:i_row_ub, :]
label_buf_cut = label_buf_live[i_row_lb:i_row_ub, :]
# Save data to file
time_axis = np.arange(X_raw_buf_cut.shape[0]).reshape((X_raw_buf_cut.shape[0], 1))
print 'time_axis.shape:', time_axis.shape
data_merged = np.concatenate((time_axis, X_raw_buf_cut, label_buf_cut), axis=1)
print 'data_merged.shape: ', data_merged.shape
time_save = datetime.now()
np.savetxt('../data/MIBBCI_REC_{0}Hz_{1}{2:02}{3:02}_{4:02}h{5:02}m{6:02}s_RAW.csv'.format(
int(freq_sampling),
time_save.year, time_save.month, time_save.day,
time_save.hour, time_save.minute, time_save.second),
X=data_merged, fmt='%.8f', delimiter=",",
header='time, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, red, blue, idle',
comments='')
print 'cursor_func(.) terminates.'