ANTsX / ANTsPy

A fast medical imaging analysis library in Python with algorithms for registration, segmentation, and more.
https://antspyx.readthedocs.io
Apache License 2.0
586 stars 161 forks source link

B-spline curve fitting failures #660

Closed ntustison closed 1 month ago

ntustison commented 1 month ago

@ncullen93 , the following test_utils.py example doesn't work anymore, i.e. it erroneously returns all zeros. It seems that the other two curve examples (2-D and 3-D) also fail whereas the multi-parametric examples (image and displacement field approximation) work as expected. Looking into it now but if you could help identify any changes you might've made, that would be helpful. Thanks.

x = np.linspace(-4, 4, num=100) + np.random.uniform(-0.1, 0.1, 100)
u = np.linspace(0, 1.0, num=len(x))
scattered_data = np.expand_dims(u, axis=-1)
parametric_data = np.expand_dims(u, axis=-1)
spacing = 1/(len(x)-1) * 1.0
bspline_curve = ants.fit_bspline_object_to_scattered_data(
        scattered_data, parametric_data,
        parametric_domain_origin=[0.0], parametric_domain_spacing=[spacing],
        parametric_domain_size=[len(x)], is_parametric_dimension_closed=None,
        number_of_fitting_levels=5, mesh_size=1)

# Erroneously returns all zeros.
print(bspline_curve)
ntustison commented 1 month ago

I'm pretty sure I found it.