code: def check_diag_results(
      results,
      img_shape,
      time_axis,
      slice_axis,
      ncomps,
      out_path,
      froot,
      ext=".nii.gz",
  ):
      S = img_shape[slice_axis]
      T = img_shape[time_axis]
      pca_shape = list(img_shape)
      pca_shape[time_axis] = ncomps
      assert results["pca"].shape == tuple(pca_shape)
      assert results["pca_res"]["basis_projections"].shape == tuple(
          pca_shape
      )
      # Roll pca axis last to test shape of output image
      ax_order = list(range(4))
      ax_order.remove(time_axis)
      ax_order.append(time_axis)
      rolled_shape = tuple(pca_shape[i] for i in ax_order)
      pca_img = load_image(pjoin(out_path, "pca_" + froot + ext))
      assert pca_img.shape == rolled_shape
      for prefix in ("mean", "min", "max", "std"):
          fname = pjoin(out_path, prefix + "_" + froot + ext)
          img = load_image(fname)
          assert img.shape == rolled_shape[:-1]
      vars = np.load(
          pjoin(out_path, "vectors_components_" + froot + ".npz")
      )
      assert set(vars) == {
          "basis_vectors",
          "pcnt_var",
          "volume_means",
          "slice_mean_diff2",
      }
      assert vars["volume_means"].shape == (T,)
      assert vars["basis_vectors"].shape == (T, T - 1)
      assert vars["slice_mean_diff2"].shape == (T - 1, S)
  
imports: import os
  import shutil
  from os.path import dirname, isfile
  from os.path import join
  import nibabel
  import numpy
  import pytest
  from nibabel import AnalyzeImage, Nifti1Image, Nifti1Pair, Spm2AnalyzeImage
  from numpy.testing import assert_array_equal
  from nipy import load_image
  from nipy.io.nibcompat import get_header
  from nipy.io.nifti_ref import NiftiError
  from nipy.testing import funcfile
  from nipy.testing.decorators import needs_mpl_agg
  from ..commands import diagnose, parse_fname_axes, tsdiffana
  from ..timediff import time_slice_diffs_image
label_desc: Use image node_id 4 for calling a global function with example usage: check_diag_results(results, img_shape, time_axis, slice_axis, ncomps, out_path, froot, ext) without return types