Example #1
0
 def __init__(self, net, width="95%", height="550px", play_rate=0.5):
     self._ignore_layer_updates = False
     self.player = _Player(self, play_rate)
     self.player.start()
     self.net = net
     r = random.randint(1, 1000000)
     self.class_id = "picture-dashboard-%s-%s" % (self.net.name, r)
     self._width = width
     self._height = height
     ## Global widgets:
     style = {"description_width": "initial"}
     self.feature_columns = IntText(description="Detail columns:",
                                    value=self.net.config["dashboard.features.columns"],
                                    min=0,
                                    max=1024,
                                    style=style)
     self.feature_scale = FloatText(description="Detail scale:",
                                    value=self.net.config["dashboard.features.scale"],
                                    min=0.1,
                                    max=10,
                                    style=style)
     self.feature_columns.observe(self.regenerate, names='value')
     self.feature_scale.observe(self.regenerate, names='value')
     ## Hack to center SVG as justify-content is broken:
     self.net_svg = HTML(value="""<p style="text-align:center">%s</p>""" % ("",), layout=Layout(
         width=self._width, overflow_x='auto', overflow_y="auto",
         justify_content="center"))
     # Make controls first:
     self.output = Output()
     controls = self.make_controls()
     config = self.make_config()
     super().__init__([config, controls, self.net_svg, self.output])
Example #2
0
    def _create_notebook_widget(self, index=None):

        from ipywidgets import (FloatSlider, FloatText, Layout, HBox)

        widget_bounds = self._interactive_slider_bounds(index=index)
        thismin = FloatText(value=widget_bounds['min'],
                            description='min',
                            layout=Layout(flex='0 1 auto',
                                          width='auto'),)
        thismax = FloatText(value=widget_bounds['max'],
                            description='max',
                            layout=Layout(flex='0 1 auto',
                                          width='auto'),)
        current_value = self.value if index is None else self.value[index]
        current_name = self.name
        if index is not None:
            current_name += '_{}'.format(index)
        widget = FloatSlider(value=current_value,
                             min=thismin.value,
                             max=thismax.value,
                             step=widget_bounds['step'],
                             description=current_name,
                             layout=Layout(flex='1 1 auto', width='auto'))

        def on_min_change(change):
            if widget.max > change['new']:
                widget.min = change['new']
                widget.step = np.abs(widget.max - widget.min) * 0.001

        def on_max_change(change):
            if widget.min < change['new']:
                widget.max = change['new']
                widget.step = np.abs(widget.max - widget.min) * 0.001

        thismin.observe(on_min_change, names='value')
        thismax.observe(on_max_change, names='value')

        this_observed = functools.partial(self._interactive_update,
                                          index=index)

        widget.observe(this_observed, names='value')
        container = HBox((thismin, widget, thismax))
        return container
Example #3
0
    def InteractivePlane_Sphere(self, scale="log", fieldvalue="E", compvalue="y"):
        def foo(
            Update,
            Field,
            AmpDir,
            Component,
            Sigma0,
            Sigmab,
            Sigma1,
            Sigma2,
            Sus,
            d1,
            h,
            d2,
            R,
            Scale,
            rxOffset,
            z,
            radius,
            itime,
            Geometry=True,
            Fixed=False,
            vmin=None,
            vmax=None,
        ):

            if AmpDir == "Direction (B or dBdt)":
                Component = "vec"
            self.setLayerSphereParam(
                d1=d1,
                h=h,
                d2=d2,
                R=R,
                sig0=Sigma0,
                sigb=Sigmab,
                sig1=Sigma1,
                sig2=Sigma2,
                chi=Sus,
            )
            self.srcLoc = np.array([0.0, 0.0, z])
            self.rxLoc = np.array([[rxOffset, 0.0, z]])
            self.radius = radius
            if Update:
                self.simulate(self.srcLoc, self.rxLoc, self.time, self.radius)
            self.getFields(itime)
            return self.plotField(
                Field=Field,
                view=Component,
                scale=Scale,
                Geometry=Geometry,
                itime=itime,
                Scenario="Sphere",
                Fixed=Fixed,
                vmin=vmin,
                vmax=vmax,
            )

        out = widgetify(
            foo,
            Update=widgets.widget_bool.Checkbox(value=True, description="Update"),
            Field=widgets.ToggleButtons(
                options=["E", "B", "dBdt", "J", "Model"], value=fieldvalue
            ),
            AmpDir=widgets.ToggleButtons(
                options=["None", "Direction (B or dBdt)"], value="None"
            ),
            Component=widgets.ToggleButtons(
                options=["x", "y", "z"], value=compvalue, description="Comp."
            ),
            Sigma0=widgets.FloatText(
                value=1e-8, continuous_update=False, description="$\sigma_0$ (S/m)"
            ),
            Sigmab=widgets.FloatText(
                value=0.01, continuous_update=False, description="$\sigma_b$ (S/m)"
            ),
            Sigma1=widgets.FloatText(
                value=0.01, continuous_update=False, description="$\sigma_1$ (S/m)"
            ),
            Sigma2=widgets.FloatText(
                value=1.0, continuous_update=False, description="$\sigma_2$ (S/m)"
            ),
            Sus=widgets.FloatText(
                value=0.0, continuous_update=False, description="$\chi$"
            ),
            d1=widgets.FloatSlider(
                min=0.0,
                max=50.0,
                step=2.0,
                value=0.0,
                continuous_update=False,
                description="$d_1$ (m)",
            ),
            h=widgets.FloatSlider(
                min=2.0,
                max=40.0,
                step=2.0,
                value=20.0,
                continuous_update=False,
                description="$h$ (m)",
            ),
            d2=widgets.FloatSlider(
                min=20.0,
                max=80.0,
                step=2.0,
                value=60.0,
                continuous_update=False,
                description="$d_2$ (m)",
            ),
            R=widgets.FloatSlider(
                min=2.0,
                max=40.0,
                step=2.0,
                value=30.0,
                continuous_update=False,
                description="$R$ (m)",
            ),
            Scale=widgets.ToggleButtons(options=["log", "linear"], value="linear"),
            rxOffset=widgets.FloatSlider(
                min=0.0,
                max=50.0,
                step=2.0,
                value=10.0,
                continuous_update=False,
                description="$\Delta x$(m)",
            ),
            z=widgets.FloatSlider(
                min=0.0,
                max=50.0,
                step=2.0,
                value=0.0,
                continuous_update=False,
                description="$\Delta z$ (m)",
            ),
            radius=widgets.FloatSlider(
                min=2.0,
                max=50.0,
                step=2.0,
                value=2.0,
                continuous_update=False,
                description="Tx radius (m)",
            ),
            itime=widgets.IntSlider(
                min=1,
                max=70,
                step=1,
                value=1,
                continuous_update=False,
                description="Time index",
            ),
            Fixed=widgets.widget_bool.Checkbox(value=False, description="Fixed"),
            vmin=FloatText(value=None, description="vmin"),
            vmax=FloatText(value=None, description="vmax"),
        )
        return out
Example #4
0
    def create_param_widget(self, param, value):
        from ipywidgets import Layout, HBox

        children = (HBox(), )
        if isinstance(value, bool):
            from ipywidgets import Label, ToggleButton

            p = Label(value=param, layout=Layout(width="10%"))
            t = ToggleButton(description=str(value), value=value)

            def on_bool_change(change):
                t.description = str(change["new"])
                self.params[self._method][param] = change["new"]
                self.replot_peaks()

            t.observe(on_bool_change, names="value")

            children = (p, t)

        elif isinstance(value, float):
            from ipywidgets import FloatSlider, FloatText, BoundedFloatText, Label
            from traitlets import link

            p = Label(value=param, layout=Layout(flex="0 1 auto", width="10%"))
            b = BoundedFloatText(
                value=0,
                min=1e-10,
                layout=Layout(flex="0 1 auto", width="10%"),
                font_weight="bold",
            )
            a = FloatText(value=2 * value,
                          layout=Layout(flex="0 1 auto", width="10%"))
            f = FloatSlider(
                value=value,
                min=b.value,
                max=a.value,
                step=np.abs(a.value - b.value) * 0.01,
                layout=Layout(flex="1 1 auto", width="60%"),
            )
            lbl = FloatText(
                value=f.value,
                layout=Layout(flex="0 1 auto", width="10%"),
                disabled=True,
            )
            link((f, "value"), (lbl, "value"))

            def on_min_change(change):
                if f.max > change["new"]:
                    f.min = change["new"]
                    f.step = np.abs(f.max - f.min) * 0.01

            def on_max_change(change):
                if f.min < change["new"]:
                    f.max = change["new"]
                    f.step = np.abs(f.max - f.min) * 0.01

            def on_param_change(change):
                self.params[self._method][param] = change["new"]
                self.replot_peaks()

            b.observe(on_min_change, names="value")
            f.observe(on_param_change, names="value")
            a.observe(on_max_change, names="value")
            children = (p, lbl, b, f, a)

        elif isinstance(value, int):
            from ipywidgets import IntSlider, IntText, BoundedIntText, Label
            from traitlets import link

            p = Label(value=param, layout=Layout(flex="0 1 auto", width="10%"))
            b = BoundedIntText(
                value=0,
                min=1e-10,
                layout=Layout(flex="0 1 auto", width="10%"),
                font_weight="bold",
            )
            a = IntText(value=2 * value,
                        layout=Layout(flex="0 1 auto", width="10%"))
            f = IntSlider(
                value=value,
                min=b.value,
                max=a.value,
                step=1,
                layout=Layout(flex="1 1 auto", width="60%"),
            )
            lbl = IntText(
                value=f.value,
                layout=Layout(flex="0 1 auto", width="10%"),
                disabled=True,
            )
            link((f, "value"), (lbl, "value"))

            def on_min_change(change):
                if f.max > change["new"]:
                    f.min = change["new"]
                    f.step = 1

            def on_max_change(change):
                if f.min < change["new"]:
                    f.max = change["new"]
                    f.step = 1

            def on_param_change(change):
                self.params[self._method][param] = change["new"]
                self.replot_peaks()

            b.observe(on_min_change, names="value")
            f.observe(on_param_change, names="value")
            a.observe(on_max_change, names="value")
            children = (p, lbl, b, f, a)
        container = HBox(children)
        return container
Example #5
0
    def __init__(self):

        self.output_dir = '.'
        #        self.output_dir = 'tmpdir'

        # self.fig = plt.figure(figsize=(7.2,6))  # this strange figsize results in a ~square contour plot

        # initial value
        self.field_index = 4
        # self.field_index = self.mcds_field.value + 4

        tab_height = '500px'
        constWidth = '180px'
        constWidth2 = '150px'
        tab_layout = Layout(
            width='900px',  # border='2px solid black',
            height=tab_height,
        )  #overflow_y='scroll')

        max_frames = 1
        self.mcds_plot = interactive(self.plot_substrate,
                                     frame=(0, max_frames),
                                     continuous_update=False)
        svg_plot_size = '700px'
        self.mcds_plot.layout.width = svg_plot_size
        self.mcds_plot.layout.height = svg_plot_size

        self.max_frames = BoundedIntText(
            min=0,
            max=99999,
            value=max_frames,
            description='Max',
            layout=Layout(width='160px'),
        )
        self.max_frames.observe(self.update_max_frames)

        self.field_min_max = {'dummy': [0., 1.]}
        # hacky I know, but make a dict that's got (key,value) reversed from the dict in the Dropdown below
        self.field_dict = {0: 'dummy'}

        self.mcds_field = Dropdown(
            options={'dummy': 0},
            value=0,
            #     description='Field',
            layout=Layout(width=constWidth))
        # print("substrate __init__: self.mcds_field.value=",self.mcds_field.value)
        #        self.mcds_field.observe(self.mcds_field_cb)
        self.mcds_field.observe(self.mcds_field_changed_cb)

        # self.field_cmap = Text(
        #     value='viridis',
        #     description='Colormap',
        #     disabled=True,
        #     layout=Layout(width=constWidth),
        # )
        self.field_cmap = Dropdown(
            options=['viridis', 'jet', 'YlOrRd'],
            value='viridis',
            #     description='Field',
            layout=Layout(width=constWidth))
        #self.field_cmap.observe(self.plot_substrate)
        #        self.field_cmap.observe(self.plot_substrate)
        self.field_cmap.observe(self.mcds_field_cb)

        self.cmap_fixed = Checkbox(
            description='Fix',
            disabled=False,
            #           layout=Layout(width=constWidth2),
        )

        self.save_min_max = Button(
            description='Save',  #style={'description_width': 'initial'},
            button_style=
            'success',  # 'success', 'info', 'warning', 'danger' or ''
            tooltip='Save min/max for this substrate',
            disabled=True,
            layout=Layout(width='90px'))

        def save_min_max_cb(b):
            #            field_name = self.mcds_field.options[]
            #            field_name = next(key for key, value in self.mcds_field.options.items() if value == self.mcds_field.value)
            field_name = self.field_dict[self.mcds_field.value]
            #            print(field_name)
            #            self.field_min_max = {'oxygen': [0., 30.], 'glucose': [0., 1.], 'H+ ions': [0., 1.], 'ECM': [0., 1.], 'NP1': [0., 1.], 'NP2': [0., 1.]}
            self.field_min_max[field_name][0] = self.cmap_min.value
            self.field_min_max[field_name][1] = self.cmap_max.value
#            print(self.field_min_max)

        self.save_min_max.on_click(save_min_max_cb)

        self.cmap_min = FloatText(
            description='Min',
            value=0,
            step=0.1,
            disabled=True,
            layout=Layout(width=constWidth2),
        )
        self.cmap_min.observe(self.mcds_field_cb)

        self.cmap_max = FloatText(
            description='Max',
            value=38,
            step=0.1,
            disabled=True,
            layout=Layout(width=constWidth2),
        )
        self.cmap_max.observe(self.mcds_field_cb)

        def cmap_fixed_cb(b):
            if (self.cmap_fixed.value):
                self.cmap_min.disabled = False
                self.cmap_max.disabled = False
                self.save_min_max.disabled = False
            else:
                self.cmap_min.disabled = True
                self.cmap_max.disabled = True
                self.save_min_max.disabled = True
#            self.mcds_field_cb()

        self.cmap_fixed.observe(cmap_fixed_cb)

        field_cmap_row2 = HBox([self.field_cmap, self.cmap_fixed])

        #        field_cmap_row3 = HBox([self.save_min_max, self.cmap_min, self.cmap_max])
        items_auto = [
            self.save_min_max,  #layout=Layout(flex='3 1 auto', width='auto'),
            self.cmap_min,
            self.cmap_max,
        ]
        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='80%')
        field_cmap_row3 = Box(children=items_auto, layout=box_layout)

        #        field_cmap_row3 = Box([self.save_min_max, self.cmap_min, self.cmap_max])

        # mcds_tab = widgets.VBox([mcds_dir, mcds_plot, mcds_play], layout=tab_layout)
        mcds_params = VBox([
            self.mcds_field, field_cmap_row2, field_cmap_row3, self.max_frames
        ])  # mcds_dir
        #        mcds_params = VBox([self.mcds_field, field_cmap_row2, field_cmap_row3,])  # mcds_dir

        #        self.tab = HBox([mcds_params, self.mcds_plot], layout=tab_layout)
        #        self.tab = HBox([mcds_params, self.mcds_plot])

        help_label = Label('select slider: drag or left/right arrows')
        row1 = Box([
            help_label,
            Box([self.max_frames, self.mcds_field, self.field_cmap],
                layout=Layout(border='0px solid black',
                              width='50%',
                              height='',
                              align_items='stretch',
                              flex_direction='row',
                              display='flex'))
        ])
        row2 = Box([self.cmap_fixed, self.cmap_min, self.cmap_max],
                   layout=Layout(border='0px solid black',
                                 width='50%',
                                 height='',
                                 align_items='stretch',
                                 flex_direction='row',
                                 display='flex'))
        self.tab = VBox([row1, row2, self.mcds_plot])
Example #6
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}

        param_name1 = Button(description='tumor_radius',
                             disabled=True,
                             layout=name_button_layout)
        param_name1.style.button_color = 'lightgreen'

        self.tumor_radius = FloatText(value=250.0,
                                      step=10,
                                      style=style,
                                      layout=widget_layout)

        param_name2 = Button(description='oncoprotein_mean',
                             disabled=True,
                             layout=name_button_layout)
        param_name2.style.button_color = 'tan'

        self.oncoprotein_mean = FloatText(value=1.0,
                                          step=0.1,
                                          style=style,
                                          layout=widget_layout)

        param_name3 = Button(description='oncoprotein_sd',
                             disabled=True,
                             layout=name_button_layout)
        param_name3.style.button_color = 'lightgreen'

        self.oncoprotein_sd = FloatText(value=0.25,
                                        step=0.01,
                                        style=style,
                                        layout=widget_layout)

        param_name4 = Button(description='oncoprotein_min',
                             disabled=True,
                             layout=name_button_layout)
        param_name4.style.button_color = 'tan'

        self.oncoprotein_min = FloatText(value=0.0,
                                         step=0.01,
                                         style=style,
                                         layout=widget_layout)

        param_name5 = Button(description='oncoprotein_max',
                             disabled=True,
                             layout=name_button_layout)
        param_name5.style.button_color = 'lightgreen'

        self.oncoprotein_max = FloatText(value=2,
                                         step=0.1,
                                         style=style,
                                         layout=widget_layout)

        param_name6 = Button(description='random_seed',
                             disabled=True,
                             layout=name_button_layout)
        param_name6.style.button_color = 'tan'

        self.random_seed = IntText(value=0,
                                   step=1,
                                   style=style,
                                   layout=widget_layout)

        units_button1 = Button(description='micron',
                               disabled=True,
                               layout=units_button_layout)
        units_button1.style.button_color = 'lightgreen'
        units_button2 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button2.style.button_color = 'tan'
        units_button3 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button3.style.button_color = 'lightgreen'
        units_button4 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button4.style.button_color = 'tan'
        units_button5 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button5.style.button_color = 'lightgreen'
        units_button6 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button6.style.button_color = 'tan'

        desc_button1 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button1.style.button_color = 'lightgreen'
        desc_button2 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button2.style.button_color = 'tan'
        desc_button3 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button3.style.button_color = 'lightgreen'
        desc_button4 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button4.style.button_color = 'tan'
        desc_button5 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button6.style.button_color = 'tan'

        row1 = [param_name1, self.tumor_radius, units_button1, desc_button1]
        row2 = [
            param_name2, self.oncoprotein_mean, units_button2, desc_button2
        ]
        row3 = [param_name3, self.oncoprotein_sd, units_button3, desc_button3]
        row4 = [param_name4, self.oncoprotein_min, units_button4, desc_button4]
        row5 = [param_name5, self.oncoprotein_max, units_button5, desc_button5]
        row6 = [param_name6, self.random_seed, units_button6, desc_button6]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)

        self.tab = VBox([
            box1,
            box2,
            box3,
            box4,
            box5,
            box6,
        ])
Example #7
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        label_domain = Label('Domain (micron):')
        stepsize = 10
        self.xmin = FloatText(
            step=stepsize,
            # description='$X_{min}$',
            description='Xmin',
            layout=Layout(width=constWidth),
        )
        self.ymin = FloatText(
            step=stepsize,
            description='Ymin',
            layout=Layout(width=constWidth),
        )
        self.zmin = FloatText(
            step=stepsize,
            description='Zmin',
            layout=Layout(width=constWidth),
        )
        self.xmax = FloatText(
            step=stepsize,
            description='Xmax',
            layout=Layout(width=constWidth),
        )
        self.ymax = FloatText(
            step=stepsize,
            description='Ymax',
            layout=Layout(width=constWidth),
        )
        self.zmax = FloatText(
            step=stepsize,
            description='Zmax',
            layout=Layout(width=constWidth),
        )
        #            description='$Time_{max}$',
        self.tmax = BoundedFloatText(
            min=0.,
            max=100000000,
            step=stepsize,
            description='Max Time',
            layout=Layout(width=constWidth),
        )
        self.xdelta = BoundedFloatText(
            min=1.,
            description='dx',  # '∆x',  # Mac: opt-j for delta
            layout=Layout(width=constWidth),
        )
        self.ydelta = BoundedFloatText(
            min=1.,
            description='dy',
            layout=Layout(width=constWidth),
        )
        self.zdelta = BoundedFloatText(
            min=1.,
            description='dz',
            layout=Layout(width=constWidth),
        )

        x_row = HBox([self.xmin, self.xmax, self.xdelta])
        y_row = HBox([self.ymin, self.ymax, self.ydelta])
        z_row = HBox([self.zmin, self.zmax, self.zdelta])

        self.omp_threads = BoundedIntText(
            min=1,
            description='# threads',
            layout=Layout(width=constWidth),
        )
        self.toggle_svg = Checkbox(
            description='Cells',  # SVG
            layout=Layout(width='150px'))  # constWidth = '180px'
        self.svg_interval = BoundedIntText(
            min=1,
            max=
            99999999,  # TODO: set max on all Bounded to avoid unwanted default
            description='every',
            layout=Layout(width='160px'),
        )

        def toggle_svg_cb(b):
            if (self.toggle_svg.value):
                # self.svg_t0.disabled = False
                self.svg_interval.disabled = False
            else:
                # self.svg_t0.disabled = True
                self.svg_interval.disabled = True

        self.toggle_svg.observe(toggle_svg_cb)

        self.toggle_mcds = Checkbox(
            description='Subtrates',  # Full
            layout=Layout(width='180px'),
        )
        self.mcds_interval = BoundedIntText(
            min=0,
            max=99999999,
            description='every',
            layout=Layout(width='160px'),
        )

        def toggle_mcds_cb(b):
            if (self.toggle_mcds.value):
                self.mcds_interval.disabled = False
            else:
                self.mcds_interval.disabled = True

        self.toggle_mcds.observe(toggle_mcds_cb)

        svg_mat_output_row = HBox([
            Label('Plots:'), self.toggle_svg,
            HBox([self.svg_interval, Label('min')]), self.toggle_mcds,
            HBox([self.mcds_interval, Label('min')])
        ])

        label_blankline = Label('')

        label_substrates = Label('Substrates:')
        self.substrate = []
        self.diffusion_coef = []
        self.decay_rate = []

        width_cell_params_units = '510px'
        width_cell_params_units = '380px'
        disable_substrates_flag = False

        self.substrate.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    step=0.1,
                    disabled=True,
                    value=38,
                    description='o2: ',
                    layout=Layout(width=constWidth),
                ),
                Label('mmHg')
            ],
                 layout=Layout(width=width_cell_params_units)))
        self.substrate.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    step=0.1,
                    disabled=True,
                    value=1,
                    description='Glc: ',
                    layout=Layout(width=constWidth),
                ),
            ],
                 layout=Layout(width=width_cell_params_units)))
        self.substrate.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    step=0.1,
                    disabled=True,
                    value=7.25,
                    description='H+: ',
                    layout=Layout(width=constWidth),
                ),
                Label('pH')
            ],
                 layout=Layout(width=width_cell_params_units)))
        self.substrate.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    step=0.1,
                    disabled=True,
                    value=1.0,
                    description='ECM: ',
                    layout=Layout(width=constWidth),
                ),
            ],
                 layout=Layout(width=width_cell_params_units)))

        width_cell_params_units = '450px'
        width_cell_params_units = '400px'
        self.diffusion_coef.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    max=999999,
                    step=10.0,
                    description='diffusion coef',
                    disabled=disable_substrates_flag,
                    layout=Layout(width=constWidth),
                ),
                Label('micron^2/min')
            ],
                 layout=Layout(width=width_cell_params_units)))
        self.diffusion_coef.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    max=999999,
                    step=10.0,
                    description='diffusion coef',
                    disabled=disable_substrates_flag,
                    layout=Layout(width=constWidth),
                ),
                Label('micron^2/min')
            ],
                 layout=Layout(width=width_cell_params_units)))
        self.diffusion_coef.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    max=999999,
                    step=10.0,
                    description='diffusion coef',
                    disabled=disable_substrates_flag,
                    layout=Layout(width=constWidth),
                ),
                Label('micron^2/min')
            ],
                 layout=Layout(width=width_cell_params_units)))

        width_cell_params_units = '400px'
        width_cell_params_units = '380px'
        self.decay_rate.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    step=0.01,
                    description='decay rate',
                    disabled=disable_substrates_flag,
                    layout=Layout(width=constWidth),
                ),
                Label('1/min')
            ],
                 layout=Layout(width=width_cell_params_units)))
        self.decay_rate.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    step=0.00001,
                    description='decay rate',
                    disabled=disable_substrates_flag,
                    layout=Layout(width=constWidth),
                ),
                Label('1/min')
            ],
                 layout=Layout(width=width_cell_params_units)))
        self.decay_rate.append(
            HBox([
                BoundedFloatText(
                    min=0,
                    step=0.01,
                    description='decay rate',
                    disabled=disable_substrates_flag,
                    layout=Layout(width=constWidth),
                ),
                Label('1/min')
            ],
                 layout=Layout(width=width_cell_params_units)))

        box_layout = Layout(border='1px solid')
        domain_box = VBox([label_domain, x_row, y_row, z_row],
                          layout=box_layout)
        substrates_box = VBox([
            label_substrates,
            HBox([
                self.substrate[0], self.diffusion_coef[0], self.decay_rate[0]
            ]),
            HBox([
                self.substrate[1], self.diffusion_coef[1], self.decay_rate[1]
            ]),
            HBox([
                self.substrate[2], self.diffusion_coef[2], self.decay_rate[2]
            ])
        ],
                              layout=box_layout)

        self.tab = VBox([
            domain_box,
            HBox([self.tmax, Label('min')]),
            self.omp_threads,
            svg_mat_output_row,
        ])  # output_dir, toggle_2D_seed_
Example #8
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}

        param_name1 = Button(description='random_seed',
                             disabled=True,
                             layout=name_button_layout)
        param_name1.style.button_color = 'tan'

        self.random_seed = IntText(value=0,
                                   step=1,
                                   style=style,
                                   layout=widget_layout)

        param_name2 = Button(description='motile_cell_persistence_time',
                             disabled=True,
                             layout=name_button_layout)
        param_name2.style.button_color = 'tan'

        self.motile_cell_persistence_time = FloatText(value=15,
                                                      step=1,
                                                      style=style,
                                                      layout=widget_layout)

        param_name3 = Button(description='motile_cell_migration_speed',
                             disabled=True,
                             layout=name_button_layout)
        param_name3.style.button_color = 'tan'

        self.motile_cell_migration_speed = FloatText(value=0.5,
                                                     step=0.1,
                                                     style=style,
                                                     layout=widget_layout)

        param_name4 = Button(description='motile_cell_relative_adhesion',
                             disabled=True,
                             layout=name_button_layout)
        param_name4.style.button_color = 'tan'

        self.motile_cell_relative_adhesion = FloatText(value=0.05,
                                                       step=0.01,
                                                       style=style,
                                                       layout=widget_layout)

        param_name5 = Button(description='motile_cell_apoptosis_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name5.style.button_color = 'tan'

        self.motile_cell_apoptosis_rate = FloatText(value=0.0,
                                                    step=0.01,
                                                    style=style,
                                                    layout=widget_layout)

        param_name6 = Button(
            description='motile_cell_relative_cycle_entry_rate',
            disabled=True,
            layout=name_button_layout)
        param_name6.style.button_color = 'tan'

        self.motile_cell_relative_cycle_entry_rate = FloatText(
            value=0.1, step=0.01, style=style, layout=widget_layout)

        param_name7 = Button(description='birth_interval',
                             disabled=True,
                             layout=name_button_layout)
        param_name7.style.button_color = 'tan'

        self.birth_interval = FloatText(value=60,
                                        step=1,
                                        style=style,
                                        layout=widget_layout)

        param_name8 = Button(description='volume_total',
                             disabled=True,
                             layout=name_button_layout)
        param_name8.style.button_color = 'tan'

        self.volume_total = FloatText(value=1,
                                      step=0.1,
                                      style=style,
                                      layout=widget_layout)

        param_name9 = Button(description='target_fluid_frac',
                             disabled=True,
                             layout=name_button_layout)
        param_name9.style.button_color = 'tan'

        self.target_fluid_frac = FloatText(value=0.75,
                                           step=0.1,
                                           style=style,
                                           layout=widget_layout)

        param_name10 = Button(description='fluid_change_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name10.style.button_color = 'tan'

        self.fluid_change_rate = FloatText(value=0.15,
                                           step=0.01,
                                           style=style,
                                           layout=widget_layout)

        param_name11 = Button(description='cytoplasmic_biomass_change_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name11.style.button_color = 'tan'

        self.cytoplasmic_biomass_change_rate = FloatText(value=0.15,
                                                         step=0.01,
                                                         style=style,
                                                         layout=widget_layout)

        units_button1 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button1.style.button_color = 'tan'
        units_button2 = Button(description='min',
                               disabled=True,
                               layout=units_button_layout)
        units_button2.style.button_color = 'tan'
        units_button3 = Button(description='micron/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button3.style.button_color = 'tan'
        units_button4 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button4.style.button_color = 'tan'
        units_button5 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button5.style.button_color = 'tan'
        units_button6 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button6.style.button_color = 'tan'
        units_button7 = Button(description='min',
                               disabled=True,
                               layout=units_button_layout)
        units_button7.style.button_color = 'tan'
        units_button8 = Button(description='micron^3',
                               disabled=True,
                               layout=units_button_layout)
        units_button8.style.button_color = 'tan'
        units_button9 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button9.style.button_color = 'tan'
        units_button10 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button10.style.button_color = 'tan'
        units_button11 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button11.style.button_color = 'tan'

        row0 = [
            param_name1,
            self.random_seed,
            units_button1,
        ]
        row0 = [
            param_name2,
            self.motile_cell_persistence_time,
            units_button2,
        ]
        row0 = [
            param_name3,
            self.motile_cell_migration_speed,
            units_button3,
        ]
        row0 = [
            param_name4,
            self.motile_cell_relative_adhesion,
            units_button4,
        ]
        row0 = [
            param_name5,
            self.motile_cell_apoptosis_rate,
            units_button5,
        ]
        row0 = [
            param_name6,
            self.motile_cell_relative_cycle_entry_rate,
            units_button6,
        ]
        row0 = [
            param_name7,
            self.birth_interval,
            units_button7,
        ]
        row0 = [
            param_name8,
            self.volume_total,
            units_button8,
        ]
        row0 = [
            param_name9,
            self.target_fluid_frac,
            units_button9,
        ]
        row0 = [
            param_name10,
            self.fluid_change_rate,
            units_button10,
        ]
        row0 = [
            param_name11,
            self.cytoplasmic_biomass_change_rate,
            units_button11,
        ]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)
        box0 = Box(children=row0, layout=box_layout)

        self.tab = VBox([
            box0,
            box0,
            box0,
            box0,
            box0,
            box0,
            box0,
            box0,
            box0,
            box0,
            box0,
        ])
    def __init__(self):
        
        micron_units = Label('micron')   # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout={'width':'25%'}
        widget_layout = {'width': '15%'}
        widget2_layout = {'width': '10%'}
        units_button_layout ={'width':'15%'}
        desc_button_layout={'width':'45%'}
        divider_button_layout={'width':'40%'}

        div_row1 = Button(description='---Initial Parameters---', disabled=True, layout=divider_button_layout)

        param_name1 = Button(description='seeding_method', disabled=True, layout=name_button_layout)
        param_name1.style.button_color = 'tan'

        self.seeding_method = IntText(
          value=1,
          step=0.1,
          style=style, layout=widget_layout)

        div_row2 = Button(description='---Transition Rates---', disabled=True, layout=divider_button_layout)

        param_name2 = Button(description='r01', disabled=True, layout=name_button_layout)
        param_name2.style.button_color = 'lightgreen'

        self.r01 = FloatText(
          value=0.01666,
          step=0.001,
          style=style, layout=widget_layout)

        param_name3 = Button(description='r01_fixed_duration', disabled=True, layout=name_button_layout)
        param_name3.style.button_color = 'tan'

        self.r01_fixed_duration = Checkbox(
          value=False,
          style=style, layout=widget_layout)

        param_name4 = Button(description='r12', disabled=True, layout=name_button_layout)
        param_name4.style.button_color = 'lightgreen'

        self.r12 = FloatText(
          value=0.01666,
          step=0.001,
          style=style, layout=widget_layout)

        param_name5 = Button(description='r12_fixed_duration', disabled=True, layout=name_button_layout)
        param_name5.style.button_color = 'tan'

        self.r12_fixed_duration = Checkbox(
          value=False,
          style=style, layout=widget_layout)

        param_name6 = Button(description='r23', disabled=True, layout=name_button_layout)
        param_name6.style.button_color = 'lightgreen'

        self.r23 = FloatText(
          value=0.01666,
          step=0.001,
          style=style, layout=widget_layout)

        param_name7 = Button(description='r23_fixed_duration', disabled=True, layout=name_button_layout)
        param_name7.style.button_color = 'tan'

        self.r23_fixed_duration = Checkbox(
          value=False,
          style=style, layout=widget_layout)

        param_name8 = Button(description='r30', disabled=True, layout=name_button_layout)
        param_name8.style.button_color = 'lightgreen'

        self.r30 = FloatText(
          value=0.01666,
          step=0.001,
          style=style, layout=widget_layout)

        param_name9 = Button(description='r30_fixed_duration', disabled=True, layout=name_button_layout)
        param_name9.style.button_color = 'tan'

        self.r30_fixed_duration = Checkbox(
          value=False,
          style=style, layout=widget_layout)

        div_row3 = Button(description='---Arresting phase link between G0/G1 and S---', disabled=True, layout=divider_button_layout)

        param_name10 = Button(description='r01_arrest', disabled=True, layout=name_button_layout)
        param_name10.style.button_color = 'lightgreen'

        self.r01_arrest = Checkbox(
          value=False,
          style=style, layout=widget_layout)

        param_name11 = Button(description='oxygen_threshold', disabled=True, layout=name_button_layout)
        param_name11.style.button_color = 'tan'

        self.oxygen_threshold = FloatText(
          value=24,
          step=1,
          style=style, layout=widget_layout)

        param_name12 = Button(description='oxygen_gradient', disabled=True, layout=name_button_layout)
        param_name12.style.button_color = 'lightgreen'

        self.oxygen_gradient = Checkbox(
          value=False,
          style=style, layout=widget_layout)

        div_row4 = Button(description='---Arresting phase link between S and G2---', disabled=True, layout=divider_button_layout)

        param_name13 = Button(description='r12_arrest', disabled=True, layout=name_button_layout)
        param_name13.style.button_color = 'tan'

        self.r12_arrest = Checkbox(
          value=False,
          style=style, layout=widget_layout)

        param_name14 = Button(description='chemokine_threshold', disabled=True, layout=name_button_layout)
        param_name14.style.button_color = 'lightgreen'

        self.chemokine_threshold = FloatText(
          value=10.0,
          step=1,
          style=style, layout=widget_layout)

        div_row5 = Button(description='---Arresting phase link between G2 an M---', disabled=True, layout=divider_button_layout)

        param_name15 = Button(description='r23_arrest', disabled=True, layout=name_button_layout)
        param_name15.style.button_color = 'tan'

        self.r23_arrest = Checkbox(
          value=False,
          style=style, layout=widget_layout)

        param_name16 = Button(description='pressure_threshold', disabled=True, layout=name_button_layout)
        param_name16.style.button_color = 'lightgreen'

        self.pressure_threshold = FloatText(
          value=1.0,
          step=0.1,
          style=style, layout=widget_layout)

        div_row6 = Button(description='---Arresting phase link between M an G0/G1 (division)---', disabled=True, layout=divider_button_layout)

        param_name17 = Button(description='r30_arrest', disabled=True, layout=name_button_layout)
        param_name17.style.button_color = 'tan'

        self.r30_arrest = Checkbox(
          value=False,
          style=style, layout=widget_layout)

        param_name18 = Button(description='volume_threshold', disabled=True, layout=name_button_layout)
        param_name18.style.button_color = 'lightgreen'

        self.volume_threshold = FloatText(
          value=2490.0,
          step=100,
          style=style, layout=widget_layout)

        units_button1 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button1.style.button_color = 'lightgreen'
        units_button2 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button2.style.button_color = 'tan'
        units_button3 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button3.style.button_color = 'tan'
        units_button4 = Button(description='1/min', disabled=True, layout=units_button_layout) 
        units_button4.style.button_color = 'lightgreen'
        units_button5 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button5.style.button_color = 'tan'
        units_button6 = Button(description='1/min', disabled=True, layout=units_button_layout) 
        units_button6.style.button_color = 'lightgreen'
        units_button7 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button7.style.button_color = 'tan'
        units_button8 = Button(description='1/min', disabled=True, layout=units_button_layout) 
        units_button8.style.button_color = 'lightgreen'
        units_button9 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button9.style.button_color = 'tan'
        units_button10 = Button(description='1/min', disabled=True, layout=units_button_layout) 
        units_button10.style.button_color = 'lightgreen'
        units_button11 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button11.style.button_color = 'tan'
        units_button12 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button12.style.button_color = 'tan'
        units_button13 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button13.style.button_color = 'lightgreen'
        units_button14 = Button(description='mmHg', disabled=True, layout=units_button_layout) 
        units_button14.style.button_color = 'tan'
        units_button15 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button15.style.button_color = 'lightgreen'
        units_button16 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button16.style.button_color = 'lightgreen'
        units_button17 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button17.style.button_color = 'tan'
        units_button18 = Button(description='mM', disabled=True, layout=units_button_layout) 
        units_button18.style.button_color = 'lightgreen'
        units_button19 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button19.style.button_color = 'lightgreen'
        units_button20 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button20.style.button_color = 'tan'
        units_button21 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button21.style.button_color = 'lightgreen'
        units_button22 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button22.style.button_color = 'lightgreen'
        units_button23 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button23.style.button_color = 'tan'
        units_button24 = Button(description='micron^3', disabled=True, layout=units_button_layout) 
        units_button24.style.button_color = 'lightgreen'

        desc_button2 = Button(description='For seeding one cell => 1, For tissue seeding => 2' , tooltip='For seeding one cell => 1, For tissue seeding => 2', disabled=True, layout=desc_button_layout) 
        desc_button2.style.button_color = 'tan'
        desc_button3 = Button(description='transition rate between G0/G1 and S' , tooltip='transition rate between G0/G1 and S', disabled=True, layout=desc_button_layout) 
        desc_button3.style.button_color = 'lightgreen'
        desc_button4 = Button(description='True if transition rate (r01) are fixed duration.' , tooltip='True if transition rate (r01) are fixed duration.', disabled=True, layout=desc_button_layout) 
        desc_button4.style.button_color = 'tan'
        desc_button5 = Button(description='transition rate between S and G2' , tooltip='transition rate between S and G2', disabled=True, layout=desc_button_layout) 
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(description='True if transition rate (r12) are fixed duration.' , tooltip='True if transition rate (r12) are fixed duration.', disabled=True, layout=desc_button_layout) 
        desc_button6.style.button_color = 'tan'
        desc_button7 = Button(description='transition rate between G2 and M' , tooltip='transition rate between G2 and M', disabled=True, layout=desc_button_layout) 
        desc_button7.style.button_color = 'lightgreen'
        desc_button8 = Button(description='True if transition rate (r23) are fixed duration.' , tooltip='True if transition rate (r23) are fixed duration.', disabled=True, layout=desc_button_layout) 
        desc_button8.style.button_color = 'tan'
        desc_button9 = Button(description='transition rate between M and G0/G1' , tooltip='transition rate between M and G0/G1', disabled=True, layout=desc_button_layout) 
        desc_button9.style.button_color = 'lightgreen'
        desc_button10 = Button(description='True if transition rate (r30) are fixed duration.' , tooltip='True if transition rate (r30) are fixed duration.', disabled=True, layout=desc_button_layout) 
        desc_button10.style.button_color = 'tan'
        desc_button11 = Button(description='if true and conditions were matched, it arrests phase link.' , tooltip='if true and conditions were matched, it arrests phase link.', disabled=True, layout=desc_button_layout) 
        desc_button11.style.button_color = 'lightgreen'
        desc_button12 = Button(description='environmental oxygen threshold for phase transition. If less than threshold, it stops' , tooltip='environmental oxygen threshold for phase transition. If less than threshold, it stops', disabled=True, layout=desc_button_layout) 
        desc_button12.style.button_color = 'tan'
        desc_button13 = Button(description='True, if environment has oxygen gradient' , tooltip='True, if environment has oxygen gradient', disabled=True, layout=desc_button_layout) 
        desc_button13.style.button_color = 'lightgreen'
        desc_button14 = Button(description='arrest function according to chemokine level' , tooltip='arrest function according to chemokine level', disabled=True, layout=desc_button_layout) 
        desc_button14.style.button_color = 'tan'
        desc_button15 = Button(description='environmental chemokine threshold for phase transition. If more, it stops' , tooltip='environmental chemokine threshold for phase transition. If more, it stops', disabled=True, layout=desc_button_layout) 
        desc_button15.style.button_color = 'lightgreen'
        desc_button16 = Button(description='arrest function according to pressure level' , tooltip='arrest function according to pressure level', disabled=True, layout=desc_button_layout) 
        desc_button16.style.button_color = 'tan'
        desc_button17 = Button(description='cell pressure threshold to stall this phase transition. If more, it stops' , tooltip='cell pressure threshold to stall this phase transition. If more, it stops', disabled=True, layout=desc_button_layout) 
        desc_button17.style.button_color = 'lightgreen'
        desc_button18 = Button(description='arrest function according to cell volume' , tooltip='arrest function according to cell volume', disabled=True, layout=desc_button_layout) 
        desc_button18.style.button_color = 'tan'
        desc_button19 = Button(description='target cell volume threshold. If less, it does not cycle.' , tooltip='target cell volume threshold. If less, it does not cycle.', disabled=True, layout=desc_button_layout) 
        desc_button19.style.button_color = 'lightgreen'

        row2 = [param_name1, self.seeding_method, units_button2, desc_button2] 
        row3 = [param_name2, self.r01, units_button4, desc_button3] 
        row4 = [param_name3, self.r01_fixed_duration, units_button5, desc_button4] 
        row5 = [param_name4, self.r12, units_button6, desc_button5] 
        row6 = [param_name5, self.r12_fixed_duration, units_button7, desc_button6] 
        row7 = [param_name6, self.r23, units_button8, desc_button7] 
        row8 = [param_name7, self.r23_fixed_duration, units_button9, desc_button8] 
        row9 = [param_name8, self.r30, units_button10, desc_button9] 
        row10 = [param_name9, self.r30_fixed_duration, units_button11, desc_button10] 
        row11 = [param_name10, self.r01_arrest, units_button13, desc_button11] 
        row12 = [param_name11, self.oxygen_threshold, units_button14, desc_button12] 
        row13 = [param_name12, self.oxygen_gradient, units_button15, desc_button13] 
        row14 = [param_name13, self.r12_arrest, units_button17, desc_button14] 
        row15 = [param_name14, self.chemokine_threshold, units_button18, desc_button15] 
        row16 = [param_name15, self.r23_arrest, units_button20, desc_button16] 
        row17 = [param_name16, self.pressure_threshold, units_button21, desc_button17] 
        row18 = [param_name17, self.r30_arrest, units_button23, desc_button18] 
        row19 = [param_name18, self.volume_threshold, units_button24, desc_button19] 

        box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%')
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)
        box9 = Box(children=row9, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)
        box11 = Box(children=row11, layout=box_layout)
        box12 = Box(children=row12, layout=box_layout)
        box13 = Box(children=row13, layout=box_layout)
        box14 = Box(children=row14, layout=box_layout)
        box15 = Box(children=row15, layout=box_layout)
        box16 = Box(children=row16, layout=box_layout)
        box17 = Box(children=row17, layout=box_layout)
        box18 = Box(children=row18, layout=box_layout)
        box19 = Box(children=row19, layout=box_layout)

        self.tab = VBox([
          div_row1,
          box2,
          div_row2,
          box3,
          box4,
          box5,
          box6,
          box7,
          box8,
          box9,
          box10,
          div_row3,
          box11,
          box12,
          box13,
          div_row4,
          box14,
          box15,
          div_row5,
          box16,
          box17,
          div_row6,
          box18,
          box19,
        ])
Example #10
0
    def __init__(self):

        #        micron_units = HTMLMath(value=r"$\mu M$")
        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)
        #        micron_units = Label('microns')   # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        # tab_height = '400px'
        tab_height = '500px'
        #        tab_layout = Layout(width='900px',   # border='2px solid black',
        #        tab_layout = Layout(width='850px',   # border='2px solid black',
        #                            height=tab_height, overflow_y='scroll',)
        #        np_tab_layout = Layout(width='800px',  # border='2px solid black',
        #                               height='350px', overflow_y='scroll',)

        # my_domain = [0,0,-10, 2000,2000,10, 20,20,20]  # [x,y,zmin,  x,y,zmax, x,y,zdelta]
        #        label_domain = Label('Domain ($\mu M$):')
        label_domain = Label('Domain (micron):')
        stepsize = 10
        disable_domain = False
        self.xmin = FloatText(
            step=stepsize,
            # description='$X_{min}$',
            description='Xmin',
            disabled=disable_domain,
            layout=Layout(width=constWidth),
        )
        self.ymin = FloatText(
            step=stepsize,
            description='Ymin',
            disabled=disable_domain,
            layout=Layout(width=constWidth),
        )
        self.zmin = FloatText(
            step=stepsize,
            description='Zmin',
            disabled=disable_domain,
            layout=Layout(width=constWidth),
        )
        self.xmax = FloatText(
            step=stepsize,
            description='Xmax',
            disabled=disable_domain,
            layout=Layout(width=constWidth),
        )
        self.ymax = FloatText(
            step=stepsize,
            description='Ymax',
            disabled=disable_domain,
            layout=Layout(width=constWidth),
        )
        self.zmax = FloatText(
            step=stepsize,
            description='Zmax',
            disabled=disable_domain,
            layout=Layout(width=constWidth),
        )
        #            description='$Time_{max}$',
        self.tmax = BoundedFloatText(
            min=0.,
            max=100000000,
            step=stepsize,
            description='Max Time',
            layout=Layout(width=constWidth),
        )
        self.xdelta = BoundedFloatText(
            min=1.,
            description='dx',  # '∆x',  # Mac: opt-j for delta
            disabled=disable_domain,
            layout=Layout(width=constWidth),
        )
        self.ydelta = BoundedFloatText(
            min=1.,
            description='dy',
            disabled=disable_domain,
            layout=Layout(width=constWidth),
        )
        self.zdelta = BoundedFloatText(
            min=1.,
            description='dz',
            disabled=disable_domain,
            layout=Layout(width=constWidth),
        )
        """
        self.tdelta = BoundedFloatText(
            min=0.01,
            description='$Time_{delta}$',
            layout=Layout(width=constWidth),
        )
        """
        """
        self.toggle2D = Checkbox(
            description='2-D',
            layout=Layout(width=constWidth),
        )
        def toggle2D_cb(b):
            if (self.toggle2D.value):
                #zmin.disabled = zmax.disabled = zdelta.disabled = True
                zmin.disabled = True
                zmax.disabled = True
                zdelta.disabled = True
            else:
                zmin.disabled = False
                zmax.disabled = False
                zdelta.disabled = False
            
        self.toggle2D.observe(toggle2D_cb)
        """

        x_row = HBox([self.xmin, self.xmax, self.xdelta])
        y_row = HBox([self.ymin, self.ymax, self.ydelta])
        z_row = HBox([self.zmin, self.zmax, self.zdelta])

        self.omp_threads = BoundedIntText(
            min=1,
            max=4,
            description='# threads',
            layout=Layout(width=constWidth),
        )

        # self.toggle_prng = Checkbox(
        #     description='Seed PRNG', style={'description_width': 'initial'},  # e.g. 'initial'  '120px'
        #     layout=Layout(width=constWidth),
        # )
        # self.prng_seed = BoundedIntText(
        #     min = 1,
        #     description='Seed',
        #     disabled=True,
        #     layout=Layout(width=constWidth),
        # )
        # def toggle_prng_cb(b):
        #     if (toggle_prng.value):
        #         self.prng_seed.disabled = False
        #     else:
        #         self.prng_seed.disabled = True

        # self.toggle_prng.observe(toggle_prng_cb)
        #prng_row = HBox([toggle_prng, prng_seed])

        self.toggle_svg = Checkbox(
            description='Cells',  # SVG
            layout=Layout(width='150px'))  # constWidth = '180px'
        # self.svg_t0 = BoundedFloatText (
        #     min=0,
        #     description='$T_0$',
        #     layout=Layout(width=constWidth),
        # )
        # self.svg_interval = BoundedIntText(
        self.svg_interval = BoundedFloatText(
            min=1,
            max=
            99999999,  # TODO: set max on all Bounded to avoid unwanted default
            description='every',
            layout=Layout(width='160px'),
        )
        # self.mcds_interval = BoundedIntText(
        self.mcds_interval = BoundedFloatText(
            min=1,
            max=99999999,
            description='every',
            #            disabled=True,
            layout=Layout(width='160px'),
        )

        # don't let this be > mcds interval
        def svg_interval_cb(b):
            if (self.svg_interval.value > self.mcds_interval.value):
                self.svg_interval.value = self.mcds_interval.value

        self.svg_interval.observe(
            svg_interval_cb)  # BEWARE: when fill_gui, this sets value = 1 !

        # don't let this be < svg interval
        def mcds_interval_cb(b):
            if (self.mcds_interval.value < self.svg_interval.value):
                self.mcds_interval.value = self.svg_interval.value

        self.mcds_interval.observe(
            mcds_interval_cb)  # BEWARE: see warning above

        def toggle_svg_cb(b):
            if (self.toggle_svg.value):
                # self.svg_t0.disabled = False
                self.svg_interval.disabled = False
            else:
                # self.svg_t0.disabled = True
                self.svg_interval.disabled = True

        self.toggle_svg.observe(toggle_svg_cb)

        self.toggle_mcds = Checkbox(
            #     value=False,
            description='Subtrates',  # Full
            layout=Layout(width='180px'),
        )

        # self.mcds_t0 = FloatText(
        #     description='$T_0$',
        #     disabled=True,
        #     layout=Layout(width=constWidth),
        # )
        def toggle_mcds_cb(b):
            if (self.toggle_mcds.value):
                # self.mcds_t0.disabled = False #False
                self.mcds_interval.disabled = False
            else:
                # self.mcds_t0.disabled = True
                self.mcds_interval.disabled = True

        self.toggle_mcds.observe(toggle_mcds_cb)

        svg_mat_output_row = HBox([
            Label('Plots:'), self.toggle_svg,
            HBox([self.svg_interval, Label('min')]), self.toggle_mcds,
            HBox([self.mcds_interval, Label('min')])
        ])

        # to sync, do this
        # svg_mat_output_row = HBox( [Label('Plots:'), self.svg_interval, Label('min')])

        #write_config_row = HBox([write_config_button, write_config_file])
        #run_sim_row = HBox([run_button, run_command_str, kill_button])
        # run_sim_row = HBox([run_button, run_command_str])
        # run_sim_row = HBox([run_button.w])  # need ".w" for the custom RunCommand widget

        label_blankline = Label('')
        # toggle_2D_seed_row = HBox([toggle_prng, prng_seed])  # toggle2D

        box_layout = Layout(border='1px solid')
        #        domain_box = VBox([label_domain,x_row,y_row,z_row], layout=box_layout)
        domain_box = VBox([label_domain, x_row, y_row], layout=box_layout)
        self.tab = VBox([
            domain_box,
            #                         label_blankline,
            HBox([self.tmax, Label('min')]),
            self.omp_threads,
            svg_mat_output_row,
            #                         HBox([self.substrate[3], self.diffusion_coef[3], self.decay_rate[3] ]),
        ])  # output_dir, toggle_2D_seed_
Example #11
0
def DataApp():

    frequency = FloatText(value=0.5, description="f (Hz)")
    zsrc = FloatText(value=-950.0, description="src height (m)")
    zrx = FloatText(value=-1000.0, description="rx height (m)")
    rho0 = FloatText(value=1e8, description="$\\rho_{0} \ (\Omega m)$")
    rho1 = FloatText(value=0.3, description="$\\rho_{1} \ (\Omega m)$")
    rho2 = FloatText(value=1.0, description="$\\rho_{2} \ (\Omega m)$")
    rho3 = FloatText(value=100.0, description="$\\rho_{3} \ (\Omega m)$")
    rho4 = FloatText(value=1.0, description="$\\rho_{4} \ (\Omega m)$")
    rv_rh = FloatText(value=1.0, description="$\\rho_{2 \ v} / \\rho_{2 \ h}$")
    dz1 = FloatText(value=1000.0, description="dz1 (m)")
    dz2 = FloatText(value=1000.0, description="dz2 (m)")
    dz3 = FloatText(value=200.0, description="dz3 (m)")
    frequency_bg = FloatText(value=0.5, description="f$^{BG}$ (Hz)")
    zsrc_bg = FloatText(value=-950.0, description="src height$^{BG}$ (m)")
    zrx_bg = FloatText(value=-1000.0, description="rx height$^{BG}$ (m)")
    rho0_bg = FloatText(value=1e8, description="$\\rho_{0}^{BG} \ (\Omega m)$")
    rho1_bg = FloatText(value=0.3, description="$\\rho_{1}^{BG} \ (\Omega m)$")
    rho2_bg = FloatText(value=1.0, description="$\\rho_{2}^{BG} \ (\Omega m)$")
    rho3_bg = FloatText(value=1.0, description="$\\rho_{3}^{BG} \ (\Omega m)$")
    rho4_bg = FloatText(value=1.0, description="$\\rho_{4}^{BG} \ (\Omega m)$")
    rv_rh_bg = FloatText(
        value=1.0, description="$\\rho_{2 \ v}^{BG} / \\rho_{2 \ h}^{BG}$")
    dz1_bg = FloatText(value=1000.0, description="dz1$^{BG}$ (m)")
    dz2_bg = FloatText(value=1000.0, description="dz2$^{BG}$ (m)")
    dz3_bg = FloatText(value=200.0, description="dz3$^{BG}$ (m)")
    Field = ToggleButtons(options=["E", "H", "Zxy"],
                          value="E",
                          description="Field")
    Plane = ToggleButtons(options=["XZ", "YZ"],
                          value="XZ",
                          description="Plane")
    Component = ToggleButtons(options=["x", "y", "z"],
                              value="x",
                              description="rx direction")
    Complex = ToggleButtons(options=["Real", "Imag", "Amp", "Phase"],
                            value="Amp",
                            description="Complex")
    scale = ToggleButtons(options=["log", "linear"],
                          value="log",
                          description="Scale")
    Fixed = widgets.widget_bool.Checkbox(value=False, description="Fixed")
    vmin = FloatText(value=None, description="vmin")
    vmax = FloatText(value=None, description="vmax")
    # __manual = True

    out = widgets.interactive_output(
        csem_data_app,
        {
            "frequency": frequency,
            "zsrc": zsrc,
            "zrx": zrx,
            "rho0": rho0,
            "rho1": rho1,
            "rho2": rho2,
            "rho3": rho3,
            "rho4": rho4,
            "rv_rh": rv_rh,
            "dz1": dz1,
            "dz2": dz2,
            "dz3": dz3,
            "frequency_bg": frequency_bg,
            "zsrc_bg": zsrc_bg,
            "zrx_bg": zrx_bg,
            "rho0_bg": rho0_bg,
            "rho1_bg": rho1_bg,
            "rho2_bg": rho2_bg,
            "rho3_bg": rho3_bg,
            "rho4_bg": rho4_bg,
            "rv_rh_bg": rv_rh_bg,
            "dz1_bg": dz1_bg,
            "dz2_bg": dz2_bg,
            "dz3_bg": dz3_bg,
            "Field": Field,
            "Plane": Plane,
            "Component": Component,
            "Complex": Complex,
            "scale": scale,
            "Fixed": Fixed,
            "vmin": vmin,
            "vmax": vmax,
        },
    )

    panel = VBox([
        frequency, zsrc, zrx, rho0, rho1, rho2, rho3, rho4, rv_rh, dz1, dz2,
        dz3
    ])
    panel_bg = VBox([
        frequency_bg,
        zsrc_bg,
        zrx_bg,
        rho0_bg,
        rho1_bg,
        rho2_bg,
        rho3_bg,
        rho4_bg,
        rv_rh_bg,
        dz1_bg,
        dz2_bg,
        dz3_bg,
    ])
    panel_type = VBox(
        [Field, Plane, Component, Complex, scale, Fixed, vmin, vmax])
    return VBox([HBox([panel, panel_bg]), panel_type, out])
Example #12
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}
        divider_button_layout = {'width': '40%'}

        param_name1 = Button(description='hypoxia_pers_time',
                             disabled=True,
                             layout=name_button_layout)
        param_name1.style.button_color = 'lightgreen'

        self.hypoxia_pers_time = FloatText(value=300,
                                           step=10,
                                           style=style,
                                           layout=widget_layout)

        param_name2 = Button(description='fraction_rsp',
                             disabled=True,
                             layout=name_button_layout)
        param_name2.style.button_color = 'tan'

        self.fraction_rsp = FloatText(value=0.5,
                                      step=0.1,
                                      style=style,
                                      layout=widget_layout)

        param_name3 = Button(description='bias_green_rsp',
                             disabled=True,
                             layout=name_button_layout)
        param_name3.style.button_color = 'lightgreen'

        self.bias_green_rsp = FloatText(value=1.0,
                                        step=0.1,
                                        style=style,
                                        layout=widget_layout)

        param_name4 = Button(description='hypoxyprobe',
                             disabled=True,
                             layout=name_button_layout)
        param_name4.style.button_color = 'tan'

        self.hypoxyprobe = Checkbox(value=False,
                                    style=style,
                                    layout=widget_layout)

        param_name5 = Button(description='speed_red',
                             disabled=True,
                             layout=name_button_layout)
        param_name5.style.button_color = 'lightgreen'

        self.speed_red = FloatText(value=0.2938,
                                   step=0.01,
                                   style=style,
                                   layout=widget_layout)

        param_name6 = Button(description='pers_time_red',
                             disabled=True,
                             layout=name_button_layout)
        param_name6.style.button_color = 'tan'

        self.pers_time_red = FloatText(value=15.0,
                                       step=1,
                                       style=style,
                                       layout=widget_layout)

        param_name7 = Button(description='bias_red',
                             disabled=True,
                             layout=name_button_layout)
        param_name7.style.button_color = 'lightgreen'

        self.bias_red = FloatText(value=0.1719,
                                  step=0.01,
                                  style=style,
                                  layout=widget_layout)

        param_name8 = Button(description='speed_green',
                             disabled=True,
                             layout=name_button_layout)
        param_name8.style.button_color = 'tan'

        self.speed_green = FloatText(value=0.4755,
                                     step=0.1,
                                     style=style,
                                     layout=widget_layout)

        param_name9 = Button(description='pers_time_green',
                             disabled=True,
                             layout=name_button_layout)
        param_name9.style.button_color = 'lightgreen'

        self.pers_time_green = FloatText(value=15.0,
                                         step=1,
                                         style=style,
                                         layout=widget_layout)

        param_name10 = Button(description='bias_green',
                              disabled=True,
                              layout=name_button_layout)
        param_name10.style.button_color = 'tan'

        self.bias_green = FloatText(value=0.1791,
                                    step=0.01,
                                    style=style,
                                    layout=widget_layout)

        param_name11 = Button(description='initial_tumor_rad',
                              disabled=True,
                              layout=name_button_layout)
        param_name11.style.button_color = 'lightgreen'

        self.initial_tumor_rad = FloatText(value=250.0,
                                           step=10,
                                           style=style,
                                           layout=widget_layout)

        param_name12 = Button(description='cell_oxy_cons',
                              disabled=True,
                              layout=name_button_layout)
        param_name12.style.button_color = 'tan'

        self.cell_oxy_cons = FloatText(value=10.0,
                                       step=1,
                                       style=style,
                                       layout=widget_layout)

        param_name13 = Button(description='rate_KnToKp',
                              disabled=True,
                              layout=name_button_layout)
        param_name13.style.button_color = 'lightgreen'

        self.rate_KnToKp = FloatText(value=0.00363,
                                     step=0.001,
                                     style=style,
                                     layout=widget_layout)

        param_name14 = Button(description='rate_KpToKn',
                              disabled=True,
                              layout=name_button_layout)
        param_name14.style.button_color = 'tan'

        self.rate_KpToKn = FloatText(value=0.00107,
                                     step=0.0001,
                                     style=style,
                                     layout=widget_layout)

        param_name15 = Button(description='sigma_S',
                              disabled=True,
                              layout=name_button_layout)
        param_name15.style.button_color = 'lightgreen'

        self.sigma_S = FloatText(value=38.0,
                                 step=1,
                                 style=style,
                                 layout=widget_layout)

        param_name16 = Button(description='sigma_T',
                              disabled=True,
                              layout=name_button_layout)
        param_name16.style.button_color = 'tan'

        self.sigma_T = FloatText(value=6.0,
                                 step=0.1,
                                 style=style,
                                 layout=widget_layout)

        param_name17 = Button(description='sigma_H',
                              disabled=True,
                              layout=name_button_layout)
        param_name17.style.button_color = 'lightgreen'

        self.sigma_H = FloatText(value=10.0,
                                 step=1,
                                 style=style,
                                 layout=widget_layout)

        param_name18 = Button(description='protein_prod_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name18.style.button_color = 'tan'

        self.protein_prod_rate = FloatText(value=4.8e-4,
                                           step=0.0001,
                                           style=style,
                                           layout=widget_layout)

        param_name19 = Button(description='protein_deg_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name19.style.button_color = 'lightgreen'

        self.protein_deg_rate = FloatText(value=6.8e-5,
                                          step=1e-05,
                                          style=style,
                                          layout=widget_layout)

        units_button1 = Button(description='min',
                               disabled=True,
                               layout=units_button_layout)
        units_button1.style.button_color = 'lightgreen'
        units_button2 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button2.style.button_color = 'tan'
        units_button3 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button3.style.button_color = 'lightgreen'
        units_button4 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button4.style.button_color = 'tan'
        units_button5 = Button(description='micron/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button5.style.button_color = 'lightgreen'
        units_button6 = Button(description='min',
                               disabled=True,
                               layout=units_button_layout)
        units_button6.style.button_color = 'tan'
        units_button7 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button7.style.button_color = 'lightgreen'
        units_button8 = Button(description='micron/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button8.style.button_color = 'tan'
        units_button9 = Button(description='min',
                               disabled=True,
                               layout=units_button_layout)
        units_button9.style.button_color = 'lightgreen'
        units_button10 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button10.style.button_color = 'tan'
        units_button11 = Button(description='micron',
                                disabled=True,
                                layout=units_button_layout)
        units_button11.style.button_color = 'lightgreen'
        units_button12 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button12.style.button_color = 'tan'
        units_button13 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button13.style.button_color = 'lightgreen'
        units_button14 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button14.style.button_color = 'tan'
        units_button15 = Button(description='mmHg',
                                disabled=True,
                                layout=units_button_layout)
        units_button15.style.button_color = 'lightgreen'
        units_button16 = Button(description='mmHg',
                                disabled=True,
                                layout=units_button_layout)
        units_button16.style.button_color = 'tan'
        units_button17 = Button(description='mmHg',
                                disabled=True,
                                layout=units_button_layout)
        units_button17.style.button_color = 'lightgreen'
        units_button18 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button18.style.button_color = 'tan'
        units_button19 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button19.style.button_color = 'lightgreen'

        desc_button1 = Button(
            description='phenotype persistent time of GFP+ cells',
            tooltip='phenotype persistent time of GFP+ cells',
            disabled=True,
            layout=desc_button_layout)
        desc_button1.style.button_color = 'lightgreen'
        desc_button2 = Button(
            description=
            'fraction of GFP+ cells with different migration bias (bias_green_rsp)',
            tooltip=
            'fraction of GFP+ cells with different migration bias (bias_green_rsp)',
            disabled=True,
            layout=desc_button_layout)
        desc_button2.style.button_color = 'tan'
        desc_button3 = Button(
            description='migration bias for GFP + cells (for fraction_rsp)',
            tooltip='migration bias for GFP + cells (for fraction_rsp)',
            disabled=True,
            layout=desc_button_layout)
        desc_button3.style.button_color = 'lightgreen'
        desc_button4 = Button(description='mark with hypoxyprobe',
                              tooltip='mark with hypoxyprobe',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button4.style.button_color = 'tan'
        desc_button5 = Button(description='migration speed for DsRed+ cells',
                              tooltip='migration speed for DsRed+ cells',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(
            description='migration persistent time for DsRed+ cells',
            tooltip='migration persistent time for DsRed+ cells',
            disabled=True,
            layout=desc_button_layout)
        desc_button6.style.button_color = 'tan'
        desc_button7 = Button(description='migration bias for DsRed+ cells',
                              tooltip='migration bias for DsRed+ cells',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button7.style.button_color = 'lightgreen'
        desc_button8 = Button(description='migration speed for GFP+ cells',
                              tooltip='migration speed for GFP+ cells',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button8.style.button_color = 'tan'
        desc_button9 = Button(
            description='migration persistent time for GFP+ cells',
            tooltip='migration persistent time for GFP+ cells',
            disabled=True,
            layout=desc_button_layout)
        desc_button9.style.button_color = 'lightgreen'
        desc_button10 = Button(description='migration bias for GFP+ cells',
                               tooltip='migration bias for GFP+ cells',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button10.style.button_color = 'tan'
        desc_button11 = Button(description='initial tumor radius',
                               tooltip='initial tumor radius',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button11.style.button_color = 'lightgreen'
        desc_button12 = Button(
            description='oxygen consumption rate by each cell',
            tooltip='oxygen consumption rate by each cell',
            disabled=True,
            layout=desc_button_layout)
        desc_button12.style.button_color = 'tan'
        desc_button13 = Button(
            description=
            'transition rate from Ki67- to Ki67+ (for saturated signal)',
            tooltip=
            'transition rate from Ki67- to Ki67+ (for saturated signal)',
            disabled=True,
            layout=desc_button_layout)
        desc_button13.style.button_color = 'lightgreen'
        desc_button14 = Button(
            description='transition rate from Ki67+ to Ki67-',
            tooltip='transition rate from Ki67+ to Ki67-',
            disabled=True,
            layout=desc_button_layout)
        desc_button14.style.button_color = 'tan'
        desc_button15 = Button(
            description=
            'oxygen pressure threshold to signal proliferation saturation',
            tooltip=
            'oxygen pressure threshold to signal proliferation saturation',
            disabled=True,
            layout=desc_button_layout)
        desc_button15.style.button_color = 'lightgreen'
        desc_button16 = Button(
            description='min oxygen pressure to signal proliferation',
            tooltip='min oxygen pressure to signal proliferation',
            disabled=True,
            layout=desc_button_layout)
        desc_button16.style.button_color = 'tan'
        desc_button17 = Button(
            description='oxygen pressure threshold to signal hypoxia',
            tooltip='oxygen pressure threshold to signal hypoxia',
            disabled=True,
            layout=desc_button_layout)
        desc_button17.style.button_color = 'lightgreen'
        desc_button18 = Button(description='protein production rate',
                               tooltip='protein production rate',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button18.style.button_color = 'tan'
        desc_button19 = Button(description='protein degradation rate',
                               tooltip='protein degradation rate',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button19.style.button_color = 'lightgreen'

        row1 = [
            param_name1, self.hypoxia_pers_time, units_button1, desc_button1
        ]
        row2 = [param_name2, self.fraction_rsp, units_button2, desc_button2]
        row3 = [param_name3, self.bias_green_rsp, units_button3, desc_button3]
        row4 = [param_name4, self.hypoxyprobe, units_button4, desc_button4]
        row5 = [param_name5, self.speed_red, units_button5, desc_button5]
        row6 = [param_name6, self.pers_time_red, units_button6, desc_button6]
        row7 = [param_name7, self.bias_red, units_button7, desc_button7]
        row8 = [param_name8, self.speed_green, units_button8, desc_button8]
        row9 = [param_name9, self.pers_time_green, units_button9, desc_button9]
        row10 = [param_name10, self.bias_green, units_button10, desc_button10]
        row11 = [
            param_name11, self.initial_tumor_rad, units_button11, desc_button11
        ]
        row12 = [
            param_name12, self.cell_oxy_cons, units_button12, desc_button12
        ]
        row13 = [param_name13, self.rate_KnToKp, units_button13, desc_button13]
        row14 = [param_name14, self.rate_KpToKn, units_button14, desc_button14]
        row15 = [param_name15, self.sigma_S, units_button15, desc_button15]
        row16 = [param_name16, self.sigma_T, units_button16, desc_button16]
        row17 = [param_name17, self.sigma_H, units_button17, desc_button17]
        row18 = [
            param_name18, self.protein_prod_rate, units_button18, desc_button18
        ]
        row19 = [
            param_name19, self.protein_deg_rate, units_button19, desc_button19
        ]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)
        box9 = Box(children=row9, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)
        box11 = Box(children=row11, layout=box_layout)
        box12 = Box(children=row12, layout=box_layout)
        box13 = Box(children=row13, layout=box_layout)
        box14 = Box(children=row14, layout=box_layout)
        box15 = Box(children=row15, layout=box_layout)
        box16 = Box(children=row16, layout=box_layout)
        box17 = Box(children=row17, layout=box_layout)
        box18 = Box(children=row18, layout=box_layout)
        box19 = Box(children=row19, layout=box_layout)

        self.tab = VBox([
            box1,
            box2,
            box3,
            box4,
            box5,
            box6,
            box7,
            box8,
            box9,
            box10,
            box11,
            box12,
            box13,
            box14,
            box15,
            box16,
            box17,
            box18,
            box19,
        ])
Example #13
0
    def _init_gui(self, **kwargs):
        """Initialize generic GUI controls and observe callbacks."""
        mainopts = super(TensorContainer, self)._init_gui(**kwargs)
        scn = self.scenes[0]
        alo = Layout(width='74px')
        rlo = Layout(width='235px')
        if self._df is not None:
            scn.txx = self._df.loc[0, 'xx']
            scn.txy = self._df.loc[0, 'xy']
            scn.txz = self._df.loc[0, 'xz']
            scn.tyx = self._df.loc[0, 'yx']
            scn.tyy = self._df.loc[0, 'yy']
            scn.tyz = self._df.loc[0, 'yz']
            scn.tzx = self._df.loc[0, 'zx']
            scn.tzy = self._df.loc[0, 'zy']
            scn.tzz = self._df.loc[0, 'zz']
        xs = [
            FloatText(value=scn.txx, layout=alo),
            FloatText(value=scn.txy, layout=alo),
            FloatText(value=scn.txz, layout=alo)
        ]
        ys = [
            FloatText(value=scn.tyx, layout=alo),
            FloatText(value=scn.tyy, layout=alo),
            FloatText(value=scn.tyz, layout=alo)
        ]
        zs = [
            FloatText(value=scn.tzx, layout=alo),
            FloatText(value=scn.tzy, layout=alo),
            FloatText(value=scn.tzz, layout=alo)
        ]
        opt = [0] if self._df is None else [
            int(x) for x in self._df.index.values
        ]
        tensorIndex = Dropdown(options=opt, value=opt[0], layout=rlo)
        tdxlabel = Label(value='Select the tensor index:')

        def _x0(c):
            for scn in self.active():
                scn.txx = c.new

        def _x1(c):
            for scn in self.active():
                scn.txy = c.new

        def _x2(c):
            for scn in self.active():
                scn.txz = c.new

        def _y0(c):
            for scn in self.active():
                scn.tyx = c.new

        def _y1(c):
            for scn in self.active():
                scn.tyy = c.new

        def _y2(c):
            for scn in self.active():
                scn.tyz = c.new

        def _z0(c):
            for scn in self.active():
                scn.tzx = c.new

        def _z1(c):
            for scn in self.active():
                scn.tzy = c.new

        def _z2(c):
            for scn in self.active():
                scn.tzz = c.new

        xs[0].observe(_x0, names='value')
        xs[1].observe(_x1, names='value')
        xs[2].observe(_x2, names='value')
        ys[0].observe(_y0, names='value')
        ys[1].observe(_y1, names='value')
        ys[2].observe(_y2, names='value')
        zs[0].observe(_z0, names='value')
        zs[1].observe(_z1, names='value')
        zs[2].observe(_z2, names='value')
        rlo = Layout(width='234px')
        xbox = HBox(xs, layout=rlo)
        ybox = HBox(ys, layout=rlo)
        zbox = HBox(zs, layout=rlo)
        geom = Button(icon='cubes', description=' Geometry', layout=_wlo)

        def _change_tensor(tdx=0):
            carts = ['x', 'y', 'z']
            for i, bra in enumerate(carts):
                for j, ket in enumerate(carts):
                    if i == 0:
                        xs[j].value = self._df.loc[tdx, bra + ket]
                    elif i == 1:
                        ys[j].value = self._df.loc[tdx, bra + ket]
                    elif i == 2:
                        zs[j].value = self._df.loc[tdx, bra + ket]

        def _geom(b):
            for scn in self.active():
                scn.geom = not scn.geom

        def _tdx(c):
            for scn in self.active():
                scn.tdx = c.new
            _change_tensor(c.new)

        geom.on_click(_geom)
        tensorIndex.observe(_tdx, names="value")
        mainopts.update([('geom', geom), ('tlbl', tdxlabel),
                         ('tidx', tensorIndex), ('xbox', xbox), ('ybox', ybox),
                         ('zbox', zbox)])
        return mainopts
Example #14
0
    def dsc_config(dsc_value):
        values = config.read()
        ds_db = Dropdown(options=["1"],
                         value="1",
                         description='Database:',
                         disabled=False,
                         layout=Layout(width='140px'))

        try:
            with open(f"{config.get_value(['paths','temp'])}tb_prefix",
                      'r') as f:
                code_value = f.read()
        except Exception:
            code_value = dsc_value

        ds_code = Combobox(
            value=code_value,
            placeholder='abc',
            options=[m for m in data_options.eu_ms()] + [''],
            description='AOI code:',
            ensure_option=False,
            disabled=False,
            layout=Layout(width='200px'),
            tooltip='Lowercase AOI code name for the dataset (5chr max).')
        ds_year = BoundedIntText(value=int(dsy.value),
                                 min=1980,
                                 max=2100,
                                 step=1,
                                 description='Dataset year:',
                                 disabled=False,
                                 layout=Layout(width='180px'))
        ds_desc = Text(value=values['ds_conf'][dsc_value]['desc'],
                       description='Description:',
                       disabled=False)

        info_map_text = [
            "Set default map view options. ",
            "You can get automatically the dataset ", "center coordinates."
        ]

        lat, lon = values['ds_conf'][dsc_value]['center'].split(",")
        map_cent_lat = FloatText(value=float(lat),
                                 description='Lat:',
                                 disabled=False,
                                 layout=Layout(width='160px'))
        map_cent_lon = FloatText(value=float(lon),
                                 description='Lon:',
                                 disabled=False,
                                 layout=Layout(width='160px'))
        map_zoom = BoundedIntText(value=values['ds_conf'][dsc_value]['zoom'],
                                  min=0,
                                  max=20,
                                  step=1,
                                  description='Zoom:',
                                  disabled=False,
                                  layout=Layout(width='140px'))
        bt_get_center = Button(layout=Layout(width='40px'),
                               icon='bullseye',
                               tooltip='Get center point from database.')

        ds_box = HBox([ds_code, ds_year, ds_desc])
        map_box = HBox([
            Label("Map center: "), map_cent_lat, map_cent_lon, bt_get_center,
            map_zoom
        ])

        info_config = Label(
            """Change 'AOI code' value to create a new configuration set or 
            leave the same 'AOI code' value to configure the selected one.""")

        db = int(values['ds_conf'][dsc_value]['db'])

        def get_tb_list():
            tbls = database.tables(db, None, False)
            if tbls is None:
                return []
            else:
                return tbls

        tb_dc = Dropdown(options=get_tb_list(),
                         value=config.autoselect(
                             values['ds_conf'][dsc_value]['years'][str(
                                 ds_year.value)]['tables']['dias_catalog'],
                             get_tb_list(), False),
                         description='DIAS catalog:',
                         disabled=False)
        tb_pr = Dropdown(options=get_tb_list(),
                         value=config.autoselect(
                             values['ds_conf'][dsc_value]['years'][str(
                                 ds_year.value)]['tables']['parcels'],
                             get_tb_list(), False),
                         description='Parcels:',
                         disabled=False)

        def get_pr_columns():
            try:
                colms = database.table_columns(tb_pr.value, 1, None)
                if colms is None:
                    return []
                else:
                    return colms
            except Exception:
                return []

        tc_id = Dropdown(options=get_pr_columns(),
                         value=config.autoselect(
                             values['ds_conf'][dsc_value]['years'][str(
                                 ds_year.value)]['columns']['parcels_id'],
                             get_pr_columns(), False),
                         description='Parcels ID:',
                         disabled=False,
                         layout=Layout(width='180px'))
        tc_cn = Dropdown(options=get_pr_columns(),
                         value=config.autoselect(
                             values['ds_conf'][dsc_value]['years'][str(
                                 ds_year.value)]['columns']['crop_names'],
                             get_pr_columns(), False),
                         description='Crop names:',
                         disabled=False,
                         layout=Layout(width='180px'))
        tc_cc = Dropdown(options=get_pr_columns(),
                         value=config.autoselect(
                             values['ds_conf'][dsc_value]['years'][str(
                                 ds_year.value)]['columns']['crop_codes'],
                             get_pr_columns(), False),
                         description='Crop codes:',
                         disabled=False,
                         layout=Layout(width='180px'))

        def on_tb_pr_change(change):
            tc_id.options = get_pr_columns()
            tc_cn.options = get_pr_columns()
            tc_cc.options = get_pr_columns()

        tb_pr.observe(on_tb_pr_change, 'value')

        parcel_box = HBox([tb_pr, tc_id, tc_cn, tc_cc])

        tb_s2 = Dropdown(options=get_tb_list(),
                         value=config.autoselect(
                             values['ds_conf'][dsc_value]['years'][str(
                                 ds_year.value)]['tables']['s2'],
                             get_tb_list(), False),
                         description='S2 signatures:',
                         disabled=False)
        tb_bs = Dropdown(options=get_tb_list(),
                         value=config.autoselect(
                             values['ds_conf'][dsc_value]['years'][str(
                                 ds_year.value)]['tables']['bs'],
                             get_tb_list(), False),
                         description='Backscattering:',
                         disabled=False)
        tb_6c = Dropdown(options=get_tb_list(),
                         value=config.autoselect(
                             values['ds_conf'][dsc_value]['years'][str(
                                 ds_year.value)]['tables']['c6'],
                             get_tb_list(), False),
                         description='6 day coherence:',
                         disabled=False)

        wb_save = Button(description='Save', disabled=False, icon='save')

        @bt_get_center.on_click
        def bt_get_center_on_click(b):
            import json
            center_json = json.loads(
                database.getTableCentroid(tb_pr.value)['center'][0])
            map_cent_lat.value = round(center_json['coordinates'][1], 2)
            map_cent_lon.value = round(center_json['coordinates'][0], 2)
            map_zoom.value = 10

        @wb_save.on_click
        def wb_save_on_click(b):
            progress.clear_output()
            dscode = ds_code.value
            config.update([
                'ds_conf', dscode, 'years',
                str(ds_year.value), 'tables', 'dias_catalog'
            ], str(tb_dc.value))
            config.update([
                'ds_conf', dscode, 'years',
                str(ds_year.value), 'tables', 'parcels'
            ], str(tb_pr.value))
            config.update([
                'ds_conf', dscode, 'years',
                str(ds_year.value), 'columns', 'parcels_id'
            ], str(tc_id.value))
            config.update([
                'ds_conf', dscode, 'years',
                str(ds_year.value), 'columns', 'crop_names'
            ], str(tc_cn.value))
            config.update([
                'ds_conf', dscode, 'years',
                str(ds_year.value), 'columns', 'crop_codes'
            ], str(tc_cc.value))
            config.update([
                'ds_conf', dscode, 'years',
                str(ds_year.value), 'tables', 's2'
            ], str(tb_s2.value))
            config.update([
                'ds_conf', dscode, 'years',
                str(ds_year.value), 'tables', 'bs'
            ], str(tb_bs.value))
            config.update([
                'ds_conf', dscode, 'years',
                str(ds_year.value), 'tables', 'c6'
            ], str(tb_6c.value))
            config.update(['ds_conf', dscode, 'db'], str(ds_db.value))
            config.update(['ds_conf', dscode, 'desc'], str(ds_desc.value))
            config.update(['ds_conf', dscode, 'center'],
                          f"{map_cent_lat.value},{map_cent_lon.value}")
            config.update(['ds_conf', dscode, 'zoom'], str(map_zoom.value))
            config.update(['set', 'ds_conf'], str(dscode))
            config.update(['set', 'ds_year'], str(ds_year.value))
            values = config.read()
            ds_c = values['set']['ds_conf']
            ds_y = values['set']['ds_year']
            dsc.options = [d for d in values['ds_conf']]
            dsy.options = [int(y) for y in values['ds_conf'][ds_c]['years']]
            dsc.value = ds_c
            dsy.value = int(ds_y)
            outlog("The configurations are saved.")

        return VBox([
            info_config, ds_box, parcel_box, tb_dc, tb_s2, tb_bs, tb_6c,
            Label(''.join(info_map_text)), map_box, wb_save
        ])
Example #15
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}

        param_name1 = Button(description='Model_Initialization',
                             disabled=True,
                             layout=name_button_layout)
        param_name1.style.button_color = 'lightgreen'

        self.Model_Initialization = FloatText(value=0,
                                              step=0.01,
                                              style=style,
                                              layout=widget_layout)

        param_name2 = Button(description='ECM_initialization_parameters',
                             disabled=True,
                             layout=name_button_layout)
        param_name2.style.button_color = 'tan'

        self.ECM_initialization_parameters = FloatText(value=0,
                                                       step=0.01,
                                                       style=style,
                                                       layout=widget_layout)

        param_name3 = Button(description='initial_anisotropy',
                             disabled=True,
                             layout=name_button_layout)
        param_name3.style.button_color = 'lightgreen'

        self.initial_anisotropy = FloatText(value=0,
                                            step=0.01,
                                            style=style,
                                            layout=widget_layout)

        param_name4 = Button(description='initial_ECM_density',
                             disabled=True,
                             layout=name_button_layout)
        param_name4.style.button_color = 'tan'

        self.initial_ECM_density = FloatText(value=0.5,
                                             step=0.1,
                                             style=style,
                                             layout=widget_layout)

        param_name5 = Button(description='Lesion_intialization',
                             disabled=True,
                             layout=name_button_layout)
        param_name5.style.button_color = 'lightgreen'

        self.Lesion_intialization = FloatText(value=0,
                                              step=0.01,
                                              style=style,
                                              layout=widget_layout)

        param_name6 = Button(description='tumor_radius',
                             disabled=True,
                             layout=name_button_layout)
        param_name6.style.button_color = 'tan'

        self.tumor_radius = FloatText(value=175,
                                      step=10,
                                      style=style,
                                      layout=widget_layout)

        param_name7 = Button(description='initial_leader_cell_fraction',
                             disabled=True,
                             layout=name_button_layout)
        param_name7.style.button_color = 'lightgreen'

        self.initial_leader_cell_fraction = FloatText(value=0.2,
                                                      step=0.01,
                                                      style=style,
                                                      layout=widget_layout)

        param_name8 = Button(description='Cell_properties',
                             disabled=True,
                             layout=name_button_layout)
        param_name8.style.button_color = 'tan'

        self.Cell_properties = FloatText(value=0,
                                         step=0.01,
                                         style=style,
                                         layout=widget_layout)

        param_name9 = Button(description='oxygen_uptake',
                             disabled=True,
                             layout=name_button_layout)
        param_name9.style.button_color = 'lightgreen'

        self.oxygen_uptake = FloatText(value=10,
                                       step=1,
                                       style=style,
                                       layout=widget_layout)

        param_name10 = Button(description='leader_adhesion',
                              disabled=True,
                              layout=name_button_layout)
        param_name10.style.button_color = 'tan'

        self.leader_adhesion = FloatText(value=5.0,
                                         step=0.1,
                                         style=style,
                                         layout=widget_layout)

        param_name11 = Button(description='leader_repulsion',
                              disabled=True,
                              layout=name_button_layout)
        param_name11.style.button_color = 'lightgreen'

        self.leader_repulsion = FloatText(value=25,
                                          step=1,
                                          style=style,
                                          layout=widget_layout)

        param_name12 = Button(description='follower_adhesion',
                              disabled=True,
                              layout=name_button_layout)
        param_name12.style.button_color = 'tan'

        self.follower_adhesion = FloatText(value=5.0,
                                           step=0.1,
                                           style=style,
                                           layout=widget_layout)

        param_name13 = Button(description='follower_repulsion',
                              disabled=True,
                              layout=name_button_layout)
        param_name13.style.button_color = 'lightgreen'

        self.follower_repulsion = FloatText(value=25,
                                            step=1,
                                            style=style,
                                            layout=widget_layout)

        param_name14 = Button(description='default_cell_speed',
                              disabled=True,
                              layout=name_button_layout)
        param_name14.style.button_color = 'tan'

        self.default_cell_speed = FloatText(value=0.5,
                                            step=0.1,
                                            style=style,
                                            layout=widget_layout)

        param_name15 = Button(description='rho_L',
                              disabled=True,
                              layout=name_button_layout)
        param_name15.style.button_color = 'lightgreen'

        self.rho_L = FloatText(value=0.0,
                               step=0.01,
                               style=style,
                               layout=widget_layout)

        param_name16 = Button(description='rho_H',
                              disabled=True,
                              layout=name_button_layout)
        param_name16.style.button_color = 'tan'

        self.rho_H = FloatText(value=1.0,
                               step=0.1,
                               style=style,
                               layout=widget_layout)

        param_name17 = Button(description='rho_I',
                              disabled=True,
                              layout=name_button_layout)
        param_name17.style.button_color = 'lightgreen'

        self.rho_I = FloatText(value=0.5,
                               step=0.1,
                               style=style,
                               layout=widget_layout)

        param_name18 = Button(description='default_persistence_time',
                              disabled=True,
                              layout=name_button_layout)
        param_name18.style.button_color = 'tan'

        self.default_persistence_time = FloatText(value=10.0,
                                                  step=1,
                                                  style=style,
                                                  layout=widget_layout)

        param_name19 = Button(description='default_ECM_density_target',
                              disabled=True,
                              layout=name_button_layout)
        param_name19.style.button_color = 'lightgreen'

        self.default_ECM_density_target = FloatText(value=0.5,
                                                    step=0.1,
                                                    style=style,
                                                    layout=widget_layout)

        param_name20 = Button(description='default_ECM_sensitivity',
                              disabled=True,
                              layout=name_button_layout)
        param_name20.style.button_color = 'tan'

        self.default_ECM_sensitivity = FloatText(value=1.0,
                                                 step=0.1,
                                                 style=style,
                                                 layout=widget_layout)

        param_name21 = Button(description='default_hysteresis_bias',
                              disabled=True,
                              layout=name_button_layout)
        param_name21.style.button_color = 'lightgreen'

        self.default_hysteresis_bias = FloatText(value=1.0,
                                                 step=0.1,
                                                 style=style,
                                                 layout=widget_layout)

        param_name22 = Button(description='oxygen_migration_bias_for_leaders',
                              disabled=True,
                              layout=name_button_layout)
        param_name22.style.button_color = 'tan'

        self.oxygen_migration_bias_for_leaders = FloatText(
            value=0.95, step=0.1, style=style, layout=widget_layout)

        param_name23 = Button(description='Microenvironment_parameters',
                              disabled=True,
                              layout=name_button_layout)
        param_name23.style.button_color = 'lightgreen'

        self.Microenvironment_parameters = FloatText(value=0,
                                                     step=0.01,
                                                     style=style,
                                                     layout=widget_layout)

        param_name24 = Button(description='chemotactic_substrate_decay_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name24.style.button_color = 'tan'

        self.chemotactic_substrate_decay_rate = FloatText(value=0.1,
                                                          step=0.01,
                                                          style=style,
                                                          layout=widget_layout)

        param_name25 = Button(description='Model_Selection_Parameters',
                              disabled=True,
                              layout=name_button_layout)
        param_name25.style.button_color = 'lightgreen'

        self.Model_Selection_Parameters = FloatText(value=0,
                                                    step=0.01,
                                                    style=style,
                                                    layout=widget_layout)

        param_name26 = Button(
            description='cell_motility_ECM_interaction_model_selector',
            disabled=True,
            layout=name_button_layout)
        param_name26.style.button_color = 'tan'

        self.cell_motility_ECM_interaction_model_selector = Text(
            value='previous motility vector based memory',
            style=style,
            layout=widget_layout)

        param_name27 = Button(description='Testing_and_setup_parameters',
                              disabled=True,
                              layout=name_button_layout)
        param_name27.style.button_color = 'lightgreen'

        self.Testing_and_setup_parameters = FloatText(value=0,
                                                      step=0.01,
                                                      style=style,
                                                      layout=widget_layout)

        param_name28 = Button(
            description='normalize_ECM_influenced_motility_vector',
            disabled=True,
            layout=name_button_layout)
        param_name28.style.button_color = 'tan'

        self.normalize_ECM_influenced_motility_vector = Checkbox(
            value=False, style=style, layout=widget_layout)

        param_name29 = Button(description='duration_of_uE_conditioning',
                              disabled=True,
                              layout=name_button_layout)
        param_name29.style.button_color = 'lightgreen'

        self.duration_of_uE_conditioning = FloatText(value=10,
                                                     step=1,
                                                     style=style,
                                                     layout=widget_layout)

        param_name30 = Button(description='freeze_uE_profile',
                              disabled=True,
                              layout=name_button_layout)
        param_name30.style.button_color = 'tan'

        self.freeze_uE_profile = Checkbox(value=False,
                                          style=style,
                                          layout=widget_layout)

        param_name31 = Button(description='unit_test_setup',
                              disabled=True,
                              layout=name_button_layout)
        param_name31.style.button_color = 'lightgreen'

        self.unit_test_setup = IntText(value=0,
                                       step=1,
                                       style=style,
                                       layout=widget_layout)

        param_name32 = Button(description='march_unit_test_setup',
                              disabled=True,
                              layout=name_button_layout)
        param_name32.style.button_color = 'tan'

        self.march_unit_test_setup = IntText(value=0,
                                             step=1,
                                             style=style,
                                             layout=widget_layout)

        param_name33 = Button(description='cell_setup',
                              disabled=True,
                              layout=name_button_layout)
        param_name33.style.button_color = 'lightgreen'

        self.cell_setup = Text(value='lesion',
                               style=style,
                               layout=widget_layout)

        param_name34 = Button(description='ECM_orientation_setup',
                              disabled=True,
                              layout=name_button_layout)
        param_name34.style.button_color = 'tan'

        self.ECM_orientation_setup = Text(value='random',
                                          style=style,
                                          layout=widget_layout)

        param_name35 = Button(description='chemical_field_setup',
                              disabled=True,
                              layout=name_button_layout)
        param_name35.style.button_color = 'lightgreen'

        self.chemical_field_setup = Text(value='none',
                                         style=style,
                                         layout=widget_layout)

        param_name36 = Button(description='angle_of_chemical_field_gradient',
                              disabled=True,
                              layout=name_button_layout)
        param_name36.style.button_color = 'tan'

        self.angle_of_chemical_field_gradient = FloatText(value=45.0,
                                                          step=1,
                                                          style=style,
                                                          layout=widget_layout)

        units_button1 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button1.style.button_color = 'lightgreen'
        units_button2 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button2.style.button_color = 'tan'
        units_button3 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button3.style.button_color = 'lightgreen'
        units_button4 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button4.style.button_color = 'tan'
        units_button5 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button5.style.button_color = 'lightgreen'
        units_button6 = Button(description='microns',
                               disabled=True,
                               layout=units_button_layout)
        units_button6.style.button_color = 'tan'
        units_button7 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button7.style.button_color = 'lightgreen'
        units_button8 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button8.style.button_color = 'tan'
        units_button9 = Button(description='mmHg/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button9.style.button_color = 'lightgreen'
        units_button10 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button10.style.button_color = 'tan'
        units_button11 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button11.style.button_color = 'lightgreen'
        units_button12 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button12.style.button_color = 'tan'
        units_button13 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button13.style.button_color = 'lightgreen'
        units_button14 = Button(description='microns/minute',
                                disabled=True,
                                layout=units_button_layout)
        units_button14.style.button_color = 'tan'
        units_button15 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button15.style.button_color = 'lightgreen'
        units_button16 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button16.style.button_color = 'tan'
        units_button17 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button17.style.button_color = 'lightgreen'
        units_button18 = Button(description='minutes',
                                disabled=True,
                                layout=units_button_layout)
        units_button18.style.button_color = 'tan'
        units_button19 = Button(description='dimenionless',
                                disabled=True,
                                layout=units_button_layout)
        units_button19.style.button_color = 'lightgreen'
        units_button20 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button20.style.button_color = 'tan'
        units_button21 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button21.style.button_color = 'lightgreen'
        units_button22 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button22.style.button_color = 'tan'
        units_button23 = Button(description='dimensionlesss',
                                disabled=True,
                                layout=units_button_layout)
        units_button23.style.button_color = 'lightgreen'
        units_button24 = Button(description='1/minutes',
                                disabled=True,
                                layout=units_button_layout)
        units_button24.style.button_color = 'tan'
        units_button25 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button25.style.button_color = 'lightgreen'
        units_button26 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button26.style.button_color = 'tan'
        units_button27 = Button(description='dimensionlesss',
                                disabled=True,
                                layout=units_button_layout)
        units_button27.style.button_color = 'lightgreen'
        units_button28 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button28.style.button_color = 'tan'
        units_button29 = Button(description='minutes',
                                disabled=True,
                                layout=units_button_layout)
        units_button29.style.button_color = 'lightgreen'
        units_button30 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button30.style.button_color = 'tan'
        units_button31 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button31.style.button_color = 'lightgreen'
        units_button32 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button32.style.button_color = 'tan'
        units_button33 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button33.style.button_color = 'lightgreen'
        units_button34 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button34.style.button_color = 'tan'
        units_button35 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button35.style.button_color = 'lightgreen'
        units_button36 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button36.style.button_color = 'tan'

        desc_button1 = Button(description='This is a spacer',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button1.style.button_color = 'lightgreen'
        desc_button2 = Button(description='ECM_initialization_parameters',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button2.style.button_color = 'tan'
        desc_button3 = Button(description='Initial ECM anisotropy',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button3.style.button_color = 'lightgreen'
        desc_button4 = Button(description='Initial ECM density',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button4.style.button_color = 'tan'
        desc_button5 = Button(description='Lesion_intialization',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(description='Initial cell mass radius',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button6.style.button_color = 'tan'
        desc_button7 = Button(
            description='Average percentage of leaders initialized',
            disabled=True,
            layout=desc_button_layout)
        desc_button7.style.button_color = 'lightgreen'
        desc_button8 = Button(description='Cell_properties',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button8.style.button_color = 'tan'
        desc_button9 = Button(description='Default cell oxygen uptake rate',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button9.style.button_color = 'lightgreen'
        desc_button10 = Button(
            description='Strength of leader cells\' cell-cell adhesion',
            disabled=True,
            layout=desc_button_layout)
        desc_button10.style.button_color = 'tan'
        desc_button11 = Button(
            description='Strength of leader cells\' cell-cell repulsion',
            disabled=True,
            layout=desc_button_layout)
        desc_button11.style.button_color = 'lightgreen'
        desc_button12 = Button(
            description='Strength of follower cells\' cell-cell adhesion',
            disabled=True,
            layout=desc_button_layout)
        desc_button12.style.button_color = 'tan'
        desc_button13 = Button(
            description='Strength of follower cells\' cell-cell repulsion',
            disabled=True,
            layout=desc_button_layout)
        desc_button13.style.button_color = 'lightgreen'
        desc_button14 = Button(description='Base/maximum cell speed',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button14.style.button_color = 'tan'
        desc_button15 = Button(
            description='Minimum ECM density required for cell motility',
            disabled=True,
            layout=desc_button_layout)
        desc_button15.style.button_color = 'lightgreen'
        desc_button16 = Button(
            description='Maximum ECM density allowing cell motility',
            disabled=True,
            layout=desc_button_layout)
        desc_button16.style.button_color = 'tan'
        desc_button17 = Button(description='Ideal ECM density cell motility',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button17.style.button_color = 'lightgreen'
        desc_button18 = Button(description='Cell directional persistence time',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button18.style.button_color = 'tan'
        desc_button19 = Button(description='Cell ECM density target',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button19.style.button_color = 'lightgreen'
        desc_button20 = Button(
            description=
            'Cell sensitivity to ECM orientation for ECM following type cells',
            disabled=True,
            layout=desc_button_layout)
        desc_button20.style.button_color = 'tan'
        desc_button21 = Button(
            description=
            "Cell's base sensivity to previous cell direction - cell motility history bias",
            disabled=True,
            layout=desc_button_layout)
        desc_button21.style.button_color = 'lightgreen'
        desc_button22 = Button(
            description='Chemotaxis bias for non-ECM influenced cell types',
            disabled=True,
            layout=desc_button_layout)
        desc_button22.style.button_color = 'tan'
        desc_button23 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button23.style.button_color = 'lightgreen'
        desc_button24 = Button(description='Chemotactic subsrate decay rate',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button24.style.button_color = 'tan'
        desc_button25 = Button(
            description='Allows selection of various cell motility-ECM models',
            disabled=True,
            layout=desc_button_layout)
        desc_button25.style.button_color = 'lightgreen'
        desc_button26 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button26.style.button_color = 'tan'
        desc_button27 = Button(description='Testing and setup parameters',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button27.style.button_color = 'lightgreen'
        desc_button28 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button28.style.button_color = 'tan'
        desc_button29 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button29.style.button_color = 'lightgreen'
        desc_button30 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button30.style.button_color = 'tan'
        desc_button31 = Button(
            description=
            'Specifies cell, ECM, and domain parameters for consistent unit tests of ECM influenced mechanics and mechanics influence on ECM: 1 for testing set up, 0 for regular set up',
            disabled=True,
            layout=desc_button_layout)
        desc_button31.style.button_color = 'lightgreen'
        desc_button32 = Button(
            description=
            'Specifies that cells will reset their position to the left boundary and that density is 0.5 for the behavior to ECM march test 1 for march set up, 0 for regular set up',
            disabled=True,
            layout=desc_button_layout)
        desc_button32.style.button_color = 'tan'
        desc_button33 = Button(
            description=
            'Specifies the initial cell setup: single, random, lesion, cells at y = 0, circle of cells, or cells at left boundary/march',
            disabled=True,
            layout=desc_button_layout)
        desc_button33.style.button_color = 'lightgreen'
        desc_button34 = Button(
            description=
            'Specifies the initial ECM orietation: random, horizontal, vertical, circular, or starburst',
            disabled=True,
            layout=desc_button_layout)
        desc_button34.style.button_color = 'tan'
        desc_button35 = Button(
            description=
            'Specifies the chemotatic field gradient orientation: starburst, vertical up, horizontal right, angle, or none',
            disabled=True,
            layout=desc_button_layout)
        desc_button35.style.button_color = 'lightgreen'
        desc_button36 = Button(
            description=
            'Angle of chemical field gradient orientation, specified in degrees',
            disabled=True,
            layout=desc_button_layout)
        desc_button36.style.button_color = 'tan'

        row1 = [
            param_name1, self.Model_Initialization, units_button1, desc_button1
        ]
        row2 = [
            param_name2, self.ECM_initialization_parameters, units_button2,
            desc_button2
        ]
        row3 = [
            param_name3, self.initial_anisotropy, units_button3, desc_button3
        ]
        row4 = [
            param_name4, self.initial_ECM_density, units_button4, desc_button4
        ]
        row5 = [
            param_name5, self.Lesion_intialization, units_button5, desc_button5
        ]
        row6 = [param_name6, self.tumor_radius, units_button6, desc_button6]
        row7 = [
            param_name7, self.initial_leader_cell_fraction, units_button7,
            desc_button7
        ]
        row8 = [param_name8, self.Cell_properties, units_button8, desc_button8]
        row9 = [param_name9, self.oxygen_uptake, units_button9, desc_button9]
        row10 = [
            param_name10, self.leader_adhesion, units_button10, desc_button10
        ]
        row11 = [
            param_name11, self.leader_repulsion, units_button11, desc_button11
        ]
        row12 = [
            param_name12, self.follower_adhesion, units_button12, desc_button12
        ]
        row13 = [
            param_name13, self.follower_repulsion, units_button13,
            desc_button13
        ]
        row14 = [
            param_name14, self.default_cell_speed, units_button14,
            desc_button14
        ]
        row15 = [param_name15, self.rho_L, units_button15, desc_button15]
        row16 = [param_name16, self.rho_H, units_button16, desc_button16]
        row17 = [param_name17, self.rho_I, units_button17, desc_button17]
        row18 = [
            param_name18, self.default_persistence_time, units_button18,
            desc_button18
        ]
        row19 = [
            param_name19, self.default_ECM_density_target, units_button19,
            desc_button19
        ]
        row20 = [
            param_name20, self.default_ECM_sensitivity, units_button20,
            desc_button20
        ]
        row21 = [
            param_name21, self.default_hysteresis_bias, units_button21,
            desc_button21
        ]
        row22 = [
            param_name22, self.oxygen_migration_bias_for_leaders,
            units_button22, desc_button22
        ]
        row23 = [
            param_name23, self.Microenvironment_parameters, units_button23,
            desc_button23
        ]
        row24 = [
            param_name24, self.chemotactic_substrate_decay_rate,
            units_button24, desc_button24
        ]
        row25 = [
            param_name25, self.Model_Selection_Parameters, units_button25,
            desc_button25
        ]
        row26 = [
            param_name26, self.cell_motility_ECM_interaction_model_selector,
            units_button26, desc_button26
        ]
        row27 = [
            param_name27, self.Testing_and_setup_parameters, units_button27,
            desc_button27
        ]
        row28 = [
            param_name28, self.normalize_ECM_influenced_motility_vector,
            units_button28, desc_button28
        ]
        row29 = [
            param_name29, self.duration_of_uE_conditioning, units_button29,
            desc_button29
        ]
        row30 = [
            param_name30, self.freeze_uE_profile, units_button30, desc_button30
        ]
        row31 = [
            param_name31, self.unit_test_setup, units_button31, desc_button31
        ]
        row32 = [
            param_name32, self.march_unit_test_setup, units_button32,
            desc_button32
        ]
        row33 = [param_name33, self.cell_setup, units_button33, desc_button33]
        row34 = [
            param_name34, self.ECM_orientation_setup, units_button34,
            desc_button34
        ]
        row35 = [
            param_name35, self.chemical_field_setup, units_button35,
            desc_button35
        ]
        row36 = [
            param_name36, self.angle_of_chemical_field_gradient,
            units_button36, desc_button36
        ]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)
        box9 = Box(children=row9, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)
        box11 = Box(children=row11, layout=box_layout)
        box12 = Box(children=row12, layout=box_layout)
        box13 = Box(children=row13, layout=box_layout)
        box14 = Box(children=row14, layout=box_layout)
        box15 = Box(children=row15, layout=box_layout)
        box16 = Box(children=row16, layout=box_layout)
        box17 = Box(children=row17, layout=box_layout)
        box18 = Box(children=row18, layout=box_layout)
        box19 = Box(children=row19, layout=box_layout)
        box20 = Box(children=row20, layout=box_layout)
        box21 = Box(children=row21, layout=box_layout)
        box22 = Box(children=row22, layout=box_layout)
        box23 = Box(children=row23, layout=box_layout)
        box24 = Box(children=row24, layout=box_layout)
        box25 = Box(children=row25, layout=box_layout)
        box26 = Box(children=row26, layout=box_layout)
        box27 = Box(children=row27, layout=box_layout)
        box28 = Box(children=row28, layout=box_layout)
        box29 = Box(children=row29, layout=box_layout)
        box30 = Box(children=row30, layout=box_layout)
        box31 = Box(children=row31, layout=box_layout)
        box32 = Box(children=row32, layout=box_layout)
        box33 = Box(children=row33, layout=box_layout)
        box34 = Box(children=row34, layout=box_layout)
        box35 = Box(children=row35, layout=box_layout)
        box36 = Box(children=row36, layout=box_layout)

        self.tab = VBox([
            box1,
            box2,
            box3,
            box4,
            box5,
            box6,
            box7,
            box8,
            box9,
            box10,
            box11,
            box12,
            box13,
            box14,
            box15,
            box16,
            box17,
            box18,
            box19,
            box20,
            box21,
            box22,
            box23,
            box24,
            box25,
            box26,
            box27,
            box28,
            box29,
            box30,
            box31,
            box32,
            box33,
            box34,
            box35,
            box36,
        ])
Example #16
0
def plate_app():
    app = widgetify(
        plot_Surface_Potentials,
        survey=ToggleButtons(
            options=[
                "Dipole-Dipole", "Dipole-Pole", "Pole-Dipole", "Pole-Pole"
            ],
            value="Dipole-Dipole",
        ),
        dx=FloatSlider(min=1.0,
                       max=80.0,
                       step=1.0,
                       value=10.0,
                       continuous_update=False),
        dz=FloatSlider(min=1.0,
                       max=40.0,
                       step=1.0,
                       value=10.0,
                       continuous_update=False),
        xc=FloatSlider(min=-30.0,
                       max=30.0,
                       step=1.0,
                       value=0.0,
                       continuous_update=False),
        zc=FloatSlider(min=-30.0,
                       max=0.0,
                       step=1.0,
                       value=-10.0,
                       continuous_update=False),
        rotAng=FloatSlider(
            min=-90.0,
            max=90.0,
            step=1.0,
            value=0.0,
            continuous_update=False,
            description="$\\theta$",
        ),
        rhoplate=FloatText(
            min=1e-8,
            max=1e8,
            value=500.0,
            continuous_update=False,
            description="$\\rho_2$",
        ),
        rhohalf=FloatText(
            min=1e-8,
            max=1e8,
            value=500.0,
            continuous_update=False,
            description="$\\rho_1$",
        ),
        A=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=-30.25,
                      continuous_update=False),
        B=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=30.25,
                      continuous_update=False),
        M=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=-10.25,
                      continuous_update=False),
        N=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=10.25,
                      continuous_update=False),
        Field=ToggleButtons(
            options=["Model", "Potential", "E", "J", "Charge", "Sensitivity"],
            value="Model",
        ),
        Type=ToggleButtons(options=["Total", "Primary", "Secondary"],
                           value="Total"),
        Scale=ToggleButtons(options=["Linear", "Log"], value="Linear"),
    )
    return app
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        widget2_layout = {'width': '10%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}

        menv_var1 = Button(description='oxygen (mmHg)',
                           disabled=True,
                           layout=name_button_layout)
        menv_var1.style.button_color = 'tan'

        menv_atten = Button(
            description=
            'Attention! Diffusion is closed in this application to make simulation faster. Initial conditions can be specified still.',
            disabled=True,
            layout={'width': '75%'})
        menv_atten.style.button_color = 'orange'

        param_name1 = Button(description='diffusion_coefficient',
                             disabled=True,
                             layout=name_button_layout)

        self.oxygen_diffusion_coefficient = FloatText(value=0.0,
                                                      step=0.01,
                                                      style=style,
                                                      layout=widget_layout)

        param_name2 = Button(description='decay_rate',
                             disabled=True,
                             layout=name_button_layout)

        self.oxygen_decay_rate = FloatText(value=0.0,
                                           step=0.01,
                                           style=style,
                                           layout=widget_layout)
        param_name3 = Button(description='initial_condition',
                             disabled=True,
                             layout=name_button_layout)
        self.oxygen_initial_condition = FloatText(value=20.0,
                                                  style=style,
                                                  layout=widget_layout)
        param_name4 = Button(description='Dirichlet_boundary_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.oxygen_Dirichlet_boundary_condition = FloatText(
            value=20.0, style=style, layout=widget_layout)
        self.oxygen_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)

        menv_var2 = Button(description='chemokine (mM)',
                           disabled=True,
                           layout=name_button_layout)
        menv_var2.style.button_color = 'lightgreen'

        param_name5 = Button(description='diffusion_coefficient',
                             disabled=True,
                             layout=name_button_layout)

        self.chemokine_diffusion_coefficient = FloatText(value=30000.0,
                                                         step=1000,
                                                         style=style,
                                                         layout=widget_layout)

        param_name6 = Button(description='decay_rate',
                             disabled=True,
                             layout=name_button_layout)

        self.chemokine_decay_rate = FloatText(value=0.0,
                                              step=0.01,
                                              style=style,
                                              layout=widget_layout)
        param_name7 = Button(description='initial_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.chemokine_initial_condition = FloatText(value=0.0,
                                                     style=style,
                                                     layout=widget_layout)
        param_name8 = Button(description='Dirichlet_boundary_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.chemokine_Dirichlet_boundary_condition = FloatText(
            value=0.0, style=style, layout=widget_layout)
        self.chemokine_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)
        self.calculate_gradient = Checkbox(description='calculate_gradients',
                                           disabled=False,
                                           layout=desc_button_layout)
        self.track_internal = Checkbox(description='track_in_agents',
                                       disabled=False,
                                       layout=desc_button_layout)

        #  ------- micronenv info
        menv_units_button1 = Button(description='micron^2/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button2 = Button(description='1/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button3 = Button(description='mmHg',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button4 = Button(description='mmHg',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button5 = Button(description='micron^2/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button6 = Button(description='1/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button7 = Button(description='mM',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button8 = Button(description='mmHg',
                                    disabled=True,
                                    layout=units_button_layout)

        row_atten = [
            menv_atten,
        ]
        row_oxygen = [
            menv_var1,
        ]
        row1 = [
            param_name1, self.oxygen_diffusion_coefficient, menv_units_button1
        ]
        row2 = [param_name2, self.oxygen_decay_rate, menv_units_button2]
        row3 = [param_name3, self.oxygen_initial_condition, menv_units_button3]
        row4 = [
            param_name4, self.oxygen_Dirichlet_boundary_condition,
            menv_units_button4, self.oxygen_Dirichlet_boundary_condition_toggle
        ]
        row_chemokine = [
            menv_var2,
        ]
        row5 = [
            param_name5, self.chemokine_diffusion_coefficient,
            menv_units_button5
        ]
        row6 = [param_name6, self.chemokine_decay_rate, menv_units_button6]
        row7 = [
            param_name7, self.chemokine_initial_condition, menv_units_button7
        ]
        row8 = [
            param_name8, self.chemokine_Dirichlet_boundary_condition,
            menv_units_button8,
            self.chemokine_Dirichlet_boundary_condition_toggle
        ]
        row9 = [
            self.calculate_gradient,
        ]
        row10 = [
            self.track_internal,
        ]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box_atten = Box(children=row_atten)
        box_oxygen = Box(children=row_oxygen, layout=box_layout)
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box_chemokine = Box(children=row_chemokine, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)
        box9 = Box(children=row9, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)

        self.tab = VBox([
            box_atten,
            box_oxygen,
            box1,
            box2,
            box3,
            box4,
            box_chemokine,
            box5,
            box6,
            box7,
            box8,
            box9,
            box10,
        ])
Example #18
0
    def make_config(self):
        layout = Layout()
        style = {"description_width": "initial"}
        checkbox1 = Checkbox(description="Show Targets", value=self.net.config["show_targets"],
                             layout=layout, style=style)
        checkbox1.observe(lambda change: self.set_attr(self.net.config, "show_targets", change["new"]), names='value')
        checkbox2 = Checkbox(description="Errors", value=self.net.config["show_errors"],
                             layout=layout, style=style)
        checkbox2.observe(lambda change: self.set_attr(self.net.config, "show_errors", change["new"]), names='value')

        hspace = IntText(value=self.net.config["hspace"], description="Horizontal space between banks:",
                         style=style, layout=layout)
        hspace.observe(lambda change: self.set_attr(self.net.config, "hspace", change["new"]), names='value')
        vspace = IntText(value=self.net.config["vspace"], description="Vertical space between layers:",
                         style=style, layout=layout)
        vspace.observe(lambda change: self.set_attr(self.net.config, "vspace", change["new"]), names='value')
        self.feature_bank = Select(description="Details:", value=self.net.config["dashboard.features.bank"],
                              options=[""] + [layer.name for layer in self.net.layers],
                              rows=1)
        self.feature_bank.observe(self.regenerate, names='value')
        self.control_select = Select(
            options=['Test', 'Train'],
            value=self.net.config["dashboard.dataset"],
            description='Dataset:',
            rows=1
        )
        self.control_select.observe(self.change_select, names='value')
        column1 = [self.control_select,
                   self.zoom_slider,
                   hspace,
                   vspace,
                   HBox([checkbox1, checkbox2]),
                   self.feature_bank,
                   self.feature_columns,
                   self.feature_scale
        ]
        ## Make layer selectable, and update-able:
        column2 = []
        layer = self.net.layers[-1]
        self.layer_select = Select(description="Layer:", value=layer.name,
                                   options=[layer.name for layer in
                                            self.net.layers],
                                   rows=1)
        self.layer_select.observe(self.update_layer_selection, names='value')
        column2.append(self.layer_select)
        self.layer_visible_checkbox = Checkbox(description="Visible", value=layer.visible, layout=layout)
        self.layer_visible_checkbox.observe(self.update_layer, names='value')
        column2.append(self.layer_visible_checkbox)
        self.layer_colormap = Select(description="Colormap:",
                                     options=[""] + AVAILABLE_COLORMAPS,
                                     value=layer.colormap if layer.colormap is not None else "", layout=layout, rows=1)
        self.layer_colormap_image = HTML(value="""<img src="%s"/>""" % self.net._image_to_uri(self.make_colormap_image(layer.colormap)))
        self.layer_colormap.observe(self.update_layer, names='value')
        column2.append(self.layer_colormap)
        column2.append(self.layer_colormap_image)
        ## get dynamic minmax; if you change it it will set it in layer as override:
        minmax = layer.get_act_minmax()
        self.layer_mindim = FloatText(description="Leftmost color maps to:", value=minmax[0], style=style)
        self.layer_maxdim = FloatText(description="Rightmost color maps to:", value=minmax[1], style=style)
        self.layer_mindim.observe(self.update_layer, names='value')
        self.layer_maxdim.observe(self.update_layer, names='value')
        column2.append(self.layer_mindim)
        column2.append(self.layer_maxdim)
        output_shape = layer.get_output_shape()
        self.layer_feature = IntText(value=layer.feature, description="Feature to show:", style=style)
        self.svg_rotate = Checkbox(description="Rotate", value=layer.visible, layout=layout)
        self.layer_feature.observe(self.update_layer, names='value')
        column2.append(self.layer_feature)
        self.svg_rotate = Checkbox(description="Rotate network",
                                   value=self.net.config["svg_rotate"],
                                   style={"description_width": 'initial'},
                                   layout=Layout(width="52%"))
        self.svg_rotate.observe(lambda change: self.set_attr(self.net.config, "svg_rotate", change["new"]), names='value')
        self.save_config_button = Button(icon="save", layout=Layout(width="10%"))
        self.save_config_button.on_click(self.save_config)
        column2.append(HBox([self.svg_rotate, self.save_config_button]))
        config_children = HBox([VBox(column1, layout=Layout(width="100%")),
                                VBox(column2, layout=Layout(width="100%"))])
        accordion = Accordion(children=[config_children])
        accordion.set_title(0, self.net.name)
        accordion.selected_index = None
        return accordion
Example #19
0
def FieldsApp():
    Q1 = interactive(
        csem_fields_app,
        rho0=FloatText(value=1e8, description="$\\rho_{0} \ (\Omega m)$"),
        rho1=FloatText(value=0.3, description="$\\rho_{1} \ (\Omega m)$"),
        rho2=FloatText(value=1.0, description="$\\rho_{2} \ (\Omega m)$"),
        rho3=FloatText(value=100.0, description="$\\rho_{3} \ (\Omega m)$"),
        rho4=FloatText(value=1.0, description="$\\rho_{4} \ (\Omega m)$"),
        zsrc=FloatText(value=-950.0, description="src height (m)"),
        rv_rh=FloatText(value=1.0,
                        description="$\\rho_{2 \ v} / \\rho_{2 \ h}$"),
        dz1=FloatText(value=1000.0, description="dz1 (m)"),
        dz2=FloatText(value=1000.0, description="dz2 (m)"),
        dz3=FloatText(value=200.0, description="dz3 (m)"),
        frequency=FloatText(value=0.5, description="f (Hz)"),
        Field=ToggleButtons(options=["E", "H", "P"], value="E"),
        Plane=ToggleButtons(options=["XZ", "YZ"], value="XZ"),
        Fixed=widgets.widget_bool.Checkbox(value=False),
        vmin=FloatText(value=None),
        vmax=FloatText(value=None),
        __manual=True,
    )
    return Q1
Example #20
0
    def __init__(self):
        
        micron_units = Label('micron')   # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout={'width':'25%'}
        widget_layout = {'width': '15%'}
        units_button_layout ={'width':'15%'}
        desc_button_layout={'width':'45%'}

        param_name1 = Button(description='immune_activation_time', disabled=True, layout=name_button_layout)
        param_name1.style.button_color = 'lightgreen'

        self.immune_activation_time = FloatText(
          value=20160,
          step=1000,
          style=style, layout=widget_layout)

        param_name2 = Button(description='number_of_immune_cells', disabled=True, layout=name_button_layout)
        param_name2.style.button_color = 'tan'

        self.number_of_immune_cells = IntText(
          value=125,
          step=10,
          style=style, layout=widget_layout)

        param_name3 = Button(description='save_interval_after_therapy_start', disabled=True, layout=name_button_layout)
        param_name3.style.button_color = 'lightgreen'

        self.save_interval_after_therapy_start = FloatText(
          value=60,
          step=1,
          style=style, layout=widget_layout)

        param_name4 = Button(description='immune_apoptosis_rate', disabled=True, layout=name_button_layout)
        param_name4.style.button_color = 'tan'

        self.immune_apoptosis_rate = FloatText(
          value=6.944e-5,
          step=1e-05,
          style=style, layout=widget_layout)

        param_name5 = Button(description='oncoprotein_threshold', disabled=True, layout=name_button_layout)
        param_name5.style.button_color = 'lightgreen'

        self.oncoprotein_threshold = FloatText(
          value=0.1,
          step=0.01,
          style=style, layout=widget_layout)

        param_name6 = Button(description='immune_kill_rate', disabled=True, layout=name_button_layout)
        param_name6.style.button_color = 'tan'

        self.immune_kill_rate = FloatText(
          value=0.8762,
          step=0.1,
          style=style, layout=widget_layout)

        param_name7 = Button(description='immune_attachment_rate', disabled=True, layout=name_button_layout)
        param_name7.style.button_color = 'lightgreen'

        self.immune_attachment_rate = FloatText(
          value=0.72138388,
          step=0.1,
          style=style, layout=widget_layout)

        param_name8 = Button(description='immune_attachment_lifetime', disabled=True, layout=name_button_layout)
        param_name8.style.button_color = 'tan'

        self.immune_attachment_lifetime = FloatText(
          value=90.0,
          step=1,
          style=style, layout=widget_layout)

        param_name9 = Button(description='immune_migration_bias', disabled=True, layout=name_button_layout)
        param_name9.style.button_color = 'lightgreen'

        self.immune_migration_bias = FloatText(
          value=0.679587213,
          step=0.1,
          style=style, layout=widget_layout)

        param_name10 = Button(description='immune_motility_persistence_time', disabled=True, layout=name_button_layout)
        param_name10.style.button_color = 'tan'

        self.immune_motility_persistence_time = FloatText(
          value=10,
          step=1,
          style=style, layout=widget_layout)

        param_name11 = Button(description='immune_migration_speed', disabled=True, layout=name_button_layout)
        param_name11.style.button_color = 'lightgreen'

        self.immune_migration_speed = FloatText(
          value=1.0,
          step=0.1,
          style=style, layout=widget_layout)

        param_name12 = Button(description='tumor_radius', disabled=True, layout=name_button_layout)
        param_name12.style.button_color = 'tan'

        self.tumor_radius = FloatText(
          value=250,
          step=10,
          style=style, layout=widget_layout)

        param_name13 = Button(description='tumor_mean_immunogenicity', disabled=True, layout=name_button_layout)
        param_name13.style.button_color = 'lightgreen'

        self.tumor_mean_immunogenicity = FloatText(
          value=1.0,
          step=0.1,
          style=style, layout=widget_layout)

        param_name14 = Button(description='tumor_immunogenicity_standard_deviation', disabled=True, layout=name_button_layout)
        param_name14.style.button_color = 'tan'

        self.tumor_immunogenicity_standard_deviation = FloatText(
          value=0.25,
          step=0.01,
          style=style, layout=widget_layout)

        units_button1 = Button(description='min', disabled=True, layout=units_button_layout) 
        units_button1.style.button_color = 'lightgreen'
        units_button2 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button2.style.button_color = 'tan'
        units_button3 = Button(description='min', disabled=True, layout=units_button_layout) 
        units_button3.style.button_color = 'lightgreen'
        units_button4 = Button(description='1/min', disabled=True, layout=units_button_layout) 
        units_button4.style.button_color = 'tan'
        units_button5 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button5.style.button_color = 'lightgreen'
        units_button6 = Button(description='1/min', disabled=True, layout=units_button_layout) 
        units_button6.style.button_color = 'tan'
        units_button7 = Button(description='1/min', disabled=True, layout=units_button_layout) 
        units_button7.style.button_color = 'lightgreen'
        units_button8 = Button(description='min', disabled=True, layout=units_button_layout) 
        units_button8.style.button_color = 'tan'
        units_button9 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button9.style.button_color = 'lightgreen'
        units_button10 = Button(description='min', disabled=True, layout=units_button_layout) 
        units_button10.style.button_color = 'tan'
        units_button11 = Button(description='micron/min', disabled=True, layout=units_button_layout) 
        units_button11.style.button_color = 'lightgreen'
        units_button12 = Button(description='micron', disabled=True, layout=units_button_layout) 
        units_button12.style.button_color = 'tan'
        units_button13 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button13.style.button_color = 'lightgreen'
        units_button14 = Button(description='', disabled=True, layout=units_button_layout) 
        units_button14.style.button_color = 'tan'

        desc_button1 = Button(description='time at which therapy begins', disabled=True, layout=desc_button_layout) 
        desc_button1.style.button_color = 'lightgreen'
        desc_button2 = Button(description='number of immune cells at start of therapy', disabled=True, layout=desc_button_layout) 
        desc_button2.style.button_color = 'tan'
        desc_button3 = Button(description='save (output) interval after therapy begins', disabled=True, layout=desc_button_layout) 
        desc_button3.style.button_color = 'lightgreen'
        desc_button4 = Button(description='immune cell apoptosis rate (d1)', disabled=True, layout=desc_button_layout) 
        desc_button4.style.button_color = 'tan'
        desc_button5 = Button(description='cancer cells are not immunogenic for p below this value (d2)', disabled=True, layout=desc_button_layout) 
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(description='rate that attached immune cells can apoptose cancer cells (d3)', disabled=True, layout=desc_button_layout) 
        desc_button6.style.button_color = 'tan'
        desc_button7 = Button(description='rate that immune cells can attach to a cell in close contact (d4)', disabled=True, layout=desc_button_layout) 
        desc_button7.style.button_color = 'lightgreen'
        desc_button8 = Button(description='max time immune cells remain attached to a target cell (d5)', disabled=True, layout=desc_button_layout) 
        desc_button8.style.button_color = 'tan'
        desc_button9 = Button(description='immune cell migration bias (d6)', disabled=True, layout=desc_button_layout) 
        desc_button9.style.button_color = 'lightgreen'
        desc_button10 = Button(description='mean immune cell migration persistence time', disabled=True, layout=desc_button_layout) 
        desc_button10.style.button_color = 'tan'
        desc_button11 = Button(description='immune cell migration speed', disabled=True, layout=desc_button_layout) 
        desc_button11.style.button_color = 'lightgreen'
        desc_button12 = Button(description='initial tumor radius', disabled=True, layout=desc_button_layout) 
        desc_button12.style.button_color = 'tan'
        desc_button13 = Button(description='mean oncoprotein p at start', disabled=True, layout=desc_button_layout) 
        desc_button13.style.button_color = 'lightgreen'
        desc_button14 = Button(description='standard deviation of tumor p at start', disabled=True, layout=desc_button_layout) 
        desc_button14.style.button_color = 'tan'

        row1 = [param_name1, self.immune_activation_time, units_button1, desc_button1] 
        row2 = [param_name2, self.number_of_immune_cells, units_button2, desc_button2] 
        row3 = [param_name3, self.save_interval_after_therapy_start, units_button3, desc_button3] 
        row4 = [param_name4, self.immune_apoptosis_rate, units_button4, desc_button4] 
        row5 = [param_name5, self.oncoprotein_threshold, units_button5, desc_button5] 
        row6 = [param_name6, self.immune_kill_rate, units_button6, desc_button6] 
        row7 = [param_name7, self.immune_attachment_rate, units_button7, desc_button7] 
        row8 = [param_name8, self.immune_attachment_lifetime, units_button8, desc_button8] 
        row9 = [param_name9, self.immune_migration_bias, units_button9, desc_button9] 
        row10 = [param_name10, self.immune_motility_persistence_time, units_button10, desc_button10] 
        row11 = [param_name11, self.immune_migration_speed, units_button11, desc_button11] 
        row12 = [param_name12, self.tumor_radius, units_button12, desc_button12] 
        row13 = [param_name13, self.tumor_mean_immunogenicity, units_button13, desc_button13] 
        row14 = [param_name14, self.tumor_immunogenicity_standard_deviation, units_button14, desc_button14] 

        box_layout = Layout(display='flex', flex_flow='row', align_items='stretch', width='100%')
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)
        box9 = Box(children=row9, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)
        box11 = Box(children=row11, layout=box_layout)
        box12 = Box(children=row12, layout=box_layout)
        box13 = Box(children=row13, layout=box_layout)
        box14 = Box(children=row14, layout=box_layout)

        self.tab = VBox([
          box1,
          box2,
          box3,
          box4,
          box5,
          box6,
          box7,
          box8,
          box9,
          box10,
          box11,
          box12,
          box13,
          box14,
        ])
Example #21
0
def ResLayer_app():
    app = widgetify(
        plot_Surface_Potentials,
        survey=ToggleButtons(options=[
            'Dipole-Dipole', 'Dipole-Pole', 'Pole-Dipole', 'Pole-Pole'
        ],
                             value='Dipole-Dipole'),
        zcLayer=FloatSlider(min=-10.,
                            max=0.,
                            step=1.,
                            value=-10.,
                            continuous_update=False,
                            description="$zc_{layer}$"),
        dzLayer=FloatSlider(min=0.5,
                            max=5.,
                            step=0.5,
                            value=1.,
                            continuous_update=False,
                            description="$dz_{layer}$"),
        rhoLayer=FloatText(min=1e-8,
                           max=1e8,
                           value=5000.,
                           continuous_update=False,
                           description='$\\rho_{2}$'),
        xc=FloatSlider(min=-30.,
                       max=30.,
                       step=1.,
                       value=0.,
                       continuous_update=False),
        zc=FloatSlider(min=-30.,
                       max=-15.,
                       step=0.5,
                       value=-25.,
                       continuous_update=False),
        r=FloatSlider(min=1.,
                      max=10.,
                      step=0.5,
                      value=5.,
                      continuous_update=False),
        rhoHalf=FloatText(min=1e-8,
                          max=1e8,
                          value=500.,
                          continuous_update=False,
                          description='$\\rho_{1}$'),
        rhoTarget=FloatText(min=1e-8,
                            max=1e8,
                            value=500.,
                            continuous_update=False,
                            description='$\\rho_{3}$'),
        A=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=-30.25,
                      continuous_update=False),
        B=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=30.25,
                      continuous_update=False),
        M=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=-10.25,
                      continuous_update=False),
        N=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=10.25,
                      continuous_update=False),
        Field=ToggleButtons(
            options=['Model', 'Potential', 'E', 'J', 'Charge', 'Sensitivity'],
            value='Model'),
        Type=ToggleButtons(options=['Total', 'Primary', 'Secondary'],
                           value='Total'),
        Scale=ToggleButtons(options=['Linear', 'Log'], value='Linear'))
    return app
Example #22
0
def FieldsApp():
    Q1 = interactive(csem_fields_app,
                     rho0=FloatText(value=1e8,
                                    description='$\\rho_{0} \ (\Omega m)$'),
                     rho1=FloatText(value=0.3,
                                    description='$\\rho_{1} \ (\Omega m)$'),
                     rho2=FloatText(value=1.,
                                    description='$\\rho_{2} \ (\Omega m)$'),
                     rho3=FloatText(value=100.,
                                    description='$\\rho_{3} \ (\Omega m)$'),
                     rho4=FloatText(value=1.,
                                    description='$\\rho_{4} \ (\Omega m)$'),
                     zsrc=FloatText(value=-950., description='src height (m)'),
                     rv_rh=FloatText(
                         value=1.,
                         description='$\\rho_{2 \ v} / \\rho_{2 \ h}$'),
                     dz1=FloatText(value=1000., description="dz1 (m)"),
                     dz2=FloatText(value=1000., description="dz2 (m)"),
                     dz3=FloatText(value=200., description="dz3 (m)"),
                     frequency=FloatText(value=0.5, description='f (Hz)'),
                     Field=ToggleButtons(options=['E', 'H', 'P'], value='E'),
                     Plane=ToggleButtons(options=['XZ', 'YZ'], value='XZ'),
                     Fixed=widgets.widget_bool.Checkbox(value=False),
                     vmin=FloatText(value=None),
                     vmax=FloatText(value=None),
                     __manual=True)
    return Q1
        FROM
            dbo.fGetNearbyObjEq({}, {}, {}) AS n
        JOIN Star AS s ON n.objID = s.objID
  
        WHERE
            g - r BETWEEN -0.5 AND 2.5
            AND g BETWEEN 14 and 24
        """.format(ra,dec,ang)
        
    return SDSS.query_sql(query, timeout = 600)

#Create widgets
style = {'description_width': 'initial'}

#Boxes and sliders to control the parameters of the query function
RABox = FloatText(value='229.0128', placeholder='', description='Right ascension (degrees)', style=style, disabled=False, grid_area = 'RABox')
RASlider = FloatSlider(value=229.0128, min=0, max=360, continuous_update = False, grid_area = 'RASlider')

DECBox = FloatText(value='-0.1082', placeholder='', description='Declination (degrees)', style=style, disabled=False, grid_area = 'DECBox')
DECSlider = FloatSlider(value=-0.1082, min=-90, max=90, continuous_update = False, grid_area = 'DECSlider')

radBox = FloatText(value='30', placeholder='', description='Radius (arcminutes)', style=style, disabled=False, grid_area = 'radBox')
radSlider = FloatSlider(value=30, min=1, max=120, step=1, continuous_update = False, grid_area = 'radSlider')

#Slider to control the grid size for the Hess diagram
gridSlider = IntSlider(value=100, min=50, max=300, step=1, description='Grid size', style=style, continuous_update = False, grid_area = 'gridSlider')

#Dropdown menu to select the color map for the Hess diagram
hexDrop = Dropdown(options = ['viridis', 'plasma', 'inferno', 'magma', 'hot', 'winter', 'ocean', 'gray', 'binary'],
                   value = 'viridis',
                   description = 'Hess diagram colormap',
Example #24
0
def DataApp():

    frequency = FloatText(value=0.5, description='f (Hz)')
    zsrc = FloatText(value=-950., description='src height (m)')
    zrx = FloatText(value=-1000., description='rx height (m)')
    rho0 = FloatText(value=1e8, description='$\\rho_{0} \ (\Omega m)$')
    rho1 = FloatText(value=0.3, description='$\\rho_{1} \ (\Omega m)$')
    rho2 = FloatText(value=1., description='$\\rho_{2} \ (\Omega m)$')
    rho3 = FloatText(value=100., description='$\\rho_{3} \ (\Omega m)$')
    rho4 = FloatText(value=1., description='$\\rho_{4} \ (\Omega m)$')
    rv_rh = FloatText(value=1., description='$\\rho_{2 \ v} / \\rho_{2 \ h}$')
    dz1 = FloatText(value=1000., description="dz1 (m)")
    dz2 = FloatText(value=1000., description="dz2 (m)")
    dz3 = FloatText(value=200., description="dz3 (m)")
    frequency_bg = FloatText(value=0.5, description='f$^{BG}$ (Hz)')
    zsrc_bg = FloatText(value=-950., description='src height$^{BG}$ (m)')
    zrx_bg = FloatText(value=-1000., description='rx height$^{BG}$ (m)')
    rho0_bg = FloatText(value=1e8, description='$\\rho_{0}^{BG} \ (\Omega m)$')
    rho1_bg = FloatText(value=0.3, description='$\\rho_{1}^{BG} \ (\Omega m)$')
    rho2_bg = FloatText(value=1., description='$\\rho_{2}^{BG} \ (\Omega m)$')
    rho3_bg = FloatText(value=1., description='$\\rho_{3}^{BG} \ (\Omega m)$')
    rho4_bg = FloatText(value=1., description='$\\rho_{4}^{BG} \ (\Omega m)$')
    rv_rh_bg = FloatText(
        value=1., description='$\\rho_{2 \ v}^{BG} / \\rho_{2 \ h}^{BG}$')
    dz1_bg = FloatText(value=1000., description="dz1$^{BG}$ (m)")
    dz2_bg = FloatText(value=1000., description="dz2$^{BG}$ (m)")
    dz3_bg = FloatText(value=200., description="dz3$^{BG}$ (m)")
    Field = ToggleButtons(options=['E', 'H', 'Zxy'],
                          value='E',
                          description="Field")
    Plane = ToggleButtons(options=['XZ', 'YZ'],
                          value='XZ',
                          description="Plane")
    Component = ToggleButtons(options=['x', 'y', 'z'],
                              value='x',
                              description="rx direction")
    Complex = ToggleButtons(options=['Real', 'Imag', "Amp", "Phase"],
                            value='Amp',
                            description="Complex")
    scale = ToggleButtons(options=['log', 'linear'],
                          value='log',
                          description="Scale")
    Fixed = widgets.widget_bool.Checkbox(value=False, description="Fixed")
    vmin = FloatText(value=None, description='vmin')
    vmax = FloatText(value=None, description='vmax')
    __manual = True

    out = widgets.interactive_output(
        csem_data_app, {
            "frequency": frequency,
            "zsrc": zsrc,
            "zrx": zrx,
            "rho0": rho0,
            "rho1": rho1,
            "rho2": rho2,
            "rho3": rho3,
            "rho4": rho4,
            "rv_rh": rv_rh,
            "dz1": dz1,
            "dz2": dz2,
            "dz3": dz3,
            "frequency_bg": frequency_bg,
            "zsrc_bg": zsrc_bg,
            "zrx_bg": zrx_bg,
            "rho0_bg": rho0_bg,
            "rho1_bg": rho1_bg,
            "rho2_bg": rho2_bg,
            "rho3_bg": rho3_bg,
            "rho4_bg": rho4_bg,
            "rv_rh_bg": rv_rh_bg,
            "dz1_bg": dz1_bg,
            "dz2_bg": dz2_bg,
            "dz3_bg": dz3_bg,
            "Field": Field,
            "Plane": Plane,
            "Component": Component,
            "Complex": Complex,
            "scale": scale,
            "Fixed": Fixed,
            "vmin": vmin,
            "vmax": vmax,
        })

    panel = VBox([
        frequency, zsrc, zrx, rho0, rho1, rho2, rho3, rho4, rv_rh, dz1, dz2,
        dz3
    ])
    panel_bg = VBox([
        frequency_bg, zsrc_bg, zrx_bg, rho0_bg, rho1_bg, rho2_bg, rho3_bg,
        rho4_bg, rv_rh_bg, dz1_bg, dz2_bg, dz3_bg
    ])
    panel_type = VBox(
        [Field, Plane, Component, Complex, scale, Fixed, vmin, vmax])
    return VBox([HBox([panel, panel_bg]), panel_type, out])
Example #25
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}

        param_name1 = Button(description='Volume',
                             disabled=True,
                             layout=name_button_layout)
        param_name1.style.button_color = 'lightgreen'

        self.Volume = Text(value='"Parameters"',
                           style=style,
                           layout=widget_layout)

        param_name2 = Button(description='Volume_target_solid_cytoplasmic',
                             disabled=True,
                             layout=name_button_layout)
        param_name2.style.button_color = 'tan'

        self.Volume_target_solid_cytoplasmic = FloatText(value=488.5,
                                                         step=10,
                                                         style=style,
                                                         layout=widget_layout)

        param_name3 = Button(description='Volume_target_solid_nuclear',
                             disabled=True,
                             layout=name_button_layout)
        param_name3.style.button_color = 'lightgreen'

        self.Volume_target_solid_nuclear = FloatText(value=135.0,
                                                     step=10,
                                                     style=style,
                                                     layout=widget_layout)

        param_name4 = Button(description='Volume_target_fluid_fraction',
                             disabled=True,
                             layout=name_button_layout)
        param_name4.style.button_color = 'tan'

        self.Volume_target_fluid_fraction = FloatText(value=0.75,
                                                      step=0.1,
                                                      style=style,
                                                      layout=widget_layout)

        param_name5 = Button(
            description='Volume_cytoplasmic_biomass_change_rate',
            disabled=True,
            layout=name_button_layout)
        param_name5.style.button_color = 'lightgreen'

        self.Volume_cytoplasmic_biomass_change_rate = FloatText(
            value=0.0045, step=0.001, style=style, layout=widget_layout)

        param_name6 = Button(description='Volume_nuclear_biomass_change_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name6.style.button_color = 'tan'

        self.Volume_nuclear_biomass_change_rate = FloatText(
            value=0.0055, step=0.001, style=style, layout=widget_layout)

        param_name7 = Button(description='Volume_fluid_change_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name7.style.button_color = 'lightgreen'

        self.Volume_fluid_change_rate = FloatText(value=0.05,
                                                  step=0.01,
                                                  style=style,
                                                  layout=widget_layout)

        param_name8 = Button(description='Volume_calcification_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name8.style.button_color = 'tan'

        self.Volume_calcification_rate = FloatText(value=0.0,
                                                   step=0.01,
                                                   style=style,
                                                   layout=widget_layout)

        param_name9 = Button(description='Volume_Total',
                             disabled=True,
                             layout=name_button_layout)
        param_name9.style.button_color = 'lightgreen'

        self.Volume_Total = FloatText(value=2494,
                                      step=100,
                                      style=style,
                                      layout=widget_layout)

        param_name10 = Button(description='Volume_solid',
                              disabled=True,
                              layout=name_button_layout)
        param_name10.style.button_color = 'tan'

        self.Volume_solid = FloatText(value=623.5,
                                      step=10,
                                      style=style,
                                      layout=widget_layout)

        param_name11 = Button(description='Volume_fluid',
                              disabled=True,
                              layout=name_button_layout)
        param_name11.style.button_color = 'lightgreen'

        self.Volume_fluid = FloatText(value=1870.5,
                                      step=100,
                                      style=style,
                                      layout=widget_layout)

        param_name12 = Button(description='Volume_fluid_fraction',
                              disabled=True,
                              layout=name_button_layout)
        param_name12.style.button_color = 'tan'

        self.Volume_fluid_fraction = FloatText(value=0.75,
                                               step=0.1,
                                               style=style,
                                               layout=widget_layout)

        param_name13 = Button(description='Volume_nuclear',
                              disabled=True,
                              layout=name_button_layout)
        param_name13.style.button_color = 'lightgreen'

        self.Volume_nuclear = FloatText(value=540.0,
                                        step=10,
                                        style=style,
                                        layout=widget_layout)

        param_name14 = Button(description='Volume_nuclear_solid',
                              disabled=True,
                              layout=name_button_layout)
        param_name14.style.button_color = 'tan'

        self.Volume_nuclear_solid = FloatText(value=135.0,
                                              step=10,
                                              style=style,
                                              layout=widget_layout)

        param_name15 = Button(description='Volume_nuclear_fluid',
                              disabled=True,
                              layout=name_button_layout)
        param_name15.style.button_color = 'lightgreen'

        self.Volume_nuclear_fluid = FloatText(value=405.0,
                                              step=10,
                                              style=style,
                                              layout=widget_layout)

        param_name16 = Button(description='Volume_cytoplasmic',
                              disabled=True,
                              layout=name_button_layout)
        param_name16.style.button_color = 'tan'

        self.Volume_cytoplasmic = FloatText(value=1954.0,
                                            step=100,
                                            style=style,
                                            layout=widget_layout)

        param_name17 = Button(description='Volume_cytoplasmic_solid',
                              disabled=True,
                              layout=name_button_layout)
        param_name17.style.button_color = 'lightgreen'

        self.Volume_cytoplasmic_solid = FloatText(value=488.5,
                                                  step=10,
                                                  style=style,
                                                  layout=widget_layout)

        param_name18 = Button(description='Volume_cytoplasmic_fluid',
                              disabled=True,
                              layout=name_button_layout)
        param_name18.style.button_color = 'tan'

        self.Volume_cytoplasmic_fluid = FloatText(value=1465.5,
                                                  step=100,
                                                  style=style,
                                                  layout=widget_layout)

        param_name19 = Button(description='Volume_clacification_fraction',
                              disabled=True,
                              layout=name_button_layout)
        param_name19.style.button_color = 'lightgreen'

        self.Volume_clacification_fraction = FloatText(value=0.0,
                                                       step=0.01,
                                                       style=style,
                                                       layout=widget_layout)

        param_name20 = Button(
            description='Volume_cytoplasmic_to_nuclear_ratio',
            disabled=True,
            layout=name_button_layout)
        param_name20.style.button_color = 'tan'

        self.Volume_cytoplasmic_to_nuclear_ratio = FloatText(
            value=3.6, step=0.1, style=style, layout=widget_layout)

        param_name21 = Button(description='use_function_multiply_by_ratio',
                              disabled=True,
                              layout=name_button_layout)
        param_name21.style.button_color = 'lightgreen'

        self.use_function_multiply_by_ratio = Checkbox(value=False,
                                                       style=style,
                                                       layout=widget_layout)

        param_name22 = Button(description='multiplication_ratio_value',
                              disabled=True,
                              layout=name_button_layout)
        param_name22.style.button_color = 'tan'

        self.multiplication_ratio_value = FloatText(value=2.0,
                                                    step=0.1,
                                                    style=style,
                                                    layout=widget_layout)

        units_button1 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button1.style.button_color = 'lightgreen'
        units_button2 = Button(description='cubic_micron',
                               disabled=True,
                               layout=units_button_layout)
        units_button2.style.button_color = 'tan'
        units_button3 = Button(description='cubic_micron',
                               disabled=True,
                               layout=units_button_layout)
        units_button3.style.button_color = 'lightgreen'
        units_button4 = Button(description='cubic_micron',
                               disabled=True,
                               layout=units_button_layout)
        units_button4.style.button_color = 'tan'
        units_button5 = Button(description='cubic_micron/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button5.style.button_color = 'lightgreen'
        units_button6 = Button(description='cubic_micron/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button6.style.button_color = 'tan'
        units_button7 = Button(description='cubic_micron/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button7.style.button_color = 'lightgreen'
        units_button8 = Button(description='cubic_micron/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button8.style.button_color = 'tan'
        units_button9 = Button(description='cubic_micron',
                               disabled=True,
                               layout=units_button_layout)
        units_button9.style.button_color = 'lightgreen'
        units_button10 = Button(description='cubic_micron',
                                disabled=True,
                                layout=units_button_layout)
        units_button10.style.button_color = 'tan'
        units_button11 = Button(description='cubic_micron',
                                disabled=True,
                                layout=units_button_layout)
        units_button11.style.button_color = 'lightgreen'
        units_button12 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button12.style.button_color = 'tan'
        units_button13 = Button(description='cubic_micron',
                                disabled=True,
                                layout=units_button_layout)
        units_button13.style.button_color = 'lightgreen'
        units_button14 = Button(description='cubic_micron',
                                disabled=True,
                                layout=units_button_layout)
        units_button14.style.button_color = 'tan'
        units_button15 = Button(description='cubic_micron',
                                disabled=True,
                                layout=units_button_layout)
        units_button15.style.button_color = 'lightgreen'
        units_button16 = Button(description='cubic_micron',
                                disabled=True,
                                layout=units_button_layout)
        units_button16.style.button_color = 'tan'
        units_button17 = Button(description='cubic_micron',
                                disabled=True,
                                layout=units_button_layout)
        units_button17.style.button_color = 'lightgreen'
        units_button18 = Button(description='cubic_micron',
                                disabled=True,
                                layout=units_button_layout)
        units_button18.style.button_color = 'tan'
        units_button19 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button19.style.button_color = 'lightgreen'
        units_button20 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button20.style.button_color = 'tan'
        units_button21 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button21.style.button_color = 'lightgreen'
        units_button22 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button22.style.button_color = 'tan'

        desc_button1 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button1.style.button_color = 'lightgreen'
        desc_button2 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button2.style.button_color = 'tan'
        desc_button3 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button3.style.button_color = 'lightgreen'
        desc_button4 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button4.style.button_color = 'tan'
        desc_button5 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button6.style.button_color = 'tan'
        desc_button7 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button7.style.button_color = 'lightgreen'
        desc_button8 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button8.style.button_color = 'tan'
        desc_button9 = Button(description='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button9.style.button_color = 'lightgreen'
        desc_button10 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button10.style.button_color = 'tan'
        desc_button11 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button11.style.button_color = 'lightgreen'
        desc_button12 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button12.style.button_color = 'tan'
        desc_button13 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button13.style.button_color = 'lightgreen'
        desc_button14 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button14.style.button_color = 'tan'
        desc_button15 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button15.style.button_color = 'lightgreen'
        desc_button16 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button16.style.button_color = 'tan'
        desc_button17 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button17.style.button_color = 'lightgreen'
        desc_button18 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button18.style.button_color = 'tan'
        desc_button19 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button19.style.button_color = 'lightgreen'
        desc_button20 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button20.style.button_color = 'tan'
        desc_button21 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button21.style.button_color = 'lightgreen'
        desc_button22 = Button(description='',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button22.style.button_color = 'tan'

        row1 = [param_name1, self.Volume, units_button1, desc_button1]
        row2 = [
            param_name2, self.Volume_target_solid_cytoplasmic, units_button2,
            desc_button2
        ]
        row3 = [
            param_name3, self.Volume_target_solid_nuclear, units_button3,
            desc_button3
        ]
        row4 = [
            param_name4, self.Volume_target_fluid_fraction, units_button4,
            desc_button4
        ]
        row5 = [
            param_name5, self.Volume_cytoplasmic_biomass_change_rate,
            units_button5, desc_button5
        ]
        row6 = [
            param_name6, self.Volume_nuclear_biomass_change_rate,
            units_button6, desc_button6
        ]
        row7 = [
            param_name7, self.Volume_fluid_change_rate, units_button7,
            desc_button7
        ]
        row8 = [
            param_name8, self.Volume_calcification_rate, units_button8,
            desc_button8
        ]
        row9 = [param_name9, self.Volume_Total, units_button9, desc_button9]
        row10 = [
            param_name10, self.Volume_solid, units_button10, desc_button10
        ]
        row11 = [
            param_name11, self.Volume_fluid, units_button11, desc_button11
        ]
        row12 = [
            param_name12, self.Volume_fluid_fraction, units_button12,
            desc_button12
        ]
        row13 = [
            param_name13, self.Volume_nuclear, units_button13, desc_button13
        ]
        row14 = [
            param_name14, self.Volume_nuclear_solid, units_button14,
            desc_button14
        ]
        row15 = [
            param_name15, self.Volume_nuclear_fluid, units_button15,
            desc_button15
        ]
        row16 = [
            param_name16, self.Volume_cytoplasmic, units_button16,
            desc_button16
        ]
        row17 = [
            param_name17, self.Volume_cytoplasmic_solid, units_button17,
            desc_button17
        ]
        row18 = [
            param_name18, self.Volume_cytoplasmic_fluid, units_button18,
            desc_button18
        ]
        row19 = [
            param_name19, self.Volume_clacification_fraction, units_button19,
            desc_button19
        ]
        row20 = [
            param_name20, self.Volume_cytoplasmic_to_nuclear_ratio,
            units_button20, desc_button20
        ]
        row21 = [
            param_name21, self.use_function_multiply_by_ratio, units_button21,
            desc_button21
        ]
        row22 = [
            param_name22, self.multiplication_ratio_value, units_button22,
            desc_button22
        ]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)
        box9 = Box(children=row9, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)
        box11 = Box(children=row11, layout=box_layout)
        box12 = Box(children=row12, layout=box_layout)
        box13 = Box(children=row13, layout=box_layout)
        box14 = Box(children=row14, layout=box_layout)
        box15 = Box(children=row15, layout=box_layout)
        box16 = Box(children=row16, layout=box_layout)
        box17 = Box(children=row17, layout=box_layout)
        box18 = Box(children=row18, layout=box_layout)
        box19 = Box(children=row19, layout=box_layout)
        box20 = Box(children=row20, layout=box_layout)
        box21 = Box(children=row21, layout=box_layout)
        box22 = Box(children=row22, layout=box_layout)

        self.tab = VBox([
            box1,
            box2,
            box3,
            box4,
            box5,
            box6,
            box7,
            box8,
            box9,
            box10,
            box11,
            box12,
            box13,
            box14,
            box15,
            box16,
            box17,
            box18,
            box19,
            box20,
            box21,
            box22,
        ])
Example #26
0
def ResLayer_app():
    app = widgetify(
        PLOT,
        manual=True,
        survey=ToggleButtons(
            options=[
                "Dipole-Dipole", "Dipole-Pole", "Pole-Dipole", "Pole-Pole"
            ],
            value="Dipole-Dipole",
        ),
        zcLayer=FloatSlider(
            min=-10.0,
            max=0.0,
            step=1.0,
            value=-10.0,
            continuous_update=False,
            description="$zc_{layer}$",
        ),
        dzLayer=FloatSlider(
            min=0.5,
            max=5.0,
            step=0.5,
            value=1.0,
            continuous_update=False,
            description="$dz_{layer}$",
        ),
        rholayer=FloatText(
            min=1e-8,
            max=1e8,
            value=5000.0,
            continuous_update=False,
            description="$\\rho_{2}$",
        ),
        xc=FloatSlider(min=-30.0,
                       max=30.0,
                       step=1.0,
                       value=0.0,
                       continuous_update=False),
        zc=FloatSlider(min=-30.0,
                       max=-15.0,
                       step=0.5,
                       value=-25.0,
                       continuous_update=False),
        r=FloatSlider(min=1.0,
                      max=10.0,
                      step=0.5,
                      value=5.0,
                      continuous_update=False),
        rhoTarget=FloatText(
            min=1e-8,
            max=1e8,
            value=500.0,
            continuous_update=False,
            description="$\\rho_{3}$",
        ),
        rhohalf=FloatText(
            min=1e-8,
            max=1e8,
            value=500.0,
            continuous_update=False,
            description="$\\rho_{1}$",
        ),
        A=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=-30.25,
                      continuous_update=False),
        B=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=30.25,
                      continuous_update=False),
        M=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=-10.25,
                      continuous_update=False),
        N=FloatSlider(min=-30.25,
                      max=30.25,
                      step=0.5,
                      value=10.25,
                      continuous_update=False),
        Field=ToggleButtons(
            options=["Model", "Potential", "E", "J", "Charge", "Sensitivity"],
            value="Model",
        ),
        Type=ToggleButtons(options=["Total", "Primary", "Secondary"],
                           value="Total"),
        Scale=ToggleButtons(options=["Linear", "Log"], value="Linear"),
    )
    return app
 def interact_plot_model(self):
     Q = interact(
         self.plot_model,
         m_background=FloatSlider(
             min=-2,
             max=2,
             step=0.05,
             value=0.0,
             continuous_update=False,
             description="m$_{background}$",
         ),
         m1=FloatSlider(
             min=-2,
             max=2,
             step=0.05,
             value=1.0,
             continuous_update=False,
             description="m1",
         ),
         m2=FloatSlider(
             min=-2,
             max=2,
             step=0.05,
             value=2.0,
             continuous_update=False,
             description="m2",
         ),
         m1_center=FloatSlider(
             min=-2,
             max=2,
             step=0.05,
             value=0.2,
             continuous_update=False,
             description="m1$_{center}$",
         ),
         dm1=FloatSlider(
             min=0,
             max=0.5,
             step=0.05,
             value=0.2,
             continuous_update=False,
             description="m1$_{width}$",
         ),
         m2_center=FloatSlider(
             min=-2,
             max=2,
             step=0.05,
             value=0.75,
             continuous_update=False,
             description="m2$_{center}$",
         ),
         sigma_2=FloatSlider(
             min=0.01,
             max=0.1,
             step=0.01,
             value=0.07,
             continuous_update=False,
             description="m2$_{sigma}$",
         ),
         option=SelectMultiple(
             options=["kernel", "model", "data"],
             value=["model"],
             description="option",
         ),
         percentage=FloatText(value=5),
         floor=FloatText(value=0.02),
     )
     return Q
Example #28
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}

        menv_var1 = Button(description='resource',
                           disabled=True,
                           layout=name_button_layout)
        menv_var1.style.button_color = 'tan'

        param_name1 = Button(description='diffusion_coefficient',
                             disabled=True,
                             layout=name_button_layout)

        self.resource_diffusion_coefficient = FloatText(value=100000,
                                                        step=10000,
                                                        style=style,
                                                        layout=widget_layout)

        param_name2 = Button(description='decay_rate',
                             disabled=True,
                             layout=name_button_layout)

        self.resource_decay_rate = FloatText(value=0.1,
                                             step=0.01,
                                             style=style,
                                             layout=widget_layout)
        param_name3 = Button(description='initial_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.resource_initial_condition = FloatText(value=0,
                                                    style=style,
                                                    layout=widget_layout)
        param_name4 = Button(description='Dirichlet_boundary_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.resource_Dirichlet_boundary_condition = FloatText(
            value=0, style=style, layout=widget_layout)
        self.resource_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)

        menv_var2 = Button(description='quorum',
                           disabled=True,
                           layout=name_button_layout)
        menv_var2.style.button_color = 'lightgreen'

        param_name5 = Button(description='diffusion_coefficient',
                             disabled=True,
                             layout=name_button_layout)

        self.quorum_diffusion_coefficient = FloatText(value=100000,
                                                      step=10000,
                                                      style=style,
                                                      layout=widget_layout)

        param_name6 = Button(description='decay_rate',
                             disabled=True,
                             layout=name_button_layout)

        self.quorum_decay_rate = FloatText(value=10,
                                           step=1,
                                           style=style,
                                           layout=widget_layout)
        param_name7 = Button(description='initial_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.quorum_initial_condition = FloatText(value=0,
                                                  style=style,
                                                  layout=widget_layout)
        param_name8 = Button(description='Dirichlet_boundary_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.quorum_Dirichlet_boundary_condition = FloatText(
            value=0, style=style, layout=widget_layout)
        self.quorum_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)

        menv_var3 = Button(description='death_signal',
                           disabled=True,
                           layout=name_button_layout)
        menv_var3.style.button_color = 'tan'

        param_name9 = Button(description='diffusion_coefficient',
                             disabled=True,
                             layout=name_button_layout)

        self.death_signal_diffusion_coefficient = FloatText(
            value=40000, step=1000, style=style, layout=widget_layout)

        param_name10 = Button(description='decay_rate',
                              disabled=True,
                              layout=name_button_layout)

        self.death_signal_decay_rate = FloatText(value=1,
                                                 step=0.1,
                                                 style=style,
                                                 layout=widget_layout)
        param_name11 = Button(description='initial_condition',
                              disabled=True,
                              layout=name_button_layout)

        self.death_signal_initial_condition = FloatText(value=0,
                                                        style=style,
                                                        layout=widget_layout)
        param_name12 = Button(description='Dirichlet_boundary_condition',
                              disabled=True,
                              layout=name_button_layout)

        self.death_signal_Dirichlet_boundary_condition = FloatText(
            value=0, style=style, layout=widget_layout)
        self.death_signal_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)

        menv_var4 = Button(description='signal',
                           disabled=True,
                           layout=name_button_layout)
        menv_var4.style.button_color = 'lightgreen'

        param_name13 = Button(description='diffusion_coefficient',
                              disabled=True,
                              layout=name_button_layout)

        self.signal_diffusion_coefficient = FloatText(value=25000,
                                                      step=1000,
                                                      style=style,
                                                      layout=widget_layout)

        param_name14 = Button(description='decay_rate',
                              disabled=True,
                              layout=name_button_layout)

        self.signal_decay_rate = FloatText(value=0.1,
                                           step=0.01,
                                           style=style,
                                           layout=widget_layout)
        param_name15 = Button(description='initial_condition',
                              disabled=True,
                              layout=name_button_layout)

        self.signal_initial_condition = FloatText(value=0,
                                                  style=style,
                                                  layout=widget_layout)
        param_name16 = Button(description='Dirichlet_boundary_condition',
                              disabled=True,
                              layout=name_button_layout)

        self.signal_Dirichlet_boundary_condition = FloatText(
            value=0, style=style, layout=widget_layout)
        self.signal_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)

        menv_var5 = Button(description='poison',
                           disabled=True,
                           layout=name_button_layout)
        menv_var5.style.button_color = 'tan'

        param_name17 = Button(description='diffusion_coefficient',
                              disabled=True,
                              layout=name_button_layout)

        self.poison_diffusion_coefficient = FloatText(value=50000,
                                                      step=1000,
                                                      style=style,
                                                      layout=widget_layout)

        param_name18 = Button(description='decay_rate',
                              disabled=True,
                              layout=name_button_layout)

        self.poison_decay_rate = FloatText(value=20.,
                                           step=1,
                                           style=style,
                                           layout=widget_layout)
        param_name19 = Button(description='initial_condition',
                              disabled=True,
                              layout=name_button_layout)

        self.poison_initial_condition = FloatText(value=0,
                                                  style=style,
                                                  layout=widget_layout)
        param_name20 = Button(description='Dirichlet_boundary_condition',
                              disabled=True,
                              layout=name_button_layout)

        self.poison_Dirichlet_boundary_condition = FloatText(
            value=0, style=style, layout=widget_layout)
        self.poison_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)
        self.calculate_gradient = Checkbox(description='calculate_gradients',
                                           disabled=False,
                                           layout=desc_button_layout)
        self.track_internal = Checkbox(description='track_in_agents',
                                       disabled=False,
                                       layout=desc_button_layout)

        #  ------- micronenv info
        menv_units_button1 = Button(description='micron^2/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button2 = Button(description='1/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button3 = Button(description='mmHg',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button4 = Button(description='mmHg',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button5 = Button(description='micron^2/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button6 = Button(description='1/min',
                                    disabled=True,
                                    layout=units_button_layout)
        units_button1 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button2 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        menv_units_button9 = Button(description='micron^2/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button10 = Button(description='1/min',
                                     disabled=True,
                                     layout=units_button_layout)
        units_button3 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button4 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        menv_units_button13 = Button(description='micron^2/min',
                                     disabled=True,
                                     layout=units_button_layout)
        menv_units_button14 = Button(description='1/min',
                                     disabled=True,
                                     layout=units_button_layout)
        units_button5 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button6 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        menv_units_button17 = Button(description='micron^2/min',
                                     disabled=True,
                                     layout=units_button_layout)
        menv_units_button18 = Button(description='1/min',
                                     disabled=True,
                                     layout=units_button_layout)
        units_button7 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button8 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)

        row_resource = [
            menv_var1,
        ]
        row1 = [
            param_name1, self.resource_diffusion_coefficient,
            menv_units_button1
        ]
        row2 = [param_name2, self.resource_decay_rate, menv_units_button2]
        row3 = [
            param_name3, self.resource_initial_condition, menv_units_button3
        ]
        row4 = [
            param_name4, self.resource_Dirichlet_boundary_condition,
            menv_units_button4,
            self.resource_Dirichlet_boundary_condition_toggle
        ]
        row_quorum = [
            menv_var2,
        ]
        row5 = [
            param_name5, self.quorum_diffusion_coefficient, menv_units_button5
        ]
        row6 = [param_name6, self.quorum_decay_rate, menv_units_button6]
        row7 = [param_name7, self.quorum_initial_condition, units_button1]
        row8 = [
            param_name8, self.quorum_Dirichlet_boundary_condition,
            units_button2, self.quorum_Dirichlet_boundary_condition_toggle
        ]
        row_death_signal = [
            menv_var3,
        ]
        row9 = [
            param_name9, self.death_signal_diffusion_coefficient,
            menv_units_button9
        ]
        row10 = [
            param_name10, self.death_signal_decay_rate, menv_units_button10
        ]
        row11 = [
            param_name11, self.death_signal_initial_condition, units_button3
        ]
        row12 = [
            param_name12, self.death_signal_Dirichlet_boundary_condition,
            units_button4,
            self.death_signal_Dirichlet_boundary_condition_toggle
        ]
        row_signal = [
            menv_var4,
        ]
        row13 = [
            param_name13, self.signal_diffusion_coefficient,
            menv_units_button13
        ]
        row14 = [param_name14, self.signal_decay_rate, menv_units_button14]
        row15 = [param_name15, self.signal_initial_condition, units_button5]
        row16 = [
            param_name16, self.signal_Dirichlet_boundary_condition,
            units_button6, self.signal_Dirichlet_boundary_condition_toggle
        ]
        row_poison = [
            menv_var5,
        ]
        row17 = [
            param_name17, self.poison_diffusion_coefficient,
            menv_units_button17
        ]
        row18 = [param_name18, self.poison_decay_rate, menv_units_button18]
        row19 = [param_name19, self.poison_initial_condition, units_button7]
        row20 = [
            param_name20, self.poison_Dirichlet_boundary_condition,
            units_button8, self.poison_Dirichlet_boundary_condition_toggle
        ]
        row21 = [
            self.calculate_gradient,
        ]
        row22 = [
            self.track_internal,
        ]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box_resource = Box(children=row_resource, layout=box_layout)
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box_quorum = Box(children=row_quorum, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)
        box_death_signal = Box(children=row_death_signal, layout=box_layout)
        box9 = Box(children=row9, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)
        box11 = Box(children=row11, layout=box_layout)
        box12 = Box(children=row12, layout=box_layout)
        box_signal = Box(children=row_signal, layout=box_layout)
        box13 = Box(children=row13, layout=box_layout)
        box14 = Box(children=row14, layout=box_layout)
        box15 = Box(children=row15, layout=box_layout)
        box16 = Box(children=row16, layout=box_layout)
        box_poison = Box(children=row_poison, layout=box_layout)
        box17 = Box(children=row17, layout=box_layout)
        box18 = Box(children=row18, layout=box_layout)
        box19 = Box(children=row19, layout=box_layout)
        box20 = Box(children=row20, layout=box_layout)
        box21 = Box(children=row21, layout=box_layout)
        box22 = Box(children=row22, layout=box_layout)

        self.tab = VBox([
            box_resource,
            box1,
            box2,
            box3,
            box4,
            box_quorum,
            box5,
            box6,
            box7,
            box8,
            box_death_signal,
            box9,
            box10,
            box11,
            box12,
            box_signal,
            box13,
            box14,
            box15,
            box16,
            box_poison,
            box17,
            box18,
            box19,
            box20,
            box21,
            box22,
        ])
Example #29
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        widget2_layout = {'width': '10%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}

        menv_var1 = Button(description='electrical_potential (volt)',
                           disabled=True,
                           layout=name_button_layout)
        menv_var1.style.button_color = 'tan'

        param_name1 = Button(description='diffusion_coefficient',
                             disabled=True,
                             layout=name_button_layout)

        self.electrical_potential_diffusion_coefficient = FloatText(
            value=0, step=0.01, style=style, layout=widget_layout)

        param_name2 = Button(description='decay_rate',
                             disabled=True,
                             layout=name_button_layout)

        self.electrical_potential_decay_rate = FloatText(value=0,
                                                         step=0.01,
                                                         style=style,
                                                         layout=widget_layout)
        param_name3 = Button(description='initial_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.electrical_potential_initial_condition = FloatText(
            value=0, style=style, layout=widget_layout)
        param_name4 = Button(description='Dirichlet_boundary_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.electrical_potential_Dirichlet_boundary_condition = FloatText(
            value=0, style=style, layout=widget_layout)
        self.electrical_potential_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)

        menv_var2 = Button(description='quorum_factor_1',
                           disabled=True,
                           layout=name_button_layout)
        menv_var2.style.button_color = 'lightgreen'

        param_name5 = Button(description='diffusion_coefficient',
                             disabled=True,
                             layout=name_button_layout)

        self.quorum_factor_1_diffusion_coefficient = FloatText(
            value=50000, step=1000, style=style, layout=widget_layout)

        param_name6 = Button(description='decay_rate',
                             disabled=True,
                             layout=name_button_layout)

        self.quorum_factor_1_decay_rate = FloatText(value=0.1,
                                                    step=0.01,
                                                    style=style,
                                                    layout=widget_layout)
        param_name7 = Button(description='initial_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.quorum_factor_1_initial_condition = FloatText(
            value=0.0, style=style, layout=widget_layout)
        param_name8 = Button(description='Dirichlet_boundary_condition',
                             disabled=True,
                             layout=name_button_layout)

        self.quorum_factor_1_Dirichlet_boundary_condition = FloatText(
            value=0, style=style, layout=widget_layout)
        self.quorum_factor_1_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)

        menv_var3 = Button(description='quorum_factor_2',
                           disabled=True,
                           layout=name_button_layout)
        menv_var3.style.button_color = 'tan'

        param_name9 = Button(description='diffusion_coefficient',
                             disabled=True,
                             layout=name_button_layout)

        self.quorum_factor_2_diffusion_coefficient = FloatText(
            value=50000, step=1000, style=style, layout=widget_layout)

        param_name10 = Button(description='decay_rate',
                              disabled=True,
                              layout=name_button_layout)

        self.quorum_factor_2_decay_rate = FloatText(value=0.1,
                                                    step=0.01,
                                                    style=style,
                                                    layout=widget_layout)
        param_name11 = Button(description='initial_condition',
                              disabled=True,
                              layout=name_button_layout)

        self.quorum_factor_2_initial_condition = FloatText(
            value=0.0, style=style, layout=widget_layout)
        param_name12 = Button(description='Dirichlet_boundary_condition',
                              disabled=True,
                              layout=name_button_layout)

        self.quorum_factor_2_Dirichlet_boundary_condition = FloatText(
            value=0, style=style, layout=widget_layout)
        self.quorum_factor_2_Dirichlet_boundary_condition_toggle = Checkbox(
            description='on/off',
            disabled=False,
            style=style,
            layout=widget_layout)
        self.calculate_gradient = Checkbox(description='calculate_gradients',
                                           disabled=False,
                                           layout=desc_button_layout)
        self.track_internal = Checkbox(description='track_in_agents',
                                       disabled=False,
                                       layout=desc_button_layout)

        #  ------- micronenv info
        menv_units_button1 = Button(description='micron^2/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button2 = Button(description='1/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button3 = Button(description='mmHg',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button4 = Button(description='mmHg',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button5 = Button(description='micron^2/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button6 = Button(description='1/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button7 = Button(description='mmHg',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button8 = Button(description='mmHg',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button9 = Button(description='micron^2/min',
                                    disabled=True,
                                    layout=units_button_layout)
        menv_units_button10 = Button(description='1/min',
                                     disabled=True,
                                     layout=units_button_layout)
        menv_units_button11 = Button(description='mmHg',
                                     disabled=True,
                                     layout=units_button_layout)
        menv_units_button12 = Button(description='mmHg',
                                     disabled=True,
                                     layout=units_button_layout)

        row_electrical_potential = [
            menv_var1,
        ]
        row1 = [
            param_name1, self.electrical_potential_diffusion_coefficient,
            menv_units_button1
        ]
        row2 = [
            param_name2, self.electrical_potential_decay_rate,
            menv_units_button2
        ]
        row3 = [
            param_name3, self.electrical_potential_initial_condition,
            menv_units_button3
        ]
        row4 = [
            param_name4,
            self.electrical_potential_Dirichlet_boundary_condition,
            menv_units_button4,
            self.electrical_potential_Dirichlet_boundary_condition_toggle
        ]
        row_quorum_factor_1 = [
            menv_var2,
        ]
        row5 = [
            param_name5, self.quorum_factor_1_diffusion_coefficient,
            menv_units_button5
        ]
        row6 = [
            param_name6, self.quorum_factor_1_decay_rate, menv_units_button6
        ]
        row7 = [
            param_name7, self.quorum_factor_1_initial_condition,
            menv_units_button7
        ]
        row8 = [
            param_name8, self.quorum_factor_1_Dirichlet_boundary_condition,
            menv_units_button8,
            self.quorum_factor_1_Dirichlet_boundary_condition_toggle
        ]
        row_quorum_factor_2 = [
            menv_var3,
        ]
        row9 = [
            param_name9, self.quorum_factor_2_diffusion_coefficient,
            menv_units_button9
        ]
        row10 = [
            param_name10, self.quorum_factor_2_decay_rate, menv_units_button10
        ]
        row11 = [
            param_name11, self.quorum_factor_2_initial_condition,
            menv_units_button11
        ]
        row12 = [
            param_name12, self.quorum_factor_2_Dirichlet_boundary_condition,
            menv_units_button12,
            self.quorum_factor_2_Dirichlet_boundary_condition_toggle
        ]
        row13 = [
            self.calculate_gradient,
        ]
        row14 = [
            self.track_internal,
        ]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box_electrical_potential = Box(children=row_electrical_potential,
                                       layout=box_layout)
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box_quorum_factor_1 = Box(children=row_quorum_factor_1,
                                  layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)
        box_quorum_factor_2 = Box(children=row_quorum_factor_2,
                                  layout=box_layout)
        box9 = Box(children=row9, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)
        box11 = Box(children=row11, layout=box_layout)
        box12 = Box(children=row12, layout=box_layout)
        box13 = Box(children=row13, layout=box_layout)
        box14 = Box(children=row14, layout=box_layout)

        self.tab = VBox([
            box_electrical_potential,
            box1,
            box2,
            box3,
            box4,
            box_quorum_factor_1,
            box5,
            box6,
            box7,
            box8,
            box_quorum_factor_2,
            box9,
            box10,
            box11,
            box12,
            box13,
            box14,
        ])
Example #30
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}
        divider_button_layout = {'width': '40%'}

        param_name1 = Button(description='tumor_transition_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name1.style.button_color = 'tan'

        self.tumor_transition_rate = FloatText(value=0.0022956841138659324,
                                               step=0.0001,
                                               style=style,
                                               layout=widget_layout)

        param_name2 = Button(description='tumor_max_necrosis_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name2.style.button_color = 'lightgreen'

        self.tumor_max_necrosis_rate = FloatText(value=0.002777777777777778,
                                                 step=0.0001,
                                                 style=style,
                                                 layout=widget_layout)

        param_name3 = Button(description='elastic_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name3.style.button_color = 'tan'

        self.elastic_rate = FloatText(value=0.05,
                                      step=0.01,
                                      style=style,
                                      layout=widget_layout)

        param_name4 = Button(description='plastic_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name4.style.button_color = 'lightgreen'

        self.plastic_rate = FloatText(value=0.0005,
                                      step=0.0001,
                                      style=style,
                                      layout=widget_layout)

        param_name5 = Button(description='max_ECM_displacement',
                             disabled=True,
                             layout=name_button_layout)
        param_name5.style.button_color = 'tan'

        self.max_ECM_displacement = FloatText(value=0.75,
                                              step=0.1,
                                              style=style,
                                              layout=widget_layout)

        param_name6 = Button(description='tumor_max_pressue',
                             disabled=True,
                             layout=name_button_layout)
        param_name6.style.button_color = 'lightgreen'

        self.tumor_max_pressue = FloatText(value=1.0,
                                           step=0.1,
                                           style=style,
                                           layout=widget_layout)

        param_name7 = Button(description='if_random_seed',
                             disabled=True,
                             layout=name_button_layout)
        param_name7.style.button_color = 'tan'

        self.if_random_seed = Checkbox(value=False,
                                       style=style,
                                       layout=widget_layout)

        units_button1 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button1.style.button_color = 'tan'
        units_button2 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button2.style.button_color = 'lightgreen'
        units_button3 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button3.style.button_color = 'tan'
        units_button4 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button4.style.button_color = 'lightgreen'
        units_button5 = Button(description='micron',
                               disabled=True,
                               layout=units_button_layout)
        units_button5.style.button_color = 'tan'
        units_button6 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button6.style.button_color = 'lightgreen'
        units_button7 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button7.style.button_color = 'tan'

        desc_button2 = Button(
            description='The proliferation rate of tumor cells',
            tooltip='The proliferation rate of tumor cells',
            disabled=True,
            layout=desc_button_layout)
        desc_button2.style.button_color = 'tan'
        desc_button3 = Button(
            description='The maximum necrosis rate of tumor cells',
            tooltip='The maximum necrosis rate of tumor cells',
            disabled=True,
            layout=desc_button_layout)
        desc_button3.style.button_color = 'lightgreen'
        desc_button4 = Button(
            description='The elastic force rate for parenchyma',
            tooltip='The elastic force rate for parenchyma',
            disabled=True,
            layout=desc_button_layout)
        desc_button4.style.button_color = 'tan'
        desc_button5 = Button(
            description='The plastic reorganization force rate for parenchyma',
            tooltip='The plastic reorganization force rate for parenchyma',
            disabled=True,
            layout=desc_button_layout)
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(
            description='The maximum tolerated displacement for parenchyma',
            tooltip='The maximum tolerated displacement for parenchyma',
            disabled=True,
            layout=desc_button_layout)
        desc_button6.style.button_color = 'tan'
        desc_button7 = Button(
            description=
            'The maximum pressure threshold for tumor cells proliferation',
            tooltip=
            'The maximum pressure threshold for tumor cells proliferation',
            disabled=True,
            layout=desc_button_layout)
        desc_button7.style.button_color = 'lightgreen'
        desc_button8 = Button(
            description=
            'Boolean variable that used to enable or disable random seeding',
            tooltip=
            'Boolean variable that used to enable or disable random seeding',
            disabled=True,
            layout=desc_button_layout)
        desc_button8.style.button_color = 'tan'

        row2 = [
            param_name1, self.tumor_transition_rate, units_button1,
            desc_button2
        ]
        row3 = [
            param_name2, self.tumor_max_necrosis_rate, units_button2,
            desc_button3
        ]
        row4 = [param_name3, self.elastic_rate, units_button3, desc_button4]
        row5 = [param_name4, self.plastic_rate, units_button4, desc_button5]
        row6 = [
            param_name5, self.max_ECM_displacement, units_button5, desc_button6
        ]
        row7 = [
            param_name6, self.tumor_max_pressue, units_button6, desc_button7
        ]
        row8 = [param_name7, self.if_random_seed, units_button7, desc_button8]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)

        self.tab = VBox([
            box2,
            box3,
            box4,
            box5,
            box6,
            box7,
            box8,
        ])
Example #31
0
class SubstrateTab(object):
    def __init__(self):

        self.output_dir = '.'
        #        self.output_dir = 'tmpdir'

        # self.fig = plt.figure(figsize=(7.2,6))  # this strange figsize results in a ~square contour plot

        # initial value
        self.field_index = 4
        # self.field_index = self.mcds_field.value + 4

        tab_height = '500px'
        constWidth = '180px'
        constWidth2 = '150px'
        tab_layout = Layout(
            width='900px',  # border='2px solid black',
            height=tab_height,
        )  #overflow_y='scroll')

        max_frames = 1
        self.mcds_plot = interactive(self.plot_substrate,
                                     frame=(0, max_frames),
                                     continuous_update=False)
        svg_plot_size = '700px'
        self.mcds_plot.layout.width = svg_plot_size
        self.mcds_plot.layout.height = svg_plot_size

        self.max_frames = BoundedIntText(
            min=0,
            max=99999,
            value=max_frames,
            description='Max',
            layout=Layout(width='160px'),
        )
        self.max_frames.observe(self.update_max_frames)

        self.field_min_max = {'dummy': [0., 1.]}
        # hacky I know, but make a dict that's got (key,value) reversed from the dict in the Dropdown below
        self.field_dict = {0: 'dummy'}

        self.mcds_field = Dropdown(
            options={'dummy': 0},
            value=0,
            #     description='Field',
            layout=Layout(width=constWidth))
        # print("substrate __init__: self.mcds_field.value=",self.mcds_field.value)
        #        self.mcds_field.observe(self.mcds_field_cb)
        self.mcds_field.observe(self.mcds_field_changed_cb)

        # self.field_cmap = Text(
        #     value='viridis',
        #     description='Colormap',
        #     disabled=True,
        #     layout=Layout(width=constWidth),
        # )
        self.field_cmap = Dropdown(
            options=['viridis', 'jet', 'YlOrRd'],
            value='viridis',
            #     description='Field',
            layout=Layout(width=constWidth))
        #self.field_cmap.observe(self.plot_substrate)
        #        self.field_cmap.observe(self.plot_substrate)
        self.field_cmap.observe(self.mcds_field_cb)

        self.cmap_fixed = Checkbox(
            description='Fix',
            disabled=False,
            #           layout=Layout(width=constWidth2),
        )

        self.save_min_max = Button(
            description='Save',  #style={'description_width': 'initial'},
            button_style=
            'success',  # 'success', 'info', 'warning', 'danger' or ''
            tooltip='Save min/max for this substrate',
            disabled=True,
            layout=Layout(width='90px'))

        def save_min_max_cb(b):
            #            field_name = self.mcds_field.options[]
            #            field_name = next(key for key, value in self.mcds_field.options.items() if value == self.mcds_field.value)
            field_name = self.field_dict[self.mcds_field.value]
            #            print(field_name)
            #            self.field_min_max = {'oxygen': [0., 30.], 'glucose': [0., 1.], 'H+ ions': [0., 1.], 'ECM': [0., 1.], 'NP1': [0., 1.], 'NP2': [0., 1.]}
            self.field_min_max[field_name][0] = self.cmap_min.value
            self.field_min_max[field_name][1] = self.cmap_max.value
#            print(self.field_min_max)

        self.save_min_max.on_click(save_min_max_cb)

        self.cmap_min = FloatText(
            description='Min',
            value=0,
            step=0.1,
            disabled=True,
            layout=Layout(width=constWidth2),
        )
        self.cmap_min.observe(self.mcds_field_cb)

        self.cmap_max = FloatText(
            description='Max',
            value=38,
            step=0.1,
            disabled=True,
            layout=Layout(width=constWidth2),
        )
        self.cmap_max.observe(self.mcds_field_cb)

        def cmap_fixed_cb(b):
            if (self.cmap_fixed.value):
                self.cmap_min.disabled = False
                self.cmap_max.disabled = False
                self.save_min_max.disabled = False
            else:
                self.cmap_min.disabled = True
                self.cmap_max.disabled = True
                self.save_min_max.disabled = True
#            self.mcds_field_cb()

        self.cmap_fixed.observe(cmap_fixed_cb)

        field_cmap_row2 = HBox([self.field_cmap, self.cmap_fixed])

        #        field_cmap_row3 = HBox([self.save_min_max, self.cmap_min, self.cmap_max])
        items_auto = [
            self.save_min_max,  #layout=Layout(flex='3 1 auto', width='auto'),
            self.cmap_min,
            self.cmap_max,
        ]
        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='80%')
        field_cmap_row3 = Box(children=items_auto, layout=box_layout)

        #        field_cmap_row3 = Box([self.save_min_max, self.cmap_min, self.cmap_max])

        # mcds_tab = widgets.VBox([mcds_dir, mcds_plot, mcds_play], layout=tab_layout)
        mcds_params = VBox([
            self.mcds_field, field_cmap_row2, field_cmap_row3, self.max_frames
        ])  # mcds_dir
        #        mcds_params = VBox([self.mcds_field, field_cmap_row2, field_cmap_row3,])  # mcds_dir

        #        self.tab = HBox([mcds_params, self.mcds_plot], layout=tab_layout)
        #        self.tab = HBox([mcds_params, self.mcds_plot])

        help_label = Label('select slider: drag or left/right arrows')
        row1 = Box([
            help_label,
            Box([self.max_frames, self.mcds_field, self.field_cmap],
                layout=Layout(border='0px solid black',
                              width='50%',
                              height='',
                              align_items='stretch',
                              flex_direction='row',
                              display='flex'))
        ])
        row2 = Box([self.cmap_fixed, self.cmap_min, self.cmap_max],
                   layout=Layout(border='0px solid black',
                                 width='50%',
                                 height='',
                                 align_items='stretch',
                                 flex_direction='row',
                                 display='flex'))
        self.tab = VBox([row1, row2, self.mcds_plot])

    #---------------------------------------------------
    def update_dropdown_fields(self, data_dir):
        # print('update_dropdown_fields called --------')
        self.output_dir = data_dir
        tree = None
        try:
            fname = os.path.join(self.output_dir, "initial.xml")
            tree = ET.parse(fname)
#            return
        except:
            print("Cannot open ", fname, " to get names of substrate fields.")
            return

        xml_root = tree.getroot()
        self.field_min_max = {}
        self.field_dict = {}
        dropdown_options = {}
        uep = xml_root.find('.//variables')
        comment_str = ""
        field_idx = 0
        if (uep):
            for elm in uep.findall('variable'):
                # print("-----> ",elm.attrib['name'])
                self.field_min_max[elm.attrib['name']] = [0., 1.]
                self.field_dict[field_idx] = elm.attrib['name']
                dropdown_options[elm.attrib['name']] = field_idx
                field_idx += 1

#        constWidth = '180px'
# print('options=',dropdown_options)
        self.mcds_field.value = 0
        self.mcds_field.options = dropdown_options
#         self.mcds_field = Dropdown(
# #            options={'oxygen': 0, 'glucose': 1},
#             options=dropdown_options,
#             value=0,
#             #     description='Field',
#            layout=Layout(width=constWidth)
#         )

    def update_max_frames_expected(
            self, value):  # called when beginning an interactive Run
        self.max_frames.value = value  # assumes naming scheme: "snapshot%08d.svg"
        self.mcds_plot.children[0].max = self.max_frames.value

    def update(self, rdir):
        self.output_dir = rdir
        if rdir == '':
            # self.max_frames.value = 0
            tmpdir = os.path.abspath('tmpdir')
            self.output_dir = tmpdir
            all_files = sorted(glob.glob(os.path.join(tmpdir, 'output*.xml')))
            if len(all_files) > 0:
                last_file = all_files[-1]
                self.max_frames.value = int(
                    last_file[-12:-4]
                )  # assumes naming scheme: "output%08d.xml"
                self.mcds_plot.update()
            return

        all_files = sorted(glob.glob(os.path.join(rdir, 'output*.xml')))
        if len(all_files) > 0:
            last_file = all_files[-1]
            self.max_frames.value = int(
                last_file[-12:-4])  # assumes naming scheme: "output%08d.xml"
            self.mcds_plot.update()

    def update_max_frames(self, _b):
        self.mcds_plot.children[0].max = self.max_frames.value

    def mcds_field_changed_cb(self, b):
        # print("mcds_field_changed_cb: self.mcds_field.value=",self.mcds_field.value)
        if (self.mcds_field.value == None):
            return
        self.field_index = self.mcds_field.value + 4

        field_name = self.field_dict[self.mcds_field.value]
        #        print('mcds_field_cb: '+field_name)
        self.cmap_min.value = self.field_min_max[field_name][0]
        self.cmap_max.value = self.field_min_max[field_name][1]
        self.mcds_plot.update()

    def mcds_field_cb(self, b):
        #self.field_index = self.mcds_field.value
        #        self.field_index = self.mcds_field.options.index(self.mcds_field.value) + 4
        #        self.field_index = self.mcds_field.options[self.mcds_field.value]
        self.field_index = self.mcds_field.value + 4

        # field_name = self.mcds_field.options[self.mcds_field.value]
        # self.cmap_min.value = self.field_min_max[field_name][0]  # oxygen, etc
        # self.cmap_max.value = self.field_min_max[field_name][1]  # oxygen, etc

        #        self.field_index = self.mcds_field.value + 4

        #        print('field_index=',self.field_index)
        self.mcds_plot.update()

    def plot_substrate(self, frame):
        # global current_idx, axes_max, gFileId, field_index
        fname = "output%08d_microenvironment0.mat" % frame
        xml_fname = "output%08d.xml" % frame
        # fullname = output_dir_str + fname

        #        fullname = fname
        full_fname = os.path.join(self.output_dir, fname)
        full_xml_fname = os.path.join(self.output_dir, xml_fname)
        #        self.output_dir = '.'

        #        if not os.path.isfile(fullname):
        if not os.path.isfile(full_fname):
            #            print("File does not exist: ", full_fname)
            #            print("No: ", full_fname)
            print("Once output files are generated, click the slider."
                  )  # No:  output00000000_microenvironment0.mat

            return

#        tree = ET.parse(xml_fname)
        tree = ET.parse(full_xml_fname)
        xml_root = tree.getroot()
        mins = round(int(float(xml_root.find(
            ".//current_time").text)))  # TODO: check units = mins
        hrs = int(mins / 60)
        days = int(hrs / 24)
        title_str = '%dd, %dh, %dm' % (int(days),
                                       (hrs % 24), mins - (hrs * 60))

        info_dict = {}
        #        scipy.io.loadmat(fullname, info_dict)
        scipy.io.loadmat(full_fname, info_dict)
        M = info_dict['multiscale_microenvironment']
        #     global_field_index = int(mcds_field.value)
        #     print('plot_substrate: field_index =',field_index)
        f = M[
            self.
            field_index, :]  # 4=tumor cells field, 5=blood vessel density, 6=growth substrate
        # plt.clf()
        # my_plot = plt.imshow(f.reshape(400,400), cmap='jet', extent=[0,20, 0,20])

        self.fig = plt.figure(figsize=(
            7.2, 6))  # this strange figsize results in a ~square contour plot
        #     fig.set_tight_layout(True)
        #     ax = plt.axes([0, 0.05, 0.9, 0.9 ]) #left, bottom, width, height
        #     ax = plt.axes([0, 0.0, 1, 1 ])
        #     cmap = plt.cm.viridis # Blues, YlOrBr, ...
        #     im = ax.imshow(f.reshape(100,100), interpolation='nearest', cmap=cmap, extent=[0,20, 0,20])
        #     ax.grid(False)

        N = int(math.sqrt(len(M[0, :])))
        grid2D = M[0, :].reshape(N, N)
        xvec = grid2D[0, :]

        num_contours = 15
        #        levels = MaxNLocator(nbins=10).tick_values(vmin, vmax)
        levels = MaxNLocator(nbins=num_contours).tick_values(
            self.cmap_min.value, self.cmap_max.value)
        if (self.cmap_fixed.value):
            my_plot = plt.contourf(xvec,
                                   xvec,
                                   M[self.field_index, :].reshape(N, N),
                                   levels=levels,
                                   extend='both',
                                   cmap=self.field_cmap.value)
        else:
            #        my_plot = plt.contourf(xvec, xvec, M[self.field_index, :].reshape(N,N), num_contours, cmap=self.field_cmap.value)
            my_plot = plt.contourf(xvec,
                                   xvec,
                                   M[self.field_index, :].reshape(N, N),
                                   num_contours,
                                   cmap=self.field_cmap.value)

        plt.title(title_str)
        plt.colorbar(my_plot)
        axes_min = 0
        axes_max = 2000
Example #32
0
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}
        divider_button_layout = {'width': '40%'}

        param_name1 = Button(description='random_seed',
                             disabled=True,
                             layout=name_button_layout)
        param_name1.style.button_color = 'lightgreen'

        self.random_seed = IntText(value=0,
                                   step=1,
                                   style=style,
                                   layout=widget_layout)

        div_row1 = Button(description='---Virus Replication---',
                          disabled=True,
                          layout=divider_button_layout)

        param_name2 = Button(description='virion_uncoating_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name2.style.button_color = 'tan'

        self.virion_uncoating_rate = FloatText(value=0.01,
                                               step=0.001,
                                               style=style,
                                               layout=widget_layout)

        param_name3 = Button(description='uncoated_to_RNA_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name3.style.button_color = 'lightgreen'

        self.uncoated_to_RNA_rate = FloatText(value=0.01,
                                              step=0.001,
                                              style=style,
                                              layout=widget_layout)

        param_name4 = Button(description='protein_synthesis_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name4.style.button_color = 'tan'

        self.protein_synthesis_rate = FloatText(value=0.01,
                                                step=0.001,
                                                style=style,
                                                layout=widget_layout)

        param_name5 = Button(description='virion_assembly_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name5.style.button_color = 'lightgreen'

        self.virion_assembly_rate = FloatText(value=0.01,
                                              step=0.001,
                                              style=style,
                                              layout=widget_layout)

        div_row2 = Button(description='---Virus Adsorption and Export---',
                          disabled=True,
                          layout=divider_button_layout)

        param_name6 = Button(description='virion_export_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name6.style.button_color = 'tan'

        self.virion_export_rate = FloatText(value=0.01,
                                            step=0.001,
                                            style=style,
                                            layout=widget_layout)

        div_row3 = Button(
            description='---ACE2 receptor dynamics with virus binding---',
            disabled=True,
            layout=divider_button_layout)

        param_name7 = Button(description='ACE2_receptors_per_cell',
                             disabled=True,
                             layout=name_button_layout)
        param_name7.style.button_color = 'lightgreen'

        self.ACE2_receptors_per_cell = FloatText(value=1000,
                                                 step=100,
                                                 style=style,
                                                 layout=widget_layout)

        param_name8 = Button(description='ACE2_binding_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name8.style.button_color = 'tan'

        self.ACE2_binding_rate = FloatText(value=0.001,
                                           step=0.0001,
                                           style=style,
                                           layout=widget_layout)

        param_name9 = Button(description='ACE2_endocytosis_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name9.style.button_color = 'lightgreen'

        self.ACE2_endocytosis_rate = FloatText(value=0.01,
                                               step=0.001,
                                               style=style,
                                               layout=widget_layout)

        param_name10 = Button(description='ACE2_cargo_release_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name10.style.button_color = 'tan'

        self.ACE2_cargo_release_rate = FloatText(value=0.001,
                                                 step=0.0001,
                                                 style=style,
                                                 layout=widget_layout)

        param_name11 = Button(description='ACE2_recycling_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name11.style.button_color = 'lightgreen'

        self.ACE2_recycling_rate = FloatText(value=0.01,
                                             step=0.001,
                                             style=style,
                                             layout=widget_layout)

        div_row4 = Button(description='---Apoptotic Response---',
                          disabled=True,
                          layout=divider_button_layout)

        param_name12 = Button(description='max_infected_apoptosis_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name12.style.button_color = 'tan'

        self.max_infected_apoptosis_rate = FloatText(value=0.001,
                                                     step=0.0001,
                                                     style=style,
                                                     layout=widget_layout)

        param_name13 = Button(description='max_apoptosis_half_max',
                              disabled=True,
                              layout=name_button_layout)
        param_name13.style.button_color = 'lightgreen'

        self.max_apoptosis_half_max = FloatText(value=500,
                                                step=10,
                                                style=style,
                                                layout=widget_layout)

        param_name14 = Button(description='apoptosis_hill_power',
                              disabled=True,
                              layout=name_button_layout)
        param_name14.style.button_color = 'tan'

        self.apoptosis_hill_power = FloatText(value=1,
                                              step=0.1,
                                              style=style,
                                              layout=widget_layout)

        param_name15 = Button(description='virus_fraction_released_at_death',
                              disabled=True,
                              layout=name_button_layout)
        param_name15.style.button_color = 'lightgreen'

        self.virus_fraction_released_at_death = FloatText(value=0,
                                                          step=0.01,
                                                          style=style,
                                                          layout=widget_layout)

        div_row5 = Button(description='---Initialization Options--',
                          disabled=True,
                          layout=divider_button_layout)

        param_name16 = Button(description='multiplicity_of_infection',
                              disabled=True,
                              layout=name_button_layout)
        param_name16.style.button_color = 'tan'

        self.multiplicity_of_infection = FloatText(value=0.01,
                                                   step=0.001,
                                                   style=style,
                                                   layout=widget_layout)

        param_name17 = Button(description='use_single_infected_cell',
                              disabled=True,
                              layout=name_button_layout)
        param_name17.style.button_color = 'lightgreen'

        self.use_single_infected_cell = Checkbox(value=False,
                                                 style=style,
                                                 layout=widget_layout)

        div_row6 = Button(description='---Visualization Options---',
                          disabled=True,
                          layout=divider_button_layout)

        param_name18 = Button(description='color_variable',
                              disabled=True,
                              layout=name_button_layout)
        param_name18.style.button_color = 'tan'

        self.color_variable = Text(value='assembled virion',
                                   style=style,
                                   layout=widget_layout)

        units_button1 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button1.style.button_color = 'lightgreen'
        units_button2 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button2.style.button_color = 'lightgreen'
        units_button3 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button3.style.button_color = 'tan'
        units_button4 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button4.style.button_color = 'lightgreen'
        units_button5 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button5.style.button_color = 'tan'
        units_button6 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button6.style.button_color = 'lightgreen'
        units_button7 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button7.style.button_color = 'lightgreen'
        units_button8 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button8.style.button_color = 'tan'
        units_button9 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button9.style.button_color = 'tan'
        units_button10 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button10.style.button_color = 'lightgreen'
        units_button11 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button11.style.button_color = 'tan'
        units_button12 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button12.style.button_color = 'lightgreen'
        units_button13 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button13.style.button_color = 'tan'
        units_button14 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button14.style.button_color = 'lightgreen'
        units_button15 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button15.style.button_color = 'lightgreen'
        units_button16 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button16.style.button_color = 'tan'
        units_button17 = Button(description='virion',
                                disabled=True,
                                layout=units_button_layout)
        units_button17.style.button_color = 'lightgreen'
        units_button18 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button18.style.button_color = 'tan'
        units_button19 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button19.style.button_color = 'lightgreen'
        units_button20 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button20.style.button_color = 'lightgreen'
        units_button21 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button21.style.button_color = 'tan'
        units_button22 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button22.style.button_color = 'lightgreen'
        units_button23 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button23.style.button_color = 'lightgreen'
        units_button24 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button24.style.button_color = 'tan'

        desc_button1 = Button(description='',
                              tooltip='',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button1.style.button_color = 'lightgreen'
        desc_button2 = Button(
            description='rate at which an internalized virion is uncoated',
            tooltip='rate at which an internalized virion is uncoated',
            disabled=True,
            layout=desc_button_layout)
        desc_button2.style.button_color = 'tan'
        desc_button3 = Button(
            description=
            'rate at which uncoated virion makes its mRNA available',
            tooltip='rate at which uncoated virion makes its mRNA available',
            disabled=True,
            layout=desc_button_layout)
        desc_button3.style.button_color = 'lightgreen'
        desc_button4 = Button(
            description='rate at mRNA creates complete set of proteins',
            tooltip='rate at mRNA creates complete set of proteins',
            disabled=True,
            layout=desc_button_layout)
        desc_button4.style.button_color = 'tan'
        desc_button5 = Button(
            description=
            'rate at which viral proteins are assembled into complete virion',
            tooltip=
            'rate at which viral proteins are assembled into complete virion',
            disabled=True,
            layout=desc_button_layout)
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(
            description='rate at which a virion is exported from a live cell',
            tooltip='rate at which a virion is exported from a live cell',
            disabled=True,
            layout=desc_button_layout)
        desc_button6.style.button_color = 'tan'
        desc_button7 = Button(description='number of ACE2 receptors per cell',
                              tooltip='number of ACE2 receptors per cell',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button7.style.button_color = 'lightgreen'
        desc_button8 = Button(description='ACE2 receptor-virus binding rate',
                              tooltip='ACE2 receptor-virus binding rate',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button8.style.button_color = 'tan'
        desc_button9 = Button(
            description='ACE2 receptor-virus endocytosis rate',
            tooltip='ACE2 receptor-virus endocytosis rate',
            disabled=True,
            layout=desc_button_layout)
        desc_button9.style.button_color = 'lightgreen'
        desc_button10 = Button(
            description='ACE2 receptor-virus cargo release rate',
            tooltip='ACE2 receptor-virus cargo release rate',
            disabled=True,
            layout=desc_button_layout)
        desc_button10.style.button_color = 'tan'
        desc_button11 = Button(description='ACE2 receptor recycling rate',
                               tooltip='ACE2 receptor recycling rate',
                               disabled=True,
                               layout=desc_button_layout)
        desc_button11.style.button_color = 'lightgreen'
        desc_button12 = Button(
            description='maximum rate of cell apoptosis due to viral infection',
            tooltip='maximum rate of cell apoptosis due to viral infection',
            disabled=True,
            layout=desc_button_layout)
        desc_button12.style.button_color = 'tan'
        desc_button13 = Button(
            description=
            'viral load at which cells reach half max apoptosis rate',
            tooltip='viral load at which cells reach half max apoptosis rate',
            disabled=True,
            layout=desc_button_layout)
        desc_button13.style.button_color = 'lightgreen'
        desc_button14 = Button(
            description='Hill power for viral load apoptosis response',
            tooltip='Hill power for viral load apoptosis response',
            disabled=True,
            layout=desc_button_layout)
        desc_button14.style.button_color = 'tan'
        desc_button15 = Button(
            description='fraction of internal virus released at cell death',
            tooltip='fraction of internal virus released at cell death',
            disabled=True,
            layout=desc_button_layout)
        desc_button15.style.button_color = 'lightgreen'
        desc_button16 = Button(
            description='multiplicity of infection: virions/cells at t=0',
            tooltip='multiplicity of infection: virions/cells at t=0',
            disabled=True,
            layout=desc_button_layout)
        desc_button16.style.button_color = 'tan'
        desc_button17 = Button(
            description='Infect center cell with one virion (overrides MOI)',
            tooltip='Infect center cell with one virion (overrides MOI)',
            disabled=True,
            layout=desc_button_layout)
        desc_button17.style.button_color = 'lightgreen'
        desc_button18 = Button(
            description='color cells based on this variable',
            tooltip='color cells based on this variable',
            disabled=True,
            layout=desc_button_layout)
        desc_button18.style.button_color = 'tan'

        row1 = [param_name1, self.random_seed, units_button1, desc_button1]
        row2 = [
            param_name2, self.virion_uncoating_rate, units_button3,
            desc_button2
        ]
        row3 = [
            param_name3, self.uncoated_to_RNA_rate, units_button4, desc_button3
        ]
        row4 = [
            param_name4, self.protein_synthesis_rate, units_button5,
            desc_button4
        ]
        row5 = [
            param_name5, self.virion_assembly_rate, units_button6, desc_button5
        ]
        row6 = [
            param_name6, self.virion_export_rate, units_button8, desc_button6
        ]
        row7 = [
            param_name7, self.ACE2_receptors_per_cell, units_button10,
            desc_button7
        ]
        row8 = [
            param_name8, self.ACE2_binding_rate, units_button11, desc_button8
        ]
        row9 = [
            param_name9, self.ACE2_endocytosis_rate, units_button12,
            desc_button9
        ]
        row10 = [
            param_name10, self.ACE2_cargo_release_rate, units_button13,
            desc_button10
        ]
        row11 = [
            param_name11, self.ACE2_recycling_rate, units_button14,
            desc_button11
        ]
        row12 = [
            param_name12, self.max_infected_apoptosis_rate, units_button16,
            desc_button12
        ]
        row13 = [
            param_name13, self.max_apoptosis_half_max, units_button17,
            desc_button13
        ]
        row14 = [
            param_name14, self.apoptosis_hill_power, units_button18,
            desc_button14
        ]
        row15 = [
            param_name15, self.virus_fraction_released_at_death,
            units_button19, desc_button15
        ]
        row16 = [
            param_name16, self.multiplicity_of_infection, units_button21,
            desc_button16
        ]
        row17 = [
            param_name17, self.use_single_infected_cell, units_button22,
            desc_button17
        ]
        row18 = [
            param_name18, self.color_variable, units_button24, desc_button18
        ]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box1 = Box(children=row1, layout=box_layout)
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box4 = Box(children=row4, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box8 = Box(children=row8, layout=box_layout)
        box9 = Box(children=row9, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)
        box11 = Box(children=row11, layout=box_layout)
        box12 = Box(children=row12, layout=box_layout)
        box13 = Box(children=row13, layout=box_layout)
        box14 = Box(children=row14, layout=box_layout)
        box15 = Box(children=row15, layout=box_layout)
        box16 = Box(children=row16, layout=box_layout)
        box17 = Box(children=row17, layout=box_layout)
        box18 = Box(children=row18, layout=box_layout)

        self.tab = VBox([
            box1,
            div_row1,
            box2,
            box3,
            box4,
            box5,
            div_row2,
            box6,
            div_row3,
            box7,
            box8,
            box9,
            box10,
            box11,
            div_row4,
            box12,
            box13,
            box14,
            box15,
            div_row5,
            box16,
            box17,
            div_row6,
            box18,
        ])
    def __init__(self):

        micron_units = Label(
            'micron')  # use "option m" (Mac, for micro symbol)

        constWidth = '180px'
        tab_height = '500px'
        stepsize = 10

        #style = {'description_width': '250px'}
        style = {'description_width': '25%'}
        layout = {'width': '400px'}

        name_button_layout = {'width': '25%'}
        widget_layout = {'width': '15%'}
        widget2_layout = {'width': '10%'}
        units_button_layout = {'width': '15%'}
        desc_button_layout = {'width': '45%'}
        divider_button_layout = {'width': '40%'}

        div_row1 = Button(description='---Domain Options---',
                          disabled=True,
                          layout=divider_button_layout)

        param_name1 = Button(description='type_of_death_model',
                             disabled=True,
                             layout=name_button_layout)
        param_name1.style.button_color = 'tan'

        self.type_of_death_model = FloatText(value=1,
                                             step=0.1,
                                             style=style,
                                             layout=widget_layout)

        param_name2 = Button(description='initial_tumor_radius',
                             disabled=True,
                             layout=name_button_layout)
        param_name2.style.button_color = 'lightgreen'

        self.initial_tumor_radius = FloatText(value=150,
                                              step=10,
                                              style=style,
                                              layout=widget_layout)

        div_row2 = Button(description='---Apoptosis---',
                          disabled=True,
                          layout=divider_button_layout)

        param_name3 = Button(description='apoptosis_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name3.style.button_color = 'lightgreen'

        self.apoptosis_rate = FloatText(value=0.0014,
                                        step=0.0001,
                                        style=style,
                                        layout=widget_layout)

        div_row3 = Button(description='---Necrosis---',
                          disabled=True,
                          layout=divider_button_layout)

        param_name4 = Button(description='necrosis_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name4.style.button_color = 'tan'

        self.necrosis_rate = FloatText(value=0.00277777777,
                                       step=0.0001,
                                       style=style,
                                       layout=widget_layout)

        param_name5 = Button(description='necrosis_type',
                             disabled=True,
                             layout=name_button_layout)
        param_name5.style.button_color = 'lightgreen'

        self.necrosis_type = FloatText(value=2,
                                       step=0.1,
                                       style=style,
                                       layout=widget_layout)

        param_name6 = Button(description='o2_necrosis_threshold',
                             disabled=True,
                             layout=name_button_layout)
        param_name6.style.button_color = 'tan'

        self.o2_necrosis_threshold = FloatText(value=5.0,
                                               step=0.1,
                                               style=style,
                                               layout=widget_layout)

        param_name7 = Button(description='o2_necrosis_max',
                             disabled=True,
                             layout=name_button_layout)
        param_name7.style.button_color = 'lightgreen'

        self.o2_necrosis_max = FloatText(value=2.5,
                                         step=0.1,
                                         style=style,
                                         layout=widget_layout)

        div_row4 = Button(description='---Fluid change rates---',
                          disabled=True,
                          layout=divider_button_layout)

        param_name8 = Button(description='cytoplasmic_biomass_change_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name8.style.button_color = 'tan'

        self.cytoplasmic_biomass_change_rate = FloatText(value=0.01666666,
                                                         step=0.001,
                                                         style=style,
                                                         layout=widget_layout)

        param_name9 = Button(description='nuclear_biomass_change_rate',
                             disabled=True,
                             layout=name_button_layout)
        param_name9.style.button_color = 'lightgreen'

        self.nuclear_biomass_change_rate = FloatText(value=0.00583333333,
                                                     step=0.001,
                                                     style=style,
                                                     layout=widget_layout)

        param_name10 = Button(description='lysed_fluid_change_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name10.style.button_color = 'tan'

        self.lysed_fluid_change_rate = FloatText(value=0.00083333333,
                                                 step=0.0001,
                                                 style=style,
                                                 layout=widget_layout)

        param_name11 = Button(description='unlysed_fluid_change_rate',
                              disabled=True,
                              layout=name_button_layout)
        param_name11.style.button_color = 'lightgreen'

        self.unlysed_fluid_change_rate = FloatText(value=0.01666666,
                                                   step=0.001,
                                                   style=style,
                                                   layout=widget_layout)

        units_button1 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button1.style.button_color = 'lightgreen'
        units_button2 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button2.style.button_color = 'tan'
        units_button3 = Button(description='micrometer',
                               disabled=True,
                               layout=units_button_layout)
        units_button3.style.button_color = 'lightgreen'
        units_button4 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button4.style.button_color = 'tan'
        units_button5 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button5.style.button_color = 'lightgreen'
        units_button6 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button6.style.button_color = 'lightgreen'
        units_button7 = Button(description='1/min',
                               disabled=True,
                               layout=units_button_layout)
        units_button7.style.button_color = 'tan'
        units_button8 = Button(description='',
                               disabled=True,
                               layout=units_button_layout)
        units_button8.style.button_color = 'lightgreen'
        units_button9 = Button(description='mmHG',
                               disabled=True,
                               layout=units_button_layout)
        units_button9.style.button_color = 'tan'
        units_button10 = Button(description='mmHG',
                                disabled=True,
                                layout=units_button_layout)
        units_button10.style.button_color = 'lightgreen'
        units_button11 = Button(description='',
                                disabled=True,
                                layout=units_button_layout)
        units_button11.style.button_color = 'lightgreen'
        units_button12 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button12.style.button_color = 'tan'
        units_button13 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button13.style.button_color = 'lightgreen'
        units_button14 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button14.style.button_color = 'tan'
        units_button15 = Button(description='1/min',
                                disabled=True,
                                layout=units_button_layout)
        units_button15.style.button_color = 'lightgreen'

        desc_button2 = Button(description='1->apoptosis 2->necrosis',
                              tooltip='1->apoptosis 2->necrosis',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button2.style.button_color = 'tan'
        desc_button3 = Button(description='initial tumor radius',
                              tooltip='initial tumor radius',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button3.style.button_color = 'lightgreen'
        desc_button5 = Button(description='mean apoptosis rate',
                              tooltip='mean apoptosis rate',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button5.style.button_color = 'lightgreen'
        desc_button6 = Button(description='mean necrosis rate',
                              tooltip='mean necrosis rate',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button6.style.button_color = 'tan'
        desc_button7 = Button(description='1->deterministic 2->stochastic',
                              tooltip='1->deterministic 2->stochastic',
                              disabled=True,
                              layout=desc_button_layout)
        desc_button7.style.button_color = 'lightgreen'
        desc_button10 = Button(
            description='oxygen threshold level for dying with necrotic death',
            tooltip='oxygen threshold level for dying with necrotic death',
            disabled=True,
            layout=desc_button_layout)
        desc_button10.style.button_color = 'tan'
        desc_button11 = Button(
            description=
            'oxygen threshold level for maximum rate of necrotic death',
            tooltip='oxygen threshold level for maximum rate of necrotic death',
            disabled=True,
            layout=desc_button_layout)
        desc_button11.style.button_color = 'lightgreen'
        desc_button12 = Button(
            description=
            'rate of degradation for solids in the cytoplasm other than the nucleus',
            tooltip=
            'rate of degradation for solids in the cytoplasm other than the nucleus',
            disabled=True,
            layout=desc_button_layout)
        desc_button12.style.button_color = 'tan'
        desc_button13 = Button(
            description='rate of degradation for nucleus solids',
            tooltip='rate of degradation for nucleus solids',
            disabled=True,
            layout=desc_button_layout)
        desc_button13.style.button_color = 'lightgreen'
        desc_button14 = Button(
            description=
            'rate of fluid change (cytoplasmic fluid) after cell lysis ',
            tooltip=
            'rate of fluid change (cytoplasmic fluid) after cell lysis ',
            disabled=True,
            layout=desc_button_layout)
        desc_button14.style.button_color = 'tan'
        desc_button15 = Button(
            description=
            'rate of fluid change (cytoplasmic fluid) before cell lysis',
            tooltip=
            'rate of fluid change (cytoplasmic fluid) before cell lysis',
            disabled=True,
            layout=desc_button_layout)
        desc_button15.style.button_color = 'lightgreen'

        row2 = [
            param_name1, self.type_of_death_model, units_button2, desc_button2
        ]
        row3 = [
            param_name2, self.initial_tumor_radius, units_button3, desc_button3
        ]
        row5 = [param_name3, self.apoptosis_rate, units_button5, desc_button5]
        row6 = [param_name4, self.necrosis_rate, units_button7, desc_button6]
        row7 = [param_name5, self.necrosis_type, units_button8, desc_button7]
        row10 = [
            param_name6, self.o2_necrosis_threshold, units_button9,
            desc_button10
        ]
        row11 = [
            param_name7, self.o2_necrosis_max, units_button10, desc_button11
        ]
        row12 = [
            param_name8, self.cytoplasmic_biomass_change_rate, units_button12,
            desc_button12
        ]
        row13 = [
            param_name9, self.nuclear_biomass_change_rate, units_button13,
            desc_button13
        ]
        row14 = [
            param_name10, self.lysed_fluid_change_rate, units_button14,
            desc_button14
        ]
        row15 = [
            param_name11, self.unlysed_fluid_change_rate, units_button15,
            desc_button15
        ]

        box_layout = Layout(display='flex',
                            flex_flow='row',
                            align_items='stretch',
                            width='100%')
        box2 = Box(children=row2, layout=box_layout)
        box3 = Box(children=row3, layout=box_layout)
        box5 = Box(children=row5, layout=box_layout)
        box6 = Box(children=row6, layout=box_layout)
        box7 = Box(children=row7, layout=box_layout)
        box10 = Box(children=row10, layout=box_layout)
        box11 = Box(children=row11, layout=box_layout)
        box12 = Box(children=row12, layout=box_layout)
        box13 = Box(children=row13, layout=box_layout)
        box14 = Box(children=row14, layout=box_layout)
        box15 = Box(children=row15, layout=box_layout)

        self.tab = VBox([
            div_row1,
            box2,
            box3,
            div_row2,
            box5,
            div_row3,
            box6,
            box7,
            box10,
            box11,
            div_row4,
            box12,
            box13,
            box14,
            box15,
        ])
Example #34
0
class Dashboard(VBox):
    """
    Build the dashboard for Jupyter widgets. Requires running
    in a notebook/jupyterlab.
    """
    def __init__(self, net, width="95%", height="550px", play_rate=0.5):
        self._ignore_layer_updates = False
        self.player = _Player(self, play_rate)
        self.player.start()
        self.net = net
        r = random.randint(1, 1000000)
        self.class_id = "picture-dashboard-%s-%s" % (self.net.name, r)
        self._width = width
        self._height = height
        ## Global widgets:
        style = {"description_width": "initial"}
        self.feature_columns = IntText(description="Detail columns:",
                                       value=self.net.config["dashboard.features.columns"],
                                       min=0,
                                       max=1024,
                                       style=style)
        self.feature_scale = FloatText(description="Detail scale:",
                                       value=self.net.config["dashboard.features.scale"],
                                       min=0.1,
                                       max=10,
                                       style=style)
        self.feature_columns.observe(self.regenerate, names='value')
        self.feature_scale.observe(self.regenerate, names='value')
        ## Hack to center SVG as justify-content is broken:
        self.net_svg = HTML(value="""<p style="text-align:center">%s</p>""" % ("",), layout=Layout(
            width=self._width, overflow_x='auto', overflow_y="auto",
            justify_content="center"))
        # Make controls first:
        self.output = Output()
        controls = self.make_controls()
        config = self.make_config()
        super().__init__([config, controls, self.net_svg, self.output])

    def propagate(self, inputs):
        """
        Propagate inputs through the dashboard view of the network.
        """
        if dynamic_pictures_check():
            return self.net.propagate(inputs, class_id=self.class_id, update_pictures=True)
        else:
            self.regenerate(inputs=input)

    def goto(self, position):
        if len(self.net.dataset.inputs) == 0 or len(self.net.dataset.targets) == 0:
            return
        if self.control_select.value == "Train":
            length = len(self.net.dataset.train_inputs)
        elif self.control_select.value == "Test":
            length = len(self.net.dataset.test_inputs)
        #### Position it:
        if position == "begin":
            self.control_slider.value = 0
        elif position == "end":
            self.control_slider.value = length - 1
        elif position == "prev":
            if self.control_slider.value - 1 < 0:
                self.control_slider.value = length - 1 # wrap around
            else:
                self.control_slider.value = max(self.control_slider.value - 1, 0)
        elif position == "next":
            if self.control_slider.value + 1 > length - 1:
                self.control_slider.value = 0 # wrap around
            else:
                self.control_slider.value = min(self.control_slider.value + 1, length - 1)
        self.position_text.value = self.control_slider.value


    def change_select(self, change=None):
        """
        """
        self.update_control_slider(change)
        self.regenerate()

    def update_control_slider(self, change=None):
        self.net.config["dashboard.dataset"] = self.control_select.value
        if len(self.net.dataset.inputs) == 0 or len(self.net.dataset.targets) == 0:
            self.total_text.value = "of 0"
            self.control_slider.value = 0
            self.position_text.value = 0
            self.control_slider.disabled = True
            self.position_text.disabled = True
            for child in self.control_buttons.children:
                if not hasattr(child, "icon") or child.icon != "refresh":
                    child.disabled = True
            return
        if self.control_select.value == "Test":
            self.total_text.value = "of %s" % len(self.net.dataset.test_inputs)
            minmax = (0, max(len(self.net.dataset.test_inputs) - 1, 0))
            if minmax[0] <= self.control_slider.value <= minmax[1]:
                pass # ok
            else:
                self.control_slider.value = 0
            self.control_slider.min = minmax[0]
            self.control_slider.max = minmax[1]
            if len(self.net.dataset.test_inputs) == 0:
                disabled = True
            else:
                disabled = False
        elif self.control_select.value == "Train":
            self.total_text.value = "of %s" % len(self.net.dataset.train_inputs)
            minmax = (0, max(len(self.net.dataset.train_inputs) - 1, 0))
            if minmax[0] <= self.control_slider.value <= minmax[1]:
                pass # ok
            else:
                self.control_slider.value = 0
            self.control_slider.min = minmax[0]
            self.control_slider.max = minmax[1]
            if len(self.net.dataset.train_inputs) == 0:
                disabled = True
            else:
                disabled = False
        self.control_slider.disabled = disabled
        self.position_text.disbaled = disabled
        self.position_text.value = self.control_slider.value
        for child in self.control_buttons.children:
            if not hasattr(child, "icon") or child.icon != "refresh":
                child.disabled = disabled

    def update_zoom_slider(self, change):
        if change["name"] == "value":
            self.net.config["svg_scale"] = self.zoom_slider.value
            self.regenerate()

    def update_position_text(self, change):
        # {'name': 'value', 'old': 2, 'new': 3, 'owner': IntText(value=3, layout=Layout(width='100%')), 'type': 'change'}
        self.control_slider.value = change["new"]

    def get_current_input(self):
        if self.control_select.value == "Train" and len(self.net.dataset.train_targets) > 0:
            return self.net.dataset.train_inputs[self.control_slider.value]
        elif self.control_select.value == "Test" and len(self.net.dataset.test_targets) > 0:
            return self.net.dataset.test_inputs[self.control_slider.value]

    def get_current_targets(self):
        if self.control_select.value == "Train" and len(self.net.dataset.train_targets) > 0:
            return self.net.dataset.train_targets[self.control_slider.value]
        elif self.control_select.value == "Test" and len(self.net.dataset.test_targets) > 0:
            return self.net.dataset.test_targets[self.control_slider.value]

    def update_slider_control(self, change):
        if len(self.net.dataset.inputs) == 0 or len(self.net.dataset.targets) == 0:
            self.total_text.value = "of 0"
            return
        if change["name"] == "value":
            self.position_text.value = self.control_slider.value
            if self.control_select.value == "Train" and len(self.net.dataset.train_targets) > 0:
                self.total_text.value = "of %s" % len(self.net.dataset.train_inputs)
                if self.net.model is None:
                    return
                if not dynamic_pictures_check():
                    self.regenerate(inputs=self.net.dataset.train_inputs[self.control_slider.value],
                                    targets=self.net.dataset.train_targets[self.control_slider.value])
                    return
                output = self.net.propagate(self.net.dataset.train_inputs[self.control_slider.value],
                                            class_id=self.class_id, update_pictures=True)
                if self.feature_bank.value in self.net.layer_dict.keys():
                    self.net.propagate_to_features(self.feature_bank.value, self.net.dataset.train_inputs[self.control_slider.value],
                                                   cols=self.feature_columns.value, scale=self.feature_scale.value, html=False)
                if self.net.config["show_targets"]:
                    if len(self.net.output_bank_order) == 1: ## FIXME: use minmax of output bank
                        self.net.display_component([self.net.dataset.train_targets[self.control_slider.value]],
                                                   "targets",
                                                   class_id=self.class_id,
                                                   minmax=(-1, 1))
                    else:
                        self.net.display_component(self.net.dataset.train_targets[self.control_slider.value],
                                                   "targets",
                                                   class_id=self.class_id,
                                                   minmax=(-1, 1))
                if self.net.config["show_errors"]: ## minmax is error
                    if len(self.net.output_bank_order) == 1:
                        errors = np.array(output) - np.array(self.net.dataset.train_targets[self.control_slider.value])
                        self.net.display_component([errors.tolist()],
                                                   "errors",
                                                   class_id=self.class_id,
                                                   minmax=(-1, 1))
                    else:
                        errors = []
                        for bank in range(len(self.net.output_bank_order)):
                            errors.append( np.array(output[bank]) - np.array(self.net.dataset.train_targets[self.control_slider.value][bank]))
                        self.net.display_component(errors, "errors",  class_id=self.class_id, minmax=(-1, 1))
            elif self.control_select.value == "Test" and len(self.net.dataset.test_targets) > 0:
                self.total_text.value = "of %s" % len(self.net.dataset.test_inputs)
                if self.net.model is None:
                    return
                if not dynamic_pictures_check():
                    self.regenerate(inputs=self.net.dataset.test_inputs[self.control_slider.value],
                                    targets=self.net.dataset.test_targets[self.control_slider.value])
                    return
                output = self.net.propagate(self.net.dataset.test_inputs[self.control_slider.value],
                                            class_id=self.class_id, update_pictures=True)
                if self.feature_bank.value in self.net.layer_dict.keys():
                    self.net.propagate_to_features(self.feature_bank.value, self.net.dataset.test_inputs[self.control_slider.value],
                                               cols=self.feature_columns.value, scale=self.feature_scale.value, html=False)
                if self.net.config["show_targets"]: ## FIXME: use minmax of output bank
                    self.net.display_component([self.net.dataset.test_targets[self.control_slider.value]],
                                               "targets",
                                               class_id=self.class_id,
                                               minmax=(-1, 1))
                if self.net.config["show_errors"]: ## minmax is error
                    if len(self.net.output_bank_order) == 1:
                        errors = np.array(output) - np.array(self.net.dataset.test_targets[self.control_slider.value])
                        self.net.display_component([errors.tolist()],
                                                   "errors",
                                                   class_id=self.class_id,
                                                   minmax=(-1, 1))
                    else:
                        errors = []
                        for bank in range(len(self.net.output_bank_order)):
                            errors.append( np.array(output[bank]) - np.array(self.net.dataset.test_targets[self.control_slider.value][bank]))
                        self.net.display_component(errors, "errors", class_id=self.class_id, minmax=(-1, 1))

    def toggle_play(self, button):
        ## toggle
        if self.button_play.description == "Play":
            self.button_play.description = "Stop"
            self.button_play.icon = "pause"
            self.player.resume()
        else:
            self.button_play.description = "Play"
            self.button_play.icon = "play"
            self.player.pause()

    def prop_one(self, button=None):
        self.update_slider_control({"name": "value"})

    def regenerate(self, button=None, inputs=None, targets=None):
        ## Protection when deleting object on shutdown:
        if isinstance(button, dict) and 'new' in button and button['new'] is None:
            return
        ## Update the config:
        self.net.config["dashboard.features.bank"] = self.feature_bank.value
        self.net.config["dashboard.features.columns"] = self.feature_columns.value
        self.net.config["dashboard.features.scale"] = self.feature_scale.value
        inputs = inputs if inputs is not None else self.get_current_input()
        targets = targets if targets is not None else self.get_current_targets()
        features = None
        if self.feature_bank.value in self.net.layer_dict.keys() and inputs is not None:
            if self.net.model is not None:
                features = self.net.propagate_to_features(self.feature_bank.value, inputs,
                                                          cols=self.feature_columns.value,
                                                          scale=self.feature_scale.value, display=False)
        svg = """<p style="text-align:center">%s</p>""" % (self.net.to_svg(
            inputs=inputs,
            targets=targets,
            class_id=self.class_id,
            highlights={self.feature_bank.value: {
                "border_color": "orange",
                "border_width": 30,
            }}))
        if inputs is not None and features is not None:
            html_horizontal = """
<table align="center" style="width: 100%%;">
 <tr>
  <td valign="top" style="width: 50%%;">%s</td>
  <td valign="top" align="center" style="width: 50%%;"><p style="text-align:center"><b>%s</b></p>%s</td>
</tr>
</table>"""
            html_vertical = """
<table align="center" style="width: 100%%;">
 <tr>
  <td valign="top">%s</td>
</tr>
<tr>
  <td valign="top" align="center"><p style="text-align:center"><b>%s</b></p>%s</td>
</tr>
</table>"""
            self.net_svg.value = (html_vertical if self.net.config["svg_rotate"] else html_horizontal) % (
                svg, "%s details" % self.feature_bank.value, features)
        else:
            self.net_svg.value = svg

    def make_colormap_image(self, colormap_name):
        from .layers import Layer
        if not colormap_name:
            colormap_name = get_colormap()
        layer = Layer("Colormap", 100)
        minmax = layer.get_act_minmax()
        image = layer.make_image(np.arange(minmax[0], minmax[1], .01),
                                 colormap_name,
                                 {"pixels_per_unit": 1,
                                  "svg_rotate": self.net.config["svg_rotate"]}).resize((300, 25))
        return image

    def set_attr(self, obj, attr, value):
        if value not in [{}, None]: ## value is None when shutting down
            if isinstance(value, dict):
                value = value["value"]
            if isinstance(obj, dict):
                obj[attr] = value
            else:
                setattr(obj, attr, value)
            ## was crashing on Widgets.__del__, if get_ipython() no longer existed
            self.regenerate()

    def make_controls(self):
        layout = Layout(width='100%', height="100%")
        button_begin = Button(icon="fast-backward", layout=layout)
        button_prev = Button(icon="backward", layout=layout)
        button_next = Button(icon="forward", layout=layout)
        button_end = Button(icon="fast-forward", layout=layout)
        #button_prop = Button(description="Propagate", layout=Layout(width='100%'))
        #button_train = Button(description="Train", layout=Layout(width='100%'))
        self.button_play = Button(icon="play", description="Play", layout=layout)
        step_down = Button(icon="sort-down", layout=Layout(width="95%", height="100%"))
        step_up = Button(icon="sort-up", layout=Layout(width="95%", height="100%"))
        up_down = HBox([step_down, step_up], layout=Layout(width="100%", height="100%"))
        refresh_button = Button(icon="refresh", layout=Layout(width="25%", height="100%"))

        self.position_text = IntText(value=0, layout=layout)

        self.control_buttons = HBox([
            button_begin,
            button_prev,
            #button_train,
            self.position_text,
            button_next,
            button_end,
            self.button_play,
            up_down,
            refresh_button
        ], layout=Layout(width='100%', height="100%"))
        length = (len(self.net.dataset.train_inputs) - 1) if len(self.net.dataset.train_inputs) > 0 else 0
        self.control_slider = IntSlider(description="Dataset index",
                                   continuous_update=False,
                                   min=0,
                                   max=max(length, 0),
                                   value=0,
                                   layout=Layout(width='100%'))
        if self.net.config["dashboard.dataset"] == "Train":
            length = len(self.net.dataset.train_inputs)
        else:
            length = len(self.net.dataset.test_inputs)
        self.total_text = Label(value="of %s" % length, layout=Layout(width="100px"))
        self.zoom_slider = FloatSlider(description="Zoom",
                                       continuous_update=False,
                                       min=0, max=1.0,
                                       style={"description_width": 'initial'},
                                       layout=Layout(width="65%"),
                                       value=self.net.config["svg_scale"] if self.net.config["svg_scale"] is not None else 0.5)

        ## Hook them up:
        button_begin.on_click(lambda button: self.goto("begin"))
        button_end.on_click(lambda button: self.goto("end"))
        button_next.on_click(lambda button: self.goto("next"))
        button_prev.on_click(lambda button: self.goto("prev"))
        self.button_play.on_click(self.toggle_play)
        self.control_slider.observe(self.update_slider_control, names='value')
        refresh_button.on_click(lambda widget: (self.update_control_slider(),
                                                self.output.clear_output(),
                                                self.regenerate()))
        step_down.on_click(lambda widget: self.move_step("down"))
        step_up.on_click(lambda widget: self.move_step("up"))
        self.zoom_slider.observe(self.update_zoom_slider, names='value')
        self.position_text.observe(self.update_position_text, names='value')
        # Put them together:
        controls = VBox([HBox([self.control_slider, self.total_text], layout=Layout(height="40px")),
                         self.control_buttons], layout=Layout(width='100%'))

        #net_page = VBox([control, self.net_svg], layout=Layout(width='95%'))
        controls.on_displayed(lambda widget: self.regenerate())
        return controls

    def move_step(self, direction):
        """
        Move the layer stepper up/down through network
        """
        options = [""] + [layer.name for layer in self.net.layers]
        index = options.index(self.feature_bank.value)
        if direction == "up":
            new_index = (index + 1) % len(options)
        else: ## down
            new_index = (index - 1) % len(options)
        self.feature_bank.value = options[new_index]
        self.regenerate()

    def make_config(self):
        layout = Layout()
        style = {"description_width": "initial"}
        checkbox1 = Checkbox(description="Show Targets", value=self.net.config["show_targets"],
                             layout=layout, style=style)
        checkbox1.observe(lambda change: self.set_attr(self.net.config, "show_targets", change["new"]), names='value')
        checkbox2 = Checkbox(description="Errors", value=self.net.config["show_errors"],
                             layout=layout, style=style)
        checkbox2.observe(lambda change: self.set_attr(self.net.config, "show_errors", change["new"]), names='value')

        hspace = IntText(value=self.net.config["hspace"], description="Horizontal space between banks:",
                         style=style, layout=layout)
        hspace.observe(lambda change: self.set_attr(self.net.config, "hspace", change["new"]), names='value')
        vspace = IntText(value=self.net.config["vspace"], description="Vertical space between layers:",
                         style=style, layout=layout)
        vspace.observe(lambda change: self.set_attr(self.net.config, "vspace", change["new"]), names='value')
        self.feature_bank = Select(description="Details:", value=self.net.config["dashboard.features.bank"],
                              options=[""] + [layer.name for layer in self.net.layers],
                              rows=1)
        self.feature_bank.observe(self.regenerate, names='value')
        self.control_select = Select(
            options=['Test', 'Train'],
            value=self.net.config["dashboard.dataset"],
            description='Dataset:',
            rows=1
        )
        self.control_select.observe(self.change_select, names='value')
        column1 = [self.control_select,
                   self.zoom_slider,
                   hspace,
                   vspace,
                   HBox([checkbox1, checkbox2]),
                   self.feature_bank,
                   self.feature_columns,
                   self.feature_scale
        ]
        ## Make layer selectable, and update-able:
        column2 = []
        layer = self.net.layers[-1]
        self.layer_select = Select(description="Layer:", value=layer.name,
                                   options=[layer.name for layer in
                                            self.net.layers],
                                   rows=1)
        self.layer_select.observe(self.update_layer_selection, names='value')
        column2.append(self.layer_select)
        self.layer_visible_checkbox = Checkbox(description="Visible", value=layer.visible, layout=layout)
        self.layer_visible_checkbox.observe(self.update_layer, names='value')
        column2.append(self.layer_visible_checkbox)
        self.layer_colormap = Select(description="Colormap:",
                                     options=[""] + AVAILABLE_COLORMAPS,
                                     value=layer.colormap if layer.colormap is not None else "", layout=layout, rows=1)
        self.layer_colormap_image = HTML(value="""<img src="%s"/>""" % self.net._image_to_uri(self.make_colormap_image(layer.colormap)))
        self.layer_colormap.observe(self.update_layer, names='value')
        column2.append(self.layer_colormap)
        column2.append(self.layer_colormap_image)
        ## get dynamic minmax; if you change it it will set it in layer as override:
        minmax = layer.get_act_minmax()
        self.layer_mindim = FloatText(description="Leftmost color maps to:", value=minmax[0], style=style)
        self.layer_maxdim = FloatText(description="Rightmost color maps to:", value=minmax[1], style=style)
        self.layer_mindim.observe(self.update_layer, names='value')
        self.layer_maxdim.observe(self.update_layer, names='value')
        column2.append(self.layer_mindim)
        column2.append(self.layer_maxdim)
        output_shape = layer.get_output_shape()
        self.layer_feature = IntText(value=layer.feature, description="Feature to show:", style=style)
        self.svg_rotate = Checkbox(description="Rotate", value=layer.visible, layout=layout)
        self.layer_feature.observe(self.update_layer, names='value')
        column2.append(self.layer_feature)
        self.svg_rotate = Checkbox(description="Rotate network",
                                   value=self.net.config["svg_rotate"],
                                   style={"description_width": 'initial'},
                                   layout=Layout(width="52%"))
        self.svg_rotate.observe(lambda change: self.set_attr(self.net.config, "svg_rotate", change["new"]), names='value')
        self.save_config_button = Button(icon="save", layout=Layout(width="10%"))
        self.save_config_button.on_click(self.save_config)
        column2.append(HBox([self.svg_rotate, self.save_config_button]))
        config_children = HBox([VBox(column1, layout=Layout(width="100%")),
                                VBox(column2, layout=Layout(width="100%"))])
        accordion = Accordion(children=[config_children])
        accordion.set_title(0, self.net.name)
        accordion.selected_index = None
        return accordion

    def save_config(self, widget=None):
        self.net.save_config()

    def update_layer(self, change):
        """
        Update the layer object, and redisplay.
        """
        if self._ignore_layer_updates:
            return
        ## The rest indicates a change to a display variable.
        ## We need to save the value in the layer, and regenerate
        ## the display.
        # Get the layer:
        layer = self.net[self.layer_select.value]
        # Save the changed value in the layer:
        layer.feature = self.layer_feature.value
        layer.visible = self.layer_visible_checkbox.value
        ## These three, dealing with colors of activations,
        ## can be done with a prop_one():
        if "color" in change["owner"].description.lower():
            ## Matches: Colormap, lefmost color, rightmost color
            ## overriding dynamic minmax!
            layer.minmax = (self.layer_mindim.value, self.layer_maxdim.value)
            layer.minmax = (self.layer_mindim.value, self.layer_maxdim.value)
            layer.colormap = self.layer_colormap.value if self.layer_colormap.value else None
            self.layer_colormap_image.value = """<img src="%s"/>""" % self.net._image_to_uri(self.make_colormap_image(layer.colormap))
            self.prop_one()
        else:
            self.regenerate()

    def update_layer_selection(self, change):
        """
        Just update the widgets; don't redraw anything.
        """
        ## No need to redisplay anything
        self._ignore_layer_updates = True
        ## First, get the new layer selected:
        layer = self.net[self.layer_select.value]
        ## Now, let's update all of the values without updating:
        self.layer_visible_checkbox.value = layer.visible
        self.layer_colormap.value = layer.colormap if layer.colormap != "" else ""
        self.layer_colormap_image.value = """<img src="%s"/>""" % self.net._image_to_uri(self.make_colormap_image(layer.colormap))
        minmax = layer.get_act_minmax()
        self.layer_mindim.value = minmax[0]
        self.layer_maxdim.value = minmax[1]
        self.layer_feature.value = layer.feature
        self._ignore_layer_updates = False