Commit a15db005 authored by Stephen Thompson's avatar Stephen Thompson

Issue #3 added a regression test based on a CT sphere

parent d65c4f35
......@@ -3,7 +3,7 @@
"""scikit-surgery-sphere-fitting tests"""
import numpy
#from sksurgeryspherefitting.ui.sksurgeryspherefitting_demo import run_demo
from sksurgeryvtk.models.vtk_surface_model import VTKSurfaceModel
from sksurgeryspherefitting.algorithms import sphere_fitting
import six
......@@ -11,11 +11,11 @@ import six
def test_fit_sphere_least_squares():
x_centre = 1.0
y_centre = 167.0
z_centre = 200.0
x_centre = 1.74839
y_centre = 167.0899222
z_centre = 200.738829
radius = 7.5
radius = 7.543589
#some arrays to fit data to
xs=numpy.ndarray(shape=(1000,),dtype=float )
......@@ -47,3 +47,20 @@ def test_fit_sphere_least_squares():
numpy.testing.assert_approx_equal (result.x[2], z_centre, significant = 10)
numpy.testing.assert_approx_equal (result.x[3], radius, significant = 10)
def test_fit_sphere_to_ct_regression_test1():
parameters = [0.0, 0.0, 0.0, 0.0]
parameters = [136.0, 151.0, -91.0, 8.0]
model = VTKSurfaceModel("data/CT_Level_1.vtp", [1., 0., 0.])
x_values = model.get_points_as_numpy()[:, 0]
y_values = model.get_points_as_numpy()[:, 1]
z_values = model.get_points_as_numpy()[:, 2]
result = sphere_fitting.fit_sphere_least_squares(x_values,
y_values,
z_values,
parameters)
numpy.testing.assert_approx_equal (result.x[0], 136.571, significant = 3)
numpy.testing.assert_approx_equal (result.x[1], 151.973, significant = 3)
numpy.testing.assert_approx_equal (result.x[2], -95.518, significant = 3)
numpy.testing.assert_approx_equal (result.x[3], 8.119, significant = 3)
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