class EEGMonitorTest(TransactionalTestCase): """ Unit-tests for BrainViewer. """ def setUp(self): """ Sets up the environment for running the tests; creates a test user, a test project, a connectivity and a surface; imports a CFF data-set """ self.datatypeFactory = DatatypesFactory() self.test_project = self.datatypeFactory.get_project() self.test_user = self.datatypeFactory.get_user() TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project) self.connectivity = TestFactory.get_entity(self.test_project, Connectivity()) self.assertTrue(self.connectivity is not None) self.surface = TestFactory.get_entity(self.test_project, CorticalSurface()) self.assertTrue(self.surface is not None) def tearDown(self): """ Clean-up tests data """ FilesHelper().remove_project_structure(self.test_project.name) 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 = [ 'tsStateVars', 'tsModes', 'translationStep', 'total_length', 'title', 'timeSetPaths', 'number_of_visible_points', 'normalizedSteps', 'noOfChannels', 'labelsForCheckBoxes', 'label_x', 'graphLabels', 'entities', 'channelsPage' ] for key in expected_keys: self.assertTrue(key in result)
class CovarianceViewerTest(TransactionalTestCase): """ Unit-tests for BrainViewer. """ def setUp(self): """ Sets up the environment for running the tests; creates a test user, a test project, a connectivity and a surface; imports a CFF data-set """ self.datatypeFactory = DatatypesFactory() self.test_project = self.datatypeFactory.get_project() self.test_user = self.datatypeFactory.get_user() TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project) self.connectivity = TestFactory.get_entity(self.test_project, Connectivity()) self.assertTrue(self.connectivity is not None) self.surface = TestFactory.get_entity(self.test_project, CorticalSurface()) self.assertTrue(self.surface is not None) def tearDown(self): """ Clean-up tests data """ FilesHelper().remove_project_structure(self.test_project.name) def test_launch(self): """ Check that all required keys are present in output from BrainViewer launch. """ time_series = self.datatypeFactory.create_timeseries(self.connectivity) covariance = self.datatypeFactory.create_covariance(time_series) viewer = CovarianceVisualizer() result = viewer.launch(covariance) expected_keys = [ 'matrix_strides', 'matrix_shape', 'matrix_data', 'mainContent', 'isAdapter' ] for key in expected_keys: self.assertTrue(key in result)
class CrossCoherenceViewerTest(TransactionalTestCase): """ Unit-tests for BrainViewer. """ def setUp(self): self.datatypeFactory = DatatypesFactory() self.test_project = self.datatypeFactory.get_project() self.test_user = self.datatypeFactory.get_user() TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project) self.connectivity = TestFactory.get_entity(self.test_project, Connectivity()) self.assertTrue(self.connectivity is not None) self.surface = TestFactory.get_entity(self.test_project, CorticalSurface()) self.assertTrue(self.surface is not None) def tearDown(self): """ Clean-up tests data """ FilesHelper().remove_project_structure(self.test_project.name) def test_launch(self): """ Check that all required keys are present in output from BrainViewer launch. """ time_series = self.datatypeFactory.create_timeseries(self.connectivity) ccoherence = self.datatypeFactory.create_crosscoherence(time_series) viewer = CrossCoherenceVisualizer() result = viewer.launch(ccoherence) expected_keys = [ 'strides', 'shape', 'mainContent', 'isAdapter', 'frequency', 'coherence' ] for key in expected_keys: self.assertTrue(key in result)
class PSETest(TransactionalTestCase): """ Unit-tests for BrainViewer. """ def setUp(self): self.datatypeFactory = DatatypesFactory() self.test_project = self.datatypeFactory.get_project() self.test_user = self.datatypeFactory.get_user() TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project) self.connectivity = TestFactory.get_entity(self.test_project, Connectivity()) self.assertTrue(self.connectivity is not None) self.surface = TestFactory.get_entity(self.test_project, CorticalSurface()) self.assertTrue(self.surface is not None) def tearDown(self): """ Clean-up tests data """ FilesHelper().remove_project_structure(self.test_project.name) def test_launch(self): """ Check that all required keys are present in output from BrainViewer launch. """ timeseries = self.datatypeFactory.create_timeseries(self.connectivity) viewer = TimeSeries() result = viewer.launch(timeseries) expected_keys = [ 't0', 'shape', 'preview', 'labelsStateVar', 'labelsModes', 'mainContent', 'labels', 'labels_json', 'figsize', 'dt' ] for key in expected_keys: self.assertTrue(key in result)
class BrainViewerTest(TransactionalTestCase): """ Unit-tests for BrainViewer. """ def setUp(self): self.datatypeFactory = DatatypesFactory() self.test_project = self.datatypeFactory.get_project() self.test_user = self.datatypeFactory.get_user() TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project) zip_path = os.path.join(os.path.dirname(surface_dataset.__file__), 'face-surface.zip') TestFactory.import_surface_zip(self.test_user, self.test_project, zip_path, 'Face', 1) zip_path = os.path.join(os.path.dirname(surface_dataset.__file__), 'eeg_skin_surface.zip') TestFactory.import_surface_zip(self.test_user, self.test_project, zip_path, 'EEG Cap', 1) self.connectivity = TestFactory.get_entity(self.test_project, Connectivity()) self.assertTrue(self.connectivity is not None) self.surface = TestFactory.get_entity(self.test_project, CorticalSurface()) self.assertTrue(self.surface is not None) self.face_surface = TestFactory.get_entity(self.test_project, FaceSurface()) self.assertTrue(self.face_surface is not None) self.assertTrue( TestFactory.get_entity(self.test_project, EEGCap()) is not None) def tearDown(self): """ Clean-up tests data """ FilesHelper().remove_project_structure(self.test_project.name) def test_launch(self): """ Check that all required keys are present in output from BrainViewer launch. """ time_series = self.datatypeFactory.create_timeseries(self.connectivity) viewer = BrainViewer() result = viewer.launch(time_series=time_series) expected_keys = [ 'urlVertices', 'urlNormals', 'urlTriangles', 'urlMeasurePointsLabels', 'title', 'time_series', 'shelfObject', 'pageSize', 'labelsStateVar', 'nrOfPages', 'labelsModes', 'minActivityLabels', 'minActivity', 'measure_points', 'maxActivity', 'isOneToOneMapping', 'isAdapter', 'extended_view', 'base_activity_url', 'alphas_indices' ] for key in expected_keys: self.assertTrue(key in result and result[key] is not None) self.assertFalse(result['extended_view']) def test_get_required_memory(self): """ Brainviewer should know required memory so expect positive number and not -1. """ time_series = self.datatypeFactory.create_timeseries(self.connectivity) self.assertTrue( BrainViewer().get_required_memory_size(time_series) > 0) def test_generate_preview(self): """ Check that all required keys are present in preview generate by BrainViewer. """ time_series = self.datatypeFactory.create_timeseries(self.connectivity) viewer = BrainViewer() result = viewer.generate_preview(time_series, (500, 200)) expected_keys = [ 'urlVertices', 'urlNormals', 'urlTriangles', 'pageSize', 'nrOfPages', 'minActivityLabels', 'minActivity', 'maxActivity', 'isOneToOneMapping', 'isAdapter', 'base_activity_url', 'alphas_indices' ] for key in expected_keys: self.assertTrue(key in result and result[key] is not None) def test_launch_eeg(self): 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) time_series.configure() viewer = BrainEEG() result = viewer.launch(time_series) expected_keys = [ 'urlVertices', 'urlNormals', 'urlTriangles', 'urlMeasurePointsLabels', 'title', 'time_series', 'shelfObject', 'pageSize', 'labelsStateVar', 'nrOfPages', 'labelsModes', 'minActivityLabels', 'minActivity', 'measure_points', 'maxActivity', 'isOneToOneMapping', 'isAdapter', 'extended_view', 'base_activity_url', 'alphas_indices' ] for key in expected_keys: self.assertTrue(key in result and result[key] is not None) self.assertTrue(result['extended_view'])