code: def test_load_cmaps():
      data = np.random.normal(size=list(range(7)))
      xyz_aff = np.diag([2, 3, 4, 1])
      # Default with time-like
      ni_img = nib.Nifti1Image(data, xyz_aff)
      img = nifti2nipy(ni_img)
      exp_cmap = AT(
          CS("ijktuvw", name="voxels"),
          aligned_csm(7),
          np.diag([2, 3, 4, 1, 1, 1, 1, 1]),
      )
      assert img.coordmap == exp_cmap
      # xyzt_units sets time axis name
      hdr = get_header(ni_img)
      xyz_names = aligned_csm(3).coord_names
      full_aff = exp_cmap.affine
      reduced_data = data[:, :, :, 1:2, ...]
      for t_like, units, scaling in (
          ("t", "sec", 1),
          ("t", "msec", 1 / 1000.0),
          ("t", "usec", 1 / 1000000.0),
          ("hz", "hz", 1),
          ("ppm", "ppm", 1),
          ("rads", "rads", 1),
      ):
          hdr.set_xyzt_units("mm", units)
          img = nifti2nipy(ni_img)
          in_cs = CS(
              ("i", "j", "k", t_like, "u", "v", "w"), name="voxels"
          )
          out_cs = CS(
              xyz_names + (t_like, "u", "v", "w"), name="aligned"
          )
          if scaling == 1:
              exp_aff = full_aff
          else:
              diag = np.ones((8,))
              diag[3] = scaling
              exp_aff = np.dot(np.diag(diag), full_aff)
          exp_cmap = AT(in_cs, out_cs, exp_aff)
          assert img.coordmap == exp_cmap
          assert_array_equal(img.get_fdata(), data)
          # Even if the image axis length is 1, we keep out time dimension, if
          # there is specific scaling implying time-like
          ni_img_t = nib.Nifti1Image(reduced_data, xyz_aff, hdr)
          img = nifti2nipy(ni_img_t)
          assert img.coordmap == exp_cmap
          assert_array_equal(img.get_fdata(), reduced_data)
  
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 18 for calling a global function with example usage: test_load_cmaps() without return types