def test_fslmaths(create_files_in_directory_plus_output_type): filelist, outdir, _ = create_files_in_directory_plus_output_type math = fsl.ImageMaths() # make sure command gets called assert math.cmd == "fslmaths" # test raising error with mandatory args absent with pytest.raises(ValueError): math.run() # .inputs based parameters setting math.inputs.in_file = filelist[0] math.inputs.op_string = "-add 2.5 -mul input_volume2" math.inputs.out_file = "foo_math.nii" assert ( math.cmdline == "fslmaths %s -add 2.5 -mul input_volume2 foo_math.nii" % filelist[0] ) # .run based parameter setting math2 = fsl.ImageMaths( in_file=filelist[0], op_string="-add 2.5", out_file="foo2_math.nii" ) assert math2.cmdline == "fslmaths %s -add 2.5 foo2_math.nii" % filelist[0]
def test_fslmaths(): filelist, outdir, cwd = create_files_in_directory() math = fsl.ImageMaths() # make sure command gets called yield assert_equal, math.cmd, 'fslmaths' # test raising error with mandatory args absent yield assert_raises, ValueError, math.run # .inputs based parameters setting math.inputs.in_file = filelist[0] math.inputs.op_string = '-add 2.5 -mul input_volume2' math.inputs.out_file = 'foo_math.nii' yield assert_equal, math.cmdline, \ 'fslmaths %s -add 2.5 -mul input_volume2 foo_math.nii' % filelist[0] # .run based parameter setting math2 = fsl.ImageMaths(in_file=filelist[0], op_string='-add 2.5', out_file='foo2_math.nii') yield assert_equal, math2.cmdline, 'fslmaths %s -add 2.5 foo2_math.nii' % filelist[ 0] # test arguments for opt_map # Fslmath class doesn't have opt_map{} clean_directory(outdir, cwd)
def test_fslmaths(create_files_in_directory): filelist, outdir, _ = create_files_in_directory math = fsl.ImageMaths() # make sure command gets called assert math.cmd == 'fslmaths' # test raising error with mandatory args absent with pytest.raises(ValueError): math.run() # .inputs based parameters setting math.inputs.in_file = filelist[0] math.inputs.op_string = '-add 2.5 -mul input_volume2' math.inputs.out_file = 'foo_math.nii' assert math.cmdline == \ 'fslmaths %s -add 2.5 -mul input_volume2 foo_math.nii' % filelist[0] # .run based parameter setting math2 = fsl.ImageMaths(in_file=filelist[0], op_string='-add 2.5', out_file='foo2_math.nii') assert math2.cmdline == 'fslmaths %s -add 2.5 foo2_math.nii' % filelist[0]
def test_imagemaths(): input_map = dict( args=dict(argstr='%s', ), environ=dict(), in_file=dict( argstr='%s', mandatory=True, ), in_file2=dict(argstr='%s', ), op_string=dict(argstr='%s', ), out_data_type=dict(argstr='-odt %s', ), out_file=dict(argstr='%s', ), output_type=dict(), suffix=dict(), ) instance = fsl.ImageMaths() for key, metadata in input_map.items(): for metakey, value in metadata.items(): yield assert_equal, getattr(instance.inputs.traits()[key], metakey), value