code: def test_other_axes(data_dict):
      # With a diagonal affine, we can do PCA on any axis
      ncomp = 5
      img = data_dict["fmridata"]
      in_coords = list(img.axes.coord_names)
      img_data = img.get_fdata()
      for axis_no, axis_name in enumerate("ijkt"):
          p = pca_image(img, axis_name, ncomp=ncomp)
          n = img.shape[axis_no]
          bv_key = "basis_vectors over " + axis_name
          assert _rank(p) == n - 1
          assert p[bv_key].shape == (n, n - 1)
          # We get the expected data back
          dp = pca_array(img_data, axis_no, ncomp=ncomp)
          # We have to make sure the signs are the same; on Windows it seems the
          # signs can flip even between two runs on the same data
          pos_p = img_res2pos1(p, bv_key)
          pos_dp = res2pos1(dp)
          img_bps = pos_p["basis_projections"]
          assert_almost_equal(pos_dp["basis_vectors"], pos_p[bv_key])
          assert_almost_equal(
              pos_dp["basis_projections"], img_bps.get_fdata()
          )
          # And we've replaced the expected axis
          exp_coords = in_coords[:]
          exp_coords[exp_coords.index(axis_name)] = "PCA components"
          assert img_bps.axes.coord_names == tuple(exp_coords)
      # If the affine is not diagonal, we'll get an error
      aff = from_matvec(np.arange(16).reshape(4, 4))
      nd_cmap = AffineTransform(img.axes, img.reference, aff)
      nd_img = Image(img_data, nd_cmap)
      for axis_name in "ijkt":
          pytest.raises(AxisError, pca_image, nd_img, axis_name)
      # Only for the non-diagonal parts
      aff = np.array(
          [
              [1, 2, 0, 0, 10],
              [2, 1, 0, 0, 11],
              [0, 0, 3, 0, 12],
              [0, 0, 0, 4, 13],
              [0, 0, 0, 0, 1],
          ]
      )
      nd_cmap = AffineTransform(img.axes, img.reference, aff)
      nd_img = Image(img_data, nd_cmap)
      for axis_name in "ij":
          pytest.raises(AxisError, pca_image, nd_img, axis_name)
      for axis_name in "kt":
          p = pca_image(img, axis_name, ncomp=ncomp)
          exp_coords = in_coords[:]
          exp_coords[exp_coords.index(axis_name)] = "PCA components"
          assert p["basis_projections"].axes.coord_names == tuple(
              exp_coords
          )
  
imports: import numpy
  import pytest
  from nibabel.affines import from_matvec
  from numpy.testing import assert_almost_equal, assert_array_equal
  from ....core.api import AffineTransform, Image
  from ....core.api import CoordinateSystem
  from ....core.image.image import rollimg
  from ....core.reference.coordinate_map import AxisError, drop_io_dim
  from ....core.reference.coordinate_map import product
  from ....io.api import load_image
  from ....testing import funcfile
  from ..pca import pca
  from ..pca import pca_image
  from .test_pca import res2pos1
label_desc: Use image node_id 13 for calling a global function with example usage: test_other_axes(data_dict) without return types