Example #1
0
    def create_or_find_figure(self,
                              title=None,
                              subplots=None,
                              window_name=None):
        """Create a matplotlib figure window or find one already created"""
        import cellprofiler.gui.cpfigure as cpf

        # catch any background threads trying to call display functions.
        assert not self.__in_background

        if title == None:
            title = self.__module.module_name

        if window_name == None:
            window_name = cpf.window_name(self.__module)

        if self.__create_new_window:
            figure = cpf.CPFigureFrame(self,
                                       title=title,
                                       name=window_name,
                                       subplots=subplots)
        else:
            figure = cpf.create_or_find(self.__frame,
                                        title=title,
                                        name=window_name,
                                        subplots=subplots)
        if not figure in self.__windows_used:
            self.__windows_used.append(figure)
        return figure
Example #2
0
    def get_module_figure(self, module, image_set_number, parent=None):
        """Create a CPFigure window or find one already created"""
        import cellprofiler.gui.cpfigure as cpf
        import cellprofiler.measurements as cpmeas

        # catch any background threads trying to call display functions.
        assert not self.__in_background
        window_name = cpf.window_name(module)
        if self.measurements.has_feature(cpmeas.EXPERIMENT,
                                         cpmeas.M_GROUPING_TAGS):
            group_number = self.measurements[cpmeas.IMAGE, cpmeas.GROUP_NUMBER,
                                             image_set_number]
            group_index = self.measurements[cpmeas.IMAGE, cpmeas.GROUP_INDEX,
                                            image_set_number]
            title = "%s #%d, image cycle #%d, group #%d, group index #%d" % (
                module.module_name, module.module_num, image_set_number,
                group_number, group_index)
        else:
            title = "%s #%d, image cycle #%d" % (
                module.module_name, module.module_num, image_set_number)

        if self.__create_new_window:
            figure = cpf.CPFigureFrame(parent or self.__frame,
                                       name=window_name,
                                       title=title)
        else:
            figure = cpf.create_or_find(parent or self.__frame,
                                        name=window_name,
                                        title=title)

        if not figure in self.__windows_used:
            self.__windows_used.append(figure)

        return figure
 def __display_matlab_image(self, handles, filename):
     image = handles["Image"]
     frame = FIG.CPFigureFrame(self.__list_box.GetTopLevelParent(),
                               title=filename,
                               subplots=(1, 1))
     if image.ndim == 3:
         frame.subplot_imshow(0, 0, image, filename)
     else:
         frame.subplot_imshow_grayscale(0, 0, image, filename)
     frame.Refresh()
 def __display_image(self, filename):
     lip = LoadImagesImageProvider("dummy", "", filename, True)
     image = lip.provide_image(None).pixel_data
     frame = FIG.CPFigureFrame(self.__list_box.GetTopLevelParent(),
                               title=filename,
                               subplots=(1, 1))
     if image.ndim == 3:
         frame.subplot_imshow(0, 0, image, filename)
     else:
         frame.subplot_imshow_grayscale(0, 0, image, filename)
     frame.Refresh()
Example #5
0
 def OnInit(self):
     wx.InitAllImageHandlers()
     self.frame = F.CPFigureFrame(title="Otsu", subplots=(2, 1))
     file_menu = self.frame.MenuBar.Menus[0][0]
     file_menu.Append(FILE_OPEN, "&Open")
     file_menu.AppendRadioItem(M_OTSU, "Otsu")
     file_menu.AppendRadioItem(M_ENTROPY, "Entropy")
     file_menu.AppendRadioItem(M_OTSU3, "Otsu3")
     file_menu.AppendRadioItem(M_ENTROPY3, "Entropy3")
     file_menu.AppendRadioItem(M_FAST_OTSU3, "Otsu3 Fast & Messy")
     file_menu.AppendCheckItem(M_LOG_TRANSFORM, "Log transform")
     wx.EVT_MENU(self.frame, FILE_OPEN, self.on_file_open)
     self.SetTopWindow(self.frame)
     self.frame.Show()
     return 1
Example #6
0
    def get_module_figure(self, module, image_set_number, parent=None):
        """Create a CPFigure window or find one already created"""
        import cellprofiler.gui.cpfigure as cpf

        # catch any background threads trying to call display functions.
        assert not self.__in_background

        window_name = cpf.window_name(module)
        title = "%s #%d, image cycle #%d" % (
            module.module_name, module.module_num, image_set_number)

        if self.__create_new_window:
            figure = cpf.CPFigureFrame(parent or self.__frame,
                                       name=window_name,
                                       title=title)
        else:
            figure = cpf.create_or_find(parent or self.__frame,
                                        name=window_name,
                                        title=title)

        if not figure in self.__windows_used:
            self.__windows_used.append(figure)

        return figure