code: def test_threshold():
      """Test all thresholding methods
  
      Use an image that has 1/5 of "foreground" pixels to make MOG
      happy and set the object fraction to 1/5 to test this.
      """
      numpy.random.seed(0)
      image = numpy.random.beta(2, 5, size=(100, 100))
      object_fraction = 0.2
      mask = numpy.random.binomial(1, object_fraction, size=(100, 100))
      count = numpy.sum(mask)
      image[mask == 1] = 1.0 - numpy.random.beta(2, 20, size=count)
      #
      # Kapur needs to be quantized
      #
      image = numpy.around(image, 2)
  
      workspace = make_workspace(image)
      q = workspace.module
  
      for tm, idx in zip(
          centrosome.threshold.TM_GLOBAL_METHODS,
          list(range(len(centrosome.threshold.TM_GLOBAL_METHODS))),
      ):
          if idx != 0:
              q.add_image_group()
          q.image_groups[idx].image_names.value = "my_image"
          q.image_groups[idx].include_image_scalings.value = False
          q.image_groups[idx].check_blur.value = False
          q.image_groups[idx].check_saturation.value = False
          q.image_groups[idx].check_intensity.value = False
          q.image_groups[idx].calculate_threshold.value = True
          q.image_groups[idx].use_all_threshold_methods.value = False
          t = q.image_groups[idx].threshold_groups[0]
          t.threshold_method.value = tm
          t.object_fraction.value = object_fraction
          t.two_class_otsu.value = O_THREE_CLASS
          t.assign_middle_to_foreground.value = O_FOREGROUND
          t.use_weighted_variance.value = O_WEIGHTED_VARIANCE
      q.run(workspace)
      m = workspace.measurements
      for feature_name in (
          "ImageQuality_FocusScore_my_image",
          "ImageQuality_LocalFocusScore_my_image_20",
          "ImageQuality_PercentSaturation_my_image",
          "ImageQuality_PercentMaximal_my_image",
      ):
          assert not m.has_current_measurements("Image", feature_name)
      for tm, idx in zip(
          centrosome.threshold.TM_GLOBAL_METHODS,
          list(range(len(centrosome.threshold.TM_GLOBAL_METHODS))),
      ):
          if tm == centrosome.threshold.TM_OTSU_GLOBAL:
              feature_name = "ImageQuality_ThresholdOtsu_my_image_3FW"
          elif tm == centrosome.threshold.TM_MOG_GLOBAL:
              feature_name = "ImageQuality_ThresholdMoG_my_image_20"
          else:
              feature_name = (
                  "ImageQuality_Threshold%s_my_image" % tm.split(" ")[0]
              )
          assert m.has_current_measurements("Image", feature_name)
      features_and_columns_match(m, q)
  
imports: import io
  import centrosome.threshold
  import numpy
  import cellprofiler_core.image
  import cellprofiler_core.measurement
  from cellprofiler_core.constants.measurement import COLTYPE_FLOAT, EXPERIMENT
  from cellprofiler_core.constants.module._identify import O_FOREGROUND, O_THREE_CLASS, O_WEIGHTED_VARIANCE, O_TWO_CLASS, O_ENTROPY, O_BACKGROUND
  import cellprofiler.modules.measureimagequality
  import cellprofiler_core.modules.namesandtypes
  import cellprofiler.modules.smooth
  import cellprofiler_core.object
  import cellprofiler_core.pipeline
  import cellprofiler_core.workspace
  import tests.frontend.modules
label_desc: Use image node_id 13 for calling a global function with example usage: test_threshold() without return types