docstr: Adjust image_groups and threshold_groups to account for the expected # of
  images, scales, and threshold methods
docstr_tok: ["Adjust","image_groups","and","threshold_groups","to","account","for","the","expected","#","of","images",",","scales",",","and","threshold","methods"]
code: def prepare_settings(self, setting_values):
      """Adjust image_groups and threshold_groups to account for the expected # of
      images, scales, and threshold methods"""
      image_group_count = int(setting_values[1])
      del self.image_groups[:]
      for i in range(image_group_count):
          can_remove = len(self.image_groups) > 0
          self.add_image_group(can_remove)
      for index, image_group in enumerate(self.image_groups):
          for count, group, fn in (
              (
                  int(
                      setting_values[
                          IMAGE_GROUP_SETTING_OFFSET + 2 * index
                      ]
                  ),
                  image_group.scale_groups,
                  self.add_scale_group,
              ),
              (
                  int(
                      setting_values[
                          IMAGE_GROUP_SETTING_OFFSET + 2 * index + 1
                      ]
                  ),
                  image_group.threshold_groups,
                  self.add_threshold_group,
              ),
          ):
              del group[:]
              for i in range(count):
                  can_remove = len(group) > 0
                  fn(image_group, can_remove)
  
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 5 for calling the MeasureImageQuality obj's underlying member method code with example usage: obj.prepare_settings(setting_values) without return types