Skip to content
Snippets Groups Projects
Commit 952df634 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

TEST: Expand splinterpolator tests to cover all extrapolation methods, and

order=2 interpolation
parent 7a32a55f
No related branches found
No related tags found
1 merge request!17ENH: Allow `Splinterpolator` instances to be created from an existing set of spline coefficients, and extend extrapolation options
Pipeline #25995 passed
Showing
with 104 additions and 14 deletions
......@@ -16,6 +16,7 @@ namespace fs = std::filesystem;
namespace BTF = boost::unit_test::framework;
namespace SPL = SPLINTERPOLATOR;
class TestFixture {
public:
......@@ -56,10 +57,11 @@ public:
TestFixture() {
// the data is up-sampled by 3x
for (float z = -4; z < 9.01; z+=1/3.0) {
for (float y = -4; y < 9.01; y+=1/3.0) {
for (float x = -4; x < 9.01; x+=1/3.0) {
// the data is up-sampled by 3x and
// extrapolated x3 in all directions
for (float z = -8; z < 14.01; z+=1/3.0) {
for (float y = -8; y < 14.01; y+=1/3.0) {
for (float x = -8; x < 14.01; x+=1/3.0) {
if (std::abs(x) < 0.01) x = 0;
if (std::abs(y) < 0.01) y = 0;
if (std::abs(z) < 0.01) z = 0;
......@@ -68,9 +70,9 @@ public:
zpts.push_back(z);
}}}
npts = xpts.size();
xsz = 40;
ysz = 40;
zsz = 40;
xsz = 67;
ysz = 67;
zsz = 67;
// pre-allocate space to store test outputs
values = std::vector<float>(npts);
......@@ -127,7 +129,6 @@ public:
}
compare(values, load_nifti(test_name + "_values.nii.gz"));
// derivatives are only valid for interpolation of order > 1
if (spl.Order() > 1) {
std::vector<float> gradvals;
......@@ -143,6 +144,7 @@ public:
BOOST_FIXTURE_TEST_SUITE(test_splinterpolator, TestFixture)
BOOST_AUTO_TEST_CASE(order_1_3d_extrap_zeros) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Zeros, 1));
}
......@@ -155,6 +157,37 @@ BOOST_AUTO_TEST_CASE(order_1_3d_extrap_constant) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Constant, 1));
}
BOOST_AUTO_TEST_CASE(order_1_3d_extrap_mirror) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Mirror, 1));
}
BOOST_AUTO_TEST_CASE(order_1_3d_extrap_periodic) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Periodic, 1));
}
BOOST_AUTO_TEST_CASE(order_2_3d_extrap_zeros) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Zeros, 2));
}
BOOST_AUTO_TEST_CASE(order_2_3d_extrap_soft_zeros) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::SoftZeros, 2));
}
BOOST_AUTO_TEST_CASE(order_2_3d_extrap_constant) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Constant, 2));
}
BOOST_AUTO_TEST_CASE(order_2_3d_extrap_mirror) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Mirror, 2));
}
BOOST_AUTO_TEST_CASE(order_2_3d_extrap_periodic) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Periodic, 2));
}
BOOST_AUTO_TEST_CASE(order_3_3d_extrap_zeros) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Zeros, 3));
}
......@@ -167,4 +200,13 @@ BOOST_AUTO_TEST_CASE(order_3_3d_extrap_constant) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Constant, 3));
}
BOOST_AUTO_TEST_CASE(order_3_3d_extrap_mirror) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Mirror, 3));
}
BOOST_AUTO_TEST_CASE(order_3_3d_extrap_periodic) {
run_test(SPL::Splinterpolator<float>(data.data(), dims, SPL::Periodic, 3));
}
BOOST_AUTO_TEST_SUITE_END()
File added
No preview for this file type
File added
File added
File added
File added
File added
No preview for this file type
File added
No preview for this file type
File added
File added
File added
File added
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment