code: def _check_mri(mri, subject, subjects_dir):
      """Check whether an mri exists in the Freesurfer subject directory."""
      _validate_type(mri, "path-like", "mri")
      if op.isfile(mri) and op.basename(mri) != mri:
          return mri
      if not op.isfile(mri):
          if subject is None:
              raise FileNotFoundError(
                  f"MRI file {mri!r} not found and no subject provided"
              )
          subjects_dir = str(
              get_subjects_dir(subjects_dir, raise_error=True)
          )
          mri = op.join(subjects_dir, subject, "mri", mri)
          if not op.isfile(mri):
              raise FileNotFoundError(f"MRI file {mri!r} not found")
      if op.basename(mri) == mri:
          err = (
              f"Ambiguous filename - found {mri!r} in current folder.\n"
              "If this is correct prefix name with relative or absolute path"
          )
          raise OSError(err)
      return mri
  
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 18 for calling a global function with example usage: _check_mri(mri, subject, subjects_dir) and returns: mri, mri