def test_default_values(self): print("Testing init_eeg_acquisition with default values.") client, server = init_eeg_acquisition( self.parameters, self.save, server=True) client.start_acquisition() time.sleep(0.1) client.stop_acquisition() client.cleanup() server.stop() server.join() self.assertTrue('raw_data.csv' in client._processor._filename) self.assertEqual(client.device_info.name, 'DSI') self.assertEqual(client.device_info.fs, 300)
def test_can_use_lsl(self): print("Testing init_eeg_acquisition with LSL device") params = self.parameters params['acq_device'] = 'LSL' client, server = init_eeg_acquisition(params, self.save, server=True) with client: time.sleep(0.1) client.cleanup() server.stop() server.join() self.assertEqual(client.device_info.name, 'LSL') self.assertEqual(client.device_info.fs, 256)
def test_allows_customization(self): print("Testing init_eeg_acquisition with custom values.") f = 'foo.csv' params = self.parameters params['raw_data_name'] = f params['acq_port'] = 9000 client, server = init_eeg_acquisition(params, self.save, server=True) with client: time.sleep(0.1) client.cleanup() server.stop() server.join() self.assertTrue(f in client._processor._filename) self.assertEqual(client.device_info.name, 'DSI') self.assertEqual(client.device_info.fs, 300)
def execute_task(task_type: dict, parameters: dict, save_folder: str) -> bool: """Excecute Task. Executes the desired task by setting up the display window and data acquisition, then passing on to the start_task funtion which will initialize experiment. Input: parameters (dict): parameter dictionary task_type (dict): type and mode of experiment save_folder (str): path to save folder """ exp_type = ExperimentType(task_type['exp_type']) fake = parameters['fake_data'] signal_model = None language_model = None filename = None # Init EEG Model, if needed. Calibration Tasks Don't require probabilistic # modules to be loaded. if not fake and exp_type not in ExperimentType.calibration_tasks(): # Try loading in our signal_model and starting a langmodel(if enabled) try: signal_model, filename = load_signal_model() except Exception as e: logging.debug('Cannot load signal model. Exiting') raise e # if Language Model enabled init lm if parameters['languagemodelenabled']: language_model = init_language_model(parameters) # Initialize Display Window # We have to wait until after the prompt to load the signal model before # displaying the window, otherwise in fullscreen mode this throws an error display = init_display_window(parameters) print_message(display, "Initializing...") # Initialize DAQ daq, server = init_eeg_acquisition(parameters, save_folder, server=fake) # Start Task try: start_task(display, daq, exp_type, parameters, save_folder, language_model=language_model, signal_model=signal_model, fake=fake, auc_filename=filename) # If exception, close all display and acquisition objects except Exception as e: _clean_up_session(display, daq, server) raise e return _clean_up_session(display, daq, server)
def execute_task(task_type: dict, parameters: dict, save_folder: str) -> bool: """Excecute Task. Executes the desired task by setting up the display window and data acquistion, then passing on to the start_task funtion which will initialize experiment. Input: parameters (dict): parameter dictionary task_type (dict): type and mode of experiment save_folder (str): path to save folder """ fake = parameters['fake_data'] # Init EEG Model, if needed. Calibration Tasks Don't require probalistic # modules to be loaded. if task_type['exp_type'] > 1: # Try loading in our classifier and starting a langmodel(if enabled) try: # EEG Model, Load in pre-trained classifier if fake: classifier = None else: classifier = load_classifier() except Exception as e: print("Cannot load EEG classifier. Exiting") raise e # if Language Model enabled and data not fake, init lm if parameters['languagemodelenabled'] == 'true' \ and not fake: try: lmodel = init_language_model(parameters) except: print("Cannot init language model. Setting to None.") lmodel = None else: lmodel = None else: classifier = None lmodel = None # Initialize DAQ daq, server = init_eeg_acquisition(parameters, save_folder, server=fake) # Initialize Display Window display = init_display_window(parameters) # Start Task try: start_task(display, daq, task_type, parameters, save_folder, lmodel=lmodel, classifier=classifier, fake=fake) # If exception, close all display and acquisition objects except Exception as e: _clean_up_session(display, daq, server) raise e return _clean_up_session(display, daq, server)