diff --git a/unit_tests/applyxfm4D/applyxfm4D_fail/feedsInputs b/unit_tests/applyxfm4D/applyxfm4D_fail/feedsInputs new file mode 100644 index 0000000000000000000000000000000000000000..7782318789d7b5b47150a948cb29e67c3d5a16fc --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_fail/feedsInputs @@ -0,0 +1 @@ +unit_tests/applyxfm4D diff --git a/unit_tests/applyxfm4D/applyxfm4D_fail/feedsRun b/unit_tests/applyxfm4D/applyxfm4D_fail/feedsRun new file mode 100755 index 0000000000000000000000000000000000000000..e9301f09c75e74ef4f74a70ad1b40956c1b970d8 --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_fail/feedsRun @@ -0,0 +1,33 @@ +#!/usr/bin/env fslpython +""" +test applyxfm4D correct failure +""" +from subprocess import run, PIPE, CalledProcessError +from os.path import join +from tempfile import mkdtemp +import os +import sys + +OUTDIR = sys.argv[1] +INDIR = sys.argv[2] +FSLDIR = os.environ.get('FSLDIR') +FSLBIN = join(FSLDIR, 'bin') +# applyxfm4D fmri.nii.gz brain.nii.gz applyxfm4D_out f2b.mat -singlematrix -interp nn +def test_applyxfm4D_fail(): + cmd = [ + join(FSLBIN, 'applyxfm4D'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_in.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_ref.nii.gz'), + join(OUTDIR, 'applyxfm4D_out.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_mat.mat') + ] + try: + run_result = run(cmd, stdout=PIPE, check=True) + stdout_string = run_result.stdout.decode('utf-8') + assert False + except CalledProcessError as e: + print("test_applyxfm4D correctly failed. This is good!") + assert e.returncode != 0 + +print("running test_applyxfm4D_fail()") +test_applyxfm4D_fail() diff --git a/unit_tests/applyxfm4D/applyxfm4D_fourdigit/feedsInputs b/unit_tests/applyxfm4D/applyxfm4D_fourdigit/feedsInputs new file mode 100644 index 0000000000000000000000000000000000000000..7782318789d7b5b47150a948cb29e67c3d5a16fc --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_fourdigit/feedsInputs @@ -0,0 +1 @@ +unit_tests/applyxfm4D diff --git a/unit_tests/applyxfm4D/applyxfm4D_fourdigit/feedsRun b/unit_tests/applyxfm4D/applyxfm4D_fourdigit/feedsRun new file mode 100755 index 0000000000000000000000000000000000000000..51fac7fb48ab8987695a9a49bd1751b99567f8d5 --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_fourdigit/feedsRun @@ -0,0 +1,34 @@ +#!/usr/bin/env fslpython +""" +test applyxfm4D matfile directory option with 4 digit numbers in filenames +""" +from subprocess import run, PIPE +from os.path import join +from tempfile import mkdtemp +import os +import sys + +OUTDIR = sys.argv[1] +INDIR = sys.argv[2] +FSLDIR = os.environ.get('FSLDIR') +FSLBIN = join(FSLDIR, 'bin') +print(INDIR) +def test_applyxfm4D_fourdigit(): + # use trilinear interp for speed + cmd = [ + join(FSLBIN, 'applyxfm4D'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_in.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_ref.nii.gz'), + join(OUTDIR, 'applyxfm4D_out.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'matfiles_four_digit'), + '-interp', + 'trilinear', + '-fourdigit' + ] + run_result = run(cmd, stdout=PIPE, check=True) + stdout_string = run_result.stdout.decode('utf-8') + # check that the files were written to disk + # the brain extracted input should exist + assert os.path.isfile(join(OUTDIR, 'applyxfm4D_out.nii.gz')) == True + +test_applyxfm4D_fourdigit() diff --git a/unit_tests/applyxfm4D/applyxfm4D_nn/feedsInputs b/unit_tests/applyxfm4D/applyxfm4D_nn/feedsInputs new file mode 100644 index 0000000000000000000000000000000000000000..7782318789d7b5b47150a948cb29e67c3d5a16fc --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_nn/feedsInputs @@ -0,0 +1 @@ +unit_tests/applyxfm4D diff --git a/unit_tests/applyxfm4D/applyxfm4D_nn/feedsRun b/unit_tests/applyxfm4D/applyxfm4D_nn/feedsRun new file mode 100755 index 0000000000000000000000000000000000000000..20073bd4c50763b30b752c75a15aaa2bfcb255ee --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_nn/feedsRun @@ -0,0 +1,33 @@ +#!/usr/bin/env fslpython +""" +test applyxfm4D nn interp +""" +from subprocess import run, PIPE +from os.path import join +from tempfile import mkdtemp +import os +import sys + +OUTDIR = sys.argv[1] +INDIR = sys.argv[2] +FSLDIR = os.environ.get('FSLDIR') +FSLBIN = join(FSLDIR, 'bin') +print(INDIR) +def test_applyxfm4D_nn(): + cmd = [ + join(FSLBIN, 'applyxfm4D'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_in.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_ref.nii.gz'), + join(OUTDIR, 'applyxfm4D_out.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_mat.mat'), + '-singlematrix', + '-interp', + 'nn' + ] + run_result = run(cmd, stdout=PIPE, check=True) + stdout_string = run_result.stdout.decode('utf-8') + # check that the files were written to disk + # the brain extracted input should exist + assert os.path.isfile(join(OUTDIR, 'applyxfm4D_out.nii.gz')) == True + +test_applyxfm4D_nn() diff --git a/unit_tests/applyxfm4D/applyxfm4D_sinc/feedsInputs b/unit_tests/applyxfm4D/applyxfm4D_sinc/feedsInputs new file mode 100644 index 0000000000000000000000000000000000000000..7782318789d7b5b47150a948cb29e67c3d5a16fc --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_sinc/feedsInputs @@ -0,0 +1 @@ +unit_tests/applyxfm4D diff --git a/unit_tests/applyxfm4D/applyxfm4D_sinc/feedsRun b/unit_tests/applyxfm4D/applyxfm4D_sinc/feedsRun new file mode 100755 index 0000000000000000000000000000000000000000..008de98efde7b929efb7719607ae0dfc40506fde --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_sinc/feedsRun @@ -0,0 +1,33 @@ +#!/usr/bin/env fslpython +""" +test applyxfm4D sinc interp +""" +from subprocess import run, PIPE +from os.path import join +from tempfile import mkdtemp +import os +import sys + +OUTDIR = sys.argv[1] +INDIR = sys.argv[2] +FSLDIR = os.environ.get('FSLDIR') +FSLBIN = join(FSLDIR, 'bin') +print(INDIR) +def test_applyxfm4D_sinc(): + cmd = [ + join(FSLBIN, 'applyxfm4D'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_in.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_ref.nii.gz'), + join(OUTDIR, 'applyxfm4D_out.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_mat.mat'), + '-singlematrix', + '-interp', + 'sinc' + ] + run_result = run(cmd, stdout=PIPE, check=True) + stdout_string = run_result.stdout.decode('utf-8') + # check that the files were written to disk + # the brain extracted input should exist + assert os.path.isfile(join(OUTDIR, 'applyxfm4D_out.nii.gz')) == True + +test_applyxfm4D_sinc() diff --git a/unit_tests/applyxfm4D/applyxfm4D_singlematrix/.DS_Store b/unit_tests/applyxfm4D/applyxfm4D_singlematrix/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 Binary files /dev/null and b/unit_tests/applyxfm4D/applyxfm4D_singlematrix/.DS_Store differ diff --git a/unit_tests/applyxfm4D/applyxfm4D_singlematrix/feedsInputs b/unit_tests/applyxfm4D/applyxfm4D_singlematrix/feedsInputs new file mode 100644 index 0000000000000000000000000000000000000000..7782318789d7b5b47150a948cb29e67c3d5a16fc --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_singlematrix/feedsInputs @@ -0,0 +1 @@ +unit_tests/applyxfm4D diff --git a/unit_tests/applyxfm4D/applyxfm4D_singlematrix/feedsRun b/unit_tests/applyxfm4D/applyxfm4D_singlematrix/feedsRun new file mode 100755 index 0000000000000000000000000000000000000000..76ce73949b80f3787a5c5ae7a10f39f5f6ad2058 --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_singlematrix/feedsRun @@ -0,0 +1,34 @@ +#!/usr/bin/env fslpython +""" +test applyxfm4D single matrix option +""" +from subprocess import run, PIPE +from os.path import join +from tempfile import mkdtemp +import os +import sys + +OUTDIR = sys.argv[1] +INDIR = sys.argv[2] +FSLDIR = os.environ.get('FSLDIR') +FSLBIN = join(FSLDIR, 'bin') +print(INDIR) +def test_applyxfm4D_singlematrix(): + # use nearestneighbour interp for speed + cmd = [ + join(FSLBIN, 'applyxfm4D'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_in.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_ref.nii.gz'), + join(OUTDIR, 'applyxfm4D_out.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_mat.mat'), + '-singlematrix', + '-interp', + 'nn' + ] + run_result = run(cmd, stdout=PIPE, check=True) + stdout_string = run_result.stdout.decode('utf-8') + # check that the files were written to disk + # the brain extracted input should exist + assert os.path.isfile(join(OUTDIR, 'applyxfm4D_out.nii.gz')) == True + +test_applyxfm4D_singlematrix() diff --git a/unit_tests/applyxfm4D/applyxfm4D_spline/feedsInputs b/unit_tests/applyxfm4D/applyxfm4D_spline/feedsInputs new file mode 100644 index 0000000000000000000000000000000000000000..7782318789d7b5b47150a948cb29e67c3d5a16fc --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_spline/feedsInputs @@ -0,0 +1 @@ +unit_tests/applyxfm4D diff --git a/unit_tests/applyxfm4D/applyxfm4D_spline/feedsRun b/unit_tests/applyxfm4D/applyxfm4D_spline/feedsRun new file mode 100755 index 0000000000000000000000000000000000000000..c9d20466560a1a6e664a5bb4d6225f8836725ba5 --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_spline/feedsRun @@ -0,0 +1,33 @@ +#!/usr/bin/env fslpython +""" +test applyxfm4D spline interp +""" +from subprocess import run, PIPE +from os.path import join +from tempfile import mkdtemp +import os +import sys + +OUTDIR = sys.argv[1] +INDIR = sys.argv[2] +FSLDIR = os.environ.get('FSLDIR') +FSLBIN = join(FSLDIR, 'bin') +print(INDIR) +def test_applyxfm4D_spline(): + cmd = [ + join(FSLBIN, 'applyxfm4D'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_in.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_ref.nii.gz'), + join(OUTDIR, 'applyxfm4D_out.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_mat.mat'), + '-singlematrix', + '-interp', + 'spline' + ] + run_result = run(cmd, stdout=PIPE, check=True) + stdout_string = run_result.stdout.decode('utf-8') + # check that the files were written to disk + # the brain extracted input should exist + assert os.path.isfile(join(OUTDIR, 'applyxfm4D_out.nii.gz')) == True + +test_applyxfm4D_spline() diff --git a/unit_tests/applyxfm4D/applyxfm4D_transdir/feedsInputs b/unit_tests/applyxfm4D/applyxfm4D_transdir/feedsInputs new file mode 100644 index 0000000000000000000000000000000000000000..7782318789d7b5b47150a948cb29e67c3d5a16fc --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_transdir/feedsInputs @@ -0,0 +1 @@ +unit_tests/applyxfm4D diff --git a/unit_tests/applyxfm4D/applyxfm4D_transdir/feedsRun b/unit_tests/applyxfm4D/applyxfm4D_transdir/feedsRun new file mode 100755 index 0000000000000000000000000000000000000000..69428e8fdb0a556c3786c710e9b7288df617f8d1 --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_transdir/feedsRun @@ -0,0 +1,33 @@ +#!/usr/bin/env fslpython +""" +test applyxfm4D matfile directory option +""" +from subprocess import run, PIPE +from os.path import join +from tempfile import mkdtemp +import os +import sys + +OUTDIR = sys.argv[1] +INDIR = sys.argv[2] +FSLDIR = os.environ.get('FSLDIR') +FSLBIN = join(FSLDIR, 'bin') +print(INDIR) +def test_applyxfm4D_transdir(): + # use trilinear interp for speed + cmd = [ + join(FSLBIN, 'applyxfm4D'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_in.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_ref.nii.gz'), + join(OUTDIR, 'applyxfm4D_out.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'matfiles_five_digit'), + '-interp', + 'trilinear' + ] + run_result = run(cmd, stdout=PIPE, check=True) + stdout_string = run_result.stdout.decode('utf-8') + # check that the files were written to disk + # the brain extracted input should exist + assert os.path.isfile(join(OUTDIR, 'applyxfm4D_out.nii.gz')) == True + +test_applyxfm4D_transdir() diff --git a/unit_tests/applyxfm4D/applyxfm4D_trilinear/feedsInputs b/unit_tests/applyxfm4D/applyxfm4D_trilinear/feedsInputs new file mode 100644 index 0000000000000000000000000000000000000000..7782318789d7b5b47150a948cb29e67c3d5a16fc --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_trilinear/feedsInputs @@ -0,0 +1 @@ +unit_tests/applyxfm4D diff --git a/unit_tests/applyxfm4D/applyxfm4D_trilinear/feedsRun b/unit_tests/applyxfm4D/applyxfm4D_trilinear/feedsRun new file mode 100755 index 0000000000000000000000000000000000000000..285e95ff6bc4004a3da4d654471a7c86a58ea0fd --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_trilinear/feedsRun @@ -0,0 +1,33 @@ +#!/usr/bin/env fslpython +""" +test applyxfm4D trilinear interp +""" +from subprocess import run, PIPE +from os.path import join +from tempfile import mkdtemp +import os +import sys + +OUTDIR = sys.argv[1] +INDIR = sys.argv[2] +FSLDIR = os.environ.get('FSLDIR') +FSLBIN = join(FSLDIR, 'bin') +print(INDIR) +def test_applyxfm4D_trilinear(): + cmd = [ + join(FSLBIN, 'applyxfm4D'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_in.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_ref.nii.gz'), + join(OUTDIR, 'applyxfm4D_out.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_mat.mat'), + '-singlematrix', + '-interp', + 'trilinear' + ] + run_result = run(cmd, stdout=PIPE, check=True) + stdout_string = run_result.stdout.decode('utf-8') + # check that the files were written to disk + # the brain extracted input should exist + assert os.path.isfile(join(OUTDIR, 'applyxfm4D_out.nii.gz')) == True + +test_applyxfm4D_trilinear() diff --git a/unit_tests/applyxfm4D/applyxfm4D_userprefix/feedsInputs b/unit_tests/applyxfm4D/applyxfm4D_userprefix/feedsInputs new file mode 100644 index 0000000000000000000000000000000000000000..7782318789d7b5b47150a948cb29e67c3d5a16fc --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_userprefix/feedsInputs @@ -0,0 +1 @@ +unit_tests/applyxfm4D diff --git a/unit_tests/applyxfm4D/applyxfm4D_userprefix/feedsRun b/unit_tests/applyxfm4D/applyxfm4D_userprefix/feedsRun new file mode 100755 index 0000000000000000000000000000000000000000..1679e821b791be1e28eb3b995af13b2d0ccd1c9b --- /dev/null +++ b/unit_tests/applyxfm4D/applyxfm4D_userprefix/feedsRun @@ -0,0 +1,35 @@ +#!/usr/bin/env fslpython +""" +test applyxfm4D matfile directory option with user prefix +""" +from subprocess import run, PIPE +from os.path import join +from tempfile import mkdtemp +import os +import sys + +OUTDIR = sys.argv[1] +INDIR = sys.argv[2] +FSLDIR = os.environ.get('FSLDIR') +FSLBIN = join(FSLDIR, 'bin') +print(INDIR) +def test_applyxfm4D_userprefix(): + # use trilinear interp for speed + cmd = [ + join(FSLBIN, 'applyxfm4D'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_in.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'applyxfm4D_ref.nii.gz'), + join(OUTDIR, 'applyxfm4D_out.nii.gz'), + join(INDIR, 'unit_tests', 'applyxfm4D', 'matfiles_user_prefix'), + '-interp', + 'trilinear', + '-userprefix', + 'myprefix_' + ] + run_result = run(cmd, stdout=PIPE, check=True) + stdout_string = run_result.stdout.decode('utf-8') + # check that the files were written to disk + # the brain extracted input should exist + assert os.path.isfile(join(OUTDIR, 'applyxfm4D_out.nii.gz')) == True + +test_applyxfm4D_userprefix()