def traits_view(self): self.statistics_name = "Cohen's Kappa" traits_view = View(VGroup( HGroup(Item("statistics_name", show_label=False), Item("info_button", show_label=False)), Spring(), HGroup( Spring(), Item("stats_view", style="custom", show_label=False, width=300, resizable=False), Spring()), ), width=400, resizable=True) return traits_view
def traits_view(self): db_table_editor = TableEditor( columns=[ ObjectColumn(name='data_id', label='Annotations ID', editable=False, width=0.65), ObjectColumn(name='model_name', editable=False, width=0.20), ObjectColumn(name='value', label='Log likelihood', editable=False, width=0.15) ], search=SearchIDFilter(), editable=True, deletable=True, configurable=False, sortable=True, sort_model=False, auto_size=False, orientation='vertical', show_toolbar=True, selection_mode='row', on_dclick=self.forward_to_model_data_view, on_select=self.track_selection) traits_view = View( VGroup( Item( 'results_table', editor=db_table_editor, show_label=False, ), HGroup( Item('open_to_main', show_label=False, width=100), Item('delete_action', show_label=False, enabled_when='current_selection is not None', width=100), Spring(), Item('close_view', show_label=False, width=100)), ), title='pyAnno results database', width=800, height=400, resizable=True, #buttons = [ 'OK' ], kind='live') return traits_view
def traits_view(self): if is_display_small(): w_view = 350 else: w_view = 450 info_group = VGroup(Item('_name', label='Annotations name:', style='readonly', padding=0), VGrid(Item('_nclasses', label='Number of classes:', style='readonly', width=10), Item('_labels', label='Labels:', style='readonly'), Item('_nannotators', label='Number of annotators:', style='readonly', width=10), Item('_nitems', label='Number of items:', style='readonly'), padding=0), padding=0) body = VGroup( info_group, Item('_'), HGroup( VGroup( Spring(), Item('frequency_plot', style='custom', resizable=False, show_label=False, width=w_view), Spring()), Spring(), VGroup( Spring(), Item('edit_data', enabled_when='annotations_are_defined', show_label=False), Item('save_data', enabled_when='annotations_are_defined', show_label=False), Spring())), Spring(), Item('_'), ) traits_view = View(body) return traits_view
def traits_view(self): w_view = 350 if is_display_small() else 480 parameters_group = VGroup( Item('_'), HGroup( VGroup( Spring(), Item('handler.omega_hinton_diagram', style='custom', resizable=False, show_label=False, width=w_view), Spring()), Spring(), VGroup(Spring(), Item('handler.view_omega', show_label=False), Spring())), Spring(), Item('_'), Spring(), HGroup( VGroup( UItem('handler.theta_views'), UItem('handler.theta_view', style='custom', resizable=False, width=w_view), Spring()), Spring(), VGroup(Spring(), UItem('handler.view_theta'), Spring()))) body = VGroup(Include('info_group'), parameters_group) traits_view = View(body, buttons=[OKButton], resizable=True) return traits_view
def traits_view(self): ## Model view # adjust sizes to display size if is_display_small(): # full view size w_view, h_view = 1024, 768 w_data_create_group = 350 w_data_info_group = 500 h_annotations_stats = 270 else: w_view, h_view = 1300, 850 w_data_create_group = 400 w_data_info_group = 700 h_annotations_stats = 330 model_create_group = (VGroup(HGroup( UItem(name='model_name', width=200), UItem(name='new_model', width=100), UItem(name='get_info_on_model', width=100, height=25), ), label='Create new model')) model_group = (VGroup( model_create_group, VGroup( Item('model_view', style='custom', show_label=False, width=400), label='Model view', ), ), ) ## Data view data_create_group = VGroup( #Label('Open annotation file:', width=800), HGroup( Item('annotations_file', style='simple', label='Open file:', width=w_data_create_group, height=25), UItem('new_annotations', height=25)), label='Load/create annotations', show_border=False, ) data_info_group = VGroup( Item( 'annotations_view', style='custom', show_label=False, visible_when='annotations_are_defined', width=w_data_info_group, ), Item('annotations_stats_view', style='custom', show_label=False, visible_when='annotations_are_defined', height=h_annotations_stats), label='Data view', ) data_group = (VGroup( data_create_group, data_info_group, ), ) ## (Model,Data) view model_data_group = ( VGroup( #Item('info_string', show_label=False, style='readonly'), Item('log_likelihood', label='Log likelihood', style='readonly'), HGroup( Item('ml_estimate', enabled_when='annotations_are_defined'), Item('map_estimate', enabled_when='annotations_are_defined'), Item('sample_posterior_over_accuracy', enabled_when='annotations_are_defined'), Item('estimate_labels', enabled_when='annotations_are_defined'), Spring(), Item('add_to_database', enabled_when='annotations_are_defined'), Item('open_database'), show_labels=False, ), label='Model-data view', )) ## Full view full_view = View( VGroup( HGroup(model_group, data_group), model_data_group, ), title='PyAnno - Models of data annotations by multiple curators', width=w_view, height=h_view, resizable=False) return full_view
class PosteriorPlot(PyannoPlotContainer): # data to be displayed posterior = Array ### plot-related traits plot_width = Float def _plot_width_default(self): return 450 if is_display_small() else 500 plot_height = Float def _plot_height_default(self): return 600 if is_display_small() else 750 colormap_low = Float(0.0) colormap_high = Float(1.0) origin = Str('top left') plot_container = Instance(HPlotContainer) plot_posterior = Instance(Plot) def _create_colormap(self): if self.colormap_low is None: self.colormap_low = self.posterior.min() if self.colormap_high is None: self.colormap_high = self.posterior.max() colormap = Reds( DataRange1D(low=self.colormap_low, high=self.colormap_high)) return colormap def _plot_container_default(self): data = self.posterior nannotations, nclasses = data.shape # create a plot data object plot_data = ArrayPlotData() plot_data.set_data("values", data) # create the plot plot = Plot(plot_data, origin=self.origin) img_plot = plot.img_plot("values", interpolation='nearest', xbounds=(0, nclasses), ybounds=(0, nannotations), colormap=self._create_colormap())[0] ndisp = 55 img_plot.y_mapper.range.high = ndisp img_plot.y_mapper.domain_limits = ((0, nannotations)) self._set_title(plot) plot.padding_top = 80 # create x axis for labels label_axis = self._create_increment_one_axis(plot, 0.5, nclasses, 'top') label_axis.title = 'classes' self._add_index_axis(plot, label_axis) plot.y_axis.title = 'items' # tweak plot aspect goal_aspect_ratio = 2.0 plot_width = (goal_aspect_ratio * self.plot_height * nclasses / ndisp) self.plot_width = min(max(plot_width, 200), 400) plot.aspect_ratio = self.plot_width / self.plot_height # add colorbar colormap = img_plot.color_mapper colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range), color_mapper=colormap, plot=img_plot, orientation='v', resizable='', width=15, height=250) colorbar.padding_top = plot.padding_top colorbar.padding_bottom = int(self.plot_height - colorbar.height - plot.padding_top) colorbar.padding_left = 0 colorbar.padding_right = 30 # create a container to position the plot and the colorbar side-by-side container = HPlotContainer(use_backbuffer=True) container.add(plot) container.add(colorbar) container.bgcolor = 0xFFFFFF # light gray: 0xEEEEEE # add pan tools img_plot.tools.append( PanTool(img_plot, constrain=True, constrain_direction="y", speed=7.)) self.decorate_plot(container, self.posterior) self.plot_posterior = plot return container def add_markings(self, mark_classes, mark_name, marker_shape, delta_x, delta_y, marker_size=5, line_width=1., marker_color='white'): plot = self.plot_posterior nannotations = plot.data.arrays['values'].shape[0] y_name = mark_name + '_y' x_name = mark_name + '_x' valid = is_valid(mark_classes) y_values = np.arange(nannotations)[valid] + delta_y + 0.5 x_values = mark_classes[valid].astype(float) + delta_x + 0.5 plot.data.set_data(y_name, y_values) plot.data.set_data(x_name, x_values) plot.plot((x_name, y_name), type='scatter', name=mark_name, marker=marker_shape, marker_size=marker_size, color='transparent', outline_color=marker_color, line_width=line_width) def remove_markings(self, mark_name): self.plot_posterior.delplot(mark_name) def _create_resizable_view(self): # resizable_view factory, as I need to compute the height of the plot # from the number of annotations, and I couldn't find any other way to # do that # "touch" posterior_plot to have it initialize self.plot_container if is_display_small(): height = 760 else: height = 800 resizable_plot_item = (Item( 'plot_container', editor=ComponentEditor(), resizable=True, show_label=False, width=self.plot_width, height=self.plot_height, )) resizable_view = View(VGroup( Include('instructions_group'), resizable_plot_item, ), width=450, height=height, resizable=True) return resizable_view def traits_view(self): return self._create_resizable_view() pan_instructions = Str def _pan_instructions_default(self): return 'Left-click and drag to navigate items' instructions_group = VGroup( HGroup(Spring(), Item('instructions', style='readonly', show_label=False), Spring()), HGroup(Spring(), Item('pan_instructions', style='readonly', show_label=False), Spring()))
def traits_view(self): if is_display_small(): w_view = 400 else: w_view = 510 parameters_group = VGroup( Item('_'), HGroup( Item('handler.edit_prior', show_label=False, width=100), Spring(), ), Item('_'), HGroup( VGroup( Spring(), Item('handler.pi_hinton_diagram', style='custom', resizable=False, show_label=False, width=w_view), Spring(), ), Spring(), VGroup( Spring(), Item('handler.view_pi', show_label=False), Spring() ), ), Item('_'), HGroup( VGroup( Item('handler.theta_views', show_label=False), Item('handler.theta_view', style='custom', resizable=False, show_label=False, width = w_view), Spring() ), VGroup( Spring(), Item('handler.view_theta', show_label=False), Spring() ) ), ) body = VGroup( Include('info_group'), parameters_group ) traits_view = View(body, buttons=[OKButton], resizable=True) return traits_view