code: def test_get_vertexcolor():
      fsaverage = fetch_surf_fsaverage()
      mesh = surface.load_surf_mesh(fsaverage["pial_left"])
      surf_map = np.arange(len(mesh[0]))
      colors = html_surface.colorscale("jet", surf_map, 10)
      vertexcolors = html_surface.get_vertexcolor(
          surf_map,
          colors["cmap"],
          colors["norm"],
          absolute_threshold=colors["abs_threshold"],
          bg_map=fsaverage["sulc_left"],
      )
      assert len(vertexcolors) == len(mesh[0])
      vertexcolors = html_surface.get_vertexcolor(
          surf_map,
          colors["cmap"],
          colors["norm"],
          absolute_threshold=colors["abs_threshold"],
      )
      assert len(vertexcolors) == len(mesh[0])
      # Surface map whose value in each vertex is
      # 1 if this vertex's curv > 0
      # 0 if this vertex's curv is 0
      # -1 if this vertex's curv < 0
      bg_map = np.sign(surface.load_surf_data(fsaverage["curv_left"]))
      bg_min, bg_max = np.min(bg_map), np.max(bg_map)
      assert bg_min < 0 or bg_max > 1
      vertexcolors_auto_normalized = html_surface.get_vertexcolor(
          surf_map,
          colors["cmap"],
          colors["norm"],
          absolute_threshold=colors["abs_threshold"],
          bg_map=bg_map,
      )
      assert len(vertexcolors_auto_normalized) == len(mesh[0])
      # Manually set values of background map between 0 and 1
      bg_map_normalized = (bg_map - bg_min) / (bg_max - bg_min)
      assert (
          np.min(bg_map_normalized) == 0
          and np.max(bg_map_normalized) == 1
      )
      vertexcolors_manually_normalized = html_surface.get_vertexcolor(
          surf_map,
          colors["cmap"],
          colors["norm"],
          absolute_threshold=colors["abs_threshold"],
          bg_map=bg_map_normalized,
      )
      assert len(vertexcolors_manually_normalized) == len(mesh[0])
      assert (
          vertexcolors_manually_normalized
          == vertexcolors_auto_normalized
      )
      # Scale background map between 0.25 and 0.75
      bg_map_scaled = bg_map_normalized / 2 + 0.25
      assert (
          np.min(bg_map_scaled) == 0.25
          and np.max(bg_map_scaled) == 0.75
      )
      vertexcolors_manually_rescaled = html_surface.get_vertexcolor(
          surf_map,
          colors["cmap"],
          colors["norm"],
          absolute_threshold=colors["abs_threshold"],
          bg_map=bg_map_scaled,
      )
      assert len(vertexcolors_manually_rescaled) == len(mesh[0])
      assert (
          vertexcolors_manually_rescaled != vertexcolors_auto_normalized
      )
      with pytest.warns(
          DeprecationWarning,
          match=(
              "The `darkness` parameter will be deprecated in release 0.13. "
              "We recommend setting `darkness` to None"
          ),
      ):
          vertexcolors = html_surface.get_vertexcolor(
              surf_map,
              colors["cmap"],
              colors["norm"],
              absolute_threshold=colors["abs_threshold"],
              bg_map=bg_map,
              darkness=0.5,
          )
  
file_path: nilearn/nilearn/plotting/tests/test_html_surface.py
imports: import json
  import numpy
  import pytest
  from nilearn import datasets, image, surface
  from nilearn._utils.exceptions import DimensionError
  from nilearn.datasets import fetch_surf_fsaverage
  from nilearn.image import get_data
  from nilearn.plotting import html_surface
  from nilearn.plotting.js_plotting_utils import decode
  from .test_js_plotting_utils import check_colors, check_html
label_desc: Use image node_id 2 for calling a global function with example usage: test_get_vertexcolor() without return types