diff --git a/framework_tvb/tvb/adapters/creators/local_connectivity_creator.py b/framework_tvb/tvb/adapters/creators/local_connectivity_creator.py index 7e74df4035..6d69f19914 100644 --- a/framework_tvb/tvb/adapters/creators/local_connectivity_creator.py +++ b/framework_tvb/tvb/adapters/creators/local_connectivity_creator.py @@ -36,6 +36,8 @@ from tvb.adapters.datatypes.db.local_connectivity import LocalConnectivityIndex from tvb.adapters.datatypes.db.surface import SurfaceIndex from tvb.adapters.simulator.equation_forms import GaussianEquationForm, get_form_for_equation +from tvb.adapters.simulator.subforms_mapping import GAUSSIAN_EQUATION, get_ui_name_to_equation_dict, \ + DOUBLE_GAUSSIAN_EQUATION, SIGMOID_EQUATION from tvb.basic.neotraits.api import Attr from tvb.core.adapters.abcadapter import ABCAdapterForm, ABCAdapter from tvb.core.entities.filters.chain import FilterChain @@ -83,12 +85,16 @@ class LocalConnectivityCreatorModel(ViewModel, LocalConnectivity): class LocalConnectivityCreatorForm(ABCAdapterForm): NAME_EQUATION_PARAMS_DIV = 'spatial_params' + possible_equations = {GAUSSIAN_EQUATION: get_ui_name_to_equation_dict().get(GAUSSIAN_EQUATION), + DOUBLE_GAUSSIAN_EQUATION: get_ui_name_to_equation_dict().get(DOUBLE_GAUSSIAN_EQUATION), + SIGMOID_EQUATION: get_ui_name_to_equation_dict().get(SIGMOID_EQUATION)} - def __init__(self, equation_choices=None): + def __init__(self): super(LocalConnectivityCreatorForm, self).__init__() self.surface = TraitDataTypeSelectField(LocalConnectivityCreatorModel.surface, name=self.get_input_name(), conditions=self.get_filters()) - self.spatial = SelectField(LocalConnectivityCreatorModel.equation, name='spatial', choices=equation_choices, + self.spatial = SelectField(LocalConnectivityCreatorModel.equation, name='spatial', + choices=self.possible_equations, display_none_choice=False, subform=GaussianEquationForm) self.cutoff = FloatField(LocalConnectivityCreatorModel.cutoff) self.display_name = StrField(LocalConnectivityCreatorModel.display_name, name='display_name') diff --git a/framework_tvb/tvb/interfaces/web/controllers/spatial/local_connectivity_controller.py b/framework_tvb/tvb/interfaces/web/controllers/spatial/local_connectivity_controller.py index be48f450cc..35c53cb2de 100644 --- a/framework_tvb/tvb/interfaces/web/controllers/spatial/local_connectivity_controller.py +++ b/framework_tvb/tvb/interfaces/web/controllers/spatial/local_connectivity_controller.py @@ -81,10 +81,6 @@ class LocalConnectivityController(SpatioTemporalController): def __init__(self): SpatioTemporalController.__init__(self) self.plotted_equation_prefixes = {} - ui_name_to_equation_dict = get_ui_name_to_equation_dict() - self.possible_equations = {GAUSSIAN_EQUATION: ui_name_to_equation_dict.get(GAUSSIAN_EQUATION), - DOUBLE_GAUSSIAN_EQUATION: ui_name_to_equation_dict.get(DOUBLE_GAUSSIAN_EQUATION), - SIGMOID_EQUATION: ui_name_to_equation_dict.get(SIGMOID_EQUATION)} @expose_page def step_1(self, do_reset=0, **kwargs): @@ -113,7 +109,7 @@ def step_1(self, do_reset=0, **kwargs): project_id=common.get_current_project().id) existent_lcon_form.existentEntitiesSelect.data = current_lconn.gid.hex configure_lcon_form = self.algorithm_service.prepare_adapter_form( - form_instance=LocalConnectivityCreatorForm(self.possible_equations), + form_instance=LocalConnectivityCreatorForm(), project_id=common.get_current_project().id) configure_lcon_form.fill_from_trait(current_lconn) current_lconn.equation = configure_lcon_form.spatial.value() @@ -163,20 +159,20 @@ def set_equation_param(self, **param): @cherrypy.expose def set_cutoff_value(self, **param): current_lconn = common.get_from_session(KEY_LCONN) - cutoff_form_field = LocalConnectivityCreatorForm(self.possible_equations).cutoff + cutoff_form_field = LocalConnectivityCreatorForm().cutoff cutoff_form_field.fill_from_post(param) current_lconn.cutoff = cutoff_form_field.value @cherrypy.expose def set_surface(self, **param): current_lconn = common.get_from_session(KEY_LCONN) - surface_form_field = LocalConnectivityCreatorForm(self.possible_equations).surface + surface_form_field = LocalConnectivityCreatorForm().surface surface_form_field.fill_from_post(param) current_lconn.surface = surface_form_field.value @cherrypy.expose def set_display_name(self, **param): - display_name_form_field = LocalConnectivityCreatorForm(self.possible_equations).display_name + display_name_form_field = LocalConnectivityCreatorForm().display_name display_name_form_field.fill_from_post(param) if display_name_form_field.value is not None: lconn = common.get_from_session(KEY_LCONN)