docstr: Run the module
  
  workspace    - The workspace contains
      pipeline     - instance of cpp for this run
      image_set    - the images in the image set being processed
      object_set   - the objects (labeled masks) in this image set
      measurements - the measurements for this run
      frame        - the parent frame to whatever frame is created. None means don't draw.
docstr_tok: ["Run","the","module","workspace","-","The","workspace","contains","pipeline","-","instance","of","cpp","for","this","run","image_set","-","the","images","in","the","image","set","being","processed","object_set","-","the","objects","(","labeled","masks",")","in","this","image","set","measurements","-","the","measurements","for","this","run","frame","-","the","parent","frame","to","whatever","frame","is","created",".","None","means","do","n't","draw","."]
code: def run(self, workspace):
      """Run the module
  
      workspace    - The workspace contains
          pipeline     - instance of cpp for this run
          image_set    - the images in the image set being processed
          object_set   - the objects (labeled masks) in this image set
          measurements - the measurements for this run
          frame        - the parent frame to whatever frame is created. None means don't draw.
      """
      background_image = self.get_background_image(workspace, None)
  
      if (
          self.each_or_once == EO_ONCE
          and self.get_good_gridding(workspace) is not None
      ):
          gridding = self.get_good_gridding(workspace)
      if self.auto_or_manual == AM_AUTOMATIC:
          gridding = self.run_automatic(workspace)
      elif self.manual_choice == MAN_COORDINATES:
          gridding = self.run_coordinates(workspace)
      elif self.manual_choice == MAN_MOUSE:
          gridding = workspace.interaction_request(
              self,
              background_image,
              workspace.measurements.image_set_number,
          )
      self.set_good_gridding(workspace, gridding)
      workspace.set_grid(self.grid_image.value, gridding)
      #
      # Save measurements
      #
      self.add_measurement(
          workspace,
          F_X_LOCATION_OF_LOWEST_X_SPOT,
          gridding.x_location_of_lowest_x_spot,
      )
      self.add_measurement(
          workspace,
          F_Y_LOCATION_OF_LOWEST_Y_SPOT,
          gridding.y_location_of_lowest_y_spot,
      )
      self.add_measurement(workspace, F_ROWS, gridding.rows)
      self.add_measurement(workspace, F_COLUMNS, gridding.columns)
      self.add_measurement(workspace, F_X_SPACING, gridding.x_spacing)
      self.add_measurement(workspace, F_Y_SPACING, gridding.y_spacing)
  
      # update background image
      background_image = self.get_background_image(workspace, gridding)
  
      workspace.display_data.gridding = gridding.serialize()
      workspace.display_data.background_image = background_image
      workspace.display_data.image_set_number = (
          workspace.measurements.image_set_number
      )
  
      if self.wants_image:
          import matplotlib.transforms
          import matplotlib.figure
          import matplotlib.backends.backend_agg
          from cellprofiler.gui.tools import figure_to_image
  
          figure = matplotlib.figure.Figure()
          canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(
              figure
          )
          ax = figure.add_subplot(1, 1, 1)
          self.display_grid(
              background_image,
              gridding,
              workspace.measurements.image_set_number,
              ax,
          )
          #
          # This is the recipe for just showing the axis
          #
          figure.set_frameon(False)
          ax.set_axis_off()
          figure.subplots_adjust(0, 0, 1, 1, 0, 0)
          ai = ax.images[0]
          shape = ai.get_size()
          dpi = figure.dpi
          width = float(shape[1]) / dpi
          height = float(shape[0]) / dpi
          figure.set_figheight(height)
          figure.set_figwidth(width)
          bbox = matplotlib.transforms.Bbox(
              numpy.array([[0.0, 0.0], [width, height]])
          )
          transform = matplotlib.transforms.Affine2D(
              numpy.array([[dpi, 0, 0], [0, dpi, 0], [0, 0, 1]])
          )
          figure.bbox = matplotlib.transforms.TransformedBbox(
              bbox, transform
          )
          image_pixels = figure_to_image(figure, dpi=dpi)
          image = Image(image_pixels)
  
          workspace.image_set.add(self.save_image_name.value, image)
  
imports: import logging
  import centrosome.cpmorphology
  import numpy
  from cellprofiler_core.constants.measurement import COLTYPE_FLOAT
  from cellprofiler_core.constants.measurement import COLTYPE_INTEGER
  from cellprofiler_core.constants.measurement import IMAGE
  from cellprofiler_core.image import Image
  from cellprofiler_core.module import Module
  from cellprofiler_core.setting import Binary
  from cellprofiler_core.setting import Coordinates
  from cellprofiler_core.setting import ValidationError
  from cellprofiler_core.setting.choice import Choice
  from cellprofiler_core.setting.subscriber import ImageSubscriber
  from cellprofiler_core.setting.subscriber import LabelSubscriber
  from cellprofiler_core.setting.text import GridName
  from cellprofiler_core.setting.text import ImageName
  from cellprofiler_core.setting.text import Integer
  from cellprofiler_core.utilities.grid import Grid
label_desc: Use image node_id 4 for calling the DefineGrid obj's underlying member method code with example usage: obj.run(workspace) without return types