code: def test_xyzt_units():
      # Whether xyzt_unit field gets set correctly
      fimg_orig = copy_of(funcfile)
      # Put time in output, input and both
      data = fimg_orig.get_fdata()
      hdr = fimg_orig.metadata["header"]
      aff = fimg_orig.coordmap.affine
      out_names = fimg_orig.reference.coord_names
      # Time in input only
      cmap_t_in = AT("ijkt", out_names[:3] + ("q",), aff)
      img_t_in = Image(data, cmap_t_in, {"header": hdr.copy()})
      # Time in output only
      cmap_t_out = AT("ijkl", out_names[:3] + ("t",), aff)
      img_t_out = Image(data, cmap_t_out, {"header": hdr.copy()})
      # Time in both
      cmap_t_b = AT("ijkt", out_names[:3] + ("t",), aff)
      img_t_b = Image(data, cmap_t_b, {"header": hdr.copy()})
      # In neither
      cmap_t_no = AT("ijkl", out_names[:3] + ("q",), aff)
      img_t_no = Image(data, cmap_t_no, {"header": hdr.copy()})
      # Check the default
      assert hdr.get_xyzt_units() == ("mm", "sec")
      # That default survives nifti conversion
      for img in (img_t_in, img_t_out, img_t_b):
          ni_img = nipy2nifti(img)
          assert get_header(ni_img).get_xyzt_units() == ("mm", "sec")
      # Now with no time
      for img in (img_t_no, img_t_b[..., 0]):
          ni_img = nipy2nifti(img)
          assert get_header(ni_img).get_xyzt_units() == (
              "mm",
              "unknown",
          )
      # Change to other time-like
      for units, name0, name1 in (
          ("sec", "t", "time"),
          ("hz", "hz", "frequency-hz"),
          ("ppm", "ppm", "concentration-ppm"),
          ("rads", "rads", "radians/s"),
      ):
          for name in (name0, name1):
              new_img = img_t_out.renamed_reference(t=name)
              ni_img = nipy2nifti(new_img)
              assert get_header(ni_img).get_xyzt_units() == (
                  "mm",
                  units,
              )
              new_img = img_t_in.renamed_axes(t=name)
              ni_img = nipy2nifti(new_img)
              assert get_header(ni_img).get_xyzt_units() == (
                  "mm",
                  units,
              )
              new_img = img_t_b.renamed_axes(t=name).renamed_reference(
                  t=name
              )
              ni_img = nipy2nifti(new_img)
              assert get_header(ni_img).get_xyzt_units() == (
                  "mm",
                  units,
              )
  
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 9 for calling a global function with example usage: test_xyzt_units() without return types