code: def test_decimate(tmp_path):
      """Test decimation of digitizer headshapes with too many points."""
      # load headshape and convert to meters
      hsp_mm = _get_ico_surface(5)["rr"] * 100
      hsp_m = hsp_mm / 1000.0
  
      # save headshape to a file in mm in temporary directory
      sphere_hsp_path = tmp_path / "test_sphere.txt"
      np.savetxt(sphere_hsp_path, hsp_mm)
  
      # read in raw data using spherical hsp, and extract new hsp
      with pytest.warns(
          RuntimeWarning,
          match="was automatically downsampled .* FastScan",
      ):
          raw = read_raw_kit(
              sqd_path, mrk_path, elp_txt_path, sphere_hsp_path
          )
      # collect headshape from raw (should now be in m)
      hsp_dec = np.array([dig["r"] for dig in raw.info["dig"]])[8:]
  
      # with 10242 points and _decimate_points set to resolution of 5 mm, hsp_dec
      # should be a bit over 5000 points. If not, something is wrong or
      # decimation resolution has been purposefully changed
      assert len(hsp_dec) > 5000
  
      # should have similar size, distance from center
      dist = np.sqrt(
          np.sum((hsp_m - np.mean(hsp_m, axis=0)) ** 2, axis=1)
      )
      dist_dec = np.sqrt(
          np.sum((hsp_dec - np.mean(hsp_dec, axis=0)) ** 2, axis=1)
      )
      hsp_rad = np.mean(dist)
      hsp_dec_rad = np.mean(dist_dec)
      assert_array_almost_equal(hsp_rad, hsp_dec_rad, decimal=3)
  
imports: from pathlib import Path
  import numpy
  import pytest
  import scipy.io
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy import linalg
  import mne
  from mne import Epochs, find_events, pick_types, read_events
  from mne._fiff.constants import FIFF
  from mne.datasets.testing import requires_testing_data
  from mne.io import read_epochs_kit, read_raw_fif, read_raw_kit
  from mne.io.kit.constants import KIT
  from mne.io.kit.coreg import read_sns
  from mne.io.kit.kit import get_kit_info
  from mne.io.tests.test_raw import _test_raw_reader
  from mne.surface import _get_ico_surface
  from mne.transforms import apply_trans
  from mne.utils import assert_dig_allclose
label_desc: Use image node_id 9 for calling a global function with example usage: test_decimate(tmp_path) without return types