code: def is_xyz_affable(img, name2xyz=None):
      """Return True if the image `img` has an xyz affine
  
      Parameters
      ----------
      img : ``Image`` or nibabel ``SpatialImage``
          If ``Image`` test ``img.coordmap``.  If a nibabel image, return True
      name2xyz : None or mapping
          Object such that ``name2xyz[ax_name]`` returns 'x', or 'y' or 'z' or
          raises a KeyError for a str ``ax_name``.  None means use module default.
          Not used for nibabel `img` input.
  
      Returns
      -------
      tf : bool
          True if `img` has an xyz affine, False otherwise
  
      Examples
      --------
      >>> from nipy.core.api import vox2mni, Image, rollimg
      >>> arr = np.arange(24, dtype=np.float32).reshape((2,3,4,1))
      >>> img = Image(arr, vox2mni(np.diag([2,3,4,5,1])))
      >>> img.coordmap
      AffineTransform(
         function_domain=CoordinateSystem(coord_names=('i', 'j', 'k', 'l'), name='voxels', coord_dtype=float64),
         function_range=CoordinateSystem(coord_names=('mni-x=L->R', 'mni-y=P->A', 'mni-z=I->S', 't'), name='mni', coord_dtype=float64),
         affine=array([[ 2.,  0.,  0.,  0.,  0.],
                       [ 0.,  3.,  0.,  0.,  0.],
                       [ 0.,  0.,  4.,  0.,  0.],
                       [ 0.,  0.,  0.,  5.,  0.],
                       [ 0.,  0.,  0.,  0.,  1.]])
      )
      >>> is_xyz_affable(img)
      True
      >>> time0_img = rollimg(img, 't')
      >>> time0_img.coordmap
      AffineTransform(
         function_domain=CoordinateSystem(coord_names=('l', 'i', 'j', 'k'), name='voxels', coord_dtype=float64),
         function_range=CoordinateSystem(coord_names=('mni-x=L->R', 'mni-y=P->A', 'mni-z=I->S', 't'), name='mni', coord_dtype=float64),
         affine=array([[ 0.,  2.,  0.,  0.,  0.],
                       [ 0.,  0.,  3.,  0.,  0.],
                       [ 0.,  0.,  0.,  4.,  0.],
                       [ 5.,  0.,  0.,  0.,  0.],
                       [ 0.,  0.,  0.,  0.,  1.]])
      )
      >>> is_xyz_affable(time0_img)
      False
  
      Nibabel images always have xyz affines
  
      >>> import nibabel as nib
      >>> nimg = nib.Nifti1Image(arr, np.diag([2,3,4,1]))
      >>> is_xyz_affable(nimg)
      True
      """
      try:
          xyz_affine(img, name2xyz)
      except rsp.SpaceError:
          return False
      return True
  
file_path: nipy/nipy/core/image/image_spaces.py
imports: import sys
  import numpy
  from nibabel import io_orientation
  from ...io import nibcompat
  from ..image.image import Image
  from ..reference import spaces
  from ..reference.coordinate_map import AffineTransform
label_desc: Use image node_id 2 for calling a global function with example usage: is_xyz_affable(img, name2xyz) and returns: True, False