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):
        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=self.possible_equations,
                                   display_none_choice=False, subform=GaussianEquationForm)
        self.cutoff = FloatField(LocalConnectivityCreatorModel.cutoff)
        self.display_name = StrField(LocalConnectivityCreatorModel.display_name, name='display_name')

    @staticmethod
    def get_view_model():
        return LocalConnectivityCreatorModel

    @staticmethod
    def get_required_datatype():
        return SurfaceIndex

    @staticmethod
    def get_input_name():
        return 'surface'

    @staticmethod
    def get_filters():
        return FilterChain(fields=[FilterChain.datatype + '.surface_type'], operations=["=="],
                           values=[CORTICAL])

    def fill_from_trait(self, trait):
        # type: (LocalConnectivityCreatorModel) -> None
        self.surface.data = trait.surface.hex
        self.cutoff.data = trait.cutoff
        self.display_name.data = trait.display_name
        if trait.equation:
            lc_equation = trait.equation
        else:
            lc_equation = LocalConnectivity.equation.default
        self.spatial.data = type(lc_equation)
        self.spatial.subform_field = FormField(get_form_for_equation(type(lc_equation)), self.NAME_EQUATION_PARAMS_DIV)
        self.spatial.subform_field.form.fill_from_trait(lc_equation)

    def get_rendering_dict(self):
        return {'adapter_form': self, 'next_action': 'form_spatial_local_connectivity_data',
                'equation_params_div': self.NAME_EQUATION_PARAMS_DIV, 'legend': 'Local connectivity parameters'}
 def __init__(self):
     SpatioTemporalController.__init__(self)
     ui_name_to_equation_dict = get_ui_name_to_equation_dict()
     self.equation_choices = {
         GAUSSIAN_EQUATION: ui_name_to_equation_dict.get(GAUSSIAN_EQUATION),
         SIGMOID_EQUATION: ui_name_to_equation_dict.get(SIGMOID_EQUATION)
     }
Exemple #3
0
 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)}
Exemple #4
0
    def refresh_subform(self, equation, mapping_key):
        eq_class = get_ui_name_to_equation_dict().get(equation)
        current_lconn = common.get_from_session(KEY_LCONN)
        current_lconn.equation = eq_class()

        eq_params_form = SubformHelper.get_subform_for_field_value(equation, mapping_key)
        return {'adapter_form': eq_params_form, 'equationsPrefixes': self.plotted_equation_prefixes}
Exemple #5
0
    def refresh_subform(self, temporal_equation, mapping_key):
        eq_class = get_ui_name_to_equation_dict().get(temporal_equation)
        current_region_stim = common.get_from_session(KEY_REGION_STIMULUS)
        current_region_stim.temporal = eq_class()

        eq_params_form = SubformHelper.get_subform_for_field_value(temporal_equation, mapping_key)
        # TODO: check eqPrefixes
        return {'adapter_form': eq_params_form, 'equationsPrefixes': self.plotted_equation_prefixes}
Exemple #6
0
    def __init__(self, prefix=''):
        super(MultiplicativeNoiseForm, self).__init__(prefix)
        self.equation_choices = get_ui_name_to_equation_dict()
        default_equation = list(self.equation_choices.values())[0]

        self.nsig = ArrayField(Multiplicative.nsig, self)
        self.equation = SelectField(Attr(Equation, label='Equation', default=default_equation), self, name='equation',
                                    choices=self.equation_choices, subform=get_form_for_equation(default_equation))
 def __init__(self):
     SpatioTemporalController.__init__(self)
     ui_name_to_equation_dict = get_ui_name_to_equation_dict()
     self.possible_spatial_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)}
     self.possible_temporal_equations = ui_name_to_equation_dict
class SurfaceStimulusCreatorForm(ABCAdapterForm):
    NAME_SPATIAL_PARAMS_DIV = 'spatial_params'
    NAME_TEMPORAL_PARAMS_DIV = 'temporal_params'
    default_spatial = Sigmoid
    default_temporal = PulseTrain
    choices_temporal = get_ui_name_to_equation_dict()
    choices_spatial = {GAUSSIAN_EQUATION: choices_temporal.get(GAUSSIAN_EQUATION),
                       DOUBLE_GAUSSIAN_EQUATION: choices_temporal.get(DOUBLE_GAUSSIAN_EQUATION),
                       SIGMOID_EQUATION: choices_temporal.get(SIGMOID_EQUATION)}

    def __init__(self, project_id=None):
        super(SurfaceStimulusCreatorForm, self).__init__(project_id=project_id)

        self.surface = TraitDataTypeSelectField(SurfaceStimulusCreatorModel.surface, self, name='surface',
                                                conditions=self.get_filters())
        self.spatial = SelectField(SurfaceStimulusCreatorModel.spatial, self, name='spatial',
                                   choices=self.choices_spatial,
                                   subform=get_form_for_equation(self.default_spatial))
        self.temporal = SelectField(SurfaceStimulusCreatorModel.temporal, self, name='temporal',
                                    choices=self.choices_temporal,
                                    subform=get_form_for_equation(self.default_temporal))

    @staticmethod
    def get_view_model():
        return SurfaceStimulusCreatorModel

    @staticmethod
    def get_required_datatype():
        return SurfaceIndex

    @staticmethod
    def get_input_name():
        return 'surface'

    @staticmethod
    def get_filters():
        return FilterChain(fields=[FilterChain.datatype + '.surface_type'], operations=["=="],
                           values=[CORTICAL])

    def fill_from_trait(self, trait):
        self.surface.data = trait.surface.hex
        self.spatial.data = type(trait.spatial)
        self.temporal.data = type(trait.temporal)
        self.temporal.subform_field = FormField(get_form_for_equation(type(trait.temporal)), self,
                                                self.NAME_TEMPORAL_PARAMS_DIV)
        self.temporal.subform_field.form.fill_from_trait(trait.temporal)
        self.spatial.subform_field = FormField(get_form_for_equation(type(trait.spatial)), self,
                                               self.NAME_SPATIAL_PARAMS_DIV)
        self.spatial.subform_field.form.fill_from_trait(trait.spatial)

    def get_rendering_dict(self):
        return {'adapter_form': self, 'next_action': 'form_spatial_surface_stimulus_equations',
                'spatial_params_div': self.NAME_SPATIAL_PARAMS_DIV,
                'temporal_params_div': self.NAME_TEMPORAL_PARAMS_DIV, 'legend': 'Stimulus interface'}
    def refresh_subform(self, subform_div, equation, mapping_key):
        # TODO: nicer way to differentiate between temporal and spatial equations
        eq_class = get_ui_name_to_equation_dict().get(equation)
        current_surface_stim = common.get_from_session(KEY_SURFACE_STIMULI)
        if 'temporal' in subform_div:
            current_surface_stim.temporal = eq_class()
        else:
            current_surface_stim.spatial = eq_class()

        eq_params_form = SubformHelper.get_subform_for_field_value(equation, mapping_key)
        return {'adapter_form': eq_params_form, 'equationsPrefixes': self.plotted_equation_prefixes}
class RegionStimulusCreatorForm(ABCAdapterForm):
    NAME_TEMPORAL_PARAMS_DIV = 'temporal_params'
    default_temporal = PulseTrain
    choices = get_ui_name_to_equation_dict()

    def __init__(self, project_id=None):
        super(RegionStimulusCreatorForm, self).__init__(project_id=project_id)
        self.connectivity = TraitDataTypeSelectField(
            RegionStimulusCreatorModel.connectivity,
            self.project_id,
            name='connectivity')
        self.temporal = SelectField(RegionStimulusCreatorModel.temporal,
                                    self.project_id,
                                    name='temporal',
                                    choices=self.choices,
                                    subform=get_form_for_equation(
                                        self.default_temporal))

    @staticmethod
    def get_view_model():
        return RegionStimulusCreatorModel

    @staticmethod
    def get_filters():
        return None

    @staticmethod
    def get_input_name():
        return 'connectivity'

    @staticmethod
    def get_required_datatype():
        return ConnectivityIndex

    def fill_from_trait(self, trait):
        # type: (RegionStimulusCreatorModel) -> None
        self.connectivity.data = trait.connectivity.hex
        self.temporal.data = type(trait.temporal)
        self.temporal.subform_field = FormField(
            get_form_for_equation(type(trait.temporal)), self.project_id,
            self.NAME_TEMPORAL_PARAMS_DIV)
        self.temporal.subform_field.form.fill_from_trait(trait.temporal)

    def get_rendering_dict(self):
        return {
            'adapter_form': self,
            'next_action': 'form_spatial_model_param_equations',
            'temporal_params_div': self.NAME_TEMPORAL_PARAMS_DIV,
            'legend': 'Stimulus interface'
        }
Exemple #11
0
class SurfaceModelParametersForm(ABCAdapterForm):
    NAME_EQATION_PARAMS_DIV = 'equation_params'
    default_equation = Gaussian
    ui_name_to_equation_dict = get_ui_name_to_equation_dict()
    equation_choices = {
        GAUSSIAN_EQUATION: ui_name_to_equation_dict.get(GAUSSIAN_EQUATION),
        SIGMOID_EQUATION: ui_name_to_equation_dict.get(SIGMOID_EQUATION)
    }

    def __init__(self, model_params, prefix=''):
        super(SurfaceModelParametersForm, self).__init__(prefix)

        self.model_param = SelectField(Str(label='Model parameter'),
                                       self,
                                       choices=model_params,
                                       name='model_param')
        self.equation = SelectField(Attr(SpatialApplicableEquation,
                                         label='Equation',
                                         default=self.default_equation),
                                    self,
                                    choices=self.equation_choices,
                                    name='equation',
                                    subform=get_form_for_equation(
                                        self.default_equation))

    @staticmethod
    def get_required_datatype():
        return None

    @staticmethod
    def get_input_name():
        return None

    @staticmethod
    def get_filters():
        return None

    def fill_from_trait(self, trait):
        self.equation.data = type(trait)
        self.equation.subform_field = FormField(
            get_form_for_equation(type(trait)), self,
            self.NAME_EQATION_PARAMS_DIV)
        self.equation.subform_field.form.fill_from_trait(trait)
Exemple #12
0
def get_ui_name_for_equation(equation_class):
    equation_to_ui_name = dict(
        (v, k) for k, v in get_ui_name_to_equation_dict().items())
    return equation_to_ui_name.get(equation_class)
Exemple #13
0
 def __init__(self):
     SpatioTemporalController.__init__(self)
     self.equation_choices = get_ui_name_to_equation_dict()