def CreateMask(self, imagedata=None, name=None, colour=None, opacity=None, threshold_range=None, edition_threshold_range = None, edited_points=None): future_mask = Mask() if colour: future_mask.colour = colour if opacity: future_mask.opacity = opacity if edition_threshold_range: future_mask.edition_threshold_range = edition_threshold_range if edited_points: future_mask.edited_points = edited_points # this is not the first mask, so we will import data from old imagedata if imagedata is None: old_mask = self.current_mask imagedata = old_mask.imagedata future_mask.threshold_range = old_mask.threshold_range if threshold_range: future_mask.threshold_range = threshold_range future_mask.imagedata = self.__create_mask_threshold(self.imagedata, threshold_range) else: future_mask.imagedata = vtk.vtkImageData() future_mask.imagedata.DeepCopy(imagedata) future_mask.imagedata.Update() # when this is not the first instance, user will have defined a name if name is not None: future_mask.name = name if future_mask.is_shown: self.blend_filter.SetOpacity(1, future_mask.opacity) else: self.blend_filter.SetOpacity(1, 0) self.blend_filter.Update() # insert new mask into project and retrieve its index proj = Project() index = proj.AddMask(future_mask) future_mask.index = index if threshold_range: self.SetMaskThreshold(index, threshold_range) future_mask.edited_points = {} # update gui related to mask ps.Publisher().sendMessage('Add mask', (future_mask.index, future_mask.name, future_mask.threshold_range, future_mask.colour)) self.current_mask = future_mask ps.Publisher().sendMessage('Change mask selected', future_mask.index) ps.Publisher().sendMessage('Update slice viewer')
def CreateMask( self, imagedata=None, name=None, colour=None, opacity=None, threshold_range=None, edition_threshold_range=None, edited_points=None, ): # TODO: mask system to new system. future_mask = Mask() future_mask.create_mask(self.matrix.shape) if name: future_mask.name = name if colour: future_mask.colour = colour if opacity: future_mask.opacity = opacity if edition_threshold_range: future_mask.edition_threshold_range = edition_threshold_range if edited_points: future_mask.edited_points = edited_points if threshold_range: future_mask.threshold_range = threshold_range # insert new mask into project and retrieve its index proj = Project() index = proj.AddMask(future_mask) future_mask.index = index ## update gui related to mask Publisher.sendMessage( "Add mask", (future_mask.index, future_mask.name, future_mask.threshold_range, future_mask.colour) ) self.current_mask = future_mask Publisher.sendMessage("Change mask selected", future_mask.index) Publisher.sendMessage("Update slice viewer")