Пример #1
0
    def __init__(self, spatial_equation_choices, temporal_equation_choices,
                 project_id):
        super(SurfaceStimulusCreatorForm, self).__init__()
        self.project_id = project_id

        # TODO: filter CorticalSurafces
        self.surface = TraitDataTypeSelectField(
            SurfaceStimulusCreatorModel.surface,
            self,
            name='surface',
            conditions=self.get_filters())
        self.spatial = SelectField(SurfaceStimulusCreatorModel.spatial,
                                   self,
                                   name='spatial',
                                   choices=spatial_equation_choices)
        self.spatial_params = FormField(get_form_for_equation(
            self.default_spatial),
                                        self,
                                        name=self.NAME_SPATIAL_PARAMS_DIV)
        self.temporal = SelectField(SurfaceStimulusCreatorModel.temporal,
                                    self,
                                    name='temporal',
                                    choices=temporal_equation_choices)
        self.temporal_params = FormField(get_form_for_equation(
            self.default_temporal),
                                         self,
                                         name=self.NAME_TEMPORAL_PARAMS_DIV)
Пример #2
0
 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.spatial_params.form = get_form_for_equation(type(trait.spatial))(self.NAME_SPATIAL_PARAMS_DIV)
     self.temporal_params.form = get_form_for_equation(type(trait.temporal))(self.NAME_TEMPORAL_PARAMS_DIV)
     self.spatial_params.form.fill_from_trait(trait.spatial)
     self.temporal_params.form.fill_from_trait(trait.temporal)
Пример #3
0
 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)
Пример #4
0
    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))
    def set_equation(self, equation):
        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 = get_form_for_equation(eq_class)(prefix=LocalConnectivityCreatorForm.NAME_EQUATION_PARAMS_DIV)
        return {'form': eq_params_form, 'equationsPrefixes': self.plotted_equation_prefixes}
Пример #6
0
    def __init__(self, equation_choices, project_id):
        super(RegionStimulusCreatorForm, self).__init__()
        self.project_id = project_id

        self.connectivity = TraitDataTypeSelectField(RegionStimulusCreatorModel.connectivity, self, name='connectivity')
        self.temporal = SelectField(RegionStimulusCreatorModel.temporal, self, name='temporal',
                                    choices=equation_choices, subform=get_form_for_equation(self.default_temporal))
Пример #7
0
    def set_monitor_equation(self, current_monitor_name, **data):
        session_stored_simulator, is_simulation_copy, is_simulator_load, is_branch = self.context.get_common_params(
        )
        current_monitor, next_monitor = self.monitors_handler.get_current_and_next_monitor_form(
            current_monitor_name, session_stored_simulator)

        if cherrypy.request.method == POST_REQUEST:
            form = get_form_for_equation(type(current_monitor.hrf_kernel))()
            form.fill_from_post(data)
            form.fill_trait(current_monitor.hrf_kernel)

            last_loaded_fragment_url = self.get_url_after_monitor_equation(
                next_monitor)
            self.context.add_last_loaded_form_url_to_session(
                last_loaded_fragment_url)

        previous_form_action_url = self.build_monitor_url(
            SimulatorWizzardURLs.SET_MONITOR_EQUATION_URL,
            current_monitor_name)
        rendering_rules = SimulatorFragmentRenderingRules(
            None, None, previous_form_action_url, is_simulation_copy,
            is_simulator_load, self.context.last_loaded_fragment_url,
            cherrypy.request)

        form_action_url, if_bold_url = self.get_urls_for_next_monitor_fragment(
            next_monitor, current_monitor)
        return self.monitors_handler.handle_next_fragment_for_monitors(
            self.context, rendering_rules, current_monitor, next_monitor, True,
            form_action_url, if_bold_url)
    def refresh_subform(self, equation):
        eq_class = TVBEnum.string_to_enum(list(SpatialEquationsEnum), equation).value
        current_lconn = common.get_from_session(KEY_LCONN)
        current_lconn.equation = eq_class()

        eq_params_form = get_form_for_equation(eq_class)()
        return {'adapter_form': eq_params_form, 'equationsPrefixes': self.plotted_equation_prefixes}
Пример #9
0
 def __init__(self):
     super(MultiplicativeNoiseForm, self).__init__()
     self.nsig = ArrayField(MultiplicativeNoiseViewModel.nsig)
     self.equation = SelectField(
         EnumAttr(label='Equation', default=TemporalEquationsEnum.LINEAR),
         name='equation',
         subform=get_form_for_equation(TemporalEquationsEnum.LINEAR.value))
Пример #10
0
 def fill_from_trait(self, trait):
     # type: (RegionStimulusCreatorModel) -> None
     self.connectivity.data = trait.connectivity.hex
     self.temporal.data = type(trait.temporal)
     self.temporal_params.form = get_form_for_equation(type(
         trait.temporal))(self.NAME_TEMPORAL_PARAMS_DIV)
     self.temporal_params.form.fill_from_trait(trait.temporal)
Пример #11
0
 def _prepare_next_fragment_if_bold(monitor, rendering_rules,
                                    form_action_url):
     next_form = get_form_for_equation(type(monitor.hrf_kernel))()
     next_form.fill_from_trait(monitor.hrf_kernel)
     rendering_rules.form = next_form
     rendering_rules.form_action_url = form_action_url
     return rendering_rules.to_dict()
 def set_temporal_param(self, **param):
     current_surface_stim = common.get_from_session(KEY_SURFACE_STIMULI)
     eq_param_form_class = get_form_for_equation(type(current_surface_stim.temporal))
     eq_param_form = eq_param_form_class()
     eq_param_form.fill_from_trait(current_surface_stim.temporal)
     eq_param_form.fill_from_post(param)
     eq_param_form.fill_trait(current_surface_stim.temporal)
Пример #13
0
    def set_noise_equation_params(self, **data):
        session_stored_simulator = common.get_from_session(
            common.KEY_SIMULATOR_CONFIG)
        is_simulator_copy = common.get_from_session(
            common.KEY_IS_SIMULATOR_COPY)
        is_simulator_load = common.get_from_session(
            common.KEY_IS_SIMULATOR_LOAD)

        if cherrypy.request.method == 'POST':
            is_simulator_copy = False
            form = get_form_for_equation(
                type(session_stored_simulator.integrator.noise.b))()
            form.fill_from_post(data)
            form.fill_trait(session_stored_simulator.integrator.noise.b)

        monitor_fragment = SimulatorMonitorFragment(
            '',
            common.get_current_project().id)
        monitor_fragment.fill_from_trait(session_stored_simulator)

        dict_to_render = copy.deepcopy(self.dict_to_render)
        dict_to_render[self.FORM_KEY] = monitor_fragment
        dict_to_render[self.ACTION_KEY] = '/burst/set_monitors'
        dict_to_render[
            self.PREVIOUS_ACTION_KEY] = '/burst/set_noise_equation_params'
        dict_to_render[self.IS_COPY] = is_simulator_copy
        dict_to_render[self.IS_LOAD] = is_simulator_load
        return dict_to_render
    def set_temporal(self, equation):
        eq_class = get_ui_name_to_equation_dict().get(equation)
        current_surface_stim = common.get_from_session(KEY_SURFACE_STIMULI)
        current_surface_stim.temporal = eq_class()

        eq_params_form = get_form_for_equation(eq_class)(prefix=SurfaceStimulusCreatorForm.NAME_TEMPORAL_PARAMS_DIV)
        return {'form': eq_params_form, 'equationsPrefixes': self.plotted_equation_prefixes}
Пример #15
0
 def set_equation_param(self, **param):
     current_lconn = common.get_from_session(KEY_LCONN)
     eq_param_form_class = get_form_for_equation(type(current_lconn.equation))
     eq_param_form = eq_param_form_class()
     eq_param_form.fill_from_trait(current_lconn.equation)
     eq_param_form.fill_from_post(param)
     eq_param_form.fill_trait(current_lconn.equation)
Пример #16
0
 def set_temporal_param(self, **param):
     current_region_stim = common.get_from_session(KEY_REGION_STIMULUS)
     eq_param_form_class = get_form_for_equation(type(current_region_stim.temporal))
     eq_param_form = eq_param_form_class()
     eq_param_form.fill_from_trait(current_region_stim.temporal)
     eq_param_form.fill_from_post(param)
     eq_param_form.fill_trait(current_region_stim.temporal)
 def set_equation_param(self, **param):
     context = common.get_from_session(KEY_CONTEXT_MPS)
     eq_params_form_class = get_form_for_equation(
         type(context.current_equation))
     eq_params_form = eq_params_form_class(
         prefix=SurfaceModelParametersForm.NAME_EQATION_PARAMS_DIV)
     eq_params_form.fill_from_post(param)
     eq_params_form.fill_trait(context.current_equation)
Пример #18
0
    def set_temporal(self, temporal_equation):
        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 = get_form_for_equation(eq_class)(prefix=RegionStimulusCreatorForm.NAME_TEMPORAL_PARAMS_DIV)
        #TODO: check eqPrefixes
        return {'adapter_form': eq_params_form, 'equationsPrefixes': self.plotted_equation_prefixes}
Пример #19
0
    def __init__(self):
        super(SurfaceStimulusCreatorForm, self).__init__()

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

        del self.spatial.choices[-1]
Пример #20
0
 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)
Пример #21
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))
Пример #22
0
 def __init__(self):
     super(RegionStimulusCreatorForm, self).__init__()
     self.connectivity = TraitDataTypeSelectField(
         RegionStimulusCreatorModel.connectivity, name='connectivity')
     self.temporal = SelectField(RegionStimulusCreatorModel.temporal,
                                 name='temporal',
                                 subform=get_form_for_equation(
                                     self.default_temporal.value))
Пример #23
0
 def set_equation_param(self, **param):
     current_lconn = common.get_from_session(KEY_LCONN)
     eq_param_form_class = get_form_for_equation(
         type(current_lconn.equation))
     eq_param_form = eq_param_form_class(
         prefix=LocalConnectivityCreatorForm.NAME_EQUATION_PARAMS_DIV)
     eq_param_form.fill_from_post(param)
     eq_param_form.fill_trait(current_lconn.equation)
Пример #24
0
 def set_equation_param(self, **param):
     context = common.get_from_session(KEY_CONTEXT_MPS)
     eq_params_form_class = get_form_for_equation(
         type(context.current_equation))
     eq_params_form = eq_params_form_class()
     eq_params_form.fill_from_trait(context.current_equation)
     eq_params_form.fill_from_post(param)
     eq_params_form.fill_trait(context.current_equation)
Пример #25
0
 def set_temporal_param(self, **param):
     current_surface_stim = common.get_from_session(KEY_SURFACE_STIMULI)
     eq_param_form_class = get_form_for_equation(
         type(current_surface_stim.temporal))
     eq_param_form = eq_param_form_class(
         prefix=SurfaceStimulusCreatorForm.NAME_TEMPORAL_PARAMS_DIV)
     eq_param_form.fill_from_post(param)
     eq_param_form.fill_trait(current_surface_stim.temporal)
Пример #26
0
 def set_temporal_param(self, **param):
     current_region_stim = common.get_from_session(KEY_REGION_STIMULUS)
     eq_param_form_class = get_form_for_equation(
         type(current_region_stim.temporal))
     eq_param_form = eq_param_form_class(
         prefix=RegionStimulusCreatorForm.NAME_TEMPORAL_PARAMS_DIV)
     eq_param_form.fill_from_post(param)
     eq_param_form.fill_trait(current_region_stim.temporal)
Пример #27
0
    def __init__(self, equation_choices, project_id):
        super(RegionStimulusCreatorForm, self).__init__()
        self.project_id = project_id

        self.connectivity = TraitDataTypeSelectField(RegionStimulusCreatorModel.connectivity, self, name='connectivity')
        self.temporal = SelectField(RegionStimulusCreatorModel.temporal, self, name='temporal', choices=equation_choices)
        self.temporal_params = FormField(get_form_for_equation(self.default_temporal), self,
                                         name=self.NAME_TEMPORAL_PARAMS_DIV)
    def refresh_subform(self, subform_div, equation):
        # TODO: nicer way to differentiate between temporal and spatial equations
        eq_class = TVBEnum.string_to_enum(list(TemporalEquationsEnum), equation).value
        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 = get_form_for_equation(eq_class)()
        return {'adapter_form': eq_params_form, 'equationsPrefixes': self.plotted_equation_prefixes}
    def set_equation(self, equation):
        eq_class = get_ui_name_to_equation_dict().get(equation)
        context = common.get_from_session(KEY_CONTEXT_MPS)
        context.current_equation = eq_class()

        eq_params_form = get_form_for_equation(eq_class)(
            prefix=SurfaceModelParametersForm.NAME_EQATION_PARAMS_DIV)
        return {
            'form': eq_params_form,
            'equationsPrefixes': self.plotted_equation_prefixes
        }
Пример #30
0
    def refresh_subform(self, temporal_equation):
        eq_class = TVBEnum.string_to_enum(list(TemporalEquationsEnum),
                                          temporal_equation).value
        current_region_stim = common.get_from_session(KEY_REGION_STIMULUS)
        current_region_stim.temporal = eq_class()

        eq_params_form = get_form_for_equation(eq_class)()
        # TODO: check eqPrefixes
        return {
            'adapter_form': eq_params_form,
            'equationsPrefixes': self.plotted_equation_prefixes
        }