code: def test_projection_matrix(affine_eye):
      mesh = flat_mesh(5, 7, 4)
      img = z_const_img(5, 7, 13)
      proj = surface._projection_matrix(
          mesh, affine_eye, img.shape, radius=2.0, n_points=10
      )
      # proj matrix has shape (n_vertices, img_size)
      assert proj.shape == (5 * 7, 5 * 7 * 13)
      # proj.dot(img) should give the values of img at the vertices' locations
      values = proj.dot(img.ravel()).reshape((5, 7))
      assert_array_almost_equal(values, img[:, :, 0])
      mesh = flat_mesh(5, 7)
      proj = surface._projection_matrix(
          mesh, affine_eye, (5, 7, 1), radius=0.1, n_points=10
      )
      assert_array_almost_equal(proj.toarray(), np.eye(proj.shape[0]))
      mask = np.ones(img.shape, dtype=int)
      mask[0] = 0
      proj = surface._projection_matrix(
          mesh,
          affine_eye,
          img.shape,
          radius=2.0,
          n_points=10,
          mask=mask,
      )
      proj = proj.toarray()
      # first row of the mesh is masked
      assert_array_almost_equal(proj.sum(axis=1)[:7], np.zeros(7))
      assert_array_almost_equal(
          proj.sum(axis=1)[7:], np.ones(proj.shape[0] - 7)
      )
      # mask and img should have the same shape
      with pytest.raises(ValueError):
          surface._projection_matrix(
              mesh, affine_eye, img.shape, mask=np.ones((3, 3, 2))
          )
  
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 27 for calling a global function with example usage: test_projection_matrix(affine_eye) without return types