code: def test_calculate_chpi_coil_locs_artemis():
      """Test computing just cHPI locations."""
      raw = read_raw_fif(
          chpi_fif_fname, allow_maxshield="yes", preload=True
      )
      # This is a little hack (aliasing while decimating) to make it much faster
      # for testing purposes only. We can relax this later if we find it breaks
      # something.
      raw_dec = _decimate_chpi(raw, 15)
      times, cHPI_digs = _calculate_chpi_coil_locs(
          raw_dec, verbose="debug"
      )
  
      # spot check
      assert_allclose(times[0], 9.0, atol=1e-2)
      assert_allclose(
          cHPI_digs[0][2]["r"],
          [-0.01937833, 0.00346804, 0.06331209],
          atol=1e-3,
      )
      assert_allclose(cHPI_digs[0][2]["gof"], 0.9957, atol=1e-3)
  
      assert_allclose(
          cHPI_digs[0][4]["r"], [-0.0655, 0.0755, 0.0004], atol=3e-3
      )
      assert_allclose(cHPI_digs[0][4]["gof"], 0.9323, atol=1e-3)
      _check_dists(raw.info, cHPI_digs[0], n_bad=1)
  
      # test on 5k artemis data
      raw = read_raw_artemis123(art_fname, preload=True)
      times, cHPI_digs = _calculate_chpi_coil_locs(raw, verbose="debug")
  
      assert len(np.setdiff1d(times, raw.times + raw.first_time)) == 0
      # Should be somewhere around 1.5 s, depending on coil GOF values
      # around 0.98 it can change
      assert_allclose(times[5], 1.5, atol=2e-1)
      assert_allclose(cHPI_digs[5][0]["gof"], 0.995, atol=5e-3)
      assert_allclose(
          cHPI_digs[5][0]["r"], [-0.0157, 0.0655, 0.0018], atol=1e-3
      )
      _check_dists(raw.info, cHPI_digs[5])
      coil_amplitudes = compute_chpi_amplitudes(raw)
      with pytest.raises(ValueError, match="too_close"):
          compute_chpi_locs(raw.info, coil_amplitudes, too_close="foo")
      # ensure values are in a reasonable range
      amps = np.linalg.norm(coil_amplitudes["slopes"], axis=-1)
      amps /= coil_amplitudes["slopes"].shape[-1]
      assert amps.shape == (len(coil_amplitudes["times"]), 3)
      assert_array_less(amps, 1e-11)
      assert_array_less(1e-13, amps)
      # with nan amplitudes (i.e., cHPI off) it should return an empty array,
      # but still one that is 3D
      coil_amplitudes["slopes"].fill(np.nan)
      chpi_locs = compute_chpi_locs(raw.info, coil_amplitudes)
      assert chpi_locs["rrs"].shape == (0, 3, 3)
      pos = compute_head_pos(raw.info, chpi_locs)
      assert pos.shape == (0, 10)
  
imports: from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_array_less
  from scipy.interpolate import interp1d
  from scipy.spatial.distance import cdist
  from mne import pick_info, pick_types
  from mne._fiff.constants import FIFF
  from mne.chpi import _chpi_locs_to_times_dig, _compute_good_distances, _get_hpi_initial_fit, _setup_ext_proj, compute_chpi_amplitudes, compute_chpi_locs, compute_chpi_snr, compute_head_pos, extract_chpi_locs_ctf, extract_chpi_locs_kit, filter_chpi, get_active_chpi, get_chpi_info, head_pos_to_trans_rot_t, read_head_pos, write_head_pos
  from mne.datasets import testing
  from mne.forward._compute_forward import _MAG_FACTOR
  from mne.io import RawArray, read_info, read_raw_artemis123, read_raw_ctf, read_raw_fif, read_raw_kit
  from mne.simulation import add_chpi
  from mne.transforms import _angle_between_quats, rot_to_quat
  from mne.utils import assert_meg_snr, catch_logging, object_diff, verbose
  from mne.viz import plot_head_positions
label_desc: Use image node_id 18 for calling a global function with example usage: test_calculate_chpi_coil_locs_artemis() without return types