code: def test_bbregister(create_files_in_directory):
      filelist, outdir = create_files_in_directory
      bbr = freesurfer.BBRegister()
  
      # make sure command gets called
      assert bbr.cmd == "bbregister"
  
      # test raising error with mandatory args absent
      with pytest.raises(ValueError):
          bbr.cmdline
  
      bbr.inputs.subject_id = "fsaverage"
      bbr.inputs.source_file = filelist[0]
      bbr.inputs.contrast_type = "t2"
  
      # Check that 'init' is mandatory in FS < 6, but not in 6+
      if Info.looseversion() < LooseVersion("6.0.0"):
          with pytest.raises(ValueError):
              bbr.cmdline
      else:
          bbr.cmdline
  
      bbr.inputs.init = "fsl"
  
      base, ext = os.path.splitext(os.path.basename(filelist[0]))
      if ext == ".gz":
          base, _ = os.path.splitext(base)
  
      assert bbr.cmdline == (
          "bbregister --t2 --init-fsl "
          "--reg {base}_bbreg_fsaverage.dat "
          "--mov {full} --s fsaverage".format(
              full=filelist[0], base=base
          )
      )
  
file_path: nipype/nipype/interfaces/freesurfer/tests/test_preprocess.py
imports: import os
  import pytest
  from looseversion import LooseVersion
  from nipype.testing.fixtures import create_files_in_directory
  from nipype.interfaces import freesurfer
  from nipype.interfaces.freesurfer import Info
label_desc: Use image node_id 5 for calling a global function with example usage: test_bbregister(create_files_in_directory) without return types