Commit 794987a6 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: unit tests for [line|rgb]vector unit length scaling

parent 3fbdb777
......@@ -793,8 +793,6 @@ def zero_centre(infile):
return outfile
def complex():
data = np.linspace(0, 1, 1000).reshape((10, 10, 10)) + \
......@@ -829,6 +827,16 @@ def invert(infile):
return outfile
def mul(infile, factor):
basename = fslimage.removeExt(op.basename(infile))
outfile = '{}_mul_{}.nii.gz'.format(basename, factor)
img = fslimage.Image(infile)
data = img[:]
img[:] = data * factor
img.save(outfile)
return outfile
def mockMouseEvent(profile, canvas, evType, canvasLoc):
"""Mock a mouse event on a SliceCanvas
"""
......
......@@ -5,9 +5,13 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import os.path as op
import pytest
from fsleyes.tests import run_cli_tests, roi, asrgb
import fsl.data.image as fslimage
from fsleyes.tests import run_cli_tests, roi, asrgb, mul
pytestmark = pytest.mark.overlayclitest
......@@ -35,13 +39,20 @@ dti/dti_FA.nii.gz {{asrgb('dti/dti_V1.nii.gz')}} -ot linevector
# test anisotropic voxels
dti/anisotropic/dti_FA dti/anisotropic/dti_V1 -ot linevector
"""
# unit length / colour scaling
dti/dti_FA.nii.gz dti/dti_V1.nii.gz -ot linevector -nu
dti/dti_FA.nii.gz {{mul('dti/dti_V1.nii.gz', 0.5)}} -ot linevector
dti/dti_FA.nii.gz {{mul('dti/dti_V1.nii.gz', 0.5)}} -ot linevector -nu
dti/dti_FA.nii.gz {{mul('dti/dti_V1.nii.gz', 2.0)}} -ot linevector
dti/dti_FA.nii.gz {{mul('dti/dti_V1.nii.gz', 2.0)}} -ot linevector -nu
"""
def test_overlay_linevector():
extras = {
'roi' : roi,
'asrgb' : asrgb,
'mul' : mul,
}
run_cli_tests('test_overlay_linevector',
cli_tests,
......
......@@ -9,7 +9,7 @@ from unittest import mock
import pytest
from fsleyes.tests import run_cli_tests, asrgb
from fsleyes.tests import run_cli_tests, asrgb, mul
import fsleyes.gl.textures.data as texdata
......@@ -32,11 +32,18 @@ dti/dti_V1 -ot rgbvector -in linear -b 25 -c 25
dti/dti_V1 -ot rgbvector -in spline -b 25 -c 25
{{asrgb('dti/dti_V1')}} -ot rgbvector
# unit length scaling
{{mul('dti/dti_V1', 0.5)}} -ot rgbvector -u
{{mul('dti/dti_V1', 0.5)}} -ot rgbvector
{{mul('dti/dti_V1', 2.0)}} -ot rgbvector -u
{{mul('dti/dti_V1', 2.0)}} -ot rgbvector
"""
def test_overlay_rgbvector():
extras = {
'asrgb' : asrgb,
'mul' : mul,
}
run_cli_tests('test_overlay_rgbvector', cli_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