diff --git a/EStiMo_GUI_0123.py b/EStiMo_GUI_0123_alt.py similarity index 98% rename from EStiMo_GUI_0123.py rename to EStiMo_GUI_0123_alt.py index 43b493b..0fca16e 100644 --- a/EStiMo_GUI_0123.py +++ b/EStiMo_GUI_0123_alt.py @@ -394,7 +394,8 @@ class AppForm(QMainWindow): self.log_file.flush() #flushing is applying changes we made to the file self.Fs = 1000 #5000 self.size_of_up = 2*self.Fs #5000 how much data we get from NeurOne function - + self.plot_par = 0 + self.baseline_reg = 0 #file with settings and assigning variables to them settings_file = pd.read_csv('TMS_protocol.txt',sep=':', header=None) @@ -786,16 +787,16 @@ class AppForm(QMainWindow): self.loaded_full = self.loaded.copy() #keeps it for the next second step2 = time.time()-time_start # ZeroDivisionError means that data is not yet loaded - try: - # [A,B] = ss.butter(2, 0.1/(self.Fs/2), 'highpass') - # self.loaded[:self.num_of_ch,-4*self.Fs:] = ss.filtfilt(A, B, self.loaded[:self.num_of_ch, -4*self.Fs:]) - # self.loaded[:self.num_of_ch,-4*self.Fs:] = self.loaded[:self.num_of_ch,-4*self.Fs:] - np.mean(self.loaded[:self.num_of_ch,-4*self.Fs:],1, keepdims=True) - self.loaded[:self.num_of_ch,-4*self.Fs:] = ss.detrend(self.loaded[:self.num_of_ch,-4*self.Fs:]) - except ZeroDivisionError: # This error means that buffer is still not full - if self.qmbx == None: - self.qmbx = Waiting_window() # Small window with a message to wait - print('Waiting for data (should take up to few seconds)') - return(0) # Stop function here, because in this case rest of update is not needed + # try: + # # [A,B] = ss.butter(2, 0.1/(self.Fs/2), 'highpass') + # # self.loaded[:self.num_of_ch,-4*self.Fs:] = ss.filtfilt(A, B, self.loaded[:self.num_of_ch, -4*self.Fs:]) + # # self.loaded[:self.num_of_ch,-4*self.Fs:] = self.loaded[:self.num_of_ch,-4*self.Fs:] - np.mean(self.loaded[:self.num_of_ch,-4*self.Fs:],1, keepdims=True) + # self.loaded[:self.num_of_ch,-4*self.Fs:] = ss.detrend(self.loaded[:self.num_of_ch,-4*self.Fs:]) + # except ZeroDivisionError: # This error means that buffer is still not full + # if self.qmbx == None: + # self.qmbx = Waiting_window() # Small window with a message to wait + # print('Waiting for data (should take up to few seconds)') + # return(0) # Stop function here, because in this case rest of update is not needed # Getting to this point of the code means there were no exception before # So the waiting window can be destroyed @@ -837,7 +838,9 @@ class AppForm(QMainWindow): # self.loaded[i,min(od+ind-int(int_from*self.Fs),30000-1)], # self.loaded[i,max(od+ind+int(int_to*self.Fs),30000-1)], # od+ind+int(int_to*self.Fs)-(od+ind-int(int_from*self.Fs))) - + if self.plot_par%4==0: + self.baseline_reg = np.mean(self.loaded[:self.num_of_ch,-5*self.Fs:-4*self.Fs], 1) + self.loaded[:self.num_of_ch,-4*self.Fs:] = (self.loaded[:self.num_of_ch,-4*self.Fs:].T - self.baseline_reg).T step6 = time.time()-time_start # Eye regression for visualisation #plt.figure() @@ -947,8 +950,13 @@ class AppForm(QMainWindow): else: plot_data = plot_data/self.plot_dividing_factor + self.num_of_ch - i + if self.plot_par%4!=0: + plot_data_c = plot_data.copy() + plot_data[:self.Fs*(self.plot_par%4)], plot_data[self.Fs*(self.plot_par%4):] = plot_data_c[4000-self.Fs*(self.plot_par%4):], plot_data_c[:4000-self.Fs*(self.plot_par%4)] + plot_data[self.Fs*(self.plot_par%4)-100:self.Fs*(self.plot_par%4)+100] = np.nan # plot_data = plot_data/(3.5*np.max(np.abs(plot_data))) + self.num_of_ch - i self.line[i].set_data(np.arange(0,self.plot_len*self.Fs), plot_data) + self.plot_par+=1 self.axes.set_ylim(0, self.num_of_ch+1) #self.axes.set_ylim(0,np.max(self.data[:,-self.plot_len*self.Fs:])+dif) #set ylim to fit everything on the plot if len(stim)>0: