docstr: Create a CSV file documenting the relationships between objects
docstr_tok: ["Create","a","CSV","file","documenting","the","relationships","between","objects"]
code: def make_relationships_file(
      self, image_set_numbers, workspace, settings_group=None
  ):
      """Create a CSV file documenting the relationships between objects"""
  
      file_name = self.make_objects_file_name(
          OBJECT_RELATIONSHIPS,
          workspace,
          image_set_numbers[0],
          settings_group,
      )
      m = workspace.measurements
      assert isinstance(m, Measurements)
      fd = open(file_name, "w", newline="")
      module_map = {}
      for module in workspace.pipeline.modules():
          module_map[module.module_num] = module.module_name
  
      try:
          writer = csv.writer(fd, delimiter=self.delimiter_char)
          writer.writerow(
              [
                  "Module",
                  "Module Number",
                  "Relationship",
                  "First Object Name",
                  "First Image Number",
                  "First Object Number",
                  "Second Object Name",
                  "Second Image Number",
                  "Second Object Number",
              ]
          )
          for key in m.get_relationship_groups():
              r = m.get_relationships(
                  key.module_number,
                  key.relationship,
                  key.object_name1,
                  key.object_name2,
                  image_numbers=image_set_numbers,
              )
              for (
                  image_number_1,
                  image_number_2,
                  object_number_1,
                  object_number_2,
              ) in zip(
                  r[R_FIRST_IMAGE_NUMBER],
                  r[R_SECOND_IMAGE_NUMBER],
                  r[R_FIRST_OBJECT_NUMBER],
                  r[R_SECOND_OBJECT_NUMBER],
              ):
                  module_name = module_map[key.module_number]
                  writer.writerow(
                      [
                          module_name,
                          key.module_number,
                          key.relationship,
                          key.object_name1,
                          image_number_1,
                          object_number_1,
                          key.object_name2,
                          image_number_2,
                          object_number_2,
                      ]
                  )
      finally:
          fd.close()
  
imports: import base64
  import csv
  import logging
  import os
  import numpy
  from cellprofiler_core.constants.image import C_MD5_DIGEST, C_SCALING, C_HEIGHT, C_WIDTH
  from cellprofiler_core.constants.measurement import EXPERIMENT, IMAGE, AGG_MEAN, AGG_MEDIAN, AGG_STD_DEV, C_URL, C_PATH_NAME, C_FILE_NAME, NEIGHBORS, R_FIRST_IMAGE_NUMBER, R_SECOND_IMAGE_NUMBER, R_FIRST_OBJECT_NUMBER, R_SECOND_OBJECT_NUMBER
  from cellprofiler_core.constants.module import IO_FOLDER_CHOICE_HELP_TEXT, IO_WITH_METADATA_HELP_TEXT, USING_METADATA_HELP_REF, USING_METADATA_TAGS_REF
  from cellprofiler_core.constants.pipeline import EXIT_STATUS
  from cellprofiler_core.measurement import Measurements
  from cellprofiler_core.module import Module
  from cellprofiler_core.preferences import ABSOLUTE_FOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_INPUT_FOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_INPUT_SUBFOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_OUTPUT_FOLDER_NAME
  from cellprofiler_core.preferences import DEFAULT_OUTPUT_SUBFOLDER_NAME
  from cellprofiler_core.preferences import get_headless
  from cellprofiler_core.setting import Binary
  from cellprofiler_core.setting import Divider
  from cellprofiler_core.setting import Measurement
  from cellprofiler_core.setting import SettingsGroup
  from cellprofiler_core.setting import ValidationError
  from cellprofiler_core.setting.choice import CustomChoice, Choice
  from cellprofiler_core.setting.do_something import DoSomething, RemoveSettingButton
  from cellprofiler_core.setting.multichoice import MeasurementMultiChoice
  from cellprofiler_core.setting.subscriber import ImageSubscriber, LabelSubscriber
  from cellprofiler_core.setting.text import Directory, Text
  from cellprofiler_core.utilities.core.modules.load_data import is_file_name_feature, is_path_name_feature
  from cellprofiler_core.utilities.measurement import find_metadata_tokens, get_agg_measurement_name
  from cellprofiler.gui.help.content import MEASUREMENT_NAMING_HELP
label_desc: Use image node_id 29 for calling the ExportToSpreadsheet obj's underlying member method code with example usage: obj.make_relationships_file(image_set_numbers, workspace, settings_group) without return types