Esempio n. 1
0
 def add_set(self):
     if len(self.current_point_set) > 0:
         self.current_point_set = np.array(self.current_point_set)
         while len(self.strokes) > 0:
             self.remove_stroke(delete_points=False)
         col_rand = np.random.randint(1000)
         color = self.colormap[col_rand, :3]
         median = self.add_mask(points=self.current_point_set, color=color)
         if median is not None:
             self.toggle_mask_ops()
             self.cellcolors.append(color)
             self.ncells += 1
             self.ismanual = np.append(self.ismanual, True)
             if self.NZ == 1:
                 # only save after each cell if single image
                 io._save_sets(self)
         self.current_stroke = []
         self.strokes = []
         self.current_point_set = []
         self.update_plot()
Esempio n. 2
0
 def remove_cell(self, idx):
     # remove from manual array
     self.selected = 0
     self.ismanual = np.delete(self.ismanual, idx - 1)
     for z in range(self.NZ):
         cp = self.cellpix[z] == idx
         op = self.outpix[z] == idx
         # remove from mask layer
         self.layers[z, cp] = np.array([0, 0, 0, 0])
         # remove from self.cellpix and self.outpix
         self.cellpix[z, cp] = 0
         self.outpix[z, op] = 0
         # reduce other pixels by -1
         self.cellpix[z, self.cellpix[z] > idx] -= 1
         self.outpix[z, self.outpix[z] > idx] -= 1
     self.update_plot()
     del self.cellcolors[idx]
     del self.zdraw[idx - 1]
     self.ncells -= 1
     print('removed cell %d' % (idx - 1))
     if self.ncells == 0:
         self.ClearButton.setEnabled(False)
     if self.NZ == 1:
         io._save_sets(self)