def connection(self): """ This function use MulesClient class to connect to the Mules server. Mules server will provides the eeg signal recorded from epoc sensors. The function also start a connection with an Unity server application. """ ## 1) Connection with Mules and retrieve EEG data parameters # Creates mules_client object if hasattr(self, 'mules_client'): print('Connection already established') else: self.mules_client = mules.MulesClient( 'localhost', 30000) # connects with MuLES at 127.0.0.1 : 30000 # Retrieve recording information self.device_name = self.mules_client.getdevicename() # get device name self.channel_names = self.mules_client.getnames() # get channel names self.fs = 1.0 * self.mules_client.getfs() # get sampling frequency print('fs= ', self.fs) self.nb_chl = len(self.channel_names) # Number of channel self.data = np.zeros( (int(self.bufsize * self.fs), self.nb_chl)) # init buffer # TCP Client for Unity self.unity = TcpClient('localhost', 40000) self.unity.connect()
""" import mules import numpy as np import bci_workshop_tools as BCIw import matplotlib.pyplot as plt if __name__ == "__main__": # MuLES connection paramters mules_ip = '127.0.0.1' mules_port = 30000 # Creates a mules_client mules_client = mules.MulesClient(mules_ip, mules_port) # Device parameters params = mules_client.getparams() #%% Set the experiment parameters training_secs = 20 win_test_secs = 1 # Length of the Test Window in seconds overlap_secs = 0.7 # Overlap between two consecutive Test Windows shift_secs = win_test_secs - overlap_secs eeg_buffer_secs = 30 # Size of the EEG data buffer (duration of Testing section) #%% Record training data # Record data for mental activity 0 BCIw.beep()
Uses the Sound-playing interface for Windows to play a beep Arguments f: Frequency of the beep in Hz d: Duration of the beep in ms """ winsound.Beep(f,d) if __name__ == "__main__": plt.close('all') # 1. Acquisition is started # creates mules_client object and: mules_client = mules.MulesClient('127.0.0.1', 30000) # connects with MuLES at 127.0.0.1 : 30000 device_name = mules_client.getdevicename() # get device name channel_names = mules_client.getnames() # get channel names fs = 1.0 * mules_client.getfs() # get sampling frequency # 2. Defining EEG data buffer for 10 seconds n_samples = 10 * fs; eeg_data_buffer = np.zeros((n_samples, len(channel_names)), float) time_vector = np.arange(0 , n_samples) / fs # 3. Flush old data from the Server mules_client.flushdata() beep(600,250) # Create Figure channel = 4