def __init__(self): super(SimulatorAdapterForm, self).__init__() self.coupling_choices = get_ui_name_to_coupling_dict() default_coupling = list(self.coupling_choices.values())[0] self.connectivity = TraitDataTypeSelectField( SimulatorAdapterModel.connectivity, name=self.get_input_name(), conditions=self.get_filters()) self.coupling = SelectField(Attr(Coupling, default=default_coupling, label="Coupling", doc=Simulator.coupling.doc), name='coupling', choices=self.coupling_choices) self.conduction_speed = FloatField(Simulator.conduction_speed) self.ordered_fields = (self.connectivity, self.conduction_speed, self.coupling) self.range_params = [ Simulator.connectivity, Simulator.conduction_speed ]
class SimulatorModelFragment(ABCAdapterForm): def __init__(self, project_id=None): super(SimulatorModelFragment, self).__init__(project_id) self.model_choices = get_ui_name_to_model() default_model = list(self.model_choices.values())[0] self.model = SelectField(Attr(Model, default=default_model, label=SimulatorAdapterModel.model.label, doc=SimulatorAdapterModel.model.doc), self.project_id, choices=self.model_choices, name='model') def fill_from_trait(self, trait): # type: (SimulatorAdapterModel) -> None self.model.data = trait.model.__class__ def fill_trait(self, datatype): if type(datatype.model) != self.model.value: datatype.model = self.model.value()
class SimulatorIntegratorFragment(ABCAdapterForm): def __init__(self, prefix='', project_id=None): super(SimulatorIntegratorFragment, self).__init__(prefix, project_id) self.integrator_choices = get_ui_name_to_integrator_dict() default_integrator = list(self.integrator_choices.values())[0] self.integrator = SelectField( Attr(Integrator, default=default_integrator, label=Simulator.integrator.label, doc=Simulator.integrator.doc), self, name='integrator', choices=self.integrator_choices, subform=get_form_for_integrator(default_integrator)) def fill_from_trait(self, trait): # type: (Simulator) -> None self.integrator.data = trait.integrator.__class__ def fill_trait(self, datatype): datatype.integrator = self.integrator.value()
def __init__(self, equation_choices, prefix='', project_id=None): super(LocalConnectivityCreatorForm, self).__init__(prefix, project_id) self.surface = TraitDataTypeSelectField( LocalConnectivityCreatorModel.surface, self, name=self.get_input_name(), conditions=self.get_filters()) self.spatial = SelectField(LocalConnectivityCreatorModel.equation, self, name='spatial', choices=equation_choices, display_none_choice=False) self.spatial_params = FormField(GaussianEquationForm, self, name=self.NAME_EQUATION_PARAMS_DIV, label='Equation parameters') self.cutoff = ScalarField(LocalConnectivityCreatorModel.cutoff, self) self.display_name = ScalarField( LocalConnectivityCreatorModel.display_name, self, name='display_name')
class MultiplicativeNoiseForm(NoiseForm): def __init__(self): super(MultiplicativeNoiseForm, self).__init__() self.equation_choices = get_ui_name_to_equation_dict() default_equation = list(self.equation_choices.values())[0] self.nsig = ArrayField(MultiplicativeNoiseViewModel.nsig) self.equation = SelectField(Attr(Equation, label='Equation', default=default_equation), name='equation', choices=self.equation_choices, subform=get_form_for_equation(default_equation)) def fill_trait(self, datatype): super(MultiplicativeNoiseForm, self).fill_trait(datatype) datatype.nsig = self.nsig.data if type(datatype.b) != self.equation.data: datatype.b = self.equation.data() def fill_from_trait(self, trait): # type: (NoiseViewModel) -> None super(MultiplicativeNoiseForm, self).fill_from_trait(trait) self.equation.data = trait.b.__class__
class BoldMonitorForm(MonitorForm): def __init__(self, session_stored_simulator=None): super(BoldMonitorForm, self).__init__(session_stored_simulator) self.hrf_kernel_choices = get_ui_name_to_monitor_equation_dict() default_hrf_kernel = list(self.hrf_kernel_choices.values())[0] self.period = FloatField(Bold.period) self.hrf_kernel = SelectField(Attr(HRFKernelEquation, label='Equation', default=default_hrf_kernel), name='hrf_kernel', choices=self.hrf_kernel_choices) def fill_trait(self, datatype): super(BoldMonitorForm, self).fill_trait(datatype) datatype.period = self.period.data if type(datatype.hrf_kernel) != self.hrf_kernel.data: datatype.hrf_kernel = self.hrf_kernel.data() def fill_from_trait(self, trait): super(BoldMonitorForm, self).fill_from_trait(trait) self.hrf_kernel.data = trait.hrf_kernel.__class__
class IntegratorStochasticForm(IntegratorForm): template = 'form_fields/select_field.html' def __init__(self): super(IntegratorStochasticForm, self).__init__() self.noise_choices = get_ui_name_to_noise_dict() default_noise = list(self.noise_choices.values())[0] self.noise = SelectField(Attr(NoiseViewModel, label='Noise', default=default_noise), name='noise', choices=self.noise_choices, subform=get_form_for_noise(default_noise)) def fill_trait(self, datatype): super(IntegratorStochasticForm, self).fill_trait(datatype) if self.noise.data and type(datatype.noise) != self.noise.data: datatype.noise = self.noise.data() def fill_from_trait(self, trait): # type: (IntegratorStochasticViewModel) -> None self.noise.data = trait.noise.__class__
class SimulatorIntegratorFragment(ABCAdapterForm): def __init__(self): super(SimulatorIntegratorFragment, self).__init__() self.integrator_choices = get_ui_name_to_integrator_dict() default_integrator = list(self.integrator_choices.values())[0] self.integrator = SelectField( Attr(IntegratorViewModel, default=default_integrator, label=SimulatorAdapterModel.integrator.label, doc=SimulatorAdapterModel.integrator.doc), name='integrator', choices=self.integrator_choices, subform=get_form_for_integrator(default_integrator), ui_values=get_integrator_name_list()) def fill_from_trait(self, trait): # type: (SimulatorAdapterModel) -> None self.integrator.data = trait.integrator.__class__ def fill_trait(self, datatype): if type(datatype.integrator) != self.integrator.value: datatype.integrator = self.integrator.value()
def __init__(self, session_stored_simulator=None): super(SpatialAverageMonitorForm, self).__init__(session_stored_simulator) self.spatial_mask = ArrayField(SpatialAverage.spatial_mask) self.default_mask = SelectField(SpatialAverage.default_mask)
def __init__(self): super(SensorsImporterForm, self).__init__() self.sensors_file = TraitUploadField(SensorsImporterModel.sensors_file, ('.txt', '.bz2'), 'sensors_file') self.sensors_type = SelectField(SensorsImporterModel.sensors_type, name='sensors_type', choices=SensorsImporterModel.OPTIONS)
def __init__(self, project_id=None): super(RegionStimulusCreatorForm, self).__init__(project_id=project_id) self.connectivity = TraitDataTypeSelectField(RegionStimulusCreatorModel.connectivity, self, name='connectivity') self.temporal = SelectField(RegionStimulusCreatorModel.temporal, self, name='temporal', choices=self.choices, subform=get_form_for_equation(self.default_temporal))
def __init__(self): super(AllenConnectomeBuilderForm, self).__init__() self.resolution = SelectField(AllenConnectModel.resolution) self.weighting = SelectField(AllenConnectModel.weighting) self.inj_f_thresh = FloatField(AllenConnectModel.inj_f_thresh) self.vol_thresh = FloatField(AllenConnectModel.vol_thresh)