class_docstr: Abstract image class with interface for loading/saving images from disk.
  
  The class doesn't define any image properties.
  
  It has:
  
  attributes:
  
     * extra
  
  properties:
  
     * header
  
  methods:
  
     * to_filename(fname) - writes data to filename(s) derived from
       ``fname``, where the derivation may differ between formats.
     * to_file_map() - save image to files with which the image is already
       associated.
  
  classmethods:
  
     * from_filename(fname) - make instance by loading from filename
     * from_file_map(fmap) - make instance from file map
     * instance_to_filename(img, fname) - save ``img`` instance to
       filename ``fname``.
  
  It also has a ``header`` - some standard set of meta-data that is specific
  to the image format, and ``extra`` - a dictionary container for any other
  metadata.
  
  You cannot slice an image, and trying to slice an image generates an
  informative TypeError.
  
  **There are several ways of writing data**
  
  There is the usual way, which is the default::
  
      img.to_filename(fname)
  
  and that is, to take the data encapsulated by the image and cast it to
  the datatype the header expects, setting any available header scaling
  into the header to help the data match.
  
  You can load the data into an image from file with::
  
     img.from_filename(fname)
  
  The image stores its associated files in its ``file_map`` attribute.  In
  order to just save an image, for which you know there is an associated
  filename, or other storage, you can do::
  
     img.to_file_map()
  
  **Files interface**
  
  The image has an attribute ``file_map``.  This is a mapping, that has keys
  corresponding to the file types that an image needs for storage.  For
  example, the Analyze data format needs an ``image`` and a ``header``
  file type for storage:
  
     >>> import numpy as np
     >>> import nibabel as nib
     >>> data = np.arange(24, dtype='f4').reshape((2,3,4))
     >>> img = nib.AnalyzeImage(data, np.eye(4))
     >>> sorted(img.file_map)
     ['header', 'image']
  
  The values of ``file_map`` are not in fact files but objects with
  attributes ``filename``, ``fileobj`` and ``pos``.
  
  The reason for this interface, is that the contents of files has to
  contain enough information so that an existing image instance can save
  itself back to the files pointed to in ``file_map``.  When a file holder
  holds active file-like objects, then these may be affected by the
  initial file read; in this case, the file-like objects need to
  carry the position at which a write (with ``to_file_map``) should place the
  data.  The ``file_map`` contents should therefore be such, that this will
  work.
docstr: Class method to make files holder for this image type
  
  Parameters
  ----------
  mapping : None or mapping, optional
     mapping with keys corresponding to image file types (such as
     'image', 'header' etc, depending on image class) and values
     that are filenames or file-like.  Default is None
  
  Returns
  -------
  file_map : dict
     dict with string keys given by first entry in tuples in
     sequence klass.files_types, and values of type FileHolder,
     where FileHolder objects have default values, other than
     those given by `mapping`
docstr_tok: ["Class","method","to","make","files","holder","for","this","image","type","Parameters","--","--","--","--","--","mapping",":","None","or","mapping",",","optional","mapping","with","keys","corresponding","to","image","file","types","(","such","as","'image","'",",","'header","'","etc",",","depending","on","image","class",")","and","values","that","are","filenames","or","file-like",".","Default","is","None","Returns","--","--","--","-","file_map",":","dict","dict","with","string","keys","given","by","first","entry","in","tuples","in","sequence","klass.files_types",",","and","values","of","type","FileHolder",",","where","FileHolder","objects","have","default","values",",","other","than","those","given","by","`","mapping","`"]
code: def make_file_map(
      klass, mapping: ty.Mapping[str, str | io.IOBase] | None = None
  ) -> FileMap:
      """Class method to make files holder for this image type
  
      Parameters
      ----------
      mapping : None or mapping, optional
         mapping with keys corresponding to image file types (such as
         'image', 'header' etc, depending on image class) and values
         that are filenames or file-like.  Default is None
  
      Returns
      -------
      file_map : dict
         dict with string keys given by first entry in tuples in
         sequence klass.files_types, and values of type FileHolder,
         where FileHolder objects have default values, other than
         those given by `mapping`
      """
      if mapping is None:
          mapping = {}
      file_map = {}
      for key, ext in klass.files_types:
          file_map[key] = FileHolder()
          mapval = mapping.get(key, None)
          if isinstance(mapval, str):
              file_map[key].filename = mapval
          elif hasattr(mapval, "tell"):
              file_map[key].fileobj = mapval
      return file_map
  
imports: from __future__ import annotations
  import io
  import typing
  from copy import deepcopy
  from urllib import request
  from ._compression import COMPRESSION_ERRORS
  from .fileholders import FileHolder, FileMap
  from .filename_parser import TypesFilenamesError, _stringify_path, splitext_addext, types_filenames
  from .openers import ImageOpener
label_desc: Use image node_id 11 for calling the FileBasedImage obj's underlying member method code with example usage: obj.make_file_map(klass, mapping) and returns: file_map