code: def test_rap_music_sphere():
      """Test RAP-MUSIC with real data, sphere model, MEG only."""
      evoked, noise_cov = _get_data(ch_decim=8)
      sphere = mne.make_sphere_model(r0=(0.0, 0.0, 0.04))
      src = mne.setup_volume_source_space(
          subject=None,
          pos=10.0,
          sphere=(0.0, 0.0, 40, 65.0),
          mindist=5.0,
          exclude=0.0,
          sphere_units="mm",
      )
      forward = mne.make_forward_solution(
          evoked.info, trans=None, src=src, bem=sphere
      )
  
      with catch_logging() as log:
          dipoles = rap_music(
              evoked, forward, noise_cov, n_dipoles=2, verbose=True
          )
      assert_var_exp_log(log.getvalue(), 47, 49)
      # Test that there is one dipole on each hemisphere
      pos = np.array([dip.pos[0] for dip in dipoles])
      assert pos.shape == (2, 3)
      assert (pos[:, 0] < 0).sum() == 1
      assert (pos[:, 0] > 0).sum() == 1
      # Check the amplitude scale
      assert 1e-10 < dipoles[0].amplitude[0] < 1e-7
      # Check the orientation
      dip_fit = mne.fit_dipole(evoked, noise_cov, sphere)[0]
      assert (
          np.max(np.abs(np.dot(dip_fit.ori, dipoles[0].ori[0]))) > 0.99
      )
      assert (
          np.max(np.abs(np.dot(dip_fit.ori, dipoles[1].ori[0]))) > 0.99
      )
      idx = dip_fit.gof.argmax()
      dist = np.linalg.norm(dipoles[0].pos[idx] - dip_fit.pos[idx])
      assert 0.004 <= dist < 0.007
      assert_allclose(dipoles[0].gof[idx], dip_fit.gof[idx], atol=3)
  
file_path: mne-python/mne/beamformer/tests/test_rap_music.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose
  from scipy import linalg
  import mne
  from mne.beamformer import rap_music, trap_music
  from mne.cov import regularize
  from mne.datasets import testing
  from mne.minimum_norm.tests.test_inverse import assert_var_exp_log
  from mne.utils import catch_logging
label_desc: Use image node_id 5 for calling a global function with example usage: test_rap_music_sphere() without return types