class_docstr: AFNI Image file
  
  Can be loaded from either the BRIK or HEAD file (but MUST specify one!)
  
  Examples
  --------
  >>> import nibabel as nib
  >>> brik = nib.load(os.path.join(datadir, 'example4d+orig.BRIK.gz'))
  >>> brik.shape
  (33, 41, 25, 3)
  >>> brik.affine
  array([[ -3.    ,  -0.    ,  -0.    ,  49.5   ],
         [ -0.    ,  -3.    ,  -0.    ,  82.312 ],
         [  0.    ,   0.    ,   3.    , -52.3511],
         [  0.    ,   0.    ,   0.    ,   1.    ]])
  >>> head = load(os.path.join(datadir, 'example4d+orig.HEAD'))
  >>> np.array_equal(head.get_fdata(), brik.get_fdata())
  True
docstr: Creates an AFNIImage instance from `file_map`
  
  Parameters
  ----------
  file_map : dict
      dict with keys ``image, header`` and values being fileholder
      objects for the respective BRIK and HEAD files
  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_like`` 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.
code: def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
      """
      Creates an AFNIImage instance from `file_map`
  
      Parameters
      ----------
      file_map : dict
          dict with keys ``image, header`` and values being fileholder
          objects for the respective BRIK and HEAD files
      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_like`` 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.
      """
      with file_map["header"].get_prepare_fileobj("rt") as hdr_fobj:
          hdr = klass.header_class.from_fileobj(hdr_fobj)
      imgf = file_map["image"].fileobj
      imgf = file_map["image"].filename if imgf is None else imgf
      data = klass.ImageArrayProxy(
          imgf, hdr.copy(), mmap=mmap, keep_file_open=keep_file_open
      )
      return klass(
          data,
          hdr.get_affine(),
          header=hdr,
          extra=None,
          file_map=file_map,
      )
  
imports: import os
  import re
  from copy import deepcopy
  import numpy
  from .arrayproxy import ArrayProxy
  from .fileslice import strided_scalar
  from .spatialimages import HeaderDataError, ImageDataError, SpatialHeader, SpatialImage
  from .volumeutils import Recoder
label_desc: Use image node_id 1 for calling the AFNIImage obj's underlying member method code with example usage: obj.from_file_map(klass, file_map) and returns: klass