Example #1
0
  def control_panel(self, tables):
    self.widgets.motion_chart.guess_or_remember(('multicompare motionchart', tables), None)
    
    self._add_select(
        'reduce_method', 
        'Dimensionality reduction method',
        options=[
            ('pca', 'PCA over averaged reduce_dimensions1'),
            ('ks', 'Distances are ks-score between histogram of reduce_dimensions1'),
            ('average', 'Averages over reduce dimensions 1 and 2)')],
        is_multiple=False,
        cache_key=None, 
        default=['pca'])
    
    self._add_select(
        'reduce_dims1',
        'Dimensionality reduction dims 1', 
        options=options_from_table(tables[0]),
        is_multiple=True,
        cache_key=tables,
        default=[])

    self._add_select(
        'reduce_dims2',
        'Dimensionality reduction dims 2', 
        options=options_from_table(tables[0]),
        is_multiple=True,
        cache_key=tables,
        default=[])

    self._add_select(
        'average_dims',
        'Calculate average for', 
        options=options_from_table(tables[0]),
        is_multiple=True,
        cache_key=tables,
        default=[])

    self._add_select(
        'std_dims',
        'Calculate std for', 
        options=options_from_table(tables[0]),
        is_multiple=True,
        cache_key=tables,
        default=[])

    self._add_select(
        'id_tags',
        'Id tags',
        options=tables[0].tags.keys(),
        cache_key=tables,
        default=['name'])

    self._add_select(
        'scroll_tags',
        'Animation Scroll tags',
        options=tables[0].tags.keys(),
        cache_key=tables,
        default=[])
Example #2
0
    def control_panel(self, tables):
        self.widgets.motion_chart.guess_or_remember(
            ('multicompare motionchart', tables), None)

        self._add_select(
            'reduce_method',
            'Dimensionality reduction method',
            options=[
                ('pca', 'PCA over averaged reduce_dimensions1'),
                ('ks',
                 'Distances are ks-score between histogram of reduce_dimensions1'
                 ), ('average', 'Averages over reduce dimensions 1 and 2)')
            ],
            is_multiple=False,
            cache_key=None,
            default=['pca'])

        self._add_select('reduce_dims1',
                         'Dimensionality reduction dims 1',
                         options=options_from_table(tables[0]),
                         is_multiple=True,
                         cache_key=tables,
                         default=[])

        self._add_select('reduce_dims2',
                         'Dimensionality reduction dims 2',
                         options=options_from_table(tables[0]),
                         is_multiple=True,
                         cache_key=tables,
                         default=[])

        self._add_select('average_dims',
                         'Calculate average for',
                         options=options_from_table(tables[0]),
                         is_multiple=True,
                         cache_key=tables,
                         default=[])

        self._add_select('std_dims',
                         'Calculate std for',
                         options=options_from_table(tables[0]),
                         is_multiple=True,
                         cache_key=tables,
                         default=[])

        self._add_select('id_tags',
                         'Id tags',
                         options=tables[0].tags.keys(),
                         cache_key=tables,
                         default=['name'])

        self._add_select('scroll_tags',
                         'Animation Scroll tags',
                         options=tables[0].tags.keys(),
                         cache_key=tables,
                         default=[])
Example #3
0
  def control_panel(self, tables):
    self._add_select(
        'window_dim',
        'Sliding window dimension',
        options=options_from_table(tables[0]),
        is_multiple=False,
        cache_key=tables,
        default=['Time'])
    
    self._add_input(
        'size', 
        'Sliding window size',
        cache_key=tables,
        default=1000)

    self._add_input(
        'overlap', 
        'Sliding window overlap',
        cache_key=tables,
        default=500)
    
    self._add_select(
        'agg_method',
        'From every window take',
        options=[('average', 'Average'), ('median', 'Median')],
        is_multiple=False)
Example #4
0
  def control_panel(self, tables):

    
    self._add_select(
        'tables_to_show',
        'Tables to Show',
        options=[('all', 'All tables')] + [(t.name, t.name) for t in tables],
        is_multiple=True,
        cache_key=tables,
        default=['all'])
    
    self._add_select(
        'dims',
        'Dimensions to correlate', 
        options=options_from_table(tables[0]),
        is_multiple=True,
        cache_key=tables,
        default=[])

    self._add_select(
        'corr_method',
        'Correlation method',
        options=[('corr', 'Correlation'), ('mi', 'Mutual Information')],
        is_multiple=False,
        cache_key=tables,
        default=['corr'])
Example #5
0
 def control_panel(self, tables):
     self._add_select('dims',
                      'Dimensions for box plot',
                      options=options_from_table(tables[0]),
                      is_multiple=True,
                      cache_key=tables,
                      default=[])
Example #6
0
 def control_panel(self, tables):
   self._add_select(
       'dims',
       'Dimensions to divide',
       options=options_from_table(tables[0]),
       is_multiple=True,
       cache_key=tables,
       default=[])
   
   self._add_select(
       'ratio_dim',
       'Divider dimension',
       options=options_from_table(tables[0]),
       is_multiple=False,
       cache_key=tables,
       default=[])
Example #7
0
 def control_panel(self, tables):
   self._add_select(
       'dims',
       'Dimensions for box plot',
       options=options_from_table(tables[0]),
       is_multiple=True,
       cache_key=tables,
       default=[])
Example #8
0
 def control_panel(self, tables):
     self._add_select('cluster_dims',
                      'Clustering Dimensions',
                      options=options_from_table(tables[0]),
                      is_multiple=True,
                      cache_key=tables,
                      default=[])
     return self._control_panel(tables)
Example #9
0
 def control_panel(self, tables):
   self._add_select(
       'cluster_dims',
       'Clustering Dimensions',
       options=options_from_table(tables[0]), 
       is_multiple=True, 
       cache_key=tables, 
       default=[])
   return self._control_panel(tables)  
Example #10
0
  def control_panel(self, tables):
    self._add_select(
        'dims',
        'Dimensions to discretize',
        options=options_from_table(tables[0]),
        is_multiple=True,
        cache_key=tables,
        default=[])
    
    self._add_select(
        'bin_type',
        'Bin Method',
        options=[('divide', 'Divide the range [min,max] equally to the spcified number of bins'), ('explicit', 'Use a comma separated list of bins')],
        is_multiple=False,
        cache_key=tables,
        default=['divide'])

    self._add_input(
        'bins', 
        'Bins',
        cache_key=tables,
        default='2',
        numeric_validation=False)
Example #11
0
    def control_panel(self, tables):
        self._add_select('window_dim',
                         'Sliding window dimension',
                         options=options_from_table(tables[0]),
                         is_multiple=False,
                         cache_key=tables,
                         default=['Time'])

        self._add_input('size',
                        'Sliding window size',
                        cache_key=tables,
                        default=1000)

        self._add_input('overlap',
                        'Sliding window overlap',
                        cache_key=tables,
                        default=500)

        self._add_select('agg_method',
                         'From every window take',
                         options=[('average', 'Average'),
                                  ('median', 'Median')],
                         is_multiple=False)
Example #12
0
  def control_panel(self, tables):
    AbstractPlot.control_panel(self, tables)
    self._add_select(
        'contour',
        'Draw Contour Lines',
        options=[('none', 'None'), ('regular', 'Regular Contour'), ('smooth', 'Smooth Contour')],
        is_multiple=False,
        cache_key=tables,
        default=['none'])

    self._add_select(
        'color',
        'Color',
        options=[('None', [('none', 'No Color')])] +  options_from_table(tables[0]),
        is_multiple=True,
        cache_key=tables,
        default=['none'])

    if not self.widgets.color.values.choices:
      self.widgets.color.values.choices = ['None']

    self._add_select(
        'resolution',
        'Resolution',
        options=['1', '1.25', '1.5', '2', '3', '4'],
        is_multiple=False,
        cache_key=tables,
        default=['1'])
    
    self._add_input(
        'min_cells_in_bin',
        'Minimum cells in a bin',
        cache_key=tables,
        default='1')
    
    if self.widgets.min_cells_in_bin.values.value == None:
      self.widgets.min_cells_in_bin.values.value = 1
Example #13
0
    def control_panel(self, tables):
        AbstractPlot.control_panel(self, tables)
        self._add_select('contour',
                         'Draw Contour Lines',
                         options=[('none', 'None'),
                                  ('regular', 'Regular Contour'),
                                  ('smooth', 'Smooth Contour')],
                         is_multiple=False,
                         cache_key=tables,
                         default=['none'])

        self._add_select('color',
                         'Color',
                         options=[('None', [('none', 'No Color')])] +
                         options_from_table(tables[0]),
                         is_multiple=True,
                         cache_key=tables,
                         default=['none'])

        if not self.widgets.color.values.choices:
            self.widgets.color.values.choices = ['None']

        self._add_select('resolution',
                         'Resolution',
                         options=['1', '1.25', '1.5', '2', '3', '4'],
                         is_multiple=False,
                         cache_key=tables,
                         default=['1'])

        self._add_input('min_cells_in_bin',
                        'Minimum cells in a bin',
                        cache_key=tables,
                        default='1')

        if self.widgets.min_cells_in_bin.values.value == None:
            self.widgets.min_cells_in_bin.values.value = 1
Example #14
0
    def control_panel(self, tables):
        self._add_select('dims',
                         'Dimensions to discretize',
                         options=options_from_table(tables[0]),
                         is_multiple=True,
                         cache_key=tables,
                         default=[])

        self._add_select(
            'bin_type',
            'Bin Method',
            options=
            [('divide',
              'Divide the range [min,max] equally to the spcified number of bins'
              ), ('explicit', 'Use a comma separated list of bins')],
            is_multiple=False,
            cache_key=tables,
            default=['divide'])

        self._add_input('bins',
                        'Bins',
                        cache_key=tables,
                        default='2',
                        numeric_validation=False)
Example #15
0
    def view(self, tables):
        """ The view method of this module draws the control panel and the histograms. 
    We need at least one input to be able to draw something.
    """
        if not tables:
            return View(self, 'No tables to show.')
        self.widgets.color.guess_or_remember(('histogram text', tables),
                                             ['name'])
        self.widgets.text.guess_or_remember(('histogram colors', tables),
                                            ['name'])
        self.widgets.shift.guess_or_remember(('histogram shift', tables),
                                             '0.2')
        self.widgets.sort_inside.guess_or_remember(
            ('histogram sort inside', tables), ['similarity'])
        self.widgets.sort_outside.guess_or_remember(
            ('histogram sort outside', tables), ['sort'])
        self.widgets.trim.guess_or_remember(('histogram trim', tables), ['no'])
        self.widgets.trim_thresh.guess_or_remember(
            ('histogram trim thresh', tables), '0')

        sort_inside_options = [('unsort', 'Keep original order'),
                               ('similarity', 'Put similar curves together')]
        sort_inside_options += [(x, 'Sort by %s' % x)
                                for x in tables[0].tags.keys()]

        # Create the control panel view. This will enable users to choose the dimensions.
        control_panel_view = stack_lines(
            self.widgets.dims.view('Dimension', self.widgets.apply,
                                   options_from_table(tables[0])),
            self.widgets.text.view('Text by', self.widgets.apply,
                                   tables[0].tags.keys()),
            self.widgets.color.view('Color by', self.widgets.apply,
                                    tables[0].tags.keys()),
            self.widgets.shift.view('Shift for multiple curves',
                                    self.widgets.apply),
            self.widgets.sort_inside.view('Curve sorting',
                                          self.widgets.apply,
                                          sort_inside_options,
                                          multiple=False),
            self.widgets.sort_outside.view(
                'Plot sorting',
                self.widgets.apply,
                [('sort', 'Put plots with many differences first'),
                 ('unsort', 'Keep original order')],
                multiple=False),
            self.widgets.trim.view(
                'Trim plots',
                self.widgets.apply,
                [('yes', 'Convert values lower than threshold to 0'),
                 ('no', 'Don\'t trim')],
                multiple=False),
            self.widgets.trim_thresh.view('Trim threshold',
                                          self.widgets.apply),
            self.widgets.apply.view())
        main_views = []
        shift = self.widgets.shift.value_as_float()
        plots_for_legend = OrderedDict()
        colorer = axes.Colorer()
        # Check that the user has already chosen dimensions. Otherwise, ask him
        # to do so.
        if self.widgets.dims.values.choices:
            timer = MultiTimer(len(self.widgets.dims.values.choices))
            for i, dim in enumerate(self.widgets.dims.values.choices):
                try:
                    # Go over every dimension and create the histogram:
                    # First create a new figure:
                    fig = self.create_and_adjust_figure(tables)
                    ax = fig.add_subplot(111)

                    # Draw the histogram for every input
                    plots = []
                    sorted_tables = tables
                    sort_method = self.widgets.sort_inside.values.choices[0]
                    if sort_method == 'unsort':
                        sorted_tables = tables
                    elif sort_method == 'similarity':
                        thresh = None
                        if self.widgets.trim.get_choices()[0] == 'yes':
                            thresh = self.widgets.trim_thresh.value_as_float()
                        # get distances table:
                        distances = datatable.ks_distances(tables, dim, thresh)
                        # sort by distance
                        sorted_tables = greedy_distance_sort(distances, tables)
                    else:
                        # we need to sort by tags:
                        tag_for_sort = self.widgets.sort_inside.values.choices[
                            0]
                        sorted_tables = sorted(
                            tables, key=lambda table: table.tags[tag_for_sort])
                    for i, table in enumerate(sorted_tables):
                        color_tags = self.widgets.color.values.choices
                        color_key = tuple([table.tags[c] for c in color_tags])
                        min_x = None
                        if self.widgets.trim.get_choices()[0] == 'yes':
                            min_x = self.widgets.trim_thresh.value_as_float()
                        plot = axes.kde1d(ax,
                                          table,
                                          dim,
                                          color=colorer.get_color(color_key),
                                          min_x=min_x,
                                          shift=shift * i)
                        plots_for_legend[color_key] = plot
                    # Add ticks with table names:
                    if self.widgets.shift.value_as_float() > 0:
                        ax.set_yticks(np.arange(0, len(tables) * shift, shift))
                        ax.set_yticklabels([
                            t.get_tags(self.widgets.text.values.choices)
                            for t in sorted_tables
                        ],
                                           size='xx-small')
                    # set axes y range:
                    ax.set_ylim(bottom=-0.1,
                                top=0.8 + shift * (len(sorted_tables) - 1))
                    # Make sure we don't create the same widget twice. We create a new widget
                    # for every dimension asked.
                    widget_key = self._normalize_id(dim)
                    if not widget_key in self.widgets:
                        self._add_widget(widget_key, Figure)
                    figure_widget = self.widgets[widget_key]

                    if len(tables) > 1:
                        from scipy.stats import ks_2samp
                        ks, p_ks = ks_2samp(tables[0].get_cols(dim)[0],
                                            tables[1].get_cols(dim)[0])
                        ks_view = View(self,
                                       'ks: %.3f, p_ks: %.10f' % (ks, p_ks))
                        final_view = stack_lines(ks_view,
                                                 figure_widget.view(fig))
                    else:
                        ks, p_ks = 0, 0
                        final_view = figure_widget.view(fig)
                    # Add the new widget's view
                    main_views.append((ks, p_ks, final_view))
                except Exception as e:
                    logging.exception('Exception when drawing histogram')
                    main_views.append((0, 0, View(self, str(e))))

                timer.complete_task(dim)

            # sort by the ks test:
            main_views = sorted(main_views, key=itemgetter(0), reverse=True)
            main_views = [v[2] for v in main_views]

            # create legend:
            legened_titles = plots_for_legend.keys()
            print len(legened_titles)
            max_title_len = max([len(str(t)) for t in legened_titles] + [0])
            print max_title_len
            WIDTH_PER_LETTER = 7
            EXTRA_WIDTH = 60
            HEIGHT_PER_LINE = 30
            EXTRA_HEIGHT = 50
            MIN_X = 300
            MIN_Y = 100
            legend_x = max(MIN_X,
                           EXTRA_WIDTH + WIDTH_PER_LETTER * max_title_len)
            legend_y = max(
                MIN_Y, EXTRA_HEIGHT + HEIGHT_PER_LINE * len(legened_titles))
            fig = axes.new_figure(legend_x, legend_y)
            ax = fig.add_subplot(111)
            ax.get_xaxis().set_visible(False)
            ax.get_yaxis().set_visible(False)
            ax.legend(plots_for_legend.values(),
                      plots_for_legend.keys(),
                      loc='center',
                      mode='expand',
                      frameon=False,
                      prop={'size': 'xx-small'})
            main_views = [self.widgets.legend_figure.view(fig)] + main_views
            main_view = view.stack_left(*main_views)

        else:
            main_view = View(None, 'Please select dimensions')
        # combine the control panel and the main view togeteher:
        return self.widgets.layout.view(main_view, control_panel_view)
Example #16
0
  def view(self, tables):
    """ The view method of this module draws the control panel and the histograms. 
    We need at least one input to be able to draw something.
    """
    if not tables:
      return View(self, 'No tables to show.')
    self.widgets.color.guess_or_remember(('histogram text', tables), ['name'])
    self.widgets.text.guess_or_remember(('histogram colors', tables), ['name'])
    self.widgets.shift.guess_or_remember(('histogram shift', tables), '0.2')
    self.widgets.sort_inside.guess_or_remember(('histogram sort inside', tables), ['similarity'])
    self.widgets.sort_outside.guess_or_remember(('histogram sort outside', tables), ['sort'])
    self.widgets.trim.guess_or_remember(('histogram trim', tables), ['no'])
    self.widgets.trim_thresh.guess_or_remember(('histogram trim thresh', tables), '0')

    sort_inside_options = [('unsort', 'Keep original order'), ('similarity', 'Put similar curves together')]
    sort_inside_options += [(x, 'Sort by %s' % x) for x in tables[0].tags.keys()]
    
    # Create the control panel view. This will enable users to choose the dimensions. 
    control_panel_view = stack_lines(
        self.widgets.dims.view('Dimension', self.widgets.apply, options_from_table(tables[0])),
        self.widgets.text.view('Text by', self.widgets.apply, tables[0].tags.keys()),
        self.widgets.color.view('Color by', self.widgets.apply, tables[0].tags.keys()),
        self.widgets.shift.view('Shift for multiple curves', self.widgets.apply),
        self.widgets.sort_inside.view('Curve sorting', self.widgets.apply, 
                                      sort_inside_options,
                                      multiple=False),
        self.widgets.sort_outside.view('Plot sorting', self.widgets.apply, 
                                      [('sort', 'Put plots with many differences first'), ('unsort', 'Keep original order')],
                                      multiple=False),
        self.widgets.trim.view('Trim plots', self.widgets.apply,
            [('yes', 'Convert values lower than threshold to 0'), ('no', 'Don\'t trim')], multiple=False),
        self.widgets.trim_thresh.view('Trim threshold', self.widgets.apply),
        self.widgets.apply.view())
    main_views = []
    shift = self.widgets.shift.value_as_float()
    plots_for_legend = OrderedDict()
    colorer = axes.Colorer()
    # Check that the user has already chosen dimensions. Otherwise, ask him 
    # to do so.
    if self.widgets.dims.values.choices:
      timer = MultiTimer(len(self.widgets.dims.values.choices))
      for i, dim in enumerate(self.widgets.dims.values.choices):
        try:
          # Go over every dimension and create the histogram:
          # First create a new figure:
          fig = self.create_and_adjust_figure(tables)
          ax = fig.add_subplot(111)
          
          # Draw the histogram for every input
          plots = []
          sorted_tables = tables
          sort_method = self.widgets.sort_inside.values.choices[0]
          if sort_method == 'unsort':
            sorted_tables = tables
          elif sort_method == 'similarity':
            thresh = None
            if self.widgets.trim.get_choices()[0] == 'yes':
              thresh = self.widgets.trim_thresh.value_as_float()
            # get distances table:
            distances = datatable.ks_distances(tables, dim, thresh)
            # sort by distance
            sorted_tables = greedy_distance_sort(distances, tables)
          else:
            # we need to sort by tags:
            tag_for_sort = self.widgets.sort_inside.values.choices[0]
            sorted_tables = sorted(tables, key=lambda table: table.tags[tag_for_sort])
          for i, table in enumerate(sorted_tables):
            color_tags = self.widgets.color.values.choices
            color_key = tuple([table.tags[c] for c in color_tags])
            min_x = None
            if self.widgets.trim.get_choices()[0] =='yes':
              min_x = self.widgets.trim_thresh.value_as_float()
            plot = axes.kde1d(ax, table, dim,
                              color=colorer.get_color(color_key),
                              min_x=min_x,
                              shift=shift*i)
            plots_for_legend[color_key] = plot
          # Add ticks with table names:
          if self.widgets.shift.value_as_float() > 0:
            ax.set_yticks(np.arange(0, len(tables)*shift, shift))
            ax.set_yticklabels([t.get_tags(self.widgets.text.values.choices) for t in sorted_tables], size='xx-small')
          # set axes y range:
          ax.set_ylim(bottom = -0.1, top=0.8+shift*(len(sorted_tables)-1))
          # Make sure we don't create the same widget twice. We create a new widget
          # for every dimension asked. 
          widget_key = self._normalize_id(dim)
          if not widget_key in self.widgets:
            self._add_widget(widget_key, Figure)
          figure_widget = self.widgets[widget_key]
        
          if len(tables) > 1:
            from scipy.stats import ks_2samp
            ks, p_ks = ks_2samp(tables[0].get_cols(dim)[0], tables[1].get_cols(dim)[0])
            ks_view = View(self, 'ks: %.3f, p_ks: %.10f' % (ks, p_ks))
            final_view = stack_lines(ks_view, figure_widget.view(fig))
          else:
            ks, p_ks = 0, 0
            final_view = figure_widget.view(fig)
          # Add the new widget's view
          main_views.append((ks, p_ks, final_view))
        except Exception as e:
          logging.exception('Exception when drawing histogram')
          main_views.append((0, 0, View(self, str(e))))
                  
        timer.complete_task(dim)
      
      # sort by the ks test:
      main_views = sorted(main_views, key=itemgetter(0), reverse=True)
      main_views = [v[2] for v in main_views]
      
      
      
      
      # create legend:
      legened_titles = plots_for_legend.keys()
      print len(legened_titles)
      max_title_len = max([len(str(t)) for t in legened_titles] + [0])
      print max_title_len
      WIDTH_PER_LETTER = 7
      EXTRA_WIDTH = 60
      HEIGHT_PER_LINE = 30
      EXTRA_HEIGHT = 50
      MIN_X = 300
      MIN_Y = 100
      legend_x = max(MIN_X, EXTRA_WIDTH + WIDTH_PER_LETTER * max_title_len)
      legend_y = max(MIN_Y, EXTRA_HEIGHT + HEIGHT_PER_LINE * len(legened_titles))
      fig = axes.new_figure(legend_x, legend_y)
      ax = fig.add_subplot(111)
      ax.get_xaxis().set_visible(False)
      ax.get_yaxis().set_visible(False)
      ax.legend(plots_for_legend.values(),
                plots_for_legend.keys(),
                loc='center',
                mode='expand',
                frameon=False,
                prop={'size' : 'xx-small'})
      main_views = [self.widgets.legend_figure.view(fig)] + main_views
      main_view = view.stack_left(*main_views)
      
      
    else:
      main_view = View(None, 'Please select dimensions')    
    # combine the control panel and the main view togeteher:
    return self.widgets.layout.view(main_view, control_panel_view)
Example #17
0
    def control_panel(self, tables):
        self._add_select('dim_x',
                         'X Axis',
                         options=options_from_table(tables[0]),
                         is_multiple=not self.enable_gating,
                         cache_key=tables,
                         default=[tables[0].dims[0]])

        self._add_select('dim_y',
                         'Y Axis',
                         options=options_from_table(tables[0]),
                         is_multiple=not self.enable_gating,
                         cache_key=tables,
                         default=[tables[0].dims[1]])

        self._add_select('tables_to_show',
                         'Tables to Show',
                         options=[('all', 'All tables')] + [(t.name, t.name)
                                                            for t in tables],
                         is_multiple=True,
                         cache_key=tables,
                         default=['all'])

        self._begin_section('View Area')

        self._add_input('min_x',
                        'Min X',
                        cache_key=tables,
                        default='common',
                        numeric_validation=False,
                        non_empty_validation=False,
                        size=8,
                        predefined_values=[('Fit per plot', 'auto'),
                                           ('Fit for row plots', 'common')])

        self._add_input('min_y',
                        'Min Y',
                        cache_key=tables,
                        default='common',
                        numeric_validation=False,
                        non_empty_validation=False,
                        size=8,
                        predefined_values=[('Fit per plot', 'auto'),
                                           ('Fit for row plots', 'common')])

        self._add_input('max_x',
                        'Max X',
                        cache_key=tables,
                        default='common',
                        numeric_validation=False,
                        non_empty_validation=False,
                        size=8,
                        predefined_values=[('Fit per plot', 'auto'),
                                           ('Fit for row plots', 'common')])

        self._add_input('max_y',
                        'Max Y',
                        cache_key=tables,
                        default='common',
                        numeric_validation=False,
                        non_empty_validation=False,
                        size=8,
                        predefined_values=[('Fit per plot', 'auto'),
                                           ('Fit for row plots', 'common')])

        self._end_section('View Area', False)

        if self.enable_gating:
            # we need to save ids for the gate inputs, so that the areaselect in the view function
            # can reference them.
            self.gate_min_x_id = 'min_x_%s' % self._get_unique_id()
            self.gate_max_x_id = 'max_x_%s' % self._get_unique_id()
            self.gate_min_y_id = 'min_y_%s' % self._get_unique_id()
            self.gate_max_y_id = 'max_y_%s' % self._get_unique_id()

            # we need the max/min values for the predefined values on the gate input.
            dim_x = self.widgets.dim_x.get_choice()
            dim_y = self.widgets.dim_y.get_choice()
            min_x = 0
            min_y = 0
            max_x = 0
            max_y = 0
            if dim_x:
                min_x = tables[0].min(dim_x)
                max_x = tables[0].max(dim_x)
            if dim_y:
                min_y = tables[0].min(dim_y)
                max_y = tables[0].max(dim_y)

            self._begin_section('Gate')

            self._add_input('gate_min_x',
                            'Gate Min X',
                            id=self.gate_min_x_id,
                            cache_key=tables,
                            default='%.2f' % min_x,
                            numeric_validation=False,
                            non_empty_validation=False,
                            predefined_values=[('Minimum', '%.2f' % min_x)])

            self._add_input('gate_min_y',
                            'Gate Min Y',
                            id=self.gate_min_y_id,
                            cache_key=tables,
                            default='%.2f' % min_y,
                            numeric_validation=False,
                            non_empty_validation=False,
                            predefined_values=[('Minimum', '%.2f' % min_y)])

            self._add_input('gate_max_x',
                            'Gate Max X',
                            id=self.gate_max_x_id,
                            cache_key=tables,
                            default='%.2f' % max_x,
                            numeric_validation=False,
                            non_empty_validation=False,
                            predefined_values=[('Maximum', '%.2f' % max_x)])

            self._add_input('gate_max_y',
                            'Gate Max Y',
                            id=self.gate_max_y_id,
                            cache_key=tables,
                            default='%.2f' % max_y,
                            numeric_validation=False,
                            non_empty_validation=False,
                            predefined_values=[('Maximum', '%.2f' % max_y)])

            self._end_section('Gate', False)
Example #18
0
  def control_panel(self, tables):
    self._add_select(
        'dim_x',
        'X Axis',
        options=options_from_table(tables[0]),
        is_multiple=not self.enable_gating,
        cache_key=tables,
        default=[tables[0].dims[0]])
    
    self._add_select(
        'dim_y',
        'Y Axis',
        options=options_from_table(tables[0]),
        is_multiple=not self.enable_gating,
        cache_key=tables,
        default=[tables[0].dims[1]])
      
    self._add_select(
        'tables_to_show',
        'Tables to Show',
        options=[('all', 'All tables')] + [(t.name, t.name) for t in tables],
        is_multiple=True,
        cache_key=tables,
        default=['all'])
        
    self._begin_section('View Area')
        
    self._add_input(
        'min_x',
        'Min X',
        cache_key=tables,
        default='common',
        numeric_validation=False,
        non_empty_validation=False,
        size=8,
        predefined_values=[('Fit per plot', 'auto'), ('Fit for row plots', 'common')])

    self._add_input(
        'min_y',
        'Min Y',
        cache_key=tables,
        default='common',
        numeric_validation=False,
        non_empty_validation=False,
        size=8,
        predefined_values=[('Fit per plot', 'auto'), ('Fit for row plots', 'common')])
    
    self._add_input(
        'max_x',
        'Max X',
        cache_key=tables,
        default='common',
        numeric_validation=False,
        non_empty_validation=False,
        size=8,
        predefined_values=[('Fit per plot', 'auto'), ('Fit for row plots', 'common')])

    self._add_input(
        'max_y',
        'Max Y',
        cache_key=tables,
        default='common',
        numeric_validation=False,
        non_empty_validation=False,
        size=8,
        predefined_values=[('Fit per plot', 'auto'), ('Fit for row plots', 'common')])
    
    self._end_section('View Area', False)
    
    if self.enable_gating:  
      # we need to save ids for the gate inputs, so that the areaselect in the view function 
      # can reference them.
      self.gate_min_x_id = 'min_x_%s'  % self._get_unique_id()
      self.gate_max_x_id = 'max_x_%s'  % self._get_unique_id()
      self.gate_min_y_id = 'min_y_%s'  % self._get_unique_id()
      self.gate_max_y_id = 'max_y_%s'  % self._get_unique_id()
      
      
      # we need the max/min values for the predefined values on the gate input.
      dim_x = self.widgets.dim_x.get_choice()
      dim_y = self.widgets.dim_y.get_choice()
      min_x=0; min_y=0; max_x=0; max_y=0;
      if dim_x:
        min_x = tables[0].min(dim_x)
        max_x = tables[0].max(dim_x)
      if dim_y:
        min_y = tables[0].min(dim_y)
        max_y = tables[0].max(dim_y)        
      
      
      self._begin_section('Gate')      
        
      self._add_input(
          'gate_min_x',
          'Gate Min X',
          id=self.gate_min_x_id,
          cache_key=tables,
          default='%.2f' % min_x,
          numeric_validation=False,
          non_empty_validation=False,
          predefined_values=[('Minimum', '%.2f' % min_x)])

      self._add_input(
          'gate_min_y',
          'Gate Min Y',
          id=self.gate_min_y_id,
          cache_key=tables,
          default='%.2f' % min_y,
          numeric_validation=False,
          non_empty_validation=False,
          predefined_values=[('Minimum', '%.2f' % min_y)])
    
      self._add_input(
          'gate_max_x',
          'Gate Max X',
          id=self.gate_max_x_id,
          cache_key=tables,
          default='%.2f' % max_x,
          numeric_validation=False,
          non_empty_validation=False,
          predefined_values=[('Maximum', '%.2f' % max_x)])

      self._add_input(
          'gate_max_y',
          'Gate Max Y',
          id=self.gate_max_y_id,
          cache_key=tables,
          default='%.2f' % max_y,
          numeric_validation=False,
          non_empty_validation=False,
          predefined_values=[('Maximum', '%.2f' % max_y)])
    
      self._end_section('Gate', False)