code: def _get_bf_data(save_fieldtrip=False):
      raw, epochs, evoked, data_cov, _, _, _, _, _, fwd = _get_data(
          proj=False
      )
  
      if save_fieldtrip is True:
          # raw needs to be saved with all channels and picked in FieldTrip
          raw.save(ft_data_path / "raw.fif", overwrite=True)
  
          # src (tris are not available in fwd['src'] once imported into MATLAB)
          src = fwd["src"].copy()
          mne.write_source_spaces(
              ft_data_path / "src.fif",
              src,
              verbose="error",
              overwrite=True,
          )
  
      # pick gradiometers only:
      epochs.pick(picks="grad")
      evoked.pick(picks="grad")
  
      # compute covariance matrix (ignore false alarm about no baseline)
      data_cov = mne.compute_covariance(
          epochs,
          tmin=0.04,
          tmax=0.145,
          method="empirical",
          verbose="error",
      )
  
      if save_fieldtrip is True:
          # if the covariance matrix and epochs need resaving:
          # data covariance:
          cov_savepath = ft_data_path / "sample_cov.mat"
          sample_cov = {"sample_cov": data_cov["data"]}
          savemat(cov_savepath, sample_cov)
          # evoked data:
          ev_savepath = ft_data_path / "sample_evoked.mat"
          data_ev = {"sample_evoked": evoked.data}
          savemat(ev_savepath, data_ev)
  
      return evoked, data_cov, fwd
  
file_path: mne-python/mne/beamformer/tests/test_external.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy.io import savemat
  import mne
  from mne.beamformer import apply_lcmv, apply_lcmv_cov, make_lcmv
  from mne.beamformer.tests.test_lcmv import _get_data
  from mne.datasets import testing
label_desc: Use image node_id 1 for calling a global function with example usage: _get_bf_data(save_fieldtrip) and returns: evoked,  data_cov,  fwd