当前位置: 首页>>代码示例>>Python>>正文


Python ABCAdapter.fill_defaults方法代码示例

本文整理汇总了Python中tvb.core.adapters.abcadapter.ABCAdapter.fill_defaults方法的典型用法代码示例。如果您正苦于以下问题:Python ABCAdapter.fill_defaults方法的具体用法?Python ABCAdapter.fill_defaults怎么用?Python ABCAdapter.fill_defaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tvb.core.adapters.abcadapter.ABCAdapter的用法示例。


在下文中一共展示了ABCAdapter.fill_defaults方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_default_values

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
    def update_default_values(portlet_interface, portlet_configuration):
        """
        :param portlet_interface: a list of AdapterConfiguration entities.
        :param portlet_configuration: a PortletConfiguration entity.
        
        Update the defaults from each AdapterConfiguration entity with the 
        values stored in the corresponding workflow step held in the 
        PortletConfiguration entity.
        """
        # Check for any defaults first in analyzer steps
        if portlet_configuration.analyzers:
            for adapter_idx in xrange(len(portlet_interface[:-1])):
                saved_configuration = portlet_configuration.analyzers[adapter_idx]
                replaced_defaults_dict = ABCAdapter.fill_defaults(
                    portlet_interface[adapter_idx].interface, saved_configuration.static_param
                )
                portlet_interface[adapter_idx].interface = replaced_defaults_dict

        # Check for visualization defaults
        if portlet_configuration.visualizer:
            saved_configuration = portlet_configuration.visualizer
            replaced_defaults_dict = ABCAdapter.fill_defaults(
                portlet_interface[-1].interface, saved_configuration.static_param
            )
            portlet_interface[-1].interface = replaced_defaults_dict
开发者ID:arybinski,项目名称:tvb-framework,代码行数:27,代码来源:portlet_configurer.py

示例2: get_template_for_adapter

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
    def get_template_for_adapter(self, project_id, step_key, algo_group, submit_url, session_reset=True, is_burst=True):
        """ Get Input HTML Interface template or a given adapter """
        try:
            if session_reset:
                self.context.clean_from_session()

            group = None
            # Cache some values in session, for performance
            previous_tree = self.context.get_current_input_tree()
            previous_sub_step = self.context.get_current_substep()
            if not session_reset and previous_tree is not None and previous_sub_step == algo_group.id:
                adapter_interface = previous_tree
            else:
                group, adapter_interface = self.flow_service.prepare_adapter(project_id, algo_group)
                self.context.add_adapter_to_session(algo_group, adapter_interface)

            category = self.flow_service.get_category_by_id(step_key)
            title = "Fill parameters for step " + category.displayname.lower()
            if group:
                title = title + " - " + group.displayname

            current_defaults = self.context.get_current_default()
            if current_defaults is not None:
                #Change default values in tree, according to selected input
                adapter_interface = ABCAdapter.fill_defaults(adapter_interface, current_defaults)

            template_specification = dict(submitLink=submit_url, inputList=adapter_interface, title=title)
            self._populate_section(algo_group, template_specification, is_burst)
            return template_specification
        except OperationException, oexc:
            self.logger.error("Inconsistent Adapter")
            self.logger.exception(oexc)
            common.set_warning_message('Inconsistent Adapter!  Please review the link (development problem)!')
开发者ID:rajul,项目名称:tvb-framework,代码行数:35,代码来源:flow_controller.py

示例3: load_region_stimulus

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
    def load_region_stimulus(self, region_stimulus_gid, from_step=None):
        """
        Loads the interface for the selected region stimulus.
        """
        selected_region_stimulus = ABCAdapter.load_entity_by_gid(region_stimulus_gid)
        temporal_eq = selected_region_stimulus.temporal
        spatial_eq = selected_region_stimulus.spatial
        connectivity = selected_region_stimulus.connectivity
        weights = selected_region_stimulus.weight

        temporal_eq_type = temporal_eq.__class__.__name__
        spatial_eq_type = spatial_eq.__class__.__name__
        default_dict = {'temporal': temporal_eq_type, 'spatial': spatial_eq_type,
                        'connectivity': connectivity.gid, 'weight': json.dumps(weights)}
        for param in temporal_eq.parameters:
            prepared_name = 'temporal_parameters_option_' + str(temporal_eq_type)
            prepared_name = prepared_name + '_parameters_parameters_' + str(param)
            default_dict[prepared_name] = str(temporal_eq.parameters[param])
        for param in spatial_eq.parameters:
            prepared_name = 'spatial_parameters_option_' + str(spatial_eq_type) + '_parameters_parameters_' + str(param)
            default_dict[prepared_name] = str(spatial_eq.parameters[param])

        input_list = self.get_creator_and_interface(REGION_STIMULUS_CREATOR_MODULE,
                                                    REGION_STIMULUS_CREATOR_CLASS, StimuliRegion())[1]
        input_list = ABCAdapter.fill_defaults(input_list, default_dict)
        context = common.get_from_session(KEY_REGION_CONTEXT)
        context.reset()
        context.update_from_interface(input_list)
        context.equation_kwargs[DataTypeMetaData.KEY_TAG_1] = selected_region_stimulus.user_tag_1
        context.set_active_stimulus(region_stimulus_gid)

        return self.do_step(from_step)
开发者ID:unimauro,项目名称:tvb-framework,代码行数:34,代码来源:region_stimulus_controller.py

示例4: _get_stimulus_interface

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
 def _get_stimulus_interface(self):
     """
     Returns a dictionary which contains the interface for a surface stimulus.
     """
     context = base.get_from_session(KEY_SURFACE_CONTEXT)
     input_list = self.get_creator_and_interface(SURFACE_STIMULUS_CREATOR_MODULE,
                                                 SURFACE_STIMULUS_CREATOR_CLASS, StimuliSurface(),
                                                 lock_midpoint_for_eq=[1])[1]
     input_list = ABCAdapter.fill_defaults(input_list, context.equation_kwargs)
     input_list, focal_points_list = self._remove_focal_points(input_list)
     input_list = self.prepare_entity_interface(input_list)
     input_list['selectedFocalPoints'] = focal_points_list
     return self._add_extra_fields_to_interface(input_list)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:15,代码来源:surface_stimulus_controller.py

示例5: _get_stimulus_interface

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
 def _get_stimulus_interface(self, default_connectivity_gid=None):
     """
     Returns a dictionary which contains the data needed
     for creating the interface for a stimulus.
     """
     context = common.get_from_session(KEY_REGION_CONTEXT)
     input_list = self.get_creator_and_interface(REGION_STIMULUS_CREATOR_MODULE,
                                                 REGION_STIMULUS_CREATOR_CLASS, StimuliRegion())[1]
     context.equation_kwargs.update({SCALING_PARAMETER: context.get_weights()})
     input_list = ABCAdapter.fill_defaults(input_list, context.equation_kwargs)
     input_list, any_scaling = self._remove_scaling(input_list)
     template_specification = {'inputList': input_list, common.KEY_PARAMETERS_CONFIG: False}
     return self._add_extra_fields_to_interface(template_specification), any_scaling
开发者ID:unimauro,项目名称:tvb-framework,代码行数:15,代码来源:region_stimulus_controller.py

示例6: index

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
    def index(self):
        """Get on burst main page"""
        # todo : reuse load_burst here for consistency.
        template_specification = dict(mainContent="burst/main_burst", title="Simulation Cockpit",
                                      baseUrl=TvbProfile.current.web.BASE_URL,
                                      includedResources='project/included_resources')
        portlets_list = self.burst_service.get_available_portlets()
        session_stored_burst = common.get_from_session(common.KEY_BURST_CONFIG)
        if session_stored_burst is None or session_stored_burst.id is None:
            if session_stored_burst is None:
                session_stored_burst = self.burst_service.new_burst_configuration(common.get_current_project().id)
                common.add2session(common.KEY_BURST_CONFIG, session_stored_burst)

            adapter_interface = self.cached_simulator_input_tree
            if session_stored_burst is not None:
                current_data = session_stored_burst.get_all_simulator_values()[0]
                adapter_interface = ABCAdapter.fill_defaults(adapter_interface, current_data, True)
                ### Add simulator tree to session to be available in filters
                self.context.add_adapter_to_session(self.cached_simulator_algo_group, adapter_interface, current_data)
            template_specification['inputList'] = adapter_interface

        selected_portlets = session_stored_burst.update_selected_portlets()
        template_specification['burst_list'] = self.burst_service.get_available_bursts(common.get_current_project().id)
        template_specification['portletList'] = portlets_list
        template_specification['selectedPortlets'] = json.dumps(selected_portlets)
        template_specification['draw_hidden_ranges'] = True
        template_specification['burstConfig'] = session_stored_burst

        ### Prepare PSE available metrics
        ### We put here all available algorithms, because the metrics select area is a generic one, 
        ### and not loaded with every Burst Group change in history.
        algo_group = self.flow_service.get_algorithm_by_module_and_class(MEASURE_METRICS_MODULE,
                                                                         MEASURE_METRICS_CLASS)[1]
        adapter_instance = ABCAdapter.build_adapter(algo_group)
        if adapter_instance is not None and hasattr(adapter_instance, 'available_algorithms'):
            template_specification['available_metrics'] = [metric_name for metric_name
                                                           in adapter_instance.available_algorithms.keys()]
        else:
            template_specification['available_metrics'] = []

        template_specification[common.KEY_PARAMETERS_CONFIG] = False
        template_specification[common.KEY_SECTION] = 'burst'
        return self.fill_default_attributes(template_specification)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:45,代码来源:burst_controller.py

示例7: configure_simulator_parameters

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
    def configure_simulator_parameters(self):
        """
        Return the required input tree to generate the simulator interface for
        the burst page in 'configuration mode', meaning with checkboxes next to
        each input that are checked or not depending on if the user selected 
        them so, and with the user filled defaults.
        """
        burst_config = base.get_from_session(base.KEY_BURST_CONFIG)
        default_values, any_checked = burst_config.get_all_simulator_values()
        simulator_input_tree = self.cached_simulator_input_tree
        simulator_input_tree = ABCAdapter.fill_defaults(simulator_input_tree, default_values)
        ### Add simulator tree to session to be available in filters
        self.context.add_adapter_to_session(self.cached_simulator_algo_group, simulator_input_tree, default_values)

        template_specification = {"inputList": simulator_input_tree,
                                  base.KEY_PARAMETERS_CONFIG: True,
                                  'none_checked': not any_checked,
                                  'selectedParametersDictionary': burst_config.simulator_configuration}
        ## Setting this to true means check-boxes are displayed next to all inputs ##
        return self.fill_default_attributes(template_specification)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:22,代码来源:burst_controller.py

示例8: get_template_from_context

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
    def get_template_from_context(self):
        """
        Return the parameters for the local connectivity in case one is stored in context. Load the entity
        and use it to populate the defaults from the interface accordingly.
        """
        context = common.get_from_session(KEY_LCONN_CONTEXT)
        selected_local_conn = ABCAdapter.load_entity_by_gid(context.selected_entity)
        cutoff = selected_local_conn.cutoff
        equation = selected_local_conn.equation
        surface = selected_local_conn.surface

        default_dict = {"surface": surface.gid, "cutoff": cutoff}
        if equation is not None:
            equation_type = equation.__class__.__name__
            default_dict["equation"] = equation_type
            for param in equation.parameters:
                prepared_name = "equation_parameters_option_" + str(equation_type)
                prepared_name = prepared_name + "_parameters_parameters_" + str(param)
                default_dict[prepared_name] = equation.parameters[param]
        else:
            msg = "There is no equation specified for this local connectivity. "
            msg += "The default equation is displayed into the spatial field."
            self.logger.warning(msg)
            common.set_info_message(msg)

        default_dict[DataTypeMetaData.KEY_TAG_1] = selected_local_conn.user_tag_1

        input_list = self.get_creator_and_interface(
            LOCAL_CONN_CREATOR_MODULE, LOCAL_CONN_CREATOR_CLASS, LocalConnectivity(), lock_midpoint_for_eq=[1]
        )[1]
        input_list = self._add_extra_fields_to_interface(input_list)
        input_list = ABCAdapter.fill_defaults(input_list, default_dict)

        template_specification = {
            "inputList": input_list,
            common.KEY_PARAMETERS_CONFIG: False,
            "equationViewerUrl": "/spatial/localconnectivity/get_equation_chart",
            "equationsPrefixes": json.dumps(self.plotted_equations_prefixes),
        }
        return template_specification
开发者ID:lcosters,项目名称:tvb-framework,代码行数:42,代码来源:local_connectivity_controller.py

示例9: get_reduced_simulator_interface

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
    def get_reduced_simulator_interface(self):
        """
        Get a simulator interface that only contains the inputs that are marked
        as KEY_PARAMETER_CHECKED in the current session.
        """
        burst_config = common.get_from_session(common.KEY_BURST_CONFIG)
        simulator_config = burst_config.simulator_configuration
        ## Fill with stored defaults, and see if any parameter was checked by user ##
        default_values, any_checked = burst_config.get_all_simulator_values()
        simulator_input_tree = self.cached_simulator_input_tree
        simulator_input_tree = ABCAdapter.fill_defaults(simulator_input_tree, default_values)
        ## In case no values were checked just skip tree-cut part and show entire simulator tree ##
        if any_checked:
            simulator_input_tree = self.burst_service.select_simulator_inputs(simulator_input_tree, simulator_config)

        ### Add simulator tree to session to be available in filters
        self.context.add_adapter_to_session(self.cached_simulator_algo_group, simulator_input_tree, default_values)

        template_specification = {"inputList": simulator_input_tree,
                                  common.KEY_PARAMETERS_CONFIG: False,
                                  'draw_hidden_ranges': True}
        return self.fill_default_attributes(template_specification)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:24,代码来源:burst_controller.py

示例10: load_surface_stimulus

# 需要导入模块: from tvb.core.adapters.abcadapter import ABCAdapter [as 别名]
# 或者: from tvb.core.adapters.abcadapter.ABCAdapter import fill_defaults [as 别名]
    def load_surface_stimulus(self, surface_stimulus_gid, from_step):
        """
        Loads the interface for the selected surface stimulus.
        """
        context = base.get_from_session(KEY_SURFACE_CONTEXT)
        selected_surface_stimulus = ABCAdapter.load_entity_by_gid(surface_stimulus_gid)
        temporal_eq = selected_surface_stimulus.temporal
        spatial_eq = selected_surface_stimulus.spatial
        surface = selected_surface_stimulus.surface
        focal_points_surface = selected_surface_stimulus.focal_points_surface
        focal_points_triangles = selected_surface_stimulus.focal_points_triangles

        temporal_eq_type = temporal_eq.__class__.__name__
        spatial_eq_type = spatial_eq.__class__.__name__
        default_dict = {'temporal': temporal_eq_type, 'spatial': spatial_eq_type,
                        'surface': surface.gid, 'focal_points_surface': json.dumps(focal_points_surface),
                        'focal_points_triangles': json.dumps(focal_points_triangles)}
        for param in temporal_eq.parameters:
            prepared_name = 'temporal_parameters_option_' + str(temporal_eq_type)
            prepared_name = prepared_name + '_parameters_parameters_' + str(param)
            default_dict[prepared_name] = str(temporal_eq.parameters[param])
        for param in spatial_eq.parameters:
            prepared_name = 'spatial_parameters_option_' + str(spatial_eq_type) + '_parameters_parameters_' + str(param)
            default_dict[prepared_name] = str(spatial_eq.parameters[param])

        default_dict[DataTypeMetaData.KEY_TAG_1] = selected_surface_stimulus.user_tag_1

        input_list = self.get_creator_and_interface(SURFACE_STIMULUS_CREATOR_MODULE,
                                                    SURFACE_STIMULUS_CREATOR_CLASS, StimuliSurface(),
                                                    lock_midpoint_for_eq=[1])[1]
        input_list = ABCAdapter.fill_defaults(input_list, default_dict)
        context.reset()
        context.update_from_interface(input_list)
        context.equation_kwargs[DataTypeMetaData.KEY_TAG_1] = selected_surface_stimulus.user_tag_1
        context.set_active_stimulus(surface_stimulus_gid)
        return self.do_step(from_step)
开发者ID:HuifangWang,项目名称:the-virtual-brain-website,代码行数:38,代码来源:surface_stimulus_controller.py


注:本文中的tvb.core.adapters.abcadapter.ABCAdapter.fill_defaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。