code: def _make_trans_dig(curry_paths, info, curry_dev_dev_t):
      # Coordinate frame transformations and definitions
      no_msg = "Leaving device<->head transform as None"
      info["dev_head_t"] = None
      label_fname = curry_paths["labels"]
      key = "LANDMARKS" + CHANTYPES["meg"]
      lm = _read_curry_lines(label_fname, [key])[key]
      lm = np.array(lm, float)
      lm.shape = (-1, 3)
      if len(lm) == 0:
          # no dig
          logger.info(no_msg + " (no landmarks found)")
          return
      lm /= 1000.0
      key = "LM_REMARKS" + CHANTYPES["meg"]
      remarks = _read_curry_lines(label_fname, [key])[key]
      assert len(remarks) == len(lm)
      with info._unlock():
          info["dig"] = list()
      cards = dict()
      for remark, r in zip(remarks, lm):
          kind = ident = None
          if remark in _card_dict:
              kind = FIFF.FIFFV_POINT_CARDINAL
              ident = _card_dict[remark]
              cards[ident] = r
          elif remark.startswith("HPI"):
              kind = FIFF.FIFFV_POINT_HPI
              ident = int(remark[3:]) - 1
          if kind is not None:
              info["dig"].append(
                  dict(
                      kind=kind,
                      ident=ident,
                      r=r,
                      coord_frame=FIFF.FIFFV_COORD_UNKNOWN,
                  )
              )
      with info._unlock():
          info["dig"].sort(key=lambda x: (x["kind"], x["ident"]))
      has_cards = len(cards) == 3
      has_hpi = "hpi" in curry_paths
      if has_cards and has_hpi:  # have all three
          logger.info(
              "Composing device<->head transformation from dig points"
          )
          hpi_u = np.array(
              [
                  d["r"]
                  for d in info["dig"]
                  if d["kind"] == FIFF.FIFFV_POINT_HPI
              ],
              float,
          )
          hpi_c = np.ascontiguousarray(
              _first_hpi(curry_paths["hpi"])[: len(hpi_u), 1:4]
          )
          unknown_curry_t = _quaternion_align(
              "unknown", "ctf_meg", hpi_u, hpi_c, 1e-2
          )
          angle = np.rad2deg(
              _angle_between_quats(
                  np.zeros(3),
                  rot_to_quat(unknown_curry_t["trans"][:3, :3]),
              )
          )
          dist = 1000 * np.linalg.norm(unknown_curry_t["trans"][:3, 3])
          logger.info(
              "   Fit a %0.1f° rotation, %0.1f mm translation"
              % (angle, dist)
          )
          unknown_dev_t = combine_transforms(
              unknown_curry_t, curry_dev_dev_t, "unknown", "meg"
          )
          unknown_head_t = Transform(
              "unknown",
              "head",
              get_ras_to_neuromag_trans(
                  *(
                      cards[key]
                      for key in (
                          FIFF.FIFFV_POINT_NASION,
                          FIFF.FIFFV_POINT_LPA,
                          FIFF.FIFFV_POINT_RPA,
                      )
                  )
              ),
          )
          with info._unlock():
              info["dev_head_t"] = combine_transforms(
                  invert_transform(unknown_dev_t),
                  unknown_head_t,
                  "meg",
                  "head",
              )
              for d in info["dig"]:
                  d.update(
                      coord_frame=FIFF.FIFFV_COORD_HEAD,
                      r=apply_trans(unknown_head_t, d["r"]),
                  )
      else:
          if has_cards:
              no_msg += " (no .hpi file found)"
          elif has_hpi:
              no_msg += " (not all cardinal points found)"
          else:
              no_msg += " (neither cardinal points nor .hpi file found)"
          logger.info(no_msg)
  
imports: import os.path
  import re
  from collections import namedtuple
  from datetime import datetime, timezone
  from pathlib import Path
  import numpy
  from ..._fiff._digitization import _make_dig_points
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import create_info
  from ..._fiff.tag import _coil_trans_to_loc
  from ..._fiff.utils import _mult_cal_one, _read_segments_file
  from ...annotations import Annotations
  from ...surface import _normal_orth
  from ...transforms import Transform, _angle_between_quats, apply_trans, combine_transforms, get_ras_to_neuromag_trans, invert_transform, rot_to_quat
  from ...utils import _check_fname, check_fname, logger, verbose
  from ..base import BaseRaw
  from ..ctf.trans import _quaternion_align
label_desc: Use image node_id 6 for calling a global function with example usage: _make_trans_dig(curry_paths, info, curry_dev_dev_t) without return types