code: def test_plot_volume_source_estimates(
      mode, stype, init_t, want_t, init_p, want_p, bg_img
  ):
      """Test interactive plotting of volume source estimates."""
      pytest.importorskip("nibabel")
      pytest.importorskip("dipy")
      pytest.importorskip("nilearn")
      forward = read_forward_solution(fwd_fname)
      sample_src = forward["src"]
      if init_p is not None:
          init_p = np.array(init_p) / 1000.0
  
      vertices = [s["vertno"] for s in sample_src]
      n_verts = sum(len(v) for v in vertices)
      n_time = 2
      data = np.random.RandomState(0).rand(n_verts, n_time)
  
      if stype == "vec":
          stc = VolVectorSourceEstimate(
              np.tile(data[:, np.newaxis], (1, 3, 1)), vertices, 1, 1
          )
      else:
          assert stype == "s"
          stc = VolSourceEstimate(data, vertices, 1, 1)
      # sometimes get scalars/index warning
      with _record_warnings():
          with catch_logging() as log:
              fig = stc.plot(
                  sample_src,
                  subject="sample",
                  subjects_dir=subjects_dir,
                  mode=mode,
                  initial_time=init_t,
                  initial_pos=init_p,
                  bg_img=bg_img,
                  verbose=True,
              )
      log = log.getvalue()
      want_str = "t = %0.3f s" % want_t
      assert want_str in log, (want_str, init_t)
      want_str = "(%0.1f, %0.1f, %0.1f) mm" % want_p
      assert want_str in log, (want_str, init_p)
      for ax_idx in [0, 2, 3, 4]:
          _fake_click(fig, fig.axes[ax_idx], (0.3, 0.5))
      _fake_keypress(fig, "left")
      _fake_keypress(fig, "shift+right")
      if bg_img is not None:
          with pytest.raises(
              FileNotFoundError, match="MRI file .* not found"
          ):
              stc.plot(
                  sample_src,
                  subject="sample",
                  subjects_dir=subjects_dir,
                  mode="stat_map",
                  bg_img="junk.mgz",
              )
      use_ax = None
      for ax in fig.axes:
          if ax.get_xlabel().startswith("Time"):
              use_ax = ax
              break
      assert use_ax is not None
      label = use_ax.get_legend().get_texts()[0].get_text()
      assert re.match("[0-9]*", label) is not None, label
  
file_path: mne-python/mne/viz/tests/test_3d_mpl.py
imports: import re
  import numpy
  import pytest
  from mne import SourceEstimate, VolSourceEstimate, VolVectorSourceEstimate, compute_covariance, compute_source_morph, make_fixed_length_epochs, make_forward_solution, read_bem_solution, read_forward_solution, read_trans, setup_volume_source_space
  from mne.datasets import testing
  from mne.io import read_raw_fif
  from mne.minimum_norm import apply_inverse, make_inverse_operator
  from mne.utils import _record_warnings, catch_logging
  from mne.viz import plot_volume_source_estimates
  from mne.viz.utils import _fake_click, _fake_keypress
label_desc: Use image node_id 1 for calling a global function with example usage: test_plot_volume_source_estimates(mode, stype, init_t, want_t, init_p, want_p, bg_img) without return types