code: def test_threshold(create_files_in_directory_plus_output_type):
      (
          files,
          testdir,
          out_ext,
      ) = create_files_in_directory_plus_output_type
  
      # Get the command
      thresh = fsl.Threshold(in_file="a.nii", out_file="b.nii")
  
      # Test the underlying command
      assert thresh.cmd == "fslmaths"
  
      # Test mandtory args
      with pytest.raises(ValueError):
          thresh.run()
  
      # Test the various opstrings
      cmdline = "fslmaths a.nii {} b.nii"
      for val in [0, 0.0, -1, -1.5, -0.5, 0.5, 3, 400, 400.5]:
          thresh.inputs.thresh = val
          assert thresh.cmdline == cmdline.format(f"-thr {val:.10f}")
  
      val = f"{42:.10f}"
      thresh = fsl.Threshold(
          in_file="a.nii",
          out_file="b.nii",
          thresh=42,
          use_robust_range=True,
      )
      assert thresh.cmdline == cmdline.format("-thrp " + val)
      thresh.inputs.use_nonzero_voxels = True
      assert thresh.cmdline == cmdline.format("-thrP " + val)
      thresh = fsl.Threshold(
          in_file="a.nii",
          out_file="b.nii",
          thresh=42,
          direction="above",
      )
      assert thresh.cmdline == cmdline.format("-uthr " + val)
      thresh.inputs.use_robust_range = True
      assert thresh.cmdline == cmdline.format("-uthrp " + val)
      thresh.inputs.use_nonzero_voxels = True
      assert thresh.cmdline == cmdline.format("-uthrP " + val)
  
imports: import os
  import numpy
  from nipype.interfaces.base import Undefined
  import nipype.interfaces.fsl.maths
  from nipype.interfaces.fsl import no_fsl
  import pytest
  from nipype.testing.fixtures import create_files_in_directory_plus_output_type
label_desc: Use image node_id 3 for calling a global function with example usage: test_threshold(create_files_in_directory_plus_output_type) without return types