code: def test_snirf_nirsport2_w_positions():
      """Test reading SNIRF files with known positions."""
      raw = read_raw_snirf(
          nirx_nirsport2_103_2, preload=True, optode_frame="mri"
      )
      _reorder_nirx(raw)
  
      # Test data import
      assert raw._data.shape == (40, 128)
      assert_almost_equal(raw.info["sfreq"], 10.2, decimal=1)
  
      # Test channel naming
      assert raw.info["ch_names"][:4] == [
          "S1_D1 760",
          "S1_D1 850",
          "S1_D6 760",
          "S1_D6 850",
      ]
      assert raw.info["ch_names"][24:26] == ["S6_D4 760", "S6_D4 850"]
  
      # Test frequency encoding
      assert raw.info["chs"][0]["loc"][9] == 760
      assert raw.info["chs"][1]["loc"][9] == 850
  
      assert sum(short_channels(raw.info)) == 16
  
      # Test distance between optodes matches values from
      # nirsite https://github.com/mne-tools/mne-testing-data/pull/86
      # figure 3
      allowed_distance_error = 0.005
      assert_allclose(
          source_detector_distances(raw.copy().pick("S1_D1 760").info),
          [0.0304],
          atol=allowed_distance_error,
      )
      assert_allclose(
          source_detector_distances(raw.copy().pick("S2_D2 760").info),
          [0.0400],
          atol=allowed_distance_error,
      )
  
      # Test location of detectors
      # The locations of detectors can be seen in the first
      # figure on this page...
      # https://github.com/mne-tools/mne-testing-data/pull/86
      allowed_dist_error = 0.0002
      locs = [ch["loc"][6:9] for ch in raw.info["chs"]]
      head_mri_t, _ = _get_trans("fsaverage", "head", "mri")
      mni_locs = apply_trans(head_mri_t, locs)
  
      assert raw.info["ch_names"][0][3:5] == "D1"
      assert_allclose(
          mni_locs[0],
          [-0.0841, -0.0464, -0.0129],
          atol=allowed_dist_error,
      )
  
      assert raw.info["ch_names"][2][3:5] == "D6"
      assert_allclose(
          mni_locs[2],
          [-0.0841, -0.0138, 0.0248],
          atol=allowed_dist_error,
      )
  
      assert raw.info["ch_names"][34][3:5] == "D5"
      assert_allclose(
          mni_locs[34],
          [0.0845, -0.0451, -0.0123],
          atol=allowed_dist_error,
      )
  
      # Test location of sensors
      # The locations of sensors can be seen in the second
      # figure on this page...
      # https://github.com/mne-tools/mne-testing-data/pull/86
      allowed_dist_error = 0.0002
      locs = [ch["loc"][3:6] for ch in raw.info["chs"]]
      head_mri_t, _ = _get_trans("fsaverage", "head", "mri")
      mni_locs = apply_trans(head_mri_t, locs)
  
      assert raw.info["ch_names"][0][:2] == "S1"
      assert_allclose(
          mni_locs[0],
          [-0.0848, -0.0162, -0.0163],
          atol=allowed_dist_error,
      )
  
      assert raw.info["ch_names"][9][:2] == "S2"
      assert_allclose(
          mni_locs[9], [-0.0, -0.1195, 0.0142], atol=allowed_dist_error
      )
  
      assert raw.info["ch_names"][34][:2] == "S8"
      assert_allclose(
          mni_locs[34],
          [0.0828, -0.046, 0.0285],
          atol=allowed_dist_error,
      )
  
      mon = raw.get_montage()
      assert len(mon.dig) == 27
  
imports: import shutil
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_almost_equal, assert_equal
  from mne._fiff.constants import FIFF
  from mne.datasets.testing import data_path, requires_testing_data
  from mne.io import read_raw_nirx, read_raw_snirf
  from mne.io.tests.test_raw import _test_raw_reader
  from mne.preprocessing.nirs import _reorder_nirx, beer_lambert_law, optical_density, short_channels, source_detector_distances
  from mne.transforms import _get_trans, apply_trans
  from mne.utils import catch_logging
label_desc: Use image node_id 9 for calling a global function with example usage: test_snirf_nirsport2_w_positions() without return types