Ejemplo n.º 1
0
    def OnSelectFromPopupMenu(self, evt):
        ''' Handles selections from the popup menu. '''
        choice = self.popupItemIndexById[evt.GetId()]
        if choice == 0:
            for key in self.SelectedKeys():
                if self.classifier:
                    imViewer = imagetools.ShowImage(
                        key[:-1],
                        self.chMap[:],
                        parent=self.classifier,
                        brightness=self.classifier.brightness,
                        scale=self.classifier.scale,
                        contrast=self.classifier.contrast)
                else:
                    imViewer = imagetools.ShowImage(key[:-1],
                                                    self.chMap[:],
                                                    parent=self)

                imViewer.imagePanel.SelectPoint(db.GetObjectCoords(key))
        elif choice == 1:
            self.SelectAll()
        elif choice == 2:
            self.DeselectAll()
        elif choice == 3:
            self.InvertSelection()
        elif choice == 4:
            self.RemoveSelectedTiles()
        elif choice == 5:
            self.classifier.RenameClass(self.label)
        elif choice == 6:
            self.classifier.RemoveSortClass(self.label)
Ejemplo n.º 2
0
 def OnLabelDClick(self, evt):
     if evt.Row >= 0:
         key = self.GetTable().GetKeyForRow(evt.Row)
         if self.grouping=='Image':
             imagetools.ShowImage(key, self.chMap, parent=self)
         else:
             imKeys = dm.GetImagesInGroup(self.grouping, tuple(key))
             for imKey in imKeys:
                 imagetools.ShowImage(imKey, self.chMap, parent=self)
     else:
         self.OnLabelClick(evt)
Ejemplo n.º 3
0
 def OnDClick(self, evt):
     if self.plate is not None:
         well = self.GetWellLabelAtCoord(self.GetX(evt), self.GetY(evt))
         imKeys = db.execute('SELECT %s FROM %s WHERE %s="%s" AND %s="%s"'%
                             (UniqueImageClause(), p.image_table, p.well_id, well, p.plate_id, self.plate), silent=False)
         for imKey in imKeys:
             imagetools.ShowImage(imKey, self.chMap, parent=self)
Ejemplo n.º 4
0
def show_images_from_gate(gatename, warn=10):
    '''Callback for "Show images in gate" popup item.
    gatename -- name of the gate to apply
    warn -- specify a number of objects that is considered too many to show at
      once without warning the user and prompting to input how many they want.
      set to None if you don't want to warn for any amount.'''
    q = sqltools.QueryBuilder()
    q.select(sqltools.image_cols())
    q.where([p.gates[gatename]])
    q.group_by(sqltools.image_cols())
    res = db.execute(str(q))
    if warn and len(res) > warn:
        dlg = wx.MessageDialog(
            get_main_frame_or_none(), 'You are about to open %s '
            'images. This may take some time depending on your settings. '
            'Continue?' % (len(res)), 'Warning', wx.YES_NO | wx.ICON_QUESTION)
        response = dlg.ShowModal()
        if response != wx.ID_YES:
            return
    logging.info('Opening %s images.' % (len(res)))
    import imagetools
    for row in res:
        imagetools.ShowImage(tuple(row),
                             p.image_channel_colors,
                             parent=get_main_frame_or_none())
Ejemplo n.º 5
0
    def OnSelectFromPopupMenu(self, evt):
        ''' Handles selections from the popup menu. '''
        choice = self.popupItemIndexById[evt.GetId()]
        if choice == 0:
            for obKey in self.bin.SelectedKeys():
                #View full images of selected
                imViewer = imagetools.ShowImage(obKey[:-1],
                                                self.chMap[:],
                                                parent=self.classifier,
                                                brightness=self.brightness,
                                                contrast=self.contrast,
                                                scale=1)
                if self.bin.label != 'image gallery':
                    imViewer.imagePanel.SelectPoint(db.GetObjectCoords(obKey))
                #imViewer.imagePanel.SetPosition((-db.GetObjectCoords(obKey)[0]+imViewer.Size[0]/2, -db.GetObjectCoords(obKey)[1]+imViewer.Size[1]/2))

        elif choice == 1:
            self.bin.SelectAll()
        elif choice == 2:
            self.bin.DeselectAll()
        elif choice == 3:
            self.bin.InvertSelection()
        elif choice == 4:
            self.bin.RemoveSelectedTiles()
        elif choice == 5:
            if self.classifier is not None and self.bin.label == 'unclassified':
                self.DisplayProbs()
            elif self.bin.label == 'image gallery':
                self.DisplayObjects()
Ejemplo n.º 6
0
 def OnDClick(self, evt):
     imViewer = imagetools.ShowImage(self.obKey[:-1],
                                     list(self.chMap),
                                     parent=self.classifier,
                                     brightness=self.brightness,
                                     contrast=self.contrast,
                                     scale=1)
     if self.bin.label != 'image gallery':
         imViewer.imagePanel.SelectPoint(db.GetObjectCoords(self.obKey))
Ejemplo n.º 7
0
 def on_dclick_label(self, evt):
     '''Handle display of images and objects'''
     if evt.Row >= 0:
         obkeys = self.grid.Table.get_object_keys_at_row(evt.Row)
         if self.grid.Table.grouping is None:
             # We need to know how the table is grouped to know what to do
             logging.warn(
                 'CPA does not know how to link this table to your images. Can\'t launch ImageViewer.'
             )
             return
         elif self.grid.Table.grouping.lower() == 'object':
             # For per-object grouping, show the objects in the image
             imview = imagetools.ShowImage(obkeys[0][:-1],
                                           p.image_channel_colors,
                                           parent=self.Parent)
             if obkeys is not None:
                 for obkey in obkeys:
                     imview.SelectObject(obkey)
         elif self.grid.Table.grouping.lower() == 'image':
             # For per-image grouping just show the images.
             # If there is only one object, then highlight it
             if obkeys is not None and len(obkeys) == 1:
                 imview = imagetools.ShowImage(obkeys[0][:-1],
                                               p.image_channel_colors,
                                               parent=self.Parent)
                 imview.SelectObject(obkeys[0])
             else:
                 imkeys = self.grid.Table.get_image_keys_at_row(evt.Row)
                 if imkeys:
                     #XXX: warn if there are a lot
                     for imkey in imkeys:
                         imagetools.ShowImage(imkey,
                                              p.image_channel_colors,
                                              parent=self.Parent)
         else:
             key_cols = self.grid.Table.get_row_key(evt.Row)
             if key_cols:
                 dm = DataModel.getInstance()
                 imkeys = dm.GetImagesInGroup(self.grid.Table.grouping,
                                              key_cols)
                 for imkey in imkeys:
                     imagetools.ShowImage(imkey,
                                          p.image_channel_colors,
                                          parent=self.Parent)
Ejemplo n.º 8
0
 def OnSelectFromPopupMenu(self, evt):
     ''' Handles selections from the popup menu. '''
     choice = self.popupItemIndexById[evt.GetId()]
     if choice == 0:
         for obKey in self.bin.SelectedKeys():
             imViewer = imagetools.ShowImage(obKey[:-1], self.chMap[:], parent=self.classifier,
                                     brightness=self.brightness, contrast=self.contrast,
                                     scale=self.scale)
             imViewer.imagePanel.SelectPoint(db.GetObjectCoords(obKey))
     elif choice == 1:
         self.bin.SelectAll()
     elif choice == 2:
         self.bin.DeselectAll()
     elif choice == 3:
         self.bin.InvertSelection()
     elif choice == 4:
         self.bin.RemoveSelectedTiles()
Ejemplo n.º 9
0
 def on_select_image_from_popup(self, evt):
     '''Handle selections from the popup menu.
     '''
     imkey = self.popupItemById[evt.GetId()]
     imagetools.ShowImage(imkey, p.image_channel_colors, parent=self)
Ejemplo n.º 10
0
 def handler(evt, key=key):
     imagetools.ShowImage(key, self.chMap, parent=self)
Ejemplo n.º 11
0
 def OnSelectFromPopupMenu(self, evt):
     """Handles selections from the popup menu."""
     if self.chMap:
         imKey = self.popupItemById[evt.GetId()]
         imagetools.ShowImage(imKey, self.chMap, parent=self)
Ejemplo n.º 12
0
 def OnItemActivated(self, event):
     imkey = self.imkeys[event.m_itemIndex]
     f = imagetools.ShowImage(tuple(imkey), p.image_channel_colors,
                              self.GrandParent or self.Parent)
     f.Raise()