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: Make `file_map` from filename `filespec`
  
  AFNI BRIK files can be compressed, but HEAD files cannot - see
  afni.nimh.nih.gov/pub/dist/doc/program_help/README.compression.html.
  Thus, if you have AFNI files my_image.HEAD and my_image.BRIK.gz and you
  want to load the AFNI BRIK / HEAD pair, you can specify:
  
      * The HEAD filename - e.g., my_image.HEAD
      * The BRIK filename w/o compressed extension - e.g., my_image.BRIK
      * The full BRIK filename - e.g., my_image.BRIK.gz
  
  Parameters
  ----------
  filespec : str
      Filename that might be for this image file type.
  
  Returns
  -------
  file_map : dict
      dict with keys ``image`` and ``header`` where values are fileholder
      objects for the respective BRIK and HEAD files
  
  Raises
  ------
  ImageFileError
      If `filespec` is not recognizable as being a filename for this
      image type.
code: def filespec_to_file_map(klass, filespec):
      """
      Make `file_map` from filename `filespec`
  
      AFNI BRIK files can be compressed, but HEAD files cannot - see
      afni.nimh.nih.gov/pub/dist/doc/program_help/README.compression.html.
      Thus, if you have AFNI files my_image.HEAD and my_image.BRIK.gz and you
      want to load the AFNI BRIK / HEAD pair, you can specify:
  
          * The HEAD filename - e.g., my_image.HEAD
          * The BRIK filename w/o compressed extension - e.g., my_image.BRIK
          * The full BRIK filename - e.g., my_image.BRIK.gz
  
      Parameters
      ----------
      filespec : str
          Filename that might be for this image file type.
  
      Returns
      -------
      file_map : dict
          dict with keys ``image`` and ``header`` where values are fileholder
          objects for the respective BRIK and HEAD files
  
      Raises
      ------
      ImageFileError
          If `filespec` is not recognizable as being a filename for this
          image type.
      """
      file_map = super().filespec_to_file_map(filespec)
      # check for AFNI-specific BRIK/HEAD compression idiosyncrasies
      for key, fholder in file_map.items():
          fname = fholder.filename
          if key == "header" and not os.path.exists(fname):
              for ext in klass._compressed_suffixes:
                  fname = (
                      fname[: -len(ext)]
                      if fname.endswith(ext)
                      else fname
                  )
          elif key == "image" and not os.path.exists(fname):
              for ext in klass._compressed_suffixes:
                  if os.path.exists(fname + ext):
                      fname += ext
                      break
          file_map[key].filename = fname
      return 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 2 for calling the AFNIImage obj's underlying member method code with example usage: obj.filespec_to_file_map(klass, filespec) and returns: file_map