code: def test_sample2surf(create_files_in_directory_plus_dummy_file):
      s2s = fs.SampleToSurface()
      # Test underlying command
      assert s2s.cmd == "mri_vol2surf"
  
      # Test mandatory args exception
      with pytest.raises(ValueError):
          s2s.run()
  
      # Create testing files
      files, cwd = create_files_in_directory_plus_dummy_file
  
      # Test input settings
      s2s.inputs.source_file = files[0]
      s2s.inputs.reference_file = files[1]
      s2s.inputs.hemi = "lh"
      s2s.inputs.reg_file = files[2]
      s2s.inputs.sampling_range = 0.5
      s2s.inputs.sampling_units = "frac"
      s2s.inputs.sampling_method = "point"
  
      # Test a basic command line
      assert s2s.cmdline == (
          "mri_vol2surf "
          "--hemi lh --o %s --ref %s --reg reg.dat --projfrac 0.500 --mov %s"
          % (os.path.join(cwd, "lh.a.mgz"), files[1], files[0])
      )
  
      # Test identity
      s2sish = fs.SampleToSurface(
          source_file=files[1], reference_file=files[0], hemi="rh"
      )
      assert s2s != s2sish
  
      # Test hits file name creation
      s2s.inputs.hits_file = True
      assert s2s._get_outfilename("hits_file") == os.path.join(
          cwd, "lh.a_hits.mgz"
      )
  
      # Test that a 2-tuple range raises an error
      def set_illegal_range():
          s2s.inputs.sampling_range = (0.2, 0.5)
  
      with pytest.raises(TraitError):
          set_illegal_range()
  
file_path: nipype/nipype/interfaces/freesurfer/tests/test_utils.py
imports: import os
  import os.path
  import pytest
  from nipype.testing.fixtures import create_files_in_directory_plus_dummy_file, create_surf_file_in_directory
  from nipype.pipeline import engine
  from nipype.interfaces import freesurfer
  from nipype.interfaces.base import TraitError
  from nipype.interfaces.io import FreeSurferSource
label_desc: Use image node_id 1 for calling a global function with example usage: test_sample2surf(create_files_in_directory_plus_dummy_file) without return types