Commit ef47ef6a authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: Basic unit tests for displayspace

parent 8e5f712a
......@@ -32,6 +32,7 @@ import matplotlib.image as mplimg
import fsleyes_props as props
from fsl.utils.tempdir import tempdir
import fsl.utils.idle as idle
import fsl.utils.image.resample as resample
import fsl.transform.affine as affine
import fsl.data.image as fslimage
import fsleyes
......@@ -693,6 +694,18 @@ def roi(fname, roi):
return outfile
def resampled(fname, fac):
base = fslimage.removeExt(op.basename(fname))
outfile = '{}_resampled_{}'.format(base, fac)
img = fslimage.Image(fname)
pix = np.array(img.pixdim[:3]) * fac
data, xform = resample.resampleToPixdims(img, pix)
fslimage.Image(data, header=img.header, xform=xform).save(outfile)
return outfile
def asrgb(infile):
basename = fslimage.removeExt(op.basename(infile))
outfile = '{}_asrgb.nii.gz'.format(basename)
......
#!/usr/bin/env python
#
# test_displayspace.py -
#
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import pytest
from fsleyes.tests import run_cli_tests, resampled, roi, rotate
pytestmark = pytest.mark.clitest
tests = """
-vl 10 8 8 -o 0 3d {{roi('3d', (8, 13, 6, 10, 6, 10))}} -cm red-yellow
-vl 10 8 8 -o 0 3d {{resampled(roi('3d', (8, 13, 6, 10, 6, 10)), 0.5)}} -cm red-yellow
-ds scaledVoxel -vl 0 0 0 -o 0 3d {{roi('3d', (8, 13, 6, 10, 6, 10))}} -cm red-yellow
-ds scaledVoxel -vl 0 0 0 -o 0 3d {{resampled(roi('3d', (8, 13, 6, 10, 6, 10)), 0.5)}} -cm red-yellow
3d {{rotate('3d', 20, 20, 20)}} -cm red-yellow -a 50
-ds 3d 3d {{rotate('3d', 20, 20, 20)}} -cm red-yellow -a 50
-ds 3d_rotated_20_20_20 3d {{rotate('3d', 20, 20, 20)}} -cm red-yellow -a 50
-ds world 3d {{rotate('3d', 20, 20, 20)}} -cm red-yellow -a 50
-ds scaledVoxel 3d {{rotate('3d', 20, 20, 20)}} -cm red-yellow -a 50
"""
def test_displayspace():
extras = {
'roi' : roi,
'resampled' : resampled,
'rotate' : rotate
}
run_cli_tests('test_displayspace', tests, extras=extras)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment