code: def test_project_sensors_onto_brain(tmp_path):
      """Test projecting sensors onto the brain surface."""
      pytest.importorskip("nibabel")
      raw = mne.io.read_raw_fif(fname_raw)
      trans = _get_trans(fname_trans)[0]
      # test informative error for no surface first
      with pytest.raises(
          RuntimeError, match="requires generating a BEM"
      ):
          project_sensors_onto_brain(
              raw.info, trans, "sample", subjects_dir=tmp_path
          )
      brain_surf_fname = tmp_path / "sample" / "bem" / "brain.surf"
      if not brain_surf_fname.parent.is_dir():
          os.makedirs(brain_surf_fname.parent)
      if not brain_surf_fname.is_file():
          copyfile(
              subjects_dir / "sample" / "bem" / "inner_skull.surf",
              brain_surf_fname,
          )
      # now make realistic ECoG grid
      raw.pick("eeg")
      raw.load_data()
      raw.set_eeg_reference([])
      raw.set_channel_types({ch: "ecog" for ch in raw.ch_names})
      pos = np.zeros((49, 3))
      pos[:, :2] = (
          np.array(
              np.meshgrid(
                  np.linspace(0, 0.02, 7), np.linspace(0, 0.02, 7)
              )
          )
          .reshape(2, -1)
          .T
      )
      pos[:, 2] = 0.12
      raw.drop_channels(raw.ch_names[49:])
      raw.set_montage(
          mne.channels.make_dig_montage(
              ch_pos=dict(zip(raw.ch_names[:49], pos)),
              coord_frame="head",
          )
      )
      raw.info = project_sensors_onto_brain(
          raw.info, trans, "sample", subjects_dir=tmp_path
      )
      # plot to check, should be projected down onto inner skull
      # brain = mne.viz.Brain('sample', subjects_dir=subjects_dir, alpha=0.5,
      #                       surf='white')
      # brain.add_sensors(raw.info, trans=trans)
      test_locs = [
          [0.00149, -0.001588, 0.133029],
          [0.004302, 0.001959, 0.133922],
          [0.008602, 0.00116, 0.133723],
      ]
      montage = raw.get_montage()
      assert montage is not None
      ch_pos = montage.get_positions()["ch_pos"]
      for ch, test_loc in zip(raw.ch_names[:3], test_locs):
          assert_allclose(ch_pos[ch], test_loc, atol=0.01)
  
file_path: mne-python/mne/preprocessing/ieeg/tests/test_projection.py
imports: import os
  from shutil import copyfile
  import numpy
  import pytest
  from numpy.testing import assert_allclose
  import mne
  from mne.datasets import testing
  from mne.preprocessing.ieeg import project_sensors_onto_brain
  from mne.preprocessing.ieeg._projection import _project_sensors_onto_inflated
  from mne.transforms import _get_trans
label_desc: Use image node_id 1 for calling a global function with example usage: test_project_sensors_onto_brain(tmp_path) without return types