code: def test_setup_source_space(tmp_path):
      """Test mne setup_source_space."""
      pytest.importorskip("nibabel")
      check_usage(mne_setup_source_space, force_help=True)
      # Using the sample dataset
      use_fname = op.join(tmp_path, "sources-src.fif")
      # Test  command
      with ArgvSetter(
          (
              "--src",
              use_fname,
              "-d",
              subjects_dir,
              "-s",
              "sample",
              "--morph",
              "sample",
              "--add-dist",
              "False",
              "--ico",
              "3",
              "--verbose",
          )
      ):
          mne_setup_source_space.run()
      src = read_source_spaces(use_fname)
      assert len(src) == 2
      with pytest.raises(Exception):
          with ArgvSetter(
              (
                  "--src",
                  use_fname,
                  "-d",
                  subjects_dir,
                  "-s",
                  "sample",
                  "--ico",
                  "3",
                  "--oct",
                  "3",
              )
          ):
              assert mne_setup_source_space.run()
      with pytest.raises(Exception):
          with ArgvSetter(
              (
                  "--src",
                  use_fname,
                  "-d",
                  subjects_dir,
                  "-s",
                  "sample",
                  "--ico",
                  "3",
                  "--spacing",
                  "10",
              )
          ):
              assert mne_setup_source_space.run()
      with pytest.raises(Exception):
          with ArgvSetter(
              (
                  "--src",
                  use_fname,
                  "-d",
                  subjects_dir,
                  "-s",
                  "sample",
                  "--ico",
                  "3",
                  "--spacing",
                  "10",
                  "--oct",
                  "3",
              )
          ):
              assert mne_setup_source_space.run()
  
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 16 for calling a global function with example usage: test_setup_source_space(tmp_path) without return types