code: def test_file_roundtrip(in_tmp_path):
      img = load_image(anatfile)
      data = img.get_fdata()
      save_image(img, "img.nii.gz")
      img2 = load_image("img.nii.gz")
      data2 = img2.get_fdata()
      # verify data
      assert_almost_equal(data2, data)
      assert_almost_equal(data2.mean(), data.mean())
      assert_almost_equal(data2.min(), data.min())
      assert_almost_equal(data2.max(), data.max())
      # verify shape and ndims
      assert img2.shape == img.shape
      assert img2.ndim == img.ndim
      # verify affine
      assert_almost_equal(img2.affine, img.affine)
      # Test we can use Path objects
      out_path = "path_img.nii"
      save_image(img, out_path)
      img2 = load_image(out_path)
      data2 = img2.get_fdata()
      # verify data
      assert_almost_equal(data2, data)
  
imports: from os.path import dirname
  from os.path import join
  import nibabel
  import numpy
  import pytest
  from nibabel import Nifti1Header
  from nibabel.filebasedimages import ImageFileError
  from nibabel.spatialimages import HeaderDataError
  from nibabel.tests.test_round_trip import big_bad_ulp
  from nipy.core.api import AffineTransform
  from nipy.core.api import Image, vox2mni
  from nipy.testing import anatfile, assert_almost_equal, assert_array_almost_equal, assert_array_equal, funcfile
  from nipy.testing.decorators import if_templates
  from nipy.utils import DataError, templates
  from ..api import as_image, load_image, save_image
label_desc: Use image node_id 10 for calling a global function with example usage: test_file_roundtrip(in_tmp_path) without return types