def list_elements(self):
        retrieve_material = RetrieveMaterialMetadata(material='all')
        self.list_returned = retrieve_material.full_list_material()

        # import pprint
        # pprint.pprint(list_returned)

        box4 = widgets.HBox([
            widgets.Label("List of elements",
                          layout=widgets.Layout(width=self.label_width)),
            widgets.Text(','.join(self.list_of_elements),
                         layout=widgets.Layout(width='20%'))
        ])

        box5 = widgets.HBox([
            widgets.Label("Nbr Bragg Edges",
                          layout=widgets.Layout(width=self.label_width)),
            widgets.Text(str(8), layout=widgets.Layout(width='20%'))
        ])

        vertical_box = widgets.VBox([box4, box5])
        display(vertical_box)

        self.list_elements_ui = box4.children[1]
        self.nbr_bragg_edges_ui = box5.children[1]
Exemple #2
0
    def __load_files(self):

        progress_bar_layout = widgets.Layout(border='1px solid blue')

        hbox = widgets.HBox([
            widgets.IntProgress(description="FUll Progress",
                                layout=progress_bar_layout),
            widgets.Label(value='', layout=widgets.Layout(width='10%'))
        ])
        w = hbox.children[0]
        nbr_groups = len(self.exp_dict.keys())
        w.max = nbr_groups
        label = hbox.children[1]
        label.value = f"0/{nbr_groups}"

        display(hbox)

        for _index, _key in enumerate(self.exp_dict.keys()):
            _item = self.exp_dict[_key]
            _path = _item['folder']
            list_files = _item['list_of_files']
            full_list_files = [
                os.path.join(_path, _file) for _file in list_files
            ]
            o_norm = Normalization()
            o_norm.load(file=full_list_files, notebook=True)
            _data = o_norm.data['sample']['data']
            _item['list_of_images'] = _data
            self.exp_dict[_key] = _item

            w.value = _index + 1
            label.value = f"{_index+1}/{nbr_groups}"

        hbox.close()
        display(widgets.Label(value="Done!"))
Exemple #3
0
def show_decomposition_series(node, **kwargs):
    # Use Rendering... as a placeholder
    ntabs = 2
    children = [widgets.HTML('Rendering...') for _ in range(ntabs)]

    def on_selected_index(change):
        # Click on Traces Tab
        if change.new == 1 and isinstance(change.owner.children[1],
                                          widgets.HTML):
            widget_box = show_decomposition_traces(node)
            children[1] = widget_box
            change.owner.children = children

    field_lay = widgets.Layout(max_height='40px',
                               max_width='500px',
                               min_height='30px',
                               min_width='130px')
    vbox = []
    for key, val in node.fields.items():
        lbl_key = widgets.Label(key + ':', layout=field_lay)
        lbl_val = widgets.Label(str(val), layout=field_lay)
        vbox.append(widgets.HBox(children=[lbl_key, lbl_val]))
        #vbox.append(widgets.Text(value=repr(value), description=key, disabled=True))
    children[0] = widgets.VBox(vbox)

    tab_nest = widgets.Tab()
    tab_nest.children = children
    tab_nest.set_title(0, 'Fields')
    tab_nest.set_title(1, 'Traces')
    tab_nest.observe(on_selected_index, names='selected_index')
    return tab_nest
Exemple #4
0
    def create_new_grid(self):
        """
        Creation of a new grid for the Trial representation.
        """
        if self.has_time:
            hlabels = ['Dateiname', 'Zeit', 'Treffer links', 'Treffer rechts', 'Kommentare']
            screen_width = (str(self.screen(0)-(0.05*self.screen(0))) + 'px')
            grid = GridspecLayout(len(self.table_rows)+2, len(hlabels), width=screen_width)

            for r in range(0, len(self.table_rows)+1):
                for c in range(0, len(hlabels)):
                    if r == 0:
                        grid[r,c] = widgets.Label(hlabels[c], layout=widgets.Layout(width='auto'))
                    else:
                        grid[r,c] = self.table_rows[r-1][c] 
        else:
            hlabels = ['Dateiname', 'Kommentare']
            grid = GridspecLayout(len(self.table_rows)+1, len(hlabels))

            for r in range(0, len(self.table_rows)+1):
                for c in range(0, len(hlabels)):
                    if r == 0:
                        grid[r,c] = widgets.Label(hlabels[c])
                    else:
                        grid[r,c] = self.table_rows[r-1][c]
                        
        return grid
 def __init__(self, images, vqa, use_camera=False):
     self.vqa = vqa
     self.images = images
     self.image_output = None
     self.label_question = widgets.Label(value="Is the plane red?")
     self.label_answer = widgets.Label(value="")
     self.label_query = widgets.Output(layout={'border': 'none'})
     self.label_expression = widgets.Output(layout={'border': 'none'})
     self.current_image = None
     self.text = widgets.Text()
     self.text.on_submit(self._handle_submit)
     self.use_pattern_matcher = True
     self.width = 400
     self.height = 400
     if use_camera:
         self.camera = CameraStream(
             constraints={
                 'facing_mode': 'user',
                 'audio': False,
                 'video': {
                     'width': 640,
                     'height': 480
                 }
             })
         self.image_recorder = ImageRecorder(stream=self.camera)
         self.image_recorder.recording = True
         self.image_recorder.autosave = False
     else:
         self.camera = None
Exemple #6
0
    def folder_widget_change_listener(self, change):
        """Loads checkboxes for JSON files if a new folder is selected"""
        self.selected_folder = change['new']
        self.filenames = self.dir_tree[self.selected_folder]

        self.checkbox_boxes.children = [widgets.Checkbox(
            value=False,
            indent=False,
            layout=LAYOUT_UPLOAD_PRELOAD_BOX
        )]

        self.checkbox_labels.children = [widgets.Label(
            'Loading items, please wait...',
            layout=LAYOUT_UPLOAD_PRELOAD_LABEL
        )]

        self.checkbox_dict = {}
        self.label_dict = {}

        for filename in self.filenames:
            self.checkbox_dict[filename] = widgets.Checkbox(
                value=False,
                index=False,
                layout=LAYOUT_CHECKBOX
            )
            self.checkbox_dict[filename].observe(self.checkbox_change_listener, names='value')

            self.label_dict[filename] = widgets.Label(
                f'{filename}',
                layout=LAYOUT_CHECKBOX_LABEL
            )

        self.checkbox_boxes.children = list(self.checkbox_dict.values())
        self.checkbox_labels.children = list(self.label_dict.values())
Exemple #7
0
def show_decomposition_traces(node: DecompositionSeries):
    # Produce figure
    def control_plot(x0, x1, ch0, ch1):
        fig, ax = plt.subplots(nrows=nBands,
                               ncols=1,
                               sharex=True,
                               figsize=(14, 7))
        for bd in range(nBands):
            data = node.data[x0:x1, ch0:ch1 + 1, bd]
            xx = np.arange(x0, x1)
            mu_array = np.mean(data, 0)
            sd_array = np.std(data, 0)
            offset = np.mean(sd_array) * 5
            yticks = [i * offset for i in range(ch1 + 1 - ch0)]
            for i in range(ch1 + 1 - ch0):
                ax[bd].plot(xx, data[:, i] - mu_array[i] + yticks[i])
            ax[bd].set_ylabel('Ch #', fontsize=20)
            ax[bd].set_yticks(yticks)
            ax[bd].set_yticklabels([str(i) for i in range(ch0, ch1 + 1)])
            ax[bd].tick_params(axis='both', which='major', labelsize=16)
        ax[bd].set_xlabel('Time [ms]', fontsize=20)
        return fig

    nSamples = node.data.shape[0]
    nChannels = node.data.shape[1]
    nBands = node.data.shape[2]
    fs = node.rate

    # Controls
    field_lay = widgets.Layout(max_height='40px',
                               max_width='100px',
                               min_height='30px',
                               min_width='70px')
    x0 = widgets.BoundedIntText(value=0,
                                min=0,
                                max=int(1000 * nSamples / fs - 100),
                                layout=field_lay)
    x1 = widgets.BoundedIntText(value=nSamples,
                                min=100,
                                max=int(1000 * nSamples / fs),
                                layout=field_lay)
    ch0 = widgets.BoundedIntText(value=0,
                                 min=0,
                                 max=int(nChannels - 1),
                                 layout=field_lay)
    ch1 = widgets.BoundedIntText(value=10,
                                 min=0,
                                 max=int(nChannels - 1),
                                 layout=field_lay)

    controls = {'x0': x0, 'x1': x1, 'ch0': ch0, 'ch1': ch1}
    out_fig = widgets.interactive_output(control_plot, controls)

    # Assemble layout box
    lbl_x = widgets.Label('Time [ms]:', layout=field_lay)
    lbl_ch = widgets.Label('Ch #:', layout=field_lay)
    lbl_blank = widgets.Label('    ', layout=field_lay)
    hbox0 = widgets.HBox(children=[lbl_x, x0, x1, lbl_blank, lbl_ch, ch0, ch1])
    vbox = widgets.VBox(children=[hbox0, out_fig])
    return vbox
Exemple #8
0
def show_decomposition_series(node, **kwargs):
    # Use Rendering... as a placeholder
    ntabs = 2
    children = [widgets.HTML("Rendering...") for _ in range(ntabs)]

    def on_selected_index(change):
        # Click on Traces Tab
        if change.new == 1 and isinstance(change.owner.children[1], widgets.HTML):
            widget_box = show_decomposition_traces(node)
            children[1] = widget_box
            change.owner.children = children

    field_lay = widgets.Layout(
        max_height="40px", max_width="500px", min_height="30px", min_width="130px"
    )
    vbox = []
    for key, val in node.fields.items():
        lbl_key = widgets.Label(key + ":", layout=field_lay)
        lbl_val = widgets.Label(str(val), layout=field_lay)
        vbox.append(widgets.HBox(children=[lbl_key, lbl_val]))
    children[0] = widgets.VBox(vbox)

    tab_nest = widgets.Tab()
    tab_nest.children = children
    tab_nest.set_title(0, "Fields")
    tab_nest.set_title(1, "Traces")
    tab_nest.observe(on_selected_index, names="selected_index")
    return tab_nest
Exemple #9
0
    def renamed_files(self):
        self.renamed_basename_list_of_files = self.get_renamed_basename_list_of_files(
        )
        basename_list_of_files_that_will_be_extracted = self.basename_list_of_files_that_will_be_extracted
        question_widget = widgets.Checkbox(value=True,
                                           description="Rename files?")
        question_widget.observe(self.renaming_checkbox_changed, names='value')
        self.renaming_files_widget = question_widget

        self.left_vertical_layout = widgets.VBox(
            [
                widgets.Label("Before renaming",
                              layout=widgets.Layout(width='100%')),
                widgets.Select(
                    options=basename_list_of_files_that_will_be_extracted,
                    layout=widgets.Layout(width='90%', height='400px'))
            ],
            layout=widgets.Layout(width='40%'))
        self.right_vertical_layout = widgets.VBox([
            widgets.Label("After renaming",
                          layout=widgets.Layout(width='100%')),
            widgets.Select(options=self.renamed_basename_list_of_files,
                           layout=widgets.Layout(width='90%', height='400px'))
        ],
                                                  layout=widgets.Layout(
                                                      width='40%'))
        horizontal_layout = widgets.HBox(
            [self.left_vertical_layout, self.right_vertical_layout])
        full_vertical_layout = widgets.VBox(
            [question_widget, horizontal_layout])
        display(full_vertical_layout)
Exemple #10
0
def latex_tab(db, output):

    b_table = widgets.Button(description="Display Latex Table")

    # d_avg_across_columns = widgets.Text(
    #     value=str(db.vars.get('avg_across', 'None')),
    #     description='avg_across:',
    #     disabled=False
    # )

    hparam_txt = widgets.Label(value="Select Rows:", 
                                    layout=widgets.Layout(width='300px'),)

    try:
        db.latex_rows_widget = widgets.SelectMultiple(options=db.rm.exp_params,
                            value=list(db.vars.get('latex_rows')))
    except:
        db.latex_rows_widget = widgets.SelectMultiple(options=db.rm.exp_params,
                            value=[db.rm.exp_params[0]])

    metrics_txt = widgets.Label(value="Select Columns:", 
                                    layout=db.layout_label,)
    try:
        db.latex_cols_widget =  widgets.SelectMultiple(value=list(db.vars.get('latex_columns')),
                        options=db.rm_original.score_keys)
    except:
        db.latex_cols_widget =  widgets.SelectMultiple(value=[db.rm_original.score_keys[0]],
                        options=db.rm_original.score_keys)

    button = widgets.VBox([ 
                            widgets.HBox([hparam_txt, metrics_txt]),
                            widgets.HBox([db.latex_rows_widget, db.latex_cols_widget]),
                            widgets.HBox([b_table]),
    ])
    output_plot = widgets.Output()

    with output:
        display(button)
        display(output_plot)

    def on_clicked(b):
        output_plot.clear_output()
        with output_plot:
            db.update_rm()

            db.vars['latex_rows'] = list(db.latex_rows_widget.value)
            db.vars['latex_columns'] = list(db.latex_cols_widget.value)
            # print('cols', db.hparam_dict)
            # stop
            score_table = db.rm.get_latex_table(columns=db.vars.get('latex_columns'), 
                                            rows=db.vars.get('latex_rows'),
                                            caption='Results')
            print(score_table) 


    b_table.on_click(on_clicked)

    
    
Exemple #11
0
    def __init__(self, simex_calc, time='00:10:00', partition="all"):
        """

        :param simex_calc: The SimEx Calculator that represents the simulation to perform
        :type simex_calc: AbstractBaseCalculator

        :param time: The time to reserve on the job scheduler (Default: '00:10:00 i.e. 10 minutes).
        :type time: str (HH:MM::SS) or (D-HH:MM:SS)

        :param partition: The SLURM partition to run this job on (Default: "all")
        :type partition: str

        """

        widgets.VBox.__init__(self, layout=widgets.Layout(width='100%'))

        self.verbose = False
        self.simex_calc = simex_calc
        #self.nodes_widget = widgets.IntSlider(min=1, max=10, value=nnodes)
        #self.task_widget = widgets.IntSlider(min=1, max=100,
        #                                     value=tasks_per_node)
        self.time_widget = widgets.Text(value=time)
        self.submit_widget = widgets.Button(description="Submit job",
                                            button_style="success")
        self.submit_widget.on_click(self.submit_job)
        #self.parallelism_widget = widgets.Dropdown(
        #    options=["mpirun", "CUDA"], value=parallelism)
        self.partition_widget = widgets.Dropdown(
            options=["all", "maxwell", "cfel", "exfel"], value=partition)
        # ui representation
        self.children = [
            widgets.HBox([widgets.Label("Partition"), self.partition_widget]),
            #widgets.HBox([widgets.Label("Nodes"), self.nodes_widget]),
            #widgets.HBox([widgets.Label("Tasks"), self.task_widget]),
            widgets.HBox([widgets.Label("Time"), self.time_widget]),
            #widgets.HBox([widgets.Label("parallelism"),
            #              self.parallelism_widget]),
            self.submit_widget
        ]

        temp_prefix = '''#!/bin/sh
#SBATCH --partition={0}
#SBATCH --time={1}
#SBATCH --nodes={2}
#SBATCH --cpus-per-task={3}
#SBATCH --output={4}'''

        temp_suffix = '''
export MODULEPATH=$MODULEPATH:$HOME/simex_dev_workshop/modulefiles
module load python3/3.4
module load simex

python3 {5} {6}
'''

        if self.simex_calc.parameters.gpus_per_task:
            temp_prefix += '\n#SBATCH --constraint=GPU\n'
        self.batch_template = temp_prefix + temp_suffix
    def merging(self, output_folder):
        """combine images using algorithm provided"""

        # get merging algorithm
        merging_algo = self.combine_method.value
        algorithm = self.__add
        if merging_algo == 'mean':
            algorithm = self.__mean

        # get output folder
        output_folder = os.path.abspath(output_folder)

        # create dictionary of how the images will be combined
        merging_dict = self.__create_merging_dictionary()
        self.merginc_dict_debugging = merging_dict

        # create final list of files to merge
        final_dict_of_files_to_merge = self.__create_dict_of_files_to_merge(merging_dict)
        self.final_dict_of_files_to_merge_debugging = final_dict_of_files_to_merge

        final_nbr_folders = len(merging_dict.keys())
        folder_level_ui = widgets.HBox([widgets.Label("Folder Progress:",
                                                      layout=widgets.Layout(width='20%')),
                                        widgets.IntProgress(max=final_nbr_folders,
                                                            layout=widgets.Layout(width='50%'))])
        display(folder_level_ui)
        w1 = folder_level_ui.children[1]

        nbr_files_to_merge = self.nbr_files_in_each_folder
        file_level_ui = widgets.HBox([widgets.Label("File Progress:",
                                                    layout=widgets.Layout(width='20%')),
                                     widgets.IntProgress(max=nbr_files_to_merge,
                                                         layout=widgets.Layout(width='50%'))])
        display(file_level_ui)
        w2 = file_level_ui.children[1]

        for _index_final_folder, _final_folder in enumerate(final_dict_of_files_to_merge.keys()):

            file_handler.make_or_reset_folder(os.path.join(output_folder, _final_folder))

            list_files_to_merge = final_dict_of_files_to_merge[_final_folder]
            for _index_files_to_merge, _files_to_merge in enumerate(list_files_to_merge):

                _files_to_merge = [_file for _file in _files_to_merge]
                self.files_to_merge_for_testing = _files_to_merge
                o_load = Normalization()
                o_load.load(file=_files_to_merge)
                _data = o_load.data['sample']['data']
                combined_data = self.__merging_algorithm(algorithm, _data)
                self.combined_data_for_testing = combined_data

                _base_name_file = os.path.basename(_files_to_merge[0])
                output_file_name = os.path.join(output_folder, _final_folder, _base_name_file)

                file_handler.save_data(data=combined_data, filename=output_file_name)
                w2.value = _index_files_to_merge + 1

            w1.value = _index_final_folder + 1
Exemple #13
0
def show_dict(in_dict) -> widgets.Widget:
    field_lay = widgets.Layout(max_height='40px', max_width='600px',
                               min_height='30px', min_width='130px')
    info = []
    for key, val in in_dict.items():
        lbl_key = widgets.Label(key + ':', layout=field_lay)
        lbl_val = widgets.Label(str(val), layout=field_lay)
        info.append(widgets.HBox(children=[lbl_key, lbl_val]))
    vbox = widgets.VBox(info)
    return vbox
    def define_pixel_size(self):

        box = widgets.HBox([widgets.Label("Size/Pixel Ratio"),
                            widgets.FloatText(value=1,
                                              step=0.1,
                                              layout=widgets.Layout(width='10%')),
                            widgets.Label("mm/px")])

        display(box)
        self.ratio_widget = box.children[1]
Exemple #15
0
 def populate_gridbox_from_database(self, *args):
     items = [
         widgets.Label('change point'),
         widgets.Label('followed by'),
         widgets.Label('')
     ]
     self.gridbox.children = items
     out = self.controller.database.get_change_points_from_active()
     out.sort_values('datetime', inplace=True)
     for _, row in out.iterrows():
         self.add_row2gridbox(row.datetime, row.type)
Exemple #16
0
def show_fields(node, **kwargs) -> widgets.Widget:
    field_lay = widgets.Layout(
        max_height="40px", max_width="600px", min_height="30px", min_width="130px"
    )
    info = []
    for key, val in node.fields.items():
        lbl_key = widgets.Label(key + ":", layout=field_lay)
        lbl_val = widgets.Label(str(val), layout=field_lay)
        info.append(widgets.HBox(children=[lbl_key, lbl_val]))
    vbox = widgets.VBox(info)
    return vbox
    def define_conversion_formula(self):

        self.box = widgets.HBox([
            widgets.Label("A(x,y) = "),
            widgets.Text("0.052", layout=widgets.Layout(width='10%')),
            widgets.Dropdown(options=["+", "-"],
                             layout=widgets.Layout(width='5%'),
                             value="+"),
            widgets.Text("2.55e-5", layout=widgets.Layout(width='10%')),
            widgets.Label(" * H(x,Y)")
        ])

        display(self.box)
Exemple #18
0
    def render(self):
        items = []

        for row in self.content["rows"]:
            if row["extra_class"] == "missing":
                items.append(
                    widgets.HBox([
                        widgets.FloatProgress(
                            value=row["count"],
                            min=0,
                            max=row["n"],
                            description=str(row["label"]),
                            bar_style="danger",
                        ),
                        widgets.Label(str(row["count"])),
                    ]))
            elif row["extra_class"] == "other":
                items.append(
                    widgets.HBox([
                        widgets.FloatProgress(
                            value=row["count"],
                            min=0,
                            max=row["n"],
                            description=str(row["label"]),
                            bar_style="info",
                        ),
                        widgets.Label(str(row["count"])),
                    ]))
            else:
                items.append(
                    widgets.HBox([
                        widgets.FloatProgress(
                            value=row["count"],
                            min=0,
                            max=row["n"],
                            description=str(row["label"]),
                            bar_style="",
                        ),
                        widgets.Label(str(row["count"])),
                    ]))

        ft = widgets.VBox(items)

        # Overwrite info to disabled
        # TODO: resize width of progress bar / label
        # display(
        #     HTML(
        #         "<style>.progress-bar-info{background-color: #ddd !important;} .dataframe td{     white-space: nowrap !important;}</style>"
        #     )
        # )
        return ft
Exemple #19
0
def show_widgets():
    display(
        widgets.HBox([
            widgets.VBox([
                widgets.Label('is true connection:'),
                widgets.Label('connection phrase in abstract:'),
                widgets.Label('number of articles:'),
                widgets.Label('years since first article:')
            ]),
            widgets.VBox([is_connection, causal, articles, years]),
            widgets.VBox([use_connection, use_causal, use_articles, use_years])
        ]))

    display(run_button)
Exemple #20
0
 def how_many_data_to_use_to_select_sample_roi(self):
     nbr_images = len(self.data)
     init_value = np.int(nbr_images/10)
     if init_value == 0:
         init_value = 1
     box1 = widgets.HBox([widgets.Label("Nbr of images to use:",
                                        layout=widgets.Layout(width='15')),
                          widgets.IntSlider(value=init_value,
                                            max=nbr_images,
                                            min=1,
                                            layout=widgets.Layout(width='50%'))])
     box2 = widgets.Label("(The more you select, the longer it will take to display the preview!)")
     vbox = widgets.VBox([box1, box2])
     display(vbox)
     self.number_of_data_to_use_ui = box1.children[1]
Exemple #21
0
 def with_or_without_roi(self):
     label1 = widgets.Label(
         "Do you want to select a region of interest (ROI) that will make sure that the "
         + "sample background matches the OB background")
     label2 = widgets.Label(
         "-> Make sure your selection do not overlap your sample!")
     box = widgets.HBox([
         widgets.Label("With or Without ROI?"),
         widgets.RadioButtons(options=['yes', 'no'],
                              value='yes',
                              layout=widgets.Layout(width='50%'))
     ])
     self.with_or_without_radio_button = box.children[1]
     vertical = widgets.VBox([label1, label2, box])
     display(vertical)
    def instantiate_objects(self):
        self.out_graph = widgets.Output()
        self.out_url = widgets.Output()
        self.out_func = widgets.Output()

        self.btn_gen = widgets.Button(description="Generate Vis")

        self.btn_add = widgets.Button(description="Add Mapping")
        self.btn_rem = widgets.Button(description="Remove Mapping")
        self.btn_clear_assigned = widgets.Button(description="Clear")

        self.sel_cols = widgets.Select(options=[], disabled=False)
        self.sel_fields = widgets.Select(options=[], disabled=False)
        self.sel_assigned = widgets.Select(options=[], disabled=False)

        self.lbl_cols = widgets.Label(value="Columns")
        self.chk_incidx = widgets.Checkbox(value=False,
                                           description='Inc. Index',
                                           disabled=False,
                                           indent=False)
        self.lbl_fields = widgets.Label(value="Fields")
        self.lbl_assigned = widgets.Label(value="Assigned")

        self.lbl_core = widgets.Label(value="Visualization Core")
        self.lbl_title = widgets.Label(value="Chart Title:")
        self.txt_title = widgets.Text(value="My Chart")

        self.txt_xaxis = widgets.Text(value="")
        self.txt_yaxis = widgets.Text(value="")
        self.lbl_xaxis = widgets.Label(value="X Axis")
        self.lbl_yaxis = widgets.Label(value="Y Axis")

        self.lbl_charth = widgets.Label(value="Chart Height:")
        self.lbl_chartw = widgets.Label(value="Chart Width:")
        self.txt_charth = widgets.Text(value="750")
        self.txt_chartw = widgets.Text(value="2000")

        self.lbl_break = widgets.Label(
            value=
            "---------------------------------------------------------------------------------"
        )

        self.sel_df = widgets.Select(options=[],
                                     description='Data Frame:',
                                     disabled=False)
        self.drp_charts = widgets.Dropdown(options=[],
                                           description='Chart Type:',
                                           disabled=False)
Exemple #23
0
def show_spike_event_series(ses: SpikeEventSeries, **kwargs):
    def control_plot(spk_ind):
        fig, ax = plt.subplots(figsize=(9, 5))
        data = ses.data[spk_ind]
        if nChannels > 1:
            for ch in range(nChannels):
                ax.plot(data[:, ch], color="#d9d9d9")
        else:
            ax.plot(data[:], color="#d9d9d9")
        ax.plot(np.mean(data, axis=1), color="k")
        ax.set_xlabel("Time")
        ax.set_ylabel("Amplitude")
        fig.show()
        return fig2widget(fig)

    if len(ses.data.shape) == 3:
        nChannels = ses.data.shape[2]
    else:
        nChannels = ses.data.shape[1]
    nSpikes = ses.data.shape[0]

    # Controls
    field_lay = widgets.Layout(max_height="40px",
                               max_width="100px",
                               min_height="30px",
                               min_width="70px")
    spk_ind = widgets.BoundedIntText(value=0,
                                     min=0,
                                     max=nSpikes - 1,
                                     layout=field_lay)
    controls = {"spk_ind": spk_ind}
    out_fig = widgets.interactive_output(control_plot, controls)

    # Assemble layout box
    lbl_spk = widgets.Label("Spike ID:", layout=field_lay)
    lbl_nspks0 = widgets.Label("N° spikes:", layout=field_lay)
    lbl_nspks1 = widgets.Label(str(nSpikes), layout=field_lay)
    lbl_nch0 = widgets.Label("N° channels:", layout=field_lay)
    lbl_nch1 = widgets.Label(str(nChannels), layout=field_lay)
    hbox0 = widgets.HBox(children=[lbl_spk, spk_ind])
    vbox0 = widgets.VBox(children=[
        widgets.HBox(children=[lbl_nspks0, lbl_nspks1]),
        widgets.HBox(children=[lbl_nch0, lbl_nch1]),
        hbox0,
    ])
    hbox1 = widgets.HBox(children=[vbox0, out_fig])

    return hbox1
Exemple #24
0
def columns_widget(label, column_list):
    names = []
    checkbox_objects = []
    objects = [label]
    for key in column_list:
        c = widgets.Checkbox(value=False)
        checkbox_objects.append(c)
        l = widgets.Label(key)
        l.layout.width = '500ex'
        objects.append(c)
        objects.append(l)
        names.append(key)

    arg_dict = {
        names[i]: checkbox
        for i, checkbox in enumerate(checkbox_objects)
    }
    ui = widgets.HBox(children=objects)
    selected_data = []

    def select_data(**kwargs):
        selected_data.clear()

        for key in kwargs:
            if kwargs[key] is True:
                selected_data.append(key)

        print(selected_data)

    # out = widgets.interactive_output(select_data, arg_dict)
    return ui, arg_dict
Exemple #25
0
def create_platform_product_gui(platforms, products):
    """
    Description:

    -----
    """

    # Create widgets
    platform_sel = widgets.Dropdown(options=platforms, values=platforms)
    product_sel = widgets.Dropdown(options=products, values=products)

    # Display form
    display(widgets.Label('Platform: '), platform_sel)
    display(widgets.Label('Product: '), product_sel)

    return [platform_sel, product_sel]
Exemple #26
0
    def display_metadata_list(self):
        self.list_images = self.get_list_of_images()
        list_images = self.list_images
        self.record_file_extension(filename=list_images[0])

        image0 = list_images[0]
        o_image0 = Image.open(image0)

        info = collections.OrderedDict(sorted(o_image0.tag_v2.items()))
        display_format = []
        list_default_value_selected = []
        dict_of_metadata = {}
        for tag, value in info.items():
            formatted_string = "{} -> {}".format(tag, value)
            dict_of_metadata[formatted_string] = tag
            display_format.append(formatted_string)
            if tag in self.default_metadata_to_select:
                list_default_value_selected.append(formatted_string)

        self.box1 = widgets.HBox([widgets.Label("Select Metadata:",
                                                layout=widgets.Layout(width='10%')),
                                  widgets.SelectMultiple(options=display_format,
                                                         value=list_default_value_selected,
                                                         layout=widgets.Layout(width='50%',
                                                                               height='300px'))])
        display(self.box1)
        self.dict_of_metadata = dict_of_metadata
Exemple #27
0
        def __init__(self):

            self._handle = ImageDrawHandle(sequence.frame(0).image())

            self._button_restart = widgets.Button(description='Restart')
            self._button_next = widgets.Button(description='Next')
            self._button_play = widgets.Button(description='Run')
            self._frame = widgets.Label(value="")
            self._frame.layout.display = "none"
            self._frame_feedback = widgets.Label(value="")
            self._image = widgets.Image(value="", format="png", width=sequence.size[0] * 2, height=sequence.size[1] * 2)

            state = dict(frame=0, auto=False, alive=True, region=None)
            condition = Condition()

            self._buttons = widgets.HBox(children=(frame, self._button_restart, self._button_next, button_play, frame2))
Exemple #28
0
    def __init__(self, disambiguation_map, start = 0):
        self.map = disambiguation_map.copy() #Note, deep copy to make sure this is separate
        self.todo = sorted([v for k,v in self.map.items()], key = lambda x: x[0])
        self.position = start

        self.toDisambiguate = widgets.Label(value = self.todo[self.position][0])

        self.disambiguated = widgets.Text(value=self.todo[self.position][0],
                                        placeholder='Type something',
                                        description='Root:',
                                        disabled=False)

        self.next = widgets.Button(description = 'Next')
        self.next.on_click(self.next_clicked)

        self.none = widgets.Button(description = 'None')
        self.none.on_click(self.none_clicked)

        self.previous = widgets.Button(description = 'Previous')
        self.previous.on_click(self.previous_clicked)

        bottom_rule = widgets.HBox([self.disambiguated,self.next,self.none,self.previous])
        bottom_rule.layout.justify_content = 'space-between'
        
        self.tool = widgets.VBox([self.toDisambiguate,bottom_rule])
        self.tool.layout.justify_content = 'space-around'
Exemple #29
0
def hilo_flow_widgets(quants):
    low = (quants.loc[quants['Exceedance'] == 0.95]['Qlow']).values[0]
    high = round((quants.loc[quants['Exceedance'] == 0.10]['Qhigh']).values[0],
                 2)

    low_label = widgets.Label(
        value=f'Low Flow: {low:.3g} cfs',
        description='Low Flow (cfs)',
    )

    high_label = widgets.Label(
        value=f'High Flow: {round(high,3)} cfs',
        description='Low Flow (cfs)',
    )

    return widgets.VBox([widgets.Label('Results'), low_label, high_label])
    def retrieve_parameters(self):
        if self.uniqueness:
            list_of_input_files = glob.glob(
                os.path.join(self.working_dir, '*' + self.dominant_extension))
            list_of_input_files.sort()

            self.result = self.Result(list_files=list_of_input_files,
                                      ext=self.dominant_extension,
                                      uniqueness=True)

        else:

            list_of_maj_ext = [
                _ext for _ext in self.counter_extension.keys()
                if self.counter_extension[_ext] == self.dominant_number
            ]

            box = widgets.HBox([
                widgets.Label("Select Extension to work with",
                              layout=widgets.Layout(width='20%')),
                widgets.Dropdown(options=list_of_maj_ext,
                                 layout=widgets.Layout(width='20%'),
                                 value=list_of_maj_ext[0])
            ])
            display(box)
            self.dropdown_ui = box.children[1]