docstr: Add and set channels based on an image from omero 
docstr_tok: ["Add","and","set","channels","based","on","an","image","from","omero"]
code: def load_channels(self):
      """Add and set channels based on an image from omero"""
      try:
          self.create_omero_gateway()
          id = int(self.omero_object_id.value)
  
          if self.omero_object == MS_IMAGE:
              omero_image = self.omero_gateway.getImage(id)
          elif self.omero_object == MS_DATASET:
              images_from_dataset = self.get_images_from_dataset(id, 1)
              if len(images_from_dataset) == 0:
                  omero_image = None
              else:
                  omero_image = images_from_dataset[0]
          elif self.omero_object == MS_PLATE:
              wells_from_plate = self.get_wells_from_plate(id, 1)
              if len(wells_from_plate) == 0:
                  omero_image = None
              else:
                  omero_well = wells_from_plate[0]
                  omero_image = omero_well.getWellSample(0).getImage()
  
          if omero_image is None:
              # Don't say plate or dataset not found as they might still exist but do not have
              # images attached to them. Another reason for not being able to find images is
              # because the omero account used does not have permissions to retrieve the image
              # or images.
              raise RuntimeError(
                  "No image found for %s with id %d"
                  % (self.omero_object, id)
              )
  
          omero_image_id = omero_image.getId().getValue()
          pixels = self.omero_gateway.getPixelsFromImage(
              omero_image_id
          )[0]
          # The pixels doesn't have all the (logical) channels
          # because of lazy loading. So the pixels is requested
          # again, but in a way to get the channels as well.
          pixels = self.omero_gateway.getPixels(
              pixels.getId().getValue()
          )
  
          # repopulate channels based on the retrieved pixels.
          # note: cannot say self.channels=[] because the channel_count
          # is associated with the object self.channels refers to.
          for channel in self.channels[:]:
              self.channels.remove(channel)
          omero_channels = [
              channel for channel in pixels.iterateChannels()
          ]
          number_of_channels = pixels.getSizeC().getValue()
          for channel_number in range(0, number_of_channels):
              omero_channel = omero_channels[
                  channel_number
              ].getLogicalChannel()
              # load default cpimage name in case the logical channel name
              # cannot be retrieved. e.g., when the logical channel name is null
              try:
                  omero_channel_name = (
                      omero_channel.getName().getValue().strip()
                  )
              except:
                  omero_channel_name = default_cpimage_name(
                      channel_number
                  )
              self.add_channelfn(channel_number != 0)
              self.channels[-1].cpimage_name.set_value(
                  omero_channel_name
              )
              self.channels[-1].channel_number.set_value(
                  str(channel_number)
              )
  
          # Close the session just in case the user decides not to run
          # the pipeline.
          self.omero_client.closeSession()
          self.omero_client = None
          wx.MessageBox(
              "Retrieved %d channel(s) from OMERO" % number_of_channels,
              "",
              wx.ICON_INFORMATION,
          )
      except:
          wx.MessageBox(
              traceback.format_exc(limit=0), "Exception", wx.ICON_ERROR
          )
  
imports: import traceback
  import numpy
  import wx
  import cellprofiler_core.image
  import cellprofiler_core.module
  import cellprofiler_core.measurement
  import cellprofiler_core.preferences
  import cellprofiler_core.setting
  from cellprofiler_core.modules import default_cpimage_name
  import omero
  from omero.rtypes import rlong
  from omero.rtypes import rint
  from omero_version import omero_version
label_desc: Use image node_id 4 for calling the OmeroLoadImages obj's underlying member method code with example usage: obj.load_channels() without return types