code: def test_load_surf_data_file_freesurfer(tmp_path):
      # test loading of fake data from sulc and thickness files
      # using load_surf_data.
      # We test load_surf_data by creating fake data with function
      # 'write_morph_data' that works only if nibabel
      # version is recent with nibabel >= 2.1.0
      data = np.zeros((20,))
      fs_area, filename_area = tempfile.mkstemp(
          suffix=".area", dir=str(tmp_path)
      )
      os.close(fs_area)
      nb.freesurfer.io.write_morph_data(filename_area, data)
      assert_array_equal(load_surf_data(filename_area), np.zeros((20,)))
      os.remove(filename_area)
  
      fs_curv, filename_curv = tempfile.mkstemp(
          suffix=".curv", dir=str(tmp_path)
      )
      os.close(fs_curv)
      nb.freesurfer.io.write_morph_data(filename_curv, data)
      assert_array_equal(load_surf_data(filename_curv), np.zeros((20,)))
      os.remove(filename_curv)
  
      fd_sulc, filename_sulc = tempfile.mkstemp(
          suffix=".sulc", dir=str(tmp_path)
      )
      os.close(fd_sulc)
      nb.freesurfer.io.write_morph_data(filename_sulc, data)
      assert_array_equal(load_surf_data(filename_sulc), np.zeros((20,)))
      os.remove(filename_sulc)
  
      fd_thick, filename_thick = tempfile.mkstemp(
          suffix=".thickness", dir=str(tmp_path)
      )
      os.close(fd_thick)
      nb.freesurfer.io.write_morph_data(filename_thick, data)
      assert_array_equal(
          load_surf_data(filename_thick), np.zeros((20,))
      )
      os.remove(filename_thick)
  
      # test loading of data from real label and annot files
      label_start = np.array([5900, 5899, 5901, 5902, 2638])
      label_end = np.array([8756, 6241, 8757, 1896, 6243])
      label = load_surf_data(os.path.join(datadir, "test.label"))
      assert_array_equal(label[:5], label_start)
      assert_array_equal(label[-5:], label_end)
      assert label.shape == (10,)
      del label, label_start, label_end
  
      annot_start = np.array([24, 29, 28, 27, 24, 31, 11, 25, 0, 12])
      annot_end = np.array([16, 16, 16, 16, 16, 16, 16, 16, 16, 16])
      annot = load_surf_data(os.path.join(datadir, "test.annot"))
      assert_array_equal(annot[:10], annot_start)
      assert_array_equal(annot[-10:], annot_end)
      assert annot.shape == (10242,)
      del annot, annot_start, annot_end
  
imports: import os
  import tempfile
  import warnings
  import nibabel
  import numpy
  import pytest
  from nibabel import gifti
  from numpy.testing import assert_array_almost_equal, assert_array_equal
  from scipy.spatial import Delaunay
  from scipy.stats import pearsonr
  from nilearn import datasets, image
  from nilearn._utils import data_gen
  from nilearn.image import resampling
  from nilearn.surface import Mesh, Surface, load_surf_data, load_surf_mesh, surface
  from nilearn.surface.surface import _gifti_img_to_mesh, _load_surf_files_gifti_gzip
  from nilearn.surface.tests._testing import flat_mesh, generate_surf, z_const_img
label_desc: Use image node_id 5 for calling a global function with example usage: test_load_surf_data_file_freesurfer(tmp_path) without return types