code: def test_watershed_bem(tmp_path):
      """Test mne watershed bem."""
      pytest.importorskip("nibabel")
      check_usage(mne_watershed_bem)
      # from T1.mgz
      Mdc = np.array([[-1, 0, 0], [0, 0, -1], [0, 1, 0]])
      Pxyz_c = np.array([-5.273613, 9.039085, -27.287964])
      # Copy necessary files to tempdir
      tempdir = str(tmp_path)
      mridata_path = op.join(subjects_dir, "sample", "mri")
      subject_path_new = op.join(tempdir, "sample")
      mridata_path_new = op.join(subject_path_new, "mri")
      os.makedirs(mridata_path_new)
      new_fname = op.join(mridata_path_new, "T1.mgz")
      shutil.copyfile(op.join(mridata_path, "T1.mgz"), new_fname)
      old_mode = os.stat(new_fname).st_mode
      os.chmod(new_fname, 0)
      args = ("-d", tempdir, "-s", "sample", "-o")
      with pytest.raises(
          PermissionError, match=r"read permissions.*T1\.mgz"
      ):
          with ArgvSetter(args):
              mne_watershed_bem.run()
      os.chmod(new_fname, old_mode)
      for s in ("outer_skin", "outer_skull", "inner_skull"):
          assert not op.isfile(
              op.join(subject_path_new, "bem", f"{s}.surf")
          )
      with ArgvSetter(args):
          mne_watershed_bem.run()
  
      kwargs = dict(rtol=1e-5, atol=1e-5)
      for s in ("outer_skin", "outer_skull", "inner_skull"):
          rr, tris, vol_info = read_surface(
              op.join(subject_path_new, "bem", f"{s}.surf"),
              read_metadata=True,
          )
          assert_equal(len(tris), 20480)
          assert_equal(tris.min(), 0)
          assert_equal(rr.shape[0], tris.max() + 1)
          # compare the volume info to the mgz header
          assert_allclose(vol_info["xras"], Mdc[0], **kwargs)
          assert_allclose(vol_info["yras"], Mdc[1], **kwargs)
          assert_allclose(vol_info["zras"], Mdc[2], **kwargs)
          assert_allclose(vol_info["cras"], Pxyz_c, **kwargs)
  
imports: import glob
  import os
  import shutil
  from os import path
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_equal
  import mne
  from mne import concatenate_raws, read_bem_solution, read_bem_surfaces, read_source_spaces, read_surface
  from mne.bem import ConductorModel, convert_flash_mris
  from mne.commands import mne_anonymize, mne_browse_raw, mne_bti2fiff, mne_clean_eog_ecg, mne_compare_fiff, mne_compute_proj_ecg, mne_compute_proj_eog, mne_coreg, mne_flash_bem, mne_kit2fiff, mne_make_scalp_surfaces, mne_prepare_bem_model, mne_report, mne_setup_forward_model, mne_setup_source_space, mne_show_fiff, mne_show_info, mne_surf2bem, mne_sys_info, mne_watershed_bem, mne_what
  from mne.datasets import testing
  from mne.io import read_info, read_raw_fif, show_fiff
  from mne.utils import ArgvSetter, _record_warnings, _stamp_to_dt, requires_freesurfer, requires_mne
label_desc: Use image node_id 14 for calling a global function with example usage: test_watershed_bem(tmp_path) without return types