def test_spatial_filter(fsl_output_type=None): prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory() # Get the command filter = fsl.SpatialFilter(in_file="a.nii", out_file="b.nii") # Test the underlying command yield assert_equal, filter.cmd, "fslmaths" # Test that it fails without an operation yield assert_raises, ValueError, filter.run # Test the different operations for op in ["mean", "meanu", "median"]: filter.inputs.operation = op yield assert_equal, filter.cmdline, "fslmaths a.nii -f%s b.nii" % op # Test that we don't need to ask for an out name filter = fsl.SpatialFilter(in_file="a.nii", operation="mean") yield assert_equal, filter.cmdline, "fslmaths a.nii -fmean %s" % os.path.join(testdir, "a_filt%s" % out_ext) # Clean up our mess clean_directory(testdir, origdir) set_output_type(prev_type)
def test_spatial_filter(create_files_in_directory): files, testdir, out_ext = create_files_in_directory # Get the command filter = fsl.SpatialFilter(in_file="a.nii", out_file="b.nii") # Test the underlying command assert filter.cmd == "fslmaths" # Test that it fails without an operation with pytest.raises(ValueError): filter.run() # Test the different operations for op in ["mean", "meanu", "median"]: filter.inputs.operation = op assert filter.cmdline == "fslmaths a.nii -f%s b.nii" % op # Test that we don't need to ask for an out name filter = fsl.SpatialFilter(in_file="a.nii", operation="mean") assert filter.cmdline == "fslmaths a.nii -fmean %s" % os.path.join(testdir, "a_filt%s" % out_ext)