code: def test_simulate_calculate_head_pos_chpi():
      """Test calculation of cHPI positions with simulated data."""
      # Read info dict from raw FIF file
      info = read_info(raw_fname)
      # Tune the info structure
      chpi_channel = "STI201"
      ncoil = len(info["hpi_results"][0]["order"])
      coil_freq = 10 + np.arange(ncoil) * 5
      hpi_subsystem = {
          "event_channel": chpi_channel,
          "hpi_coils": [
              {
                  "event_bits": np.array(
                      [256, 0, 256, 256], dtype=np.int32
                  )
              },
              {
                  "event_bits": np.array(
                      [512, 0, 512, 512], dtype=np.int32
                  )
              },
              {
                  "event_bits": np.array(
                      [1024, 0, 1024, 1024], dtype=np.int32
                  )
              },
              {
                  "event_bits": np.array(
                      [2048, 0, 2048, 2048], dtype=np.int32
                  )
              },
          ],
          "ncoil": ncoil,
      }
  
      with info._unlock():
          info["hpi_subsystem"] = hpi_subsystem
          for fi, freq in enumerate(coil_freq):
              info["hpi_meas"][0]["hpi_coils"][fi]["coil_freq"] = freq
          info["sfreq"] = 100.0  # this will speed it up a lot
      picks = pick_types(
          info, meg=True, stim=True, eeg=False, exclude=[]
      )
      info = pick_info(info, picks)
      info["chs"][info["ch_names"].index("STI 001")][
          "ch_name"
      ] = "STI201"
      info._update_redundant()
      with info._unlock():
          info["projs"] = []
  
      info_trans = info["dev_head_t"]["trans"].copy()
  
      dev_head_pos_ini = np.concatenate(
          [rot_to_quat(info_trans[:3, :3]), info_trans[:3, 3]]
      )
      ez = np.array(
          [0, 0, 1]
      )  # Unit vector in z-direction of head coordinates
  
      # Define some constants
      duration = 10  # Time / s
  
      # Quotient of head position sampling frequency
      # and raw sampling frequency
      head_pos_sfreq_quotient = 0.01
  
      # Round number of head positions to the next integer
      S = int(duration * info["sfreq"] * head_pos_sfreq_quotient)
      assert S == 10
      dz = 0.001  # Shift in z-direction is 0.1mm for each step
  
      dev_head_pos = np.zeros((S, 10))
      dev_head_pos[:, 0] = (
          np.arange(S) * info["sfreq"] * head_pos_sfreq_quotient
      )
      dev_head_pos[:, 1:4] = dev_head_pos_ini[:3]
      dev_head_pos[:, 4:7] = dev_head_pos_ini[3:] + np.outer(
          np.arange(S) * dz, ez
      )
      dev_head_pos[:, 7] = 1.0
  
      # m/s
      dev_head_pos[:, 9] = dz / (
          info["sfreq"] * head_pos_sfreq_quotient
      )
  
      # Round number of samples to the next integer
      raw_data = np.zeros(
          (len(picks), int(duration * info["sfreq"] + 0.5))
      )
      raw = RawArray(raw_data, info)
      add_chpi(raw, dev_head_pos)
      quats = _calculate_chpi_positions(
          raw,
          t_step_min=raw.info["sfreq"] * head_pos_sfreq_quotient,
          t_step_max=raw.info["sfreq"] * head_pos_sfreq_quotient,
          t_window=1.0,
      )
      _assert_quats(
          quats,
          dev_head_pos,
          dist_tol=0.001,
          angle_tol=1.0,
          vel_atol=4e-3,
      )
  
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 15 for calling a global function with example usage: test_simulate_calculate_head_pos_chpi() without return types