def step_1(self, do_reset=0, **kwargs):
     """
     Generate the html for the first step of the local connectivity page. 
     :param do_reset: Boolean telling to start from empty page or not
     :param kwargs: not actually used, but parameters are still submitted from UI since we just\
            use the same js function for this. TODO: do this in a smarter way
     """
     if int(do_reset) == 1:
         new_context = ContextLocalConnectivity()
         common.add2session(KEY_LCONN_CONTEXT, new_context)
     context = common.get_from_session(KEY_LCONN_CONTEXT)
     right_side_interface = self._get_lconn_interface()
     left_side_interface = self.get_select_existent_entities('Load Local Connectivity', LocalConnectivity,
                                                             context.selected_entity)
     # add interface to session, needed for filters
     self.add_interface_to_session(left_side_interface, right_side_interface['inputList'])
     template_specification = dict(title="Surface - Local Connectivity")
     template_specification['mainContent'] = 'spatial/local_connectivity_step1_main'
     template_specification.update(right_side_interface)
     template_specification['displayCreateLocalConnectivityBtn'] = True
     template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     template_specification['existentEntitiesInputList'] = left_side_interface
     template_specification['submit_parameters_url'] = '/spatial/localconnectivity/create_local_connectivity'
     template_specification['equationViewerUrl'] = '/spatial/localconnectivity/get_equation_chart'
     template_specification['equationsPrefixes'] = json.dumps(self.plotted_equations_prefixes)
     template_specification['next_step_url'] = '/spatial/localconnectivity/step_2'
     msg, msg_type = common.get_message_from_session()
     template_specification['displayedMessage'] = msg
     return self.fill_default_attributes(template_specification)
 def step_2(self, **kwargs):
     """
     Generate the html for the second step of the local connectivity page.
     :param kwargs: not actually used, but parameters are still submitted from UI since we just\
            use the same js function for this. TODO: do this in a smarter way
     """
     context = common.get_from_session(KEY_LCONN_CONTEXT)
     left_side_interface = self.get_select_existent_entities(
         'Load Local Connectivity:', LocalConnectivity,
         context.selected_entity)
     template_specification = dict(title="Surface - Local Connectivity")
     template_specification[
         'mainContent'] = 'spatial/local_connectivity_step2_main'
     template_specification[
         'existentEntitiesInputList'] = left_side_interface
     template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     template_specification[
         'next_step_url'] = '/spatial/localconnectivity/step_1'
     msg, _ = common.get_message_from_session()
     template_specification['displayedMessage'] = msg
     context = common.get_from_session(KEY_LCONN_CONTEXT)
     if context.selected_entity is not None:
         selected_local_conn = ABCAdapter.load_entity_by_gid(
             context.selected_entity)
         template_specification.update(
             self.display_surface(selected_local_conn.surface.gid))
         template_specification['no_local_connectivity'] = False
         min_value, max_value = selected_local_conn.get_min_max_values()
         template_specification['minValue'] = min_value
         template_specification['maxValue'] = max_value
     else:
         template_specification['no_local_connectivity'] = True
     template_specification[common.KEY_PARAMETERS_CONFIG] = False
     return self.fill_default_attributes(template_specification)
 def step_2(self, **kwargs):
     """
     Generate the html for the second step of the local connectivity page.
     :param kwargs: not actually used, but parameters are still submitted from UI since we just\
            use the same js function for this. TODO: do this in a smarter way
     """
     context = common.get_from_session(KEY_LCONN_CONTEXT)
     left_side_interface = self.get_select_existent_entities('Load Local Connectivity:', LocalConnectivity,
                                                             context.selected_entity)
     template_specification = dict(title="Surface - Local Connectivity")
     template_specification['mainContent'] = 'spatial/local_connectivity_step2_main'
     template_specification['existentEntitiesInputList'] = left_side_interface
     template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     template_specification['next_step_url'] = '/spatial/localconnectivity/step_1'
     msg, _ = common.get_message_from_session()
     template_specification['displayedMessage'] = msg
     context = common.get_from_session(KEY_LCONN_CONTEXT)
     if context.selected_entity is not None:
         selected_local_conn = ABCAdapter.load_entity_by_gid(context.selected_entity)
         template_specification.update(self.display_surface(selected_local_conn.surface.gid))
         template_specification['no_local_connectivity'] = False
         min_value, max_value = selected_local_conn.get_min_max_values()
         template_specification['minValue'] = min_value
         template_specification['maxValue'] = max_value
     else:
         template_specification['no_local_connectivity'] = True
     template_specification[common.KEY_PARAMETERS_CONFIG] = False
     return self.fill_default_attributes(template_specification)
Example #4
0
 def step_2(self, **kwargs):
     """
     Generate the html for the second step of the local connectivity page.
     :param kwargs: not actually used, but parameters are still submitted from UI since we just\
            use the same js function for this.
     """
     current_lconn = common.get_from_session(KEY_LCONN)
     left_side_form = LocalConnectivitySelectorForm(
         project_id=common.get_current_project().id)
     left_side_form.existentEntitiesSelect.data = current_lconn.gid.hex
     template_specification = dict(title="Surface - Local Connectivity")
     template_specification[
         'mainContent'] = 'spatial/local_connectivity_step2_main'
     template_specification[
         'existentEntitiesInputList'] = self.render_adapter_form(
             left_side_form)
     template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     template_specification[
         'next_step_url'] = '/spatial/localconnectivity/step_1'
     msg, _ = common.get_message_from_session()
     template_specification['displayedMessage'] = msg
     if current_lconn is not None:
         selected_local_conn = load_entity_by_gid(current_lconn.gid)
         template_specification.update(
             self.display_surface(selected_local_conn.fk_surface_gid))
         template_specification['no_local_connectivity'] = False
         template_specification[
             'minValue'] = selected_local_conn.matrix_non_zero_min
         template_specification[
             'maxValue'] = selected_local_conn.matrix_non_zero_max
     else:
         template_specification['no_local_connectivity'] = True
     template_specification[common.KEY_PARAMETERS_CONFIG] = False
     return self.fill_default_attributes(template_specification)
Example #5
0
 def step_1(self, do_reset=0, **kwargs):
     """
     Generate the html for the first step of the local connectivity page. 
     :param do_reset: Boolean telling to start from empty page or not
     :param kwargs: not actually used, but parameters are still submitted from UI since we just\
            use the same js function for this. TODO: do this in a smarter way
     """
     if int(do_reset) == 1:
         new_context = ContextLocalConnectivity()
         common.add2session(KEY_LCONN_CONTEXT, new_context)
     context = common.get_from_session(KEY_LCONN_CONTEXT)
     right_side_interface = self._get_lconn_interface()
     left_side_interface = self.get_select_existent_entities('Load Local Connectivity', LocalConnectivity,
                                                             context.selected_entity)
     # add interface to session, needed for filters
     self.add_interface_to_session(left_side_interface, right_side_interface['inputList'])
     template_specification = dict(title="Surface - Local Connectivity")
     template_specification['mainContent'] = 'spatial/local_connectivity_step1_main'
     template_specification.update(right_side_interface)
     template_specification['displayCreateLocalConnectivityBtn'] = True
     template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     template_specification['existentEntitiesInputList'] = left_side_interface
     template_specification['submit_parameters_url'] = '/spatial/localconnectivity/create_local_connectivity'
     template_specification['equationViewerUrl'] = '/spatial/localconnectivity/get_equation_chart'
     template_specification['equationsPrefixes'] = json.dumps(self.plotted_equations_prefixes)
     template_specification['next_step_url'] = '/spatial/localconnectivity/step_2'
     msg, msg_type = common.get_message_from_session()
     template_specification['displayedMessage'] = msg
     return self.fill_default_attributes(template_specification)
 def fill_default_attributes(self, template_specification):
     """
     Add some entries that are used in both steps then fill the default required attributes.
     """
     context = common.get_from_session(KEY_SURFACE_CONTEXT)
     template_specification["entitiySavedName"] = [{
         'name':
         DataTypeMetaData.KEY_TAG_1,
         'label':
         'Display name',
         'type':
         'str',
         "disabled":
         "False",
         "default":
         context.equation_kwargs.get(DataTypeMetaData.KEY_TAG_1, '')
     }]
     template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     msg, msg_type = common.get_message_from_session()
     template_specification['displayedMessage'] = msg
     template_specification['messageType'] = msg_type
     return super(SurfaceStimulusController,
                  self).fill_default_attributes(template_specification,
                                                subsection='surfacestim')
Example #7
0
 def fill_default_attributes(self, template_dictionary):
     """
     Overwrite base controller to add required parameters for adapter templates.
     """
     template_dictionary['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_dictionary['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     msg, msg_type = common.get_message_from_session()
     template_dictionary['displayedMessage'] = msg
     template_dictionary['messageType'] = msg_type
     return SpatioTemporalController.fill_default_attributes(self, template_dictionary, subsection='regionstim')
 def fill_default_attributes(self, template_specification):
     """
     Add some entries that are used in both steps then fill the default required attributes.
     """
     template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     msg, msg_type = common.get_message_from_session()
     template_specification['displayedMessage'] = msg
     template_specification['messageType'] = msg_type
     return super(SurfaceStimulusController, self).fill_default_attributes(template_specification,
                                                                           subsection='surfacestim')
 def fill_default_attributes(self, template_dictionary):
     """
     Overwrite base controller to add required parameters for adapter templates.
     """
     context = common.get_from_session(KEY_REGION_CONTEXT)
     default = context.equation_kwargs.get(DataTypeMetaData.KEY_TAG_1, '')
     template_dictionary["entitiySavedName"] = [{'name': DataTypeMetaData.KEY_TAG_1, "disabled": "False",
                                                 'label': 'Display name', 'type': 'str', "default": default}]
     template_dictionary['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_dictionary['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     msg, msg_type = common.get_message_from_session()
     template_dictionary['displayedMessage'] = msg
     template_dictionary['messageType'] = msg_type
     return SpatioTemporalController.fill_default_attributes(self, template_dictionary, subsection='regionstim')
    def step_1(self, do_reset=0, **kwargs):
        """
        Generate the html for the first step of the local connectivity page.
        :param do_reset: Boolean telling to start from empty page or not
        :param kwargs: not actually used, but parameters are still submitted from UI since we just\
               use the same js function for this. TODO: do this in a smarter way
        """
        project_id = common.get_current_project().id

        if int(do_reset) == 1:
            new_lconn = LocalConnectivityCreatorModel()
            default_surface_index = dao.try_load_last_surface_of_type(project_id, CORTICAL)
            if default_surface_index:
                new_lconn.surface = uuid.UUID(default_surface_index.gid)
            else:
                # TODO: ok to keep a default gid here?
                new_lconn.surface = uuid.uuid4()
            common.add2session(KEY_LCONN, new_lconn)

        current_lconn = common.get_from_session(KEY_LCONN)
        existent_lcon_form = LocalConnectivitySelectorForm(project_id=project_id)
        existent_lcon_form.existentEntitiesSelect.data = current_lconn.gid.hex
        configure_lcon_form = LocalConnectivityCreatorForm(self.possible_equations, project_id=project_id)

        configure_lcon_form.fill_from_trait(current_lconn)
        current_lconn.equation = configure_lcon_form.spatial.value()

        template_specification = dict(title="Surface - Local Connectivity")
        template_specification['mainContent'] = 'spatial/local_connectivity_step1_main'
        template_specification['inputList'] = configure_lcon_form
        template_specification['displayCreateLocalConnectivityBtn'] = True
        template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
        template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
        template_specification['existentEntitiesInputList'] = existent_lcon_form
        template_specification['submit_parameters_url'] = '/spatial/localconnectivity/create_local_connectivity'
        template_specification['equationViewerUrl'] = '/spatial/localconnectivity/get_equation_chart'
        template_specification['localConnBaseUrl'] = '/spatial/localconnectivity'

        self.plotted_equation_prefixes = {self.SURFACE_FIELD: configure_lcon_form.surface.name,
                                          self.EQUATION_FIELD: configure_lcon_form.spatial.name,
                                          self.CUTOFF_FIELD: configure_lcon_form.cutoff.name,
                                          self.DISPLAY_NAME_FIELD: configure_lcon_form.display_name.name,
                                          self.EQUATION_PARAMS_FIELD: configure_lcon_form.spatial_params.name[1:]}

        template_specification['equationsPrefixes'] = json.dumps(self.plotted_equation_prefixes)
        template_specification['next_step_url'] = '/spatial/localconnectivity/step_2'
        msg, msg_type = common.get_message_from_session()
        template_specification['displayedMessage'] = msg
        return self.fill_default_attributes(template_specification)
 def fill_default_attributes(self, template_specification):
     """
     Add some entries that are used in both steps then fill the default required attributes.
     """
     context = common.get_from_session(KEY_SURFACE_CONTEXT)
     template_specification["entitiySavedName"] = [
         {'name': DataTypeMetaData.KEY_TAG_1, 'label': 'Display name', 'type': 'str',
          "disabled": "False", "default": context.equation_kwargs.get(DataTypeMetaData.KEY_TAG_1, '')}]
     template_specification['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_specification['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     msg, msg_type = common.get_message_from_session()
     template_specification['displayedMessage'] = msg
     template_specification['messageType'] = msg_type
     return super(SurfaceStimulusController, self).fill_default_attributes(template_specification,
                                                                           subsection='surfacestim')
Example #12
0
 def fill_default_attributes(self, template_dictionary):
     """
     Overwrite base controller to add required parameters for adapter templates.
     """
     context = common.get_from_session(KEY_REGION_CONTEXT)
     default = context.equation_kwargs.get(DataTypeMetaData.KEY_TAG_1, '')
     template_dictionary["entitiySavedName"] = [{
         'name': DataTypeMetaData.KEY_TAG_1,
         "disabled": "False",
         'label': 'Display name',
         'type': 'str',
         "default": default
     }]
     template_dictionary['loadExistentEntityUrl'] = LOAD_EXISTING_URL
     template_dictionary['resetToDefaultUrl'] = RELOAD_DEFAULT_PAGE_URL
     msg, msg_type = common.get_message_from_session()
     template_dictionary['displayedMessage'] = msg
     template_dictionary['messageType'] = msg_type
     return SpatioTemporalController.fill_default_attributes(
         self, template_dictionary, subsection='regionstim')