class_docstr: Base for image providers: handle pathname and filename & URLs
class_docstr_tok: ["Base","for","image","providers",":","handle","pathname","and","filename","&","URLs"]
code: def __set_image(self):
      if self.__volume:
          self.__set_image_volume()
          return
  
      self.cache_file()
      channel_names = []
      if is_matlab_file(self.__filename):
          img = load_data_file(self.get_full_name(), loadmat)
          self.scale = 1.0
      elif is_numpy_file(self.__filename):
          img = load_data_file(self.get_full_name(), numpy.load)
          self.scale = 1.0
      else:
          rdr = self.get_reader()
          if numpy.isscalar(self.index) or self.index is None:
              img, self.scale = rdr.read(
                  c=self.channel,
                  z=self.z,
                  t=self.t,
                  series=self.series,
                  index=self.index,
                  rescale=self.rescale
                  if isinstance(self.rescale, bool)
                  else False,
                  wants_max_intensity=True,
                  channel_names=channel_names,
              )
          else:
              # It's a stack
              stack = []
              if numpy.isscalar(self.series):
                  series_list = [self.series] * len(self.index)
              else:
                  series_list = self.series
              if not numpy.isscalar(self.channel):
                  channel_list = [self.channel] * len(self.index)
              else:
                  channel_list = self.channel
              for series, index, channel in zip(
                  series_list, self.index, channel_list
              ):
                  img, self.scale = rdr.read(
                      c=channel,
                      z=self.z,
                      t=self.t,
                      series=series,
                      index=index,
                      rescale=self.rescale
                      if isinstance(self.rescale, bool)
                      else False,
                      wants_max_intensity=True,
                      channel_names=channel_names,
                  )
                  stack.append(img)
              img = numpy.dstack(stack)
      if isinstance(self.rescale, float):
          # Apply a manual rescale
          img = img.astype(numpy.float32) / self.rescale
      self.__image = Image(
          img,
          path_name=self.get_pathname(),
          file_name=self.get_filename(),
          scale=self.scale,
          channelstack=img.ndim == 3 and img.shape[-1] > 3,
      )
      if img.ndim == 3 and len(channel_names) == img.shape[2]:
          self.__image.channel_names = list(channel_names)
  
imports: import atexit
  import hashlib
  import logging
  import os
  import tempfile
  import urllib.parse
  import urllib.request
  import weakref
  import numpy
  import cellprofiler_core.preferences
  from .._abstract_image import AbstractImage
  from ..._image import Image
  from ....reader import get_image_reader, get_image_reader_class
  from ....utilities.image import is_numpy_file, download_to_temp_file
  from ....utilities.image import is_matlab_file
  from ....utilities.image import loadmat
  from ....utilities.image import load_data_file
  from ....utilities.image import generate_presigned_url
  from ....constants.image import FILE_SCHEME, PASSTHROUGH_SCHEMES
  from ....utilities.pathname import pathname2url, url2pathname
label_desc: Use image node_id 21 for calling the FileImage obj's underlying member method code with example usage: obj.__set_image() without return types