code: def test_mixed_source_morph(_mixed_morph_srcs, vector):
      """Test mixed source space morphing."""
      nib = pytest.importorskip("nibabel")
      pytest.importorskip("dipy")
      morph, src, src_fs = _mixed_morph_srcs
      # Test some basic properties in the subject's own space
      lut, _ = read_freesurfer_lut()
      ids = [lut[s["seg_name"]] for s in src[2:]]
      del lut
      vertices = [s["vertno"] for s in src]
      n_vertices = sum(len(v) for v in vertices)
      data = np.zeros((n_vertices, 3, 1))
      data[:, 1] = 1.0
      klass = mne.MixedVectorSourceEstimate
      if not vector:
          data = data[:, 1]
          klass = klass._scalar_class
      stc = klass(data, vertices, 0, 1, "sample")
      vol_info = _get_mri_info_data(fname_aseg, data=True)
      rrs = np.concatenate(
          [src[2]["rr"][sp["vertno"]] for sp in src[2:]]
      )
      n_want = np.isin(_get_atlas_values(vol_info, rrs), ids).sum()
      img = _get_img_fdata(
          stc.volume().as_volume(src, mri_resolution=False)
      )
      assert img.astype(bool).sum() == n_want
      img_res = nib.load(fname_aseg)
      n_want = np.isin(_get_img_fdata(img_res), ids).sum()
      img = _get_img_fdata(
          stc.volume().as_volume(src, mri_resolution=True)
      )
      assert (
          img.astype(bool).sum() > n_want
      )  # way more get interpolated into
  
      with pytest.raises(
          TypeError, match="stc_from must be an instance"
      ):
          morph.apply(1.0)
  
      # Now actually morph
      stc_fs = morph.apply(stc)
      vol_info = _get_mri_info_data(fname_aseg_fs, data=True)
      rrs = np.concatenate(
          [src_fs[2]["rr"][sp["vertno"]] for sp in src_fs[2:]]
      )
      n_want = np.isin(_get_atlas_values(vol_info, rrs), ids).sum()
      with pytest.raises(
          ValueError, match=r"stc\.subject does not match src s"
      ):
          stc_fs.volume().as_volume(src, mri_resolution=False)
      img = _get_img_fdata(
          stc_fs.volume().as_volume(src_fs, mri_resolution=False)
      )
      assert (
          img.astype(bool).sum() == n_want
      )  # correct number of voxels
  
      # Morph separate parts and compare to morphing the entire one
      stc_fs_surf = morph.apply(stc.surface())
      stc_fs_vol = morph.apply(stc.volume())
      stc_fs_2 = stc_fs.__class__(
          np.concatenate([stc_fs_surf.data, stc_fs_vol.data]),
          stc_fs_surf.vertices + stc_fs_vol.vertices,
          stc_fs.tmin,
          stc_fs.tstep,
          stc_fs.subject,
      )
      assert_allclose(stc_fs.data, stc_fs_2.data)
  
imports: from inspect import signature
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_array_less
  from scipy.sparse import csr_matrix
  from scipy.sparse import eye
  from scipy.spatial.distance import cdist
  import mne
  from mne import SourceEstimate, SourceMorph, VectorSourceEstimate, VolSourceEstimate, VolVectorSourceEstimate, compute_source_morph, get_volume_labels_from_aseg, grade_to_vertices, make_ad_hoc_cov, make_forward_solution, make_sphere_model, read_evokeds, read_forward_solution, read_freesurfer_lut, read_source_estimate, read_source_morph, setup_volume_source_space
  from mne._freesurfer import _get_atlas_values, _get_mri_info_data
  from mne.datasets import testing
  from mne.fixes import _get_img_fdata
  from mne.minimum_norm import apply_inverse, make_inverse_operator, read_inverse_operator
  from mne.source_space._source_space import _add_interpolator, _grid_interp
  from mne.transforms import quat_to_rot
  from mne.utils import _record_warnings, catch_logging
label_desc: Use image node_id 15 for calling a global function with example usage: test_mixed_source_morph(_mixed_morph_srcs, vector) without return types