code: def _quaternion_align(
      from_frame, to_frame, from_pts, to_pts, diff_tol=1e-4
  ):
      """Perform an alignment using the unit quaternions (modifies points)."""
      assert from_pts.shape[1] == to_pts.shape[1] == 3
      trans = _quat_to_affine(_fit_matched_points(from_pts, to_pts)[0])
  
      # Test the transformation and print the results
      logger.info("    Quaternion matching (desired vs. transformed):")
      for fro, to in zip(from_pts, to_pts):
          rr = apply_trans(trans, fro)
          diff = np.linalg.norm(to - rr)
          logger.info(
              "    %7.2f %7.2f %7.2f mm <-> %7.2f %7.2f %7.2f mm "
              "(orig : %7.2f %7.2f %7.2f mm) diff = %8.3f mm"
              % (
                  tuple(1000 * to)
                  + tuple(1000 * rr)
                  + tuple(1000 * fro)
                  + (1000 * diff,)
              )
          )
          if diff > diff_tol:
              raise RuntimeError(
                  "Something is wrong: quaternion matching did "
                  "not work (see above)"
              )
      return Transform(from_frame, to_frame, trans)
  
imports: import numpy
  from ..._fiff.constants import FIFF
  from ...transforms import Transform, _fit_matched_points, _quat_to_affine, apply_trans, combine_transforms, get_ras_to_neuromag_trans, invert_transform
  from ...utils import logger
  from .constants import CTF
label_desc: Use image node_id 2 for calling a global function with example usage: _quaternion_align(from_frame, to_frame, from_pts, to_pts, diff_tol) and returns: Transform