code: def test_read_write_head_pos(tmp_path):
      """Test reading and writing head position quaternion parameters."""
      temp_name = tmp_path / "temp.pos"
      # This isn't a 100% valid quat matrix but it should be okay for tests
      head_pos_rand = np.random.RandomState(0).randn(20, 10)
      # This one is valid
      head_pos_read = read_head_pos(pos_fname)
      for head_pos_orig in (head_pos_rand, head_pos_read):
          write_head_pos(temp_name, head_pos_orig)
          head_pos = read_head_pos(temp_name)
          assert_allclose(head_pos_orig, head_pos, atol=1e-3)
      # Degenerate cases
      pytest.raises(
          TypeError, write_head_pos, 0, head_pos_read
      )  # not filename
      pytest.raises(
          ValueError, write_head_pos, temp_name, "foo"
      )  # not array
      pytest.raises(
          ValueError, write_head_pos, temp_name, head_pos_read[:, :9]
      )
      pytest.raises(TypeError, read_head_pos, 0)
      pytest.raises(OSError, read_head_pos, "101")
  
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 2 for calling a global function with example usage: test_read_write_head_pos(tmp_path) without return types