code: def test_flirt(setup_flirt):
      # setup
      tmpdir, infile, reffile = setup_flirt
  
      flirter = fsl.FLIRT()
      assert flirter.cmd == "flirt"
  
      flirter.inputs.bins = 256
      flirter.inputs.cost = "mutualinfo"
  
      flirted = fsl.FLIRT(
          in_file=infile,
          reference=reffile,
          out_file="outfile",
          out_matrix_file="outmat.mat",
          bins=256,
          cost="mutualinfo",
      )
  
      flirt_est = fsl.FLIRT(
          in_file=infile,
          reference=reffile,
          out_matrix_file="outmat.mat",
          bins=256,
          cost="mutualinfo",
      )
      assert flirter.inputs != flirted.inputs
      assert flirted.inputs != flirt_est.inputs
  
      assert flirter.inputs.bins == flirted.inputs.bins
      assert flirter.inputs.cost == flirt_est.inputs.cost
      realcmd = (
          "flirt -in %s -ref %s -out outfile -omat outmat.mat "
          "-bins 256 -cost mutualinfo" % (infile, reffile)
      )
      assert flirted.cmdline == realcmd
  
      flirter = fsl.FLIRT()
      # infile not specified
      with pytest.raises(ValueError):
          flirter.cmdline
      flirter.inputs.in_file = infile
      # reference not specified
      with pytest.raises(ValueError):
          flirter.cmdline
      flirter.inputs.reference = reffile
  
      # Generate outfile and outmatrix
      pth, fname, ext = split_filename(infile)
      outfile = fsl_name(flirter, "%s_flirt" % fname)
      outmat = "%s_flirt.mat" % fname
      realcmd = "flirt -in {} -ref {} -out {} -omat {}".format(
          infile,
          reffile,
          outfile,
          outmat,
      )
      assert flirter.cmdline == realcmd
  
      # test apply_xfm option
      axfm = deepcopy(flirter)
      axfm.inputs.apply_xfm = True
      # in_matrix_file or uses_qform must be defined
      with pytest.raises(RuntimeError):
          axfm.cmdline
      axfm2 = deepcopy(axfm)
      # test uses_qform
      axfm.inputs.uses_qform = True
      assert axfm.cmdline == (realcmd + " -applyxfm -usesqform")
      # test in_matrix_file
      axfm2.inputs.in_matrix_file = reffile
      assert axfm2.cmdline == (
          realcmd + " -applyxfm -init %s" % reffile
      )
  
      tmpfile = tmpdir.join("file4test.nii")
      tmpfile.open("w")
      # Loop over all inputs, set a reasonable value and make sure the
      # cmdline is updated correctly.
      for key, trait_spec in sorted(
          fsl.FLIRT.input_spec().traits().items()
      ):
          # Skip mandatory inputs and the trait methods
          if key in (
              "trait_added",
              "trait_modified",
              "in_file",
              "reference",
              "environ",
              "output_type",
              "out_file",
              "out_matrix_file",
              "in_matrix_file",
              "apply_xfm",
              "resource_monitor",
              "out_log",
              "save_log",
          ):
              continue
          param = None
          value = None
          if key == "args":
              param = "-v"
              value = "-v"
          elif isinstance(trait_spec.trait_type, File):
              value = tmpfile.strpath
              param = trait_spec.argstr % value
          elif trait_spec.default is False:
              param = trait_spec.argstr
              value = True
          elif key in ("searchr_x", "searchr_y", "searchr_z"):
              value = [-45, 45]
              param = trait_spec.argstr % " ".join(
                  str(elt) for elt in value
              )
          else:
              value = trait_spec.default
              param = trait_spec.argstr % value
          cmdline = f"flirt -in {infile} -ref {reffile}"
          # Handle autogeneration of outfile
          pth, fname, ext = split_filename(infile)
          outfile = fsl_name(fsl.FLIRT(), "%s_flirt" % fname)
          outfile = " ".join(["-out", outfile])
          # Handle autogeneration of outmatrix
          outmatrix = "%s_flirt.mat" % fname
          outmatrix = " ".join(["-omat", outmatrix])
          # Build command line
          cmdline = " ".join([cmdline, outfile, outmatrix, param])
          flirter = fsl.FLIRT(in_file=infile, reference=reffile)
          setattr(flirter.inputs, key, value)
          assert flirter.cmdline == cmdline
  
      # Test OutputSpec
      flirter = fsl.FLIRT(in_file=infile, reference=reffile)
      pth, fname, ext = split_filename(infile)
      flirter.inputs.out_file = "".join(["foo", ext])
      flirter.inputs.out_matrix_file = "".join(["bar", ext])
      outs = flirter._list_outputs()
      assert outs["out_file"] == os.path.join(
          os.getcwd(), flirter.inputs.out_file
      )
      assert outs["out_matrix_file"] == os.path.join(
          os.getcwd(), flirter.inputs.out_matrix_file
      )
      assert not isdefined(flirter.inputs.out_log)
  
imports: import os
  from copy import deepcopy
  import pytest
  import pdb
  from nipype.utils.filemanip import split_filename, ensure_list
  from ..None import preprocess
  from nipype.interfaces.fsl import Info
  from nipype.interfaces.base import File, TraitError, Undefined, isdefined
  from nipype.interfaces.fsl import no_fsl
label_desc: Use image node_id 7 for calling a global function with example usage: test_flirt(setup_flirt) without return types