code: def run_image_set(
      projection_type, images_and_masks, frequency=9, run_last=True
  ):
      image_set_list = cellprofiler_core.image.ImageSetList()
      image_count = len(images_and_masks)
      for i in range(image_count):
          pixel_data, mask = images_and_masks[i]
          if mask is None:
              image = cellprofiler_core.image.Image(pixel_data)
          else:
              image = cellprofiler_core.image.Image(pixel_data, mask)
          image_set_list.get_image_set(i).add(IMAGE_NAME, image)
      #
      # Add bogus image at end for 2nd group
      #
      bogus_image = cellprofiler_core.image.Image(numpy.zeros((10, 20)))
      image_set_list.get_image_set(image_count).add(
          IMAGE_NAME, bogus_image
      )
  
      pipeline = cellprofiler_core.pipeline.Pipeline()
      module = cellprofiler.modules.makeprojection.MakeProjection()
      module.set_module_num(1)
      module.image_name.value = IMAGE_NAME
      module.projection_image_name.value = PROJECTED_IMAGE_NAME
      module.projection_type.value = projection_type
      module.frequency.value = frequency
      pipeline.add_module(module)
      m = cellprofiler_core.measurement.Measurements()
      workspace = cellprofiler_core.workspace.Workspace(
          pipeline, module, None, None, m, image_set_list
      )
      module.prepare_run(workspace)
      module.prepare_group(
          workspace, {}, list(range(1, len(images_and_masks) + 1))
      )
      for i in range(image_count):
          if i > 0:
              image_set_list.purge_image_set(i - 1)
          w = cellprofiler_core.workspace.Workspace(
              pipeline,
              module,
              image_set_list.get_image_set(i),
              cellprofiler_core.object.ObjectSet(),
              m,
              image_set_list,
          )
          if i < image_count - 1 or run_last:
              module.run(w)
      module.post_group(w, {})
      image = w.image_set.get_image(PROJECTED_IMAGE_NAME)
      #
      # Make sure that the image provider is reset after prepare_group
      #
      module.prepare_group(workspace, {}, [image_count + 1])
      image_set = image_set_list.get_image_set(image_count)
      w = cellprofiler_core.workspace.Workspace(
          pipeline,
          module,
          image_set,
          cellprofiler_core.object.ObjectSet(),
          m,
          image_set_list,
      )
      module.run(w)
      image_provider = image_set.get_image_provider(
          PROJECTED_IMAGE_NAME
      )
      assert numpy.max(image_provider.count) == 1
  
      return image
  
imports: import numpy
  import six.moves
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  import cellprofiler.modules.makeprojection
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.workspace
  import tests.frontend.modules
label_desc: Use image node_id 2 for calling a global function with example usage: run_image_set(projection_type, images_and_masks, frequency, run_last) and returns: image