code: def _get_fid_coords(dig, raise_error=True):
      fid_coords = Bunch(nasion=None, lpa=None, rpa=None)
      fid_coord_frames = dict()
  
      for d in dig:
          if d["kind"] == FIFF.FIFFV_POINT_CARDINAL:
              key = _cardinal_ident_mapping[d["ident"]]
              fid_coords[key] = d["r"]
              fid_coord_frames[key] = d["coord_frame"]
  
      if len(fid_coord_frames) > 0 and raise_error:
          if set(fid_coord_frames.keys()) != set(
              ["nasion", "lpa", "rpa"]
          ):
              raise ValueError(
                  "Some fiducial points are missing (got %s)."
                  % fid_coord_frames.keys()
              )
  
          if len(set(fid_coord_frames.values())) > 1:
              raise ValueError(
                  "All fiducial points must be in the same coordinate system "
                  "(got %s)" % len(fid_coord_frames)
              )
  
      coord_frame = (
          fid_coord_frames.popitem()[1] if fid_coord_frames else None
      )
  
      return fid_coords, coord_frame
  
imports: import heapq
  from collections import Counter
  import numpy
  from ..utils import Bunch, _check_fname, _validate_type, logger, verbose, warn
  from .constants import FIFF, _coord_frame_named
  from .tag import read_tag
  from .tree import dir_tree_find
  from .write import start_and_end_file, write_dig_points
label_desc: Use image node_id 8 for calling a global function with example usage: _get_fid_coords(dig, raise_error) and returns: fid_coords,  coord_frame