예제 #1
0
    def _grouped_in_projections(self,ptype):
        """
        Return a dictionary of lists of incoming Projections, grouped by type.

        Each projection of type <ptype> is grouped according to the
        name of the port, into a single list within the dictionary.

        The entry None will contain those that are not of type
        <ptype>, while the other entries will contain a list of
        Projections, each of which has type ptype.

        Example: to obtain the lists of projections that should be
        jointly normalised together, call
        __grouped_in_projection('JointNormalize').
        """
        in_proj = KeyedList()
        in_proj[None]=[] # Independent (ungrouped) connections

        for c in self.in_connections:
            d = c.dest_port
            if not isinstance(c,Projection):
                self.debug("Skipping non-Projection "+c.name)
            elif isinstance(d,tuple) and len(d)>2 and d[1]==ptype:
                if in_proj.get(d[2]):
                    in_proj[d[2]].append(c)
                else:
                    in_proj[d[2]]=[c]
            #elif isinstance(d,tuple):
            #    raise ValueError("Unable to determine appropriate action for dest_port: %s (connection %s)." % (d,c.name))
            else:
                in_proj[None].append(c)

        return in_proj
예제 #2
0
    def refresh_plots_menu(self):
        plots_menu = self['Plots']
        plots_menu.delete(0, 'end')

        # create menu entries, and get list of categories
        entries = KeyedList(
        )  # keep the order of plotgroup_templates (which is also KL)
        categories = []
        for label, plotgroup in plotgroups.items():
            entries[label] = PlotsMenuEntry(plotgroup)
            categories.append(plotgroup.category)
        categories = sorted(set(categories))

        # The Basic category items appear on the menu itself.
        assert 'Basic' in categories, "'Basic' is the category for the standard Plots menu entries."
        for label, entry in entries:
            if entry.plotgroup.category == 'Basic':
                plots_menu.add_command(label=label, command=entry.__call__)

        categories.remove('Basic')

        plots_menu.add_separator()

        # Add the other categories to the menu as cascades, and the plots of each category to
        # their cascades.
        for category in categories:
            category_menu = ControllableMenu(plots_menu, tearoff=0)
            plots_menu.add_cascade(label=category, menu=category_menu)

            # could probably search more efficiently than this
            for label, entry in sorted(entries):
                if entry.plotgroup.category == category:
                    category_menu.add_command(label=label,
                                              command=entry.__call__)

        plots_menu.add_separator()

        plots_menu.add_command(
            label="Help",
            command=(lambda x=plotting_help_locations: self.open_location(x)))
예제 #3
0
 def __init__(self,plot_templates=None,static_images=None,**params):
     super(TemplatePlotGroup,self).__init__(**params)
     self.plot_templates = KeyedList(plot_templates or [])
     # Add plots for the static images, if any
     for image_name,file_path in static_images or []:
         self.add_static_image(image_name,file_path)
예제 #4
0
        use the max timestamp as the plot label
        Displays a warning if not all curves have been measured at the same time.
        """
        for x_axis in self.sheet.curve_dict.itervalues():
            for curve_label in x_axis.itervalues():
                timestamps = [SheetView.timestamp for SheetView in curve_label.itervalues()]

        if timestamps != []:
            self.time = max(timestamps)
            if max(timestamps) != min(timestamps):
                self.warning("Displaying curves from different times (%s,%s)" %
                             (min(timestamps),max(timestamps)))



plotgroups = KeyedList()
"""
Global repository of PlotGroups, to which users can add their own as
needed.
"""

plotgroup_types = {'Connection Fields': ConnectionFieldsPlotGroup,
                   'Projection': CFProjectionPlotGroup,
                   'RF Projection': RFProjectionPlotGroup,
                   'Retinotopy': RetinotopyPlotGroup,
                   'Projection Activity': ProjectionActivityPlotGroup}


def create_plotgroup(template_plot_type='bitmap',**params):
    """
    Create a new PlotGroup and add it to the plotgroups list.