class_docstr: Class for MGH format image
class_docstr_tok: ["Class","for","MGH","format","image"]
docstr: Class method to create image from mapping in ``file_map``
  
  Parameters
  ----------
  file_map : dict
      Mapping with (kay, value) pairs of (``file_type``, FileHolder
      instance giving file-likes for each file needed for this image
      type.
  mmap : {True, False, 'c', 'r'}, optional, keyword only
      `mmap` controls the use of numpy memory mapping for reading image
      array data.  If False, do not try numpy ``memmap`` for data array.
      If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``.  A
      `mmap` value of True gives the same behavior as ``mmap='c'``.  If
      image data file cannot be memory-mapped, ignore `mmap` value and
      read array from file.
  keep_file_open : { None, True, False }, optional, keyword only
      `keep_file_open` controls whether a new file handle is created
      every time the image is accessed, or a single file handle is
      created and used for the lifetime of this ``ArrayProxy``. If
      ``True``, a single file handle is created and used. If ``False``,
      a new file handle is created every time the image is accessed.
      If ``file_map`` refers to an open file handle, this setting has no
      effect. The default value (``None``) will result in the value of
      ``nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT`` being used.
  
  Returns
  -------
  img : MGHImage instance
docstr_tok: ["Class","method","to","create","image","from","mapping","in","``","file_map","``","Parameters","--","--","--","--","--","file_map",":","dict","Mapping","with","(","kay",",","value",")","pairs","of","(","``","file_type","``",",","FileHolder","instance","giving","file-likes","for","each","file","needed","for","this","image","type",".","mmap",":","{","True",",","False",",","'","c","'",",","'","r","'","}",",","optional",",","keyword","only","`","mmap","`","controls","the","use","of","numpy","memory","mapping","for","reading","image","array","data",".","If","False",",","do","not","try","numpy","``","memmap","``","for","data","array",".","If","one","of","{","'","c","'",",","'","r","'","}",",","try","numpy","memmap","with","``","mode=mmap","``",".","A","`","mmap","`","value","of","True","gives","the","same","behavior","as","``","mmap=","'","c","'","``",".","If","image","data","file","can","not","be","memory-mapped",",","ignore","`","mmap","`","value","and","read","array","from","file",".","keep_file_open",":","{","None",",","True",",","False","}",",","optional",",","keyword","only","`","keep_file_open","`","controls","whether","a","new","file","handle","is","created","every","time","the","image","is","accessed",",","or","a","single","file","handle","is","created","and","used","for","the","lifetime","of","this","``","ArrayProxy","``",".","If","``","True","``",",","a","single","file","handle","is","created","and","used",".","If","``","False","``",",","a","new","file","handle","is","created","every","time","the","image","is","accessed",".","If","``","file_map","``","refers","to","an","open","file","handle",",","this","setting","has","no","effect",".","The","default","value","(","``","None","``",")","will","result","in","the","value","of","``","nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT","``","being","used",".","Returns","--","--","--","-","img",":","MGHImage","instance"]
code: def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
      """Class method to create image from mapping in ``file_map``
  
      Parameters
      ----------
      file_map : dict
          Mapping with (kay, value) pairs of (``file_type``, FileHolder
          instance giving file-likes for each file needed for this image
          type.
      mmap : {True, False, 'c', 'r'}, optional, keyword only
          `mmap` controls the use of numpy memory mapping for reading image
          array data.  If False, do not try numpy ``memmap`` for data array.
          If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``.  A
          `mmap` value of True gives the same behavior as ``mmap='c'``.  If
          image data file cannot be memory-mapped, ignore `mmap` value and
          read array from file.
      keep_file_open : { None, True, False }, optional, keyword only
          `keep_file_open` controls whether a new file handle is created
          every time the image is accessed, or a single file handle is
          created and used for the lifetime of this ``ArrayProxy``. If
          ``True``, a single file handle is created and used. If ``False``,
          a new file handle is created every time the image is accessed.
          If ``file_map`` refers to an open file handle, this setting has no
          effect. The default value (``None``) will result in the value of
          ``nibabel.arrayproxy.KEEP_FILE_OPEN_DEFAULT`` being used.
  
      Returns
      -------
      img : MGHImage instance
      """
      if mmap not in (True, False, "c", "r"):
          raise ValueError(
              "mmap should be one of {True, False, 'c', 'r'}"
          )
      img_fh = file_map["image"]
      mghf = img_fh.get_prepare_fileobj("rb")
      header = klass.header_class.from_fileobj(mghf)
      affine = header.get_affine()
      hdr_copy = header.copy()
      # Pass original image fileobj / filename to array proxy
      data = klass.ImageArrayProxy(
          img_fh.file_like,
          hdr_copy,
          mmap=mmap,
          keep_file_open=keep_file_open,
      )
      img = klass(data, affine, header, file_map=file_map)
      return img
  
imports: from os.path import splitext
  import numpy
  from ..affines import from_matvec, voxel_sizes
  from ..arrayproxy import ArrayProxy, reshape_dataobj
  from ..batteryrunners import BatteryRunner, Report
  from ..filebasedimages import SerializableImage
  from ..fileholders import FileHolder
  from ..filename_parser import _stringify_path
  from ..openers import ImageOpener
  from ..spatialimages import HeaderDataError, SpatialHeader, SpatialImage
  from ..volumeutils import Recoder, array_from_file, array_to_file, endian_codes
  from ..wrapstruct import LabeledWrapStruct
label_desc: Use image node_id 3 for calling the MGHImage obj's underlying member method code with example usage: obj.from_file_map(klass, file_map) and returns: img