Alternative plotting unfinished
This commit is contained in:
		
							parent
							
								
									2830c112f3
								
							
						
					
					
						commit
						714cd6dc58
					
				
					 1 changed files with 20 additions and 12 deletions
				
			
		|  | @ -394,7 +394,8 @@ class AppForm(QMainWindow): | ||||||
|         self.log_file.flush() #flushing is applying changes we made to the file |         self.log_file.flush() #flushing is applying changes we made to the file | ||||||
|         self.Fs = 1000 #5000  |         self.Fs = 1000 #5000  | ||||||
|         self.size_of_up = 2*self.Fs #5000 how much data we get from NeurOne function |         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 |         #file with settings and assigning variables to them | ||||||
|         settings_file = pd.read_csv('TMS_protocol.txt',sep=':', header=None) |         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 |         self.loaded_full = self.loaded.copy() #keeps it for the next second | ||||||
|         step2 = time.time()-time_start |         step2 = time.time()-time_start | ||||||
|         # ZeroDivisionError means that data is not yet loaded |         # ZeroDivisionError means that data is not yet loaded | ||||||
|         try: |         # try: | ||||||
|             # [A,B] = ss.butter(2, 0.1/(self.Fs/2), 'highpass') |         #     # [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:] = 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:] = 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:]) |         #     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 |         # except ZeroDivisionError: # This error means that buffer is still not full | ||||||
|             if self.qmbx == None: |         #     if self.qmbx == None: | ||||||
|                 self.qmbx = Waiting_window() # Small window with a message to wait |         #         self.qmbx = Waiting_window() # Small window with a message to wait | ||||||
|             print('Waiting for data (should take up to few seconds)') |         #     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 |         #     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 |         # Getting to this point of the code means there were no exception before | ||||||
|         # So the waiting window can be destroyed |         # 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,min(od+ind-int(int_from*self.Fs),30000-1)],  | ||||||
|                 #         self.loaded[i,max(od+ind+int(int_to*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))) |                 #         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 |         step6 = time.time()-time_start | ||||||
|         # Eye regression for visualisation |         # Eye regression for visualisation | ||||||
|         #plt.figure() |         #plt.figure() | ||||||
|  | @ -947,8 +950,13 @@ class AppForm(QMainWindow): | ||||||
|              |              | ||||||
|             else: |             else: | ||||||
|                 plot_data = plot_data/self.plot_dividing_factor + self.num_of_ch - i |                 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 |             # 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.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, 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 |         #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: |         if len(stim)>0: | ||||||
		Loading…
	
		Reference in a new issue