Skip to content

Commit

Permalink
Merge pull request #339 from the-virtual-brain/local-connectivity-form
Browse files Browse the repository at this point in the history
TVB-2850 Fix local connectivity form
  • Loading branch information
bogdanvalean1 authored Dec 23, 2020
2 parents a8ba736 + 396f9c2 commit f649640
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f649640

Please sign in to comment.