def test_launch(self): """ Check that all required keys are present in output from BrainViewer launch. """ zip_path = os.path.join(os.path.dirname(sensors_dataset.__file__), 'eeg_unitvector_62.txt.bz2') TestFactory.import_sensors(self.test_user, self.test_project, zip_path, 'EEG Sensors') sensors = TestFactory.get_entity(self.test_project, SensorsEEG()) time_series = self.datatypeFactory.create_timeseries(self.connectivity, 'EEG', sensors) viewer = EegMonitor() result = viewer.launch(time_series) expected_keys = ['tsNames', 'groupedLabels', 'tsModes', 'tsStateVars', 'longestChannelLength', 'label_x', 'entities', 'page_size', 'number_of_visible_points', 'extended_view', 'initialSelection', 'ag_settings', 'ag_settings'] for key in expected_keys: self.assertTrue(key in result, "key not found %s" % key) expected_ag_settings = ['channelsPerSet', 'channelLabels', 'noOfChannels', 'translationStep', 'normalizedSteps', 'nan_value_found', 'baseURLS', 'pageSize', 'nrOfPages', 'timeSetPaths', 'totalLength', 'number_of_visible_points', 'extended_view', 'measurePointsSelectionGIDs'] ag_settings = json.loads(result['ag_settings']) for key in expected_ag_settings: self.assertTrue(key in ag_settings, "ag_settings should have the key %s" % key)
def setUp(self): """ Reset the database before each test. """ self.test_user = TestFactory.create_user("UserPM") self.test_project = TestFactory.create_project(self.test_user) zip_path = os.path.join(os.path.dirname(tvb_data.sensors.__file__), 'eeg_brainstorm_65.txt') TestFactory.import_sensors(self.test_user, self.test_project, zip_path, Sensors_Importer.EEG_SENSORS) zip_path = os.path.join(os.path.dirname(tvb_data.surfaceData.__file__), 'cortex_16384.zip') TestFactory.import_surface_zip(self.test_user, self.test_project, zip_path, CORTICAL, True) self.surface = TestFactory.get_entity(self.test_project, CorticalSurface()) self.assertTrue(self.surface is not None) self.sensors = TestFactory.get_entity(self.test_project, SensorsEEG()) self.assertTrue(self.sensors is not None) self.importer = TestFactory.create_adapter( 'tvb.adapters.uploaders.projection_matrix_importer', 'ProjectionMatrixSurfaceEEGImporter')
def test_launch_EEG(self): """ Check that all required keys are present in output from EegSensorViewer launch. """ ## Import Sensors zip_path = os.path.join(os.path.dirname(sensors_dataset.__file__), 'EEG_unit_vectors_BrainProducts_62.txt.bz2') TestFactory.import_sensors(self.test_user, self.test_project, zip_path, Sensors_Importer.EEG_SENSORS) sensors = TestFactory.get_entity(self.test_project, SensorsEEG()) ## Import EEGCap zip_path = os.path.join(os.path.dirname(surfaces_dataset.__file__), 'eeg_skin_surface.zip') TestFactory.import_surface_zip(self.test_user, self.test_project, zip_path, EEG_CAP, True) eeg_cap_surface = TestFactory.get_entity(self.test_project, EEGCap()) viewer = EegSensorViewer() viewer.current_project_id = self.test_project.id ## Launch with EEG Cap selected result = viewer.launch(sensors, eeg_cap_surface) self.assert_compliant_dictionary(self.EXPECTED_KEYS_EEG, result) for key in ['urlVertices', 'urlTriangles', 'urlLines', 'urlNormals']: self.assertIsNotNone(result[key], "Value at key %s should not be None" % key) ## Launch without EEG Cap result = viewer.launch(sensors) self.assert_compliant_dictionary(self.EXPECTED_KEYS_EEG, result) for key in ['urlVertices', 'urlTriangles', 'urlLines', 'urlNormals']: self.assertTrue(not result[key] or result[key] == "[]", "Value at key %s should be None or empty, but is %s" % (key, result[key]))
def test_launch_internal(self): """ Check that all required keys are present in output from InternalSensorViewer launch. """ zip_path = os.path.join(os.path.dirname(sensors_dataset.__file__), 'internal_39.txt.bz2') TestFactory.import_sensors(self.test_user, self.test_project, zip_path, Sensors_Importer.INTERNAL_SENSORS) sensors = TestFactory.get_entity(self.test_project, SensorsInternal()) viewer = InternalSensorViewer() viewer.current_project_id = self.test_project.id result = viewer.launch(sensors) self.assert_compliant_dictionary(self.EXPECTED_KEYS_INTERNAL, result)
def test_launch_MEG(self): """ Check that all required keys are present in output from MEGSensorViewer launch. """ zip_path = os.path.join(os.path.dirname(sensors_dataset.__file__), 'meg_channels_reg13.txt.bz2') TestFactory.import_sensors(self.test_user, self.test_project, zip_path, Sensors_Importer.MEG_SENSORS) sensors = TestFactory.get_entity(self.test_project, SensorsMEG()) viewer = MEGSensorViewer() viewer.current_project_id = self.test_project.id result = viewer.launch(sensors) self.assert_compliant_dictionary(self.EXPECTED_KEYS_MEG, result)
def test_launch_internal(self): """ Check that all required keys are present in output from InternalSensorViewer launch. """ zip_path = os.path.join(os.path.dirname(tvb_data.sensors.__file__), 'internal_39.txt.bz2') TestFactory.import_sensors(self.test_user, self.test_project, zip_path, Sensors_Importer.INTERNAL_SENSORS) sensors = TestFactory.get_entity(self.test_project, SensorsInternal()) viewer = SensorsViewer() viewer.current_project_id = self.test_project.id result = viewer.launch(sensors) self.assert_compliant_dictionary(self.EXPECTED_KEYS_INTERNAL, result)
def test_launch_MEG(self): """ Check that all required keys are present in output from MEGSensorViewer launch. """ zip_path = os.path.join(os.path.dirname(tvb_data.sensors.__file__), 'meg_channels_reg13.txt.bz2') TestFactory.import_sensors(self.test_user, self.test_project, zip_path, Sensors_Importer.MEG_SENSORS) sensors = TestFactory.get_entity(self.test_project, SensorsMEG()) viewer = SensorsViewer() viewer.current_project_id = self.test_project.id result = viewer.launch(sensors) self.assert_compliant_dictionary(self.EXPECTED_KEYS_MEG, result)
def setUp(self): """ Reset the database before each test. """ self.test_user = TestFactory.create_user("UserPM") self.test_project = TestFactory.create_project(self.test_user) zip_path = os.path.join(os.path.dirname(tvb_data.sensors.__file__), "eeg_brainstorm_65.txt") TestFactory.import_sensors(self.test_user, self.test_project, zip_path, Sensors_Importer.EEG_SENSORS) zip_path = os.path.join(os.path.dirname(tvb_data.surfaceData.__file__), "cortex_16384.zip") TestFactory.import_surface_zip(self.test_user, self.test_project, zip_path, CORTICAL, True) self.surface = TestFactory.get_entity(self.test_project, CorticalSurface()) self.assertTrue(self.surface is not None) self.sensors = TestFactory.get_entity(self.test_project, SensorsEEG()) self.assertTrue(self.sensors is not None)
def test_launch(self): """ Check that all required keys are present in output from BrainViewer launch. """ zip_path = os.path.join(os.path.dirname(sensors_dataset.__file__), 'EEG_unit_vectors_BrainProducts_62.txt.bz2') TestFactory.import_sensors(self.test_user, self.test_project, zip_path, 'EEG Sensors') sensors = TestFactory.get_entity(self.test_project, SensorsEEG()) time_series = self.datatypeFactory.create_timeseries( self.connectivity, 'EEG', sensors) viewer = EegMonitor() result = viewer.launch(time_series) expected_keys = [ 'tsNames', 'groupedLabels', 'tsModes', 'tsStateVars', 'longestChannelLength', 'label_x', 'entities', 'page_size', 'number_of_visible_points', 'extended_view', 'initialSelection', 'ag_settings', 'ag_settings' ] for key in expected_keys: self.assertTrue(key in result, "key not found %s" % key) expected_ag_settings = [ 'channelsPerSet', 'channelLabels', 'noOfChannels', 'translationStep', 'normalizedSteps', 'nan_value_found', 'baseURLS', 'pageSize', 'nrOfPages', 'timeSetPaths', 'totalLength', 'number_of_visible_points', 'extended_view', 'measurePointsSelectionGIDs' ] ag_settings = json.loads(result['ag_settings']) for key in expected_ag_settings: self.assertTrue(key in ag_settings, "ag_settings should have the key %s" % key)
def test_launch_EEG(self): """ Check that all required keys are present in output from EegSensorViewer launch. """ ## Import Sensors zip_path = os.path.join(os.path.dirname(tvb_data.sensors.__file__), 'EEG_unit_vectors_BrainProducts_62.txt.bz2') TestFactory.import_sensors(self.test_user, self.test_project, zip_path, Sensors_Importer.EEG_SENSORS) sensors = TestFactory.get_entity(self.test_project, SensorsEEG()) ## Import EEGCap cap_path = os.path.join(os.path.dirname(tvb_data.obj.__file__), 'eeg_cap.obj') TestFactory.import_surface_obj(self.test_user, self.test_project, cap_path, EEG_CAP) eeg_cap_surface = TestFactory.get_entity(self.test_project, EEGCap()) viewer = SensorsViewer() viewer.current_project_id = self.test_project.id ## Launch with EEG Cap selected result = viewer.launch(sensors, eeg_cap_surface) self.assert_compliant_dictionary(self.EXPECTED_KEYS_EEG, result) for key in ['urlVertices', 'urlTriangles', 'urlLines', 'urlNormals']: self.assertIsNotNone(result[key], "Value at key %s should not be None" % key) ## Launch without EEG Cap result = viewer.launch(sensors) self.assert_compliant_dictionary(self.EXPECTED_KEYS_EEG, result) for key in ['urlVertices', 'urlTriangles', 'urlLines', 'urlNormals']: self.assertTrue( not result[key] or result[key] == "[]", "Value at key %s should be None or empty, but is %s" % (key, result[key]))