code: def add_grouping_metadata(self, can_remove=True):
      group = SettingsGroup()
      self.grouping_metadata.append(group)
  
      def get_group_metadata_choices(pipeline):
          choices = self.get_metadata_choices(pipeline, group)
          if len(choices) == 0:
              choices.append("None")
          return choices
  
      if self.pipeline is not None:
          choices = get_group_metadata_choices(self.pipeline)
      else:
          choices = ["None"]
  
      group.append(
          "metadata_choice",
          Choice(
              "Metadata category",
              choices,
              choices_fn=get_group_metadata_choices,
              doc="""\
  Specify the metadata category with which to define a group. Once a
  selection is made, the two listings below will display the updated
  values:
  
  -  The *grouping list* (top table) shows the unique values of the
     selected metadata under the “Group” column; each of the unique values
     comprises a group. The “Count” column shows the number of image sets
     included in a given group; this is useful as a “sanity check” to make
     sure that the expected numbers of images are present.
  -  The *image set list* (bottom table) shows the file name and location
     of each of the image sets that comprise the groups. In this example,
     the table has 26 rows, one for each of the DNA and GFP image sets
     defined by the **NamesAndTypes** module.
  
  You may specify multiple metadata tags to group with by clicking the
  “Add” button. This would be necessary if a combination of metadata is
  required in order to define a group. Upon adding a metadata category,
  the two tables will update in the panels below showing the resulting
  organization of the image data for each group.
  
  As an example, an time-lapse experiment consists of a set of movie
  images (indexed by a frame number), collected on a per-well basis. The
  plate, well, wavelength and frame number metadata have been extracted
  using the **Metadata** module. Using the **NamesAndTypes** module, the
  two image channels (OrigBlue, *w1* and OrigGreen, *w2*) have been set up
  in the following way:
  
  +------------------------+-------------------------------+--------------------------------+-------------+------------+-------------------+
  | **Image set number**   | **OrigBlue (w1) file name**   | **OrigGreen (w2) file name**   | **Plate**   | **Well**   | **FrameNumber**   |
  +========================+===============================+================================+=============+============+===================+
  | 1                      | P-12345\_A01\_t001\_w1.tif    | P-12345\_A01\_t001\_w2.tif     | P-12345     | A01        | t001              |
  +------------------------+-------------------------------+--------------------------------+-------------+------------+-------------------+
  | 2                      | P-12345\_A01\_t002\_w1.tif    | P-12345\_A01\_t002\_w2.tif     | P-12345     | A01        | t002              |
  +------------------------+-------------------------------+--------------------------------+-------------+------------+-------------------+
  | 3                      | P-12345\_B01\_t001\_w1.tif    | P-12345\_B01\_t001\_w2.tif     | P-12345     | B01        | t001              |
  +------------------------+-------------------------------+--------------------------------+-------------+------------+-------------------+
  | 4                      | P-12345\_B01\_t002\_w1.tif    | P-12345\_B01\_t002\_w2.tif     | P-12345     | B01        | t002              |
  +------------------------+-------------------------------+--------------------------------+-------------+------------+-------------------+
  | 5                      | 2-ABCDF\_A01\_t001\_w1.tif    | 2-ABCDF\_A01\_t001\_w2.tif     | 2-ABCDF\_   | A01        | t001              |
  +------------------------+-------------------------------+--------------------------------+-------------+------------+-------------------+
  | 6                      | 2-ABCDF\_A01\_t002\_w1.tif    | 2-ABCDF\_A01\_t002\_w2.tif     | 2-ABCDF\_   | A01        | t002              |
  +------------------------+-------------------------------+--------------------------------+-------------+------------+-------------------+
  | 7                      | 2-ABCDF\_B01\_t001\_w1.tif    | 2-ABCDF\_B01\_t001\_w2.tif     | 2-ABCDF\_   | B01        | t001              |
  +------------------------+-------------------------------+--------------------------------+-------------+------------+-------------------+
  | 8                      | 2-ABCDF\_B01\_t002\_w1.tif    | 2-ABCDF\_B01\_t002\_w2.tif     | 2-ABCDF\_   | B01        | t002              |
  +------------------------+-------------------------------+--------------------------------+-------------+------------+-------------------+
  
  We would like to perform object tracking for each movie, i.e., for each
  plate and well. Without the use of groups, even though image sets 1–2,
  3–4, 5–6, and 7–8 represent different movies, image set 3 will get
  processed immediately after image set 2, image set 5 after 4, and so on.
  For an object tracking assay, failure to recognize where the movies
  start and end would lead to incorrect tracking results.
  
  Selecting the *Plate* followed by the *Well* metadata as the metadata
  categories will create four groups based on the unique plate and well
  combinations:
  
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  | **Grouping tags**                          | **Image set tags**                                                               | **Channels**                                                |
  +=====================+======================+========================+=============+============+==============================+==============================+==============================+
  | **Group number**    | **Group index**      | **Image set number**   | **Plate**   | **Well**   | **FrameNumber**              | **OrigBlue**                 | **OrigGreen**                |
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  | 1                   | 1                    | 1                      | P-12345     | A01        | t001                         | P-12345\_A01\_t001\_w1.tif   | P-12345\_A01\_t001\_w2.tif   |
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  | 1                   | 2                    | 2                      | P-12345     | A01        | t002                         | P-12345\_A01\_t002\_w1.tif   | P-12345\_A01\_t002\_w2.tif   |
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  | 2                   | 1                    | 3                      | P-12345     | B01        | t001                         | P-12345\_B01\_t001\_w1.tif   | P-12345\_B01\_t001\_w2.tif   |
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  | 2                   | 2                    | 4                      | P-12345     | B01        | t002                         | P-12345\_B01\_t002\_w1.tif   | P-12345\_B01\_t002\_w2.tif   |
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  | 3                   | 1                    | 5                      | 2-ABCDF     | A01        | t001                         | 2-ABCDF\_A01\_t001\_w1.tif   | 2-ABCDF\_A01\_t001\_w2.tif   |
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  | 3                   | 2                    | 6                      | 2-ABCDF     | A01        | t002                         | 2-ABCDF\_A01\_t002\_w1.tif   | 2-ABCDF\_A01\_t002\_w2.tif   |
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  | 4                   | 1                    | 7                      | 2-ABCDF     | B01        | t001                         | 2-ABCDF\_B01\_t001\_w1.tif   | 2-ABCDF\_B01\_t001\_w2.tif   |
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  | 4                   | 2                    | 8                      | 2-ABCDF     | B01        | t002                         | 2-ABCDF\_B01\_t002\_w1.tif   | 2-ABCDF\_B01\_t002\_w2.tif   |
  +---------------------+----------------------+------------------------+-------------+------------+------------------------------+------------------------------+------------------------------+
  
  Each group will be processed independently from the others, which is the
  desired behavior.
  """,
          ),
      )
  
      group.append("divider", Divider())
  
      group.can_remove = can_remove
  
      if can_remove:
          group.append(
              "remover",
              RemoveSettingButton(
                  "",
                  "Remove this metadata item",
                  self.grouping_metadata,
                  group,
              ),
          )
  
imports: import numpy
  from ..constants.image import CT_OBJECTS
  from ..constants.measurement import COLTYPE_INTEGER, COLTYPE_VARCHAR, IMAGE
  from ..constants.measurement import C_FILE_NAME
  from ..constants.measurement import C_METADATA
  from ..constants.measurement import C_OBJECTS_FILE_NAME
  from ..constants.measurement import C_OBJECTS_PATH_NAME
  from ..constants.measurement import C_PATH_NAME
  from ..constants.measurement import EXPERIMENT
  from ..constants.measurement import GROUP_INDEX
  from ..constants.measurement import GROUP_NUMBER
  from ..constants.measurement import GROUP_LENGTH
  from ..constants.measurement import M_GROUPING_TAGS
  from ..measurement import Measurements
  from ..module import Module
  from ..pipeline import Pipeline
  from ..setting import Binary
  from ..setting import Divider
  from ..setting import HTMLText
  from ..setting import HiddenCount
  from ..setting import SettingsGroup
  from ..setting import Table
  from ..setting.choice import Choice
  from ..setting.do_something import DoSomething
  from ..setting.do_something import RemoveSettingButton
  from ..utilities.image import image_resource
label_desc: Use image node_id 2 for calling the Groups obj's underlying member method code with example usage: obj.add_grouping_metadata(can_remove) and returns: choices