# Just some chunks of code to help with development. import sys, os import time dbsgui_path = os.path.abspath(os.path.join('..', 'NeuroportDBS', 'DBSGUI')) sys.path.append(dbsgui_path) from cerebuswrapper import CbSdkConnection SAMPLINGGROUPS = ["0", "500", "1000", "2000", "10000", "30000", "RAW"] cbsdk_conn = CbSdkConnection(simulate_ok=False) cbsdk_conn.connect() cbsdk_conn.cbsdk_config = { 'reset': True, 'get_events': False, 'get_comments': False, 'get_continuous': False, 'buffer_parameter': { 'comment_length': 0 } } group_info = cbsdk_conn.get_group_config(SAMPLINGGROUPS.index("30000")) sys_config = cbsdk_conn.get_sys_config() # temp_ev = cbsdk_conn.get_event_data() # temp_cont = cbsdk_conn.get_continuous_data() chid = group_info[0]['chan'] temp_wfs, unit_ids = cbsdk_conn.get_waveforms(chid) # import matplotlib.pyplot as plt # plt.ion()
def update(self): # Added new_value handling for playback if we ever want to post-process depth # on previously recorded sessions. new_value = False out_value = None if self.comboBox_com_port.currentText() == "cbsdk playback": cbsdk_conn = CbSdkConnection() if cbsdk_conn.is_connected: comments = cbsdk_conn.get_comments() if comments: comment_strings = [x[1].decode('utf8') for x in comments] else: comment_strings = "" dtts = [] for comm_str in comment_strings: if 'DTT:' in comm_str: dtts.append(float(comm_str[4:])) if len(dtts) > 0: out_value = dtts[-1] new_value = True self.offset_ddu.display("{0:.3f}".format(out_value)) offset = self.doubleSpinBox_offset.value() self.raw_ddu.display("{0:.3f}".format(out_value - offset)) elif self.ser.is_open: in_str = self.ser.readline().decode('utf-8').strip() if in_str: try: in_value = float(in_str) # in_value /= DDUSCALEFACTOR # Uncomment this for FHC DDU V2. self.raw_ddu.display("{0:.3f}".format(in_value)) out_value = in_value + self.doubleSpinBox_offset.value() display_string = "{0:.3f}".format(out_value) self.offset_ddu.display(display_string) # Check if new value if display_string != self.display_string: new_value = True self.display_string = display_string # Push to NSP cbsdk_conn = CbSdkConnection() if cbsdk_conn.is_connected: if self.chk_NSP.isChecked() and self.chk_NSP.isEnabled( ) and new_value: cbsdk_conn.set_comments("DTT:" + display_string) else: # try connecting if not connected but button is active if self.chk_NSP.isChecked() and self.chk_NSP.isEnabled( ): cbsdk_conn.connect() cbsdk_conn.cbsdk_config = { 'reset': True, 'get_events': False, 'get_comments': False } # set button to connection status self.chk_NSP.setChecked(cbsdk_conn.is_connected) except ValueError: print("DDU result: {}".format(in_str)) # Push to LSL if self.depth_stream is not None and new_value: self.depth_stream.push_sample([out_value])