code: def test_load_spaces():
      # Test spaces get read correctly
      shape = np.array((6, 5, 4, 3, 2))
      zooms = np.array((2, 3, 4, 5, 6))
      data = np.random.normal(size=shape)
      # Default with no affine in header, or in image
      ni_img = nib.Nifti1Image(data, None)
      hdr = get_header(ni_img)
      hdr.set_zooms(zooms)
      # Expected affine is from the pixdims and the center of the image.  Default
      # is also flipped X.
      offsets = (1 - shape[:3]) / 2.0 * zooms[:3] * (-1, 1, 1)
      exp_aff = from_matvec(
          np.diag([-2, 3, 4, 5, 6]), list(offsets) + [0, 0]
      )
      in_cs = CS("ijktu", name="voxels")
      exp_cmap = AT(in_cs, unknown_csm(5), exp_aff)
      assert nifti2nipy(ni_img).coordmap == exp_cmap
      an_aff = from_matvec(np.diag([1.1, 2.2, 3.3]), [10, 11, 12])
      exp_aff = from_matvec(
          np.diag([1.1, 2.2, 3.3, 5, 6]), [10, 11, 12, 0, 0]
      )
      for label, csm in (
          ("scanner", scanner_csm),
          ("aligned", aligned_csm),
          ("talairach", talairach_csm),
          ("mni", mni_csm),
      ):
          hdr.set_sform(an_aff, label)
          assert nifti2nipy(ni_img).coordmap == AT(
              in_cs, csm(5), exp_aff
          )
  
imports: import warnings
  from copy import copy
  import nibabel
  import numpy
  import pytest
  from nibabel.affines import from_matvec
  from nibabel.spatialimages import HeaderDataError
  from numpy.testing import assert_array_equal
  from ...core.api import AffineTransform
  from ...core.api import CoordinateSystem
  from ...core.api import Image
  from ...core.reference.spaces import aligned_csm, mni_csm, scanner_csm, talairach_csm, unknown_csm, unknown_space, vox2mni
  from ...testing import anatfile, funcfile
  from ..files import load
  from ..nibcompat import get_affine, get_header
  from ..nifti_ref import NiftiError, nifti2nipy, nipy2nifti
label_desc: Use image node_id 21 for calling a global function with example usage: test_load_spaces() without return types