def test_set_stimulus(self): zip_path = path.join(path.dirname(tvb_data.__file__), 'connectivity', 'connectivity_66.zip') connectivity_index = TestFactory.import_zip_connectivity(self.test_user, self.test_project, zip_path) weight_array = numpy.zeros(connectivity_index.number_of_regions) region_stimulus_creator = RegionStimulusCreator() view_model = region_stimulus_creator.get_view_model_class()() view_model.connectivity = UUID(connectivity_index.gid) view_model.weight = weight_array view_model.temporal = TemporalApplicableEquation() view_model.temporal.parameters['a'] = 1.0 view_model.temporal.parameters['b'] = 2.0 FlowService().fire_operation(region_stimulus_creator, self.test_user, self.test_project.id, view_model=view_model) region_stimulus_index = TestFactory.get_entity(self.test_project, StimuliRegionIndex) self.sess_mock['region_stimuli'] = UUID(region_stimulus_index.gid) with patch('cherrypy.session', self.sess_mock, create=True): common.add2session(common.KEY_SIMULATOR_CONFIG, self.session_stored_simulator) self.simulator_controller.set_stimulus(**self.sess_mock._data) assert self.session_stored_simulator.stimulus.hex == region_stimulus_index.gid, \ "Stimuli was not set correctly."
def test_create_stimulus_region(self): weight_array = numpy.zeros(self.connectivity.number_of_regions) region_stimulus_creator = RegionStimulusCreator() view_model = region_stimulus_creator.get_view_model_class()() view_model.connectivity = UUID(self.connectivity.gid) view_model.weight = weight_array view_model.temporal = TemporalApplicableEquation() view_model.temporal.parameters['a'] = 1.0 view_model.temporal.parameters['b'] = 2.0 region_stimulus_index = region_stimulus_creator.launch(view_model) assert region_stimulus_index.temporal_equation == 'TemporalApplicableEquation' assert json.loads(region_stimulus_index.temporal_parameters) == {'a': 1.0, 'b': 2.0} assert region_stimulus_index.connectivity_gid == self.connectivity.gid
def test_create_stimulus_region_with_operation(self): weight_array = numpy.zeros(self.connectivity.number_of_regions) region_stimulus_creator = RegionStimulusCreator() view_model = region_stimulus_creator.get_view_model_class()() view_model.connectivity = UUID(self.connectivity.gid) view_model.weight = weight_array view_model.temporal = TemporalApplicableEquation() view_model.temporal.parameters['a'] = 1.0 view_model.temporal.parameters['b'] = 2.0 FlowService().fire_operation(region_stimulus_creator, self.test_user, self.test_project.id, view_model=view_model) region_stimulus_index = TestFactory.get_entity(self.test_project, StimuliRegionIndex) assert region_stimulus_index.temporal_equation == 'TemporalApplicableEquation' assert json.loads(region_stimulus_index.temporal_parameters) == {'a': 1.0, 'b': 2.0} assert region_stimulus_index.connectivity_gid == self.connectivity.gid
def test_create_stimulus_region_with_operation(self): weight_array = numpy.zeros(self.connectivity.number_of_regions) region_stimulus_creator = RegionStimulusCreator() view_model = region_stimulus_creator.get_view_model_class()() view_model.connectivity = self.connectivity.gid view_model.weight = weight_array view_model.temporal.parameters['T'] = 45.0 view_model.temporal.parameters['amp'] = 2.0 OperationService().fire_operation(region_stimulus_creator, self.test_user, self.test_project.id, view_model=view_model) region_stimulus_index = TestFactory.get_entity(self.test_project, StimuliRegionIndex) assert region_stimulus_index.temporal_equation == 'PulseTrain' assert json.loads(region_stimulus_index.temporal_parameters) == \ {'T': 45.0, 'amp': 2.0, 'onset': PulseTrain.parameters.default()['onset'], 'tau': PulseTrain.parameters.default()['tau']} assert region_stimulus_index.fk_connectivity_gid == self.connectivity.gid
def test_create_stimulus_region(self, operation_factory): weight_array = numpy.zeros(self.connectivity.number_of_regions) region_stimulus_creator = RegionStimulusCreator() view_model = region_stimulus_creator.get_view_model_class()() view_model.connectivity = self.connectivity.gid view_model.weight = weight_array view_model.temporal.parameters['T'] = 45.0 view_model.temporal.parameters['amp'] = 2.0 operation = operation_factory(test_user=self.test_user, test_project=self.test_project) region_stimulus_creator.extract_operation_data(operation) region_stimulus_index = region_stimulus_creator.launch(view_model) assert region_stimulus_index.temporal_equation == 'PulseTrain' assert json.loads(region_stimulus_index.temporal_parameters) == \ {'T': 45.0, 'amp': 2.0, 'onset': PulseTrain.parameters.default()['onset'], 'tau': PulseTrain.parameters.default()['tau']} assert region_stimulus_index.fk_connectivity_gid == self.connectivity.gid
def test_create_stimulus_region(self, operation_factory): weight_array = numpy.zeros(self.connectivity.number_of_regions) region_stimulus_creator = RegionStimulusCreator() view_model = region_stimulus_creator.get_view_model_class()() view_model.connectivity = self.connectivity.gid view_model.weight = weight_array view_model.temporal = TemporalApplicableEquation() view_model.temporal.parameters['a'] = 1.0 view_model.temporal.parameters['b'] = 2.0 operation = operation_factory(test_user=self.test_user, test_project=self.test_project) region_stimulus_creator.extract_operation_data(operation) region_stimulus_index = region_stimulus_creator.launch(view_model) assert region_stimulus_index.temporal_equation == 'TemporalApplicableEquation' assert json.loads(region_stimulus_index.temporal_parameters) == { 'a': 1.0, 'b': 2.0 } assert region_stimulus_index.fk_connectivity_gid == self.connectivity.gid