code: def extract_chpi_locs_ctf(raw, verbose=None):
      r"""Extract cHPI locations from CTF data.
  
      Parameters
      ----------
      raw : instance of Raw
          Raw data with CTF cHPI information.
      %(verbose)s
  
      Returns
      -------
      %(chpi_locs)s
  
      Notes
      -----
      CTF continuous head monitoring stores the x,y,z location (m) of each chpi
      coil as separate channels in the dataset:
  
      - ``HLC001[123]\\*`` - nasion
      - ``HLC002[123]\\*`` - lpa
      - ``HLC003[123]\\*`` - rpa
  
      This extracts these positions for use with
      :func:`~mne.chpi.compute_head_pos`.
  
      .. versionadded:: 0.20
      """
      # Pick channels corresponding to the cHPI positions
      hpi_picks = pick_channels_regexp(
          raw.info["ch_names"], "HLC00[123][123].*"
      )
  
      # make sure we get 9 channels
      if len(hpi_picks) != 9:
          raise RuntimeError("Could not find all 9 cHPI channels")
  
      # get indices in alphabetical order
      sorted_picks = np.array(
          sorted(hpi_picks, key=lambda k: raw.info["ch_names"][k])
      )
  
      # make picks to match order of dig cardinial ident codes.
      # LPA (HPIC002[123]-*), NAS(HPIC001[123]-*), RPA(HPIC003[123]-*)
      hpi_picks = sorted_picks[[3, 4, 5, 0, 1, 2, 6, 7, 8]]
      del sorted_picks
  
      # process the entire run
      time_sl = slice(0, len(raw.times))
      chpi_data = raw[hpi_picks, time_sl][0]
  
      # transforms
      tmp_trans = _make_ctf_coord_trans_set(None, None)
      ctf_dev_dev_t = tmp_trans["t_ctf_dev_dev"]
      del tmp_trans
  
      # find indices where chpi locations change
      indices = [0]
      indices.extend(
          np.where(np.all(np.diff(chpi_data, axis=1), axis=0))[0] + 1
      )
      # data in channels are in ctf device coordinates (cm)
      rrs = chpi_data[:, indices].T.reshape(len(indices), 3, 3)  # m
      # map to mne device coords
      rrs = apply_trans(ctf_dev_dev_t, rrs)
      gofs = np.ones(rrs.shape[:2])  # not encoded, set all good
      moments = np.zeros(rrs.shape)  # not encoded, set all zero
      times = raw.times[indices] + raw._first_time
      return dict(rrs=rrs, gofs=gofs, times=times, moments=moments)
  
imports: import copy
  import itertools
  from functools import partial
  import numpy
  from scipy.linalg import orth
  from scipy.optimize import fmin_cobyla
  from scipy.spatial.distance import cdist
  from ._fiff.constants import FIFF
  from ._fiff.meas_info import Info, _simplify_info
  from ._fiff.pick import _picks_to_idx, pick_channels, pick_channels_regexp, pick_info, pick_types
  from ._fiff.proj import Projection, setup_proj
  from .channels.channels import _get_meg_system
  from .cov import compute_whitener, make_ad_hoc_cov
  from .dipole import _make_guesses
  from .event import find_events
  from .fixes import jit
  from .forward import _concatenate_coils, _create_meg_coils, _magnetic_dipole_field_vec
  from .io import BaseRaw
  from .io.ctf.trans import _make_ctf_coord_trans_set
  from .io.kit.constants import KIT
  from .io.kit.kit import RawKIT
  from .preprocessing.maxwell import _get_mf_picks_fix_mags, _prep_mf_coils, _regularize_out, _sss_basis
  from .transforms import _angle_between_quats, _fit_matched_points, _quat_to_affine, als_ras_trans, apply_trans, invert_transform, quat_to_rot, rot_to_quat
  from .utils import ProgressBar, _check_fname, _check_option, _on_missing, _pl, _validate_type, _verbose_safe_false, logger, use_log_level, verbose, warn
label_desc: Use image node_id 4 for calling a global function with example usage: extract_chpi_locs_ctf(raw, verbose) and returns: dict