code: def test_nipy_diagnose(in_tmp_path):
      # Test nipy diagnose script
      fimg = load_image(funcfile)
      ncomps = 12
      cmd = [
          "nipy_diagnose",
          funcfile,
          f"--ncomponents={ncomps}",
          "--out-path=" + str(in_tmp_path),
      ]
      run_command(cmd)
      for out_fname in (
          "components_functional.png",
          "pcnt_var_functional.png",
          "tsdiff_functional.png",
          "vectors_components_functional.npz",
      ):
          assert isfile(out_fname)
      for out_img in (
          "max_functional.nii.gz",
          "mean_functional.nii.gz",
          "min_functional.nii.gz",
          "std_functional.nii.gz",
      ):
          img = load_image(out_img)
          assert img.shape == fimg.shape[:-1]
          del img
      pca_img = load_image("pca_functional.nii.gz")
      assert pca_img.shape == fimg.shape[:-1] + (ncomps,)
      vecs_comps = np.load("vectors_components_functional.npz")
      vec_diff = vecs_comps["slice_mean_diff2"].copy()  # just in case
      assert vec_diff.shape == (fimg.shape[-1] - 1, fimg.shape[2])
      # Check we can pass in slice and time flags
      s0_img = rollimg(fimg, "k")
      save_image(s0_img, "slice0.nii")
      cmd = [
          "nipy_diagnose",
          "slice0.nii",
          f"--ncomponents={ncomps}",
          "--out-path=" + str(in_tmp_path),
          "--time-axis=t",
          "--slice-axis=0",
      ]
      run_command(cmd)
      pca_img = load_image("pca_slice0.nii")
      assert pca_img.shape == s0_img.shape[:-1] + (ncomps,)
      vecs_comps = np.load("vectors_components_slice0.npz")
      assert_almost_equal(vecs_comps["slice_mean_diff2"], vec_diff)
      del pca_img, vecs_comps
  
file_path: nipy/nipy/tests/test_scripts.py
imports: import os
  from os.path import isfile
  from os.path import join
  from unittest import skipIf
  import numpy
  import pytest
  from nibabel.optpkg import optional_package
  from numpy.testing import assert_almost_equal
  from nipy import load_image, save_image
  from nipy.core.api import rollimg
  from nipy.testing.decorators import make_label_dec
  from ..testing import funcfile
  from .scriptrunner import ScriptRunner
label_desc: Use image node_id 1 for calling a global function with example usage: test_nipy_diagnose(in_tmp_path) without return types