code: def test_min_distance_fit_dipole():
      """Test dipole min_dist to inner_skull."""
      subject = "sample"
      raw = read_raw_fif(fname_raw, preload=True)
  
      # select eeg data
      picks = pick_types(raw.info, meg=False, eeg=True, exclude="bads")
      info = pick_info(raw.info, picks)
  
      # Let's use cov = Identity
      cov = read_cov(fname_cov)
      cov["data"] = np.eye(cov["data"].shape[0])
  
      # Simulated scal map
      simulated_scalp_map = np.zeros(picks.shape[0])
      simulated_scalp_map[27:34] = 1
  
      simulated_scalp_map = simulated_scalp_map[:, None]
  
      evoked = EvokedArray(simulated_scalp_map, info, tmin=0)
  
      min_dist = 5.0  # distance in mm
  
      bem = read_bem_solution(fname_bem)
      dip, residual = fit_dipole(
          evoked, cov, bem, fname_trans, min_dist=min_dist, tol=1e-4
      )
      assert isinstance(residual, Evoked)
  
      dist = _compute_depth(
          dip, fname_bem, fname_trans, subject, subjects_dir
      )
  
      # Constraints are not exact, so bump the minimum slightly
      assert min_dist - 0.1 < (dist[0] * 1000.0) < (min_dist + 1.0)
  
      with pytest.raises(
          ValueError, match="min_dist should be positive"
      ):
          fit_dipole(evoked, cov, fname_bem, fname_trans, -1.0)
  
imports: import os
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_array_less
  from mne import Dipole, DipoleFixed, Epochs, Evoked, EvokedArray, SourceEstimate, convert_forward_solution, fit_dipole, head_to_mni, make_ad_hoc_cov, make_fixed_length_events, make_forward_solution, make_sphere_model, pick_info, pick_types, read_cov, read_dipole, read_evokeds, read_forward_solution, read_source_spaces, transform_surface_to, write_evokeds
  from mne._fiff.constants import FIFF
  from mne.bem import _bem_find_surface, read_bem_solution
  from mne.datasets import testing
  from mne.dipole import _BDIP_ERROR_KEYS, get_phantom_dipoles
  from mne.io import read_raw_ctf, read_raw_fif
  from mne.proj import make_eeg_average_ref_proj
  from mne.simulation import simulate_evoked
  from mne.surface import _compute_nearest
  from mne.transforms import _get_trans, apply_trans
  from mne.utils import _record_warnings, requires_mne, run_subprocess
label_desc: Use image node_id 8 for calling a global function with example usage: test_min_distance_fit_dipole() without return types