code: def test_mxne_vol_sphere():
      """Test (TF-)MxNE with a sphere forward and volumic source space."""
      evoked = read_evokeds(fname_data, condition=0, baseline=(None, 0))
      evoked.crop(tmin=-0.05, tmax=0.2)
      cov = read_cov(fname_cov)
  
      evoked_l21 = evoked.copy()
      evoked_l21.crop(tmin=0.081, tmax=0.1)
  
      info = evoked.info
      sphere = mne.make_sphere_model(
          r0=(0.0, 0.0, 0.0), head_radius=0.080
      )
      src = mne.setup_volume_source_space(
          subject=None,
          pos=15.0,
          mri=None,
          sphere=(0.0, 0.0, 0.0, 0.08),
          bem=None,
          mindist=5.0,
          exclude=2.0,
          sphere_units="m",
      )
      fwd = mne.make_forward_solution(
          info, trans=None, src=src, bem=sphere, eeg=False, meg=True
      )
  
      alpha = 80.0
  
      # Computing inverse with restricted orientations should also work, since
      # we have a discrete source space.
      stc = mixed_norm(
          evoked_l21,
          fwd,
          cov,
          alpha,
          loose=0.2,
          return_residual=False,
          maxit=3,
          tol=1e-8,
          active_set_size=10,
      )
      assert_array_almost_equal(stc.times, evoked_l21.times, 5)
  
      # irMxNE tests
      with catch_logging() as log:
          stc = mixed_norm(
              evoked_l21,
              fwd,
              cov,
              alpha,
              n_mxne_iter=1,
              maxit=30,
              tol=1e-8,
              active_set_size=10,
              verbose=True,
          )
      assert isinstance(stc, VolSourceEstimate)
      assert_array_almost_equal(stc.times, evoked_l21.times, 5)
      assert_var_exp_log(log.getvalue(), 9, 11)  # 10.2
  
      # Compare orientation obtained using fit_dipole and gamma_map
      # for a simulated evoked containing a single dipole
      stc = mne.VolSourceEstimate(
          50e-9 * np.random.RandomState(42).randn(1, 4),
          vertices=[stc.vertices[0][:1]],
          tmin=stc.tmin,
          tstep=stc.tstep,
      )
      evoked_dip = mne.simulation.simulate_evoked(
          fwd, stc, info, cov, nave=1e9, use_cps=True
      )
  
      dip_mxne = mixed_norm(
          evoked_dip,
          fwd,
          cov,
          alpha=80,
          n_mxne_iter=1,
          maxit=30,
          tol=1e-8,
          active_set_size=10,
          return_as_dipoles=True,
      )
  
      amp_max = [np.max(d.amplitude) for d in dip_mxne]
      dip_mxne = dip_mxne[np.argmax(amp_max)]
      assert dip_mxne.pos[0] in src[0]["rr"][stc.vertices[0]]
  
      dip_fit = mne.fit_dipole(evoked_dip, cov, sphere)[0]
      assert np.abs(np.dot(dip_fit.ori[0], dip_mxne.ori[0])) > 0.99
      dist = 1000 * np.linalg.norm(dip_fit.pos[0] - dip_mxne.pos[0])
      assert dist < 4.0  # within 4 mm
  
      # Do with TF-MxNE for test memory savings
      alpha = 60.0  # overall regularization parameter
      l1_ratio = 0.01  # temporal regularization proportion
  
      stc, _ = tf_mixed_norm(
          evoked,
          fwd,
          cov,
          maxit=3,
          tol=1e-4,
          tstep=16,
          wsize=32,
          window=0.1,
          alpha=alpha,
          l1_ratio=l1_ratio,
          return_residual=True,
      )
      assert isinstance(stc, VolSourceEstimate)
      assert_array_almost_equal(stc.times, evoked.times, 5)
  
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_array_less
  import mne
  from mne import convert_forward_solution, read_cov, read_evokeds, read_forward_solution
  from mne.datasets import testing
  from mne.dipole import Dipole
  from mne.inverse_sparse import mixed_norm, tf_mixed_norm
  from mne.inverse_sparse.mxne_inverse import _compute_mxne_sure, _split_gof, make_stc_from_dipoles
  from mne.inverse_sparse.mxne_optim import norm_l2inf
  from mne.label import read_label
  from mne.minimum_norm import apply_inverse, make_inverse_operator
  from mne.minimum_norm.tests.test_inverse import assert_stc_res, assert_var_exp_log
  from mne.simulation import simulate_evoked, simulate_sparse_stc
  from mne.source_estimate import VolSourceEstimate
  from mne.utils import _record_warnings, assert_stcs_equal, catch_logging
label_desc: Use image node_id 3 for calling a global function with example usage: test_mxne_vol_sphere() without return types