code: def _pick_isotrak_and_hpi_coils(res4, coils, t):
      """Pick the HPI coil locations given in device coordinates."""
      if coils is None:
          return list(), list()
      dig = list()
      hpi_result = dict(dig_points=list())
      n_coil_dev = 0
      n_coil_head = 0
      for p in coils:
          if p["valid"]:
              if p["kind"] in [
                  CTF.CTFV_COIL_LPA,
                  CTF.CTFV_COIL_RPA,
                  CTF.CTFV_COIL_NAS,
              ]:
                  kind = FIFF.FIFFV_POINT_CARDINAL
                  ident = _ctf_to_fiff[p["kind"]]
              else:  # CTF.CTFV_COIL_SPARE
                  kind = FIFF.FIFFV_POINT_HPI
                  ident = p["kind"]
              if p["coord_frame"] == FIFF.FIFFV_MNE_COORD_CTF_DEVICE:
                  if t is None or t["t_ctf_dev_dev"] is None:
                      raise RuntimeError(
                          "No coordinate transformation "
                          "available for HPI coil locations"
                      )
                  d = dict(
                      kind=kind,
                      ident=ident,
                      r=apply_trans(t["t_ctf_dev_dev"], p["r"]),
                      coord_frame=FIFF.FIFFV_COORD_UNKNOWN,
                  )
                  hpi_result["dig_points"].append(d)
                  n_coil_dev += 1
              elif p["coord_frame"] == FIFF.FIFFV_MNE_COORD_CTF_HEAD:
                  if t is None or t["t_ctf_head_head"] is None:
                      raise RuntimeError(
                          "No coordinate transformation "
                          "available for (virtual) Polhemus data"
                      )
                  d = dict(
                      kind=kind,
                      ident=ident,
                      r=apply_trans(t["t_ctf_head_head"], p["r"]),
                      coord_frame=FIFF.FIFFV_COORD_HEAD,
                  )
                  dig.append(d)
                  n_coil_head += 1
      if n_coil_head > 0:
          logger.info(
              "    Polhemus data for %d HPI coils added" % n_coil_head
          )
      if n_coil_dev > 0:
          logger.info(
              "    Device coordinate locations for %d HPI coils added"
              % n_coil_dev
          )
      return dig, [hpi_result]
  
imports: import os.path
  from calendar import timegm
  from time import strptime
  import numpy
  from ..._fiff.constants import FIFF
  from ..._fiff.ctf_comp import _add_kind, _calibrate_comp
  from ..._fiff.meas_info import _empty_info
  from ..._fiff.write import get_new_file_id
  from ...annotations import Annotations
  from ...transforms import _coord_frame_name, apply_trans, combine_transforms, invert_transform
  from ...utils import _clean_names, logger, warn
  from .constants import CTF
label_desc: Use image node_id 1 for calling a global function with example usage: _pick_isotrak_and_hpi_coils(res4, coils, t) and returns: dig,  list, list,  list