コード例 #1
0
 def get_connectivity_parameters(input_connectivity, surface_data=None):
     """
     Returns a dictionary which contains all the needed data for drawing a connectivity.
     """
     viewer = ConnectivityViewer()
     global_params, global_pages = viewer.compute_connectivity_global_params(input_connectivity, surface_data)
     global_params.update(global_pages)
     global_params['selectedConnectivityGid'] = input_connectivity.gid
     return global_params
コード例 #2
0
 def test_launch(self):
     """
     Check that all required keys are present in output from BrainViewer launch.
     """
     viewer = ConnectivityViewer()
     result = viewer.launch(self.connectivity)
     expected_keys = ['weightsMin', 'weightsMax', 'urlWeights', 'urlVertices',
                      'urlTriangles', 'urlTracts', 'urlPositions', 'urlNormals',
                      'rightHemisphereJson', 'raysArray', 'rayMin', 'rayMax', 'positions',
                      'leftHemisphereJson', 'connectivity_entity', 'bothHemisphereJson']
     for key in expected_keys:
         self.assertTrue(key in result)
コード例 #3
0
 def test_launch(self):
     """
     Check that all required keys are present in output from BrainViewer launch.
     """
     viewer = ConnectivityViewer()
     view_model = viewer.get_view_model_class()()
     view_model.connectivity = UUID(self.connectivity_index.gid)
     result = viewer.launch(view_model)
     expected_keys = ['weightsMin', 'weightsMax', 'urlWeights', 'urlVertices',
                      'urlTriangles', 'urlTracts', 'urlPositions', 'urlNormals',
                      'rightHemisphereJson', 'raysArray', 'rayMin', 'rayMax', 'positions',
                      'leftHemisphereJson', 'connectivity_entity', 'bothHemisphereJson']
     for key in expected_keys:
         assert key in result
コード例 #4
0
    def index(self):
        current_user_id = common.get_logged_user().id
        # In case the number of dynamics gets big we should add a filter in the ui.
        dynamics = dao.get_dynamics_for_user(current_user_id)

        if not dynamics:
            return self.no_dynamics_page()

        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
        des = SerializationManager(burst_config)

        connectivity = des.get_connectivity()
        params = ConnectivityViewer.get_connectivity_parameters(connectivity)

        params.update({
            'title':
            'Model parameters',
            'mainContent':
            'burst/model_param_region',
            'isSingleMode':
            True,
            'submit_parameters_url':
            '/burst/modelparameters/regions/submit_model_parameters',
            'dynamics':
            dynamics,
            'dynamics_json':
            self._dynamics_json(dynamics),
            'initial_dynamic_ids':
            json.dumps(burst_config.dynamic_ids)
        })

        return self.fill_default_attributes(params, 'regionmodel')
コード例 #5
0
    def index(self):
        current_user_id = common.get_logged_user().id
        # In case the number of dynamics gets big we should add a filter in the ui.
        dynamics = dao.get_dynamics_for_user(current_user_id)

        if not dynamics:
            return self.no_dynamics_page()

        sim_config = common.get_from_session(common.KEY_SIMULATOR_CONFIG)
        connectivity = sim_config.connectivity

        if connectivity is None:
            msg = 'You have to select a connectivity before setting up the region Model. '
            common.set_error_message(msg)
            raise ValueError(msg)

        current_project = common.get_current_project()
        file_handler = FilesHelper()
        conn_idx = dao.get_datatype_by_gid(connectivity.hex)
        conn_path = file_handler.get_project_folder(current_project, str(conn_idx.fk_from_operation))

        params = ConnectivityViewer.get_connectivity_parameters(conn_idx, conn_path)
        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)

        params.update({
            'title': 'Model parameters',
            'mainContent': 'burst/model_param_region',
            'isSingleMode': True,
            'submit_parameters_url': '/burst/modelparameters/regions/submit_model_parameters',
            'dynamics': dynamics,
            'dynamics_json': self._dynamics_json(dynamics),
            'initial_dynamic_ids': burst_config.dynamic_ids
        })

        return self.fill_default_attributes(params, 'regionmodel')
コード例 #6
0
    def index(self):
        des = SerializationManager(self.simulator_context.simulator)
        conn_idx = load.load_entity_by_gid(des.conf.connectivity)
        model = des.conf.model
        integrator = des.conf.integrator

        state_vars = model.state_variables
        noise_values = self.init_noise_config_values(model, integrator,
                                                     conn_idx)
        initial_noise = self.group_noise_array_by_state_var(
            noise_values, state_vars, conn_idx.number_of_regions)

        current_project = common.get_current_project()
        file_handler = FilesHelper()
        conn_path = file_handler.get_project_folder(
            current_project, str(conn_idx.fk_from_operation))

        params = ConnectivityViewer.get_connectivity_parameters(
            conn_idx, conn_path)
        params.update({
            'title': 'Noise configuration',
            'mainContent': 'burst/noise',
            'isSingleMode': True,
            'submit_parameters_url': '/burst/noise/submit',
            'stateVars': state_vars,
            'stateVarsJson': json.dumps(state_vars),
            'noiseInputValues': initial_noise[0],
            'initialNoiseValues': json.dumps(initial_noise)
        })
        return self.fill_default_attributes(params, 'regionmodel')
コード例 #7
0
    def index(self):
        current_user_id = common.get_logged_user().id
        # In case the number of dynamics gets big we should add a filter in the ui.
        dynamics = dao.get_dynamics_for_user(current_user_id)

        if not dynamics:
            return self.no_dynamics_page()

        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
        des = SerializationManager(burst_config)

        connectivity = des.get_connectivity()
        params = ConnectivityViewer.get_connectivity_parameters(connectivity)

        params.update(
            {
                "title": "Model parameters",
                "mainContent": "burst/model_param_region",
                "isSingleMode": True,
                "submit_parameters_url": "/burst/modelparameters/regions/submit_model_parameters",
                "dynamics": dynamics,
                "dynamics_json": self._dynamics_json(dynamics),
                "initial_dynamic_ids": json.dumps(burst_config.dynamic_ids),
            }
        )

        return self.fill_default_attributes(params, "regionmodel")
コード例 #8
0
    def index(self):
        current_user_id = self.simulator_context.logged_user.id
        # In case the number of dynamics gets big we should add a filter in the ui.
        dynamics = dao.get_dynamics_for_user(current_user_id)

        if not dynamics:
            return self.no_dynamics_page()

        sim_config = self.simulator_context.simulator
        connectivity = sim_config.connectivity

        if connectivity is None:
            msg = 'You have to select a connectivity before setting up the region Model. '
            common.set_error_message(msg)
            raise ValueError(msg)

        current_project = common.get_current_project()
        conn_idx = load.load_entity_by_gid(connectivity)
        params = ConnectivityViewer.get_connectivity_parameters(conn_idx, current_project.name,
                                                                str(conn_idx.fk_from_operation))
        burst_config = self.simulator_context.burst_config

        params.update({
            'title': 'Model parameters',
            'mainContent': 'burst/model_param_region',
            'isSingleMode': True,
            'submit_parameters_url': '/burst/modelparameters/regions/submit_model_parameters',
            'dynamics': dynamics,
            'dynamics_json': self._dynamics_json(dynamics),
            'initial_dynamic_ids': burst_config.dynamic_ids
        })

        return self.fill_default_attributes(params, 'regionmodel')
    def index(self):
        current_user_id = common.get_logged_user().id
        # In case the number of dynamics gets big we should add a filter in the ui.
        dynamics = dao.get_dynamics_for_user(current_user_id)

        if not dynamics:
            return self.no_dynamics_page()

        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
        des = SerializationManager(burst_config)

        connectivity = des.get_connectivity()

        if connectivity is None:
            msg = 'You have to select a connectivity before setting up the region Model. '
            common.set_error_message(msg)
            raise ValueError(msg)

        params = ConnectivityViewer.get_connectivity_parameters(connectivity)

        params.update({
            'title': 'Model parameters',
            'mainContent': 'burst/model_param_region',
            'isSingleMode': True,
            'submit_parameters_url': '/burst/modelparameters/regions/submit_model_parameters',
            'dynamics': dynamics,
            'dynamics_json': self._dynamics_json(dynamics),
            'initial_dynamic_ids': json.dumps(burst_config.dynamic_ids)
        })

        return self.fill_default_attributes(params, 'regionmodel')
コード例 #10
0
    def display_connectivity(connectivity_gid):
        """
        Generates the html for displaying the connectivity matrix.
        """
        connectivity = ABCAdapter.load_entity_by_gid(connectivity_gid)
        connectivity_viewer_params = ConnectivityViewer.get_connectivity_parameters(connectivity)

        template_specification = dict()
        template_specification['isSingleMode'] = True
        template_specification.update(connectivity_viewer_params)
        return template_specification
コード例 #11
0
    def display_connectivity(connectivity_gid):
        """
        Generates the html for displaying the connectivity matrix.
        """
        connectivity = ABCAdapter.load_entity_by_gid(connectivity_gid)
        connectivity_viewer_params = ConnectivityViewer.get_connectivity_parameters(
            connectivity)

        template_specification = dict()
        template_specification['isSingleMode'] = True
        template_specification.update(connectivity_viewer_params)
        return template_specification
コード例 #12
0
    def display_connectivity(connectivity_gid):
        """
        Generates the html for displaying the connectivity matrix.
        """
        connectivity = ABCAdapter.load_entity_by_gid(connectivity_gid)
        if connectivity is None:
            raise MissingDataException(RegionStimulusController.MSG_MISSING_CONNECTIVITY + "!!")
        current_project = common.get_current_project()
        conn_path = FilesHelper().get_project_folder(current_project, str(connectivity.fk_from_operation))
        connectivity_viewer_params = ConnectivityViewer.get_connectivity_parameters(connectivity, conn_path)

        template_specification = dict()
        template_specification['isSingleMode'] = True
        template_specification.update(connectivity_viewer_params)
        return template_specification
コード例 #13
0
    def display_connectivity(connectivity_gid):
        """
        Generates the html for displaying the connectivity matrix.
        """
        connectivity = ABCAdapter.load_entity_by_gid(connectivity_gid)

        current_project = common.get_current_project()
        file_handler = FilesHelper()
        conn_path = file_handler.get_project_folder(current_project, str(connectivity.fk_from_operation))

        connectivity_viewer_params = ConnectivityViewer.get_connectivity_parameters(connectivity, conn_path)

        template_specification = dict()
        template_specification['isSingleMode'] = True
        template_specification.update(connectivity_viewer_params)
        return template_specification
コード例 #14
0
    def index(self):
        des = SerializationManager(common.get_from_session(common.KEY_BURST_CONFIG))
        connectivity = des.get_connectivity()
        model, integrator = des.make_model_and_integrator()

        state_vars = model.state_variables
        noise_values = self.init_noise_config_values(model, integrator, connectivity)
        initial_noise = self.group_noise_array_by_state_var(noise_values, state_vars, connectivity.number_of_regions)

        params = ConnectivityViewer.get_connectivity_parameters(connectivity)
        params.update({
            'title': 'Noise configuration',
            'mainContent': 'burst/noise',
            'isSingleMode': True,
            'submit_parameters_url': '/burst/noise/submit',
            'stateVars': state_vars,
            'stateVarsJson' : json.dumps(state_vars),
            'noiseInputValues' : initial_noise[0],
            'initialNoiseValues': json.dumps(initial_noise)
        })
        return self.fill_default_attributes(params, 'regionmodel')
コード例 #15
0
    def index(self):
        des = SerializationManager(
            common.get_from_session(common.KEY_BURST_CONFIG))
        connectivity = des.get_connectivity()
        model, integrator = des.make_model_and_integrator()

        state_vars = model.state_variables
        noise_values = self.init_noise_config_values(model, integrator,
                                                     connectivity)
        initial_noise = self.group_noise_array_by_state_var(
            noise_values, state_vars, connectivity.number_of_regions)

        params = ConnectivityViewer.get_connectivity_parameters(connectivity)
        params.update({
            'title': 'Noise configuration',
            'mainContent': 'burst/noise',
            'isSingleMode': True,
            'submit_parameters_url': '/burst/noise/submit',
            'stateVars': state_vars,
            'stateVarsJson': json.dumps(state_vars),
            'noiseInputValues': initial_noise[0],
            'initialNoiseValues': json.dumps(initial_noise)
        })
        return self.fill_default_attributes(params, 'regionmodel')