code: def _ensure_image_in_surface_RAS(image, subject, subjects_dir):
      """Check if the image is in Freesurfer surface RAS space."""
      nib = _import_nibabel("load a volume image")
      if not isinstance(image, nib.spatialimages.SpatialImage):
          image = nib.load(image)
      image = nib.MGHImage(
          image.dataobj.astype(np.float32), image.affine
      )
      fs_img = nib.load(
          op.join(subjects_dir, subject, "mri", "brain.mgz")
      )
      if not np.allclose(image.affine, fs_img.affine, atol=1e-6):
          raise RuntimeError(
              "The `image` is not aligned to Freesurfer "
              "surface RAS space. This space is required as "
              "it is the space where the anatomical "
              "segmentation and reconstructed surfaces are"
          )
      return image
  
imports: import os.path
  from gzip import GzipFile
  from pathlib import Path
  import numpy
  from ._fiff.constants import FIFF
  from ._fiff.meas_info import read_fiducials
  from .surface import _read_mri_surface, read_surface
  from .transforms import Transform, _ensure_trans, apply_trans, combine_transforms, invert_transform, read_ras_mni_t
  from .utils import _check_fname, _check_option, _import_nibabel, _validate_type, get_subjects_dir, logger, verbose
label_desc: Use image node_id 14 for calling a global function with example usage: _ensure_image_in_surface_RAS(image, subject, subjects_dir) and returns: image