code: def add_image_group(self, can_remove=True):
      group = SettingsGroup()
  
      group.can_remove = can_remove
      if can_remove:
          group.append("divider", Divider(line=True))
  
      group.append(
          "image_names",
          ImageListSubscriber(
              text="Select the images to measure",
              doc="""\
  *(Used only if “{O_SELECT}” is chosen for selecting images)*
  
  Choose one or more images from this list. In addition to loaded
  images, the list includes the images that were created by prior modules.
  """.format(
                  **{"O_SELECT": O_SELECT}
              ),
          ),
      )
  
      group.append(
          "include_image_scalings",
          Binary(
              text="Include the image rescaling value?",
              value=True,
              doc="""\
  Select *{YES}* to add the image’s rescaling value as a quality control
  metric. This value is recorded only for images loaded using the
  **Input** modules. This is useful in confirming that all images are
  rescaled by the same value, given that some acquisition device vendors may
  output this value differently. See **NamesAndTypes** for more
  information.""".format(
                  **{"YES": "Yes"}
              ),
          ),
      )
  
      group.append(
          "check_blur",
          Binary(
              text="Calculate blur metrics?",
              value=True,
              doc="""\
  Select *{YES}* to compute a series of blur metrics. The blur metrics
  are described in the overall help for this module (select the module in
  the pipeline and press the "?" button).
  """.format(
                  **{"YES": "Yes"}
              ),
          ),
      )
  
      group.append(
          "include_local_blur",
          Binary(text="Include local blur metrics?", value=True),
      )
  
      group.scale_groups = []
  
      group.scale_count = HiddenCount(group.scale_groups, "Scale count")
  
      def add_scale_group(can_remove=True):
          self.add_scale_group(group, can_remove)
  
      add_scale_group(False)
  
      group.append(
          "add_scale_button",
          DoSomething(
              "",
              "Add another scale",
              add_scale_group,
              doc="""
              Press this button to add another scale setting.""",
          ),
      )
  
      group.append(
          "check_saturation",
          Binary(
              text="Calculate saturation metrics?",
              value=True,
              doc="""\
  Select *{YES}* to calculate the saturation metrics
  *{F_PERCENT_MAXIMAL}* and *{F_PERCENT_MINIMAL}*, i.e., the
  percentage of pixels at the upper or lower limit of each individual
  image.
  
  For this calculation, the hard limits of 0 and 1 are not used because
  images often have undergone some kind of transformation such that no
  pixels ever reach the absolute maximum or minimum of the image format.
  Given the noise typical in images, both these measures should be a low
  percentage but if the images were saturated during imaging, a higher
  than usual *{F_PERCENT_MAXIMAL}* will be observed, and if there are
  no objects, the *{F_PERCENT_MINIMAL}* value will increase.
  """.format(
                  **{
                      "YES": "Yes",
                      "F_PERCENT_MAXIMAL": F_PERCENT_MAXIMAL,
                      "F_PERCENT_MINIMAL": F_PERCENT_MINIMAL,
                  }
              ),
          ),
      )
  
      group.append(
          "check_intensity",
          Binary(
              text="Calculate intensity metrics?",
              value=True,
              doc="""\
  Select *{YES}* to calculate image-based intensity measures, namely the
  mean, maximum, minimum, standard deviation and median absolute deviation
  of pixel intensities. These measures are identical to those calculated
  by **MeasureImageIntensity**.
  """.format(
                  **{"YES": "Yes"}
              ),
          ),
      )
  
      group.append(
          "calculate_threshold",
          Binary(
              text="Calculate thresholds?",
              value=True,
              doc="""\
  Automatically calculate a suggested threshold for each image. One
  indicator of image quality is that these threshold values lie within a
  typical range. Outlier images with high or low thresholds often contain
  artifacts.""",
          ),
      )
  
      group.append(
          "use_all_threshold_methods",
          Binary(
              text="Use all thresholding methods?",
              value=False,
              doc="""\
  *(Used only if image thresholds are calculated)*
  
  Select *{YES}* to calculate thresholds using all the available
  methods. Only the global methods are used.
  While most methods are straightfoward, some methods have additional
  parameters that require special handling:
  
  -  *{TM_OTSU}:* Thresholds for all combinations of class number,
     minimization parameter and middle class assignment are computed.
  -  *Mixture of Gaussians ({TM_MOG}):* Thresholds for image coverage
     fractions of 0.05, 0.25, 0.75 and 0.95 are computed.
  
  See the **IdentifyPrimaryObjects** module for more information on
  thresholding methods.
  """.format(
                  **{
                      "YES": "Yes",
                      "TM_OTSU": centrosome.threshold.TM_OTSU,
                      "TM_MOG": centrosome.threshold.TM_MOG,
                  }
              ),
          ),
      )
  
      group.threshold_groups = []
  
      group.threshold_count = HiddenCount(
          group.threshold_groups, "Threshold count"
      )
  
      def add_threshold_group(can_remove=True):
          self.add_threshold_group(group, can_remove)
  
      add_threshold_group(False)
  
      group.append(
          "add_threshold_button",
          DoSomething(
              "",
              "Add another threshold method",
              add_threshold_group,
              doc="""
              Press this button to add another set of threshold settings.""",
          ),
      )
  
      if can_remove:
          group.append(
              "remove_button",
              RemoveSettingButton(
                  "", "Remove this image list", self.image_groups, group
              ),
          )
      self.image_groups.append(group)
      return group
  
imports: import itertools
  import logging
  import cellprofiler_core.utilities.image
  import centrosome.cpmorphology
  import centrosome.haralick
  import centrosome.radial_power_spectrum
  import centrosome.threshold
  import centrosome.threshold
  import numpy
  import scipy.linalg.basic
  import scipy.ndimage
  from cellprofiler_core.constants.image import C_SCALING
  from cellprofiler_core.constants.measurement import COLTYPE_FLOAT, EXPERIMENT, MCA_AVAILABLE_POST_RUN
  from cellprofiler_core.constants.module._identify import O_WEIGHTED_VARIANCE, O_ENTROPY, O_FOREGROUND, O_BACKGROUND
  from cellprofiler_core.module import Module
  from cellprofiler_core.preferences import get_headless
  from cellprofiler_core.setting import Divider, HiddenCount, SettingsGroup, Binary, ValidationError
  from cellprofiler_core.setting.choice import Choice
  from cellprofiler_core.setting.do_something import DoSomething, RemoveSettingButton
  from cellprofiler_core.setting.subscriber import ImageListSubscriber
  from cellprofiler_core.setting.text import ImageName, Integer, Float
  from cellprofiler.modules.threshold import O_THREE_CLASS, O_TWO_CLASS
label_desc: Use image node_id 2 for calling the MeasureImageQuality obj's underlying member method code with example usage: obj.add_image_group(can_remove) and returns: group