code: def test_write_screen_res(in_tmp_path):
      img = ni.load_image(funcfile)
      res = screen(img)
      os.mkdir("myresults")
      write_screen_res(res, "myresults", "myana")
      pca_img = ni.load_image(pjoin("myresults", "pca_myana.nii"))
      assert pca_img.shape == img.shape[:-1] + (10,)
      # Make sure we get the same output image even from rolled image
      # Do fancy roll to put time axis first, and slice axis last. This does
      # a stress test on the axis ordering, but also makes sure that we are
      # getting the number of components from the right place.  If we were
      # getting the number of components from the length of the last axis,
      # instead of the length of the 't' axis in the returned pca image, this
      # would be wrong (=21) which would also be more than the number of
      # basis vectors (19) so raise an error
      rimg = img.reordered_axes([3, 2, 0, 1])
      os.mkdir("rmyresults")
      rres = screen(rimg)
      write_screen_res(rres, "rmyresults", "myana")
      rpca_img = ni.load_image(pjoin("rmyresults", "pca_myana.nii"))
      assert rpca_img.shape == img.shape[:-1] + (10,)
      del pca_img, rpca_img
  
imports: import os
  from os.path import join
  from warnings import catch_warnings, simplefilter
  import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_equal
  import nipy
  from nipy.core.api import rollimg
  from nipy.testing import funcfile
  from nipy.testing.decorators import needs_mpl_agg
  from ...utils.pca import pca
  from ...utils.tests.test_pca import res2pos1
  from ..screens import screen, write_screen_res
  from ..timediff import time_slice_diffs
label_desc: Use image node_id 6 for calling a global function with example usage: test_write_screen_res(in_tmp_path) without return types