Skip to content

Commit 3cb7894

Browse files
authored
Merge pull request #88 from EPFL-Center-for-Imaging/control_point_deriv
Add methods for analytically computed derivatives with respect to control points for common loss functions.
2 parents 20e67e5 + 42daae3 commit 3cb7894

33 files changed

Lines changed: 1428 additions & 283 deletions

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<img style="float: right;" src="https://imaging.epfl.ch/resources/logo-for-gitlab.svg">
22

33
# splinebox
4-
A python package for fitting splines.
4+
A Python package for fitting splines.
55
Developed by the [EPFL Center for Imaging](https://imaging.epfl.ch/) as part of a collaboration with the [Uhlmann Group at EMBL-EBI](https://www.ebi.ac.uk/research/uhlmann/) in Feb 2024.
66

77
[![Documentation Status](https://readthedocs.org/projects/splinebox/badge/?version=latest)](https://splinebox.readthedocs.io/en/latest/?badge=latest)
@@ -15,7 +15,7 @@ Developed by the [EPFL Center for Imaging](https://imaging.epfl.ch/) as part of
1515
## Features
1616
* Flexible spline fitting for various applications.
1717
* Support for many spline types in any dimensionality.
18-
* High-perfomance implementation in Python
18+
* High-performance implementation in Python.
1919
* Extensive [documentation](https://splinebox.readthedocs.io/en/latest/?badge=latest) with [examples](https://splinebox.readthedocs.io/en/latest/_auto_examples/index.html)
2020

2121
## Installation
@@ -48,7 +48,7 @@ plt.show()
4848

4949
## Support
5050

51-
If you encounter any problems, please [file and issue](https://github.com/EPFL-Center-for-Imaging/splinebox/issues/new) describing the issue and include minimal example to reproduce the issue.
51+
If you encounter any problems, please [file an issue](https://github.com/EPFL-Center-for-Imaging/splinebox/issues/new) describing the issue and include a minimal example to reproduce the issue.
5252

5353
## Contributing
5454

@@ -57,12 +57,12 @@ We welcome contributions! Before you submit a pull request, please ensure that t
5757
## Citing splinebox
5858

5959
If you use splinebox in the context of scientific publication, please cite it as follows.
60-
Note, that you will have to fill in the version yourself. If you are unsure what version you are running,
60+
Note that you will have to fill in the version yourself. If you are unsure what version you are running,
6161
you can find out by running
6262

6363
```python
6464
import splinebox
65-
print(splinbox.__version__)`
65+
print(splinebox.__version__)
6666
```
6767

6868
BibTeX:

‎docs/getting_started/citation.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ you can find out by running:
2222
.. code-block:: python
2323
2424
import splinebox
25-
print(splinbox.__version__)
25+
print(splinebox.__version__)

‎docs/getting_started/padding.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Despite the first and last control point, the spline curves inward toward the or
2121
.. plot:: pyplots/plot_no_padding.py
2222
:include-source: false
2323

24-
By padding with two additional points on the circle, this behavior is corrected.
24+
By padding with two additional points on the circle, this behaviour is corrected.
2525

2626
.. plot:: pyplots/plot_padding.py
2727
:include-source: false
2828

2929
If you set the control points manually, you are responsible for handling the padding.
30-
This design choice allows full control over the spline's behavior at the ends.
30+
This design choice allows full control over the spline's behaviour at the ends.
3131

3232
.. code-block:: python
3333

‎docs/index.rst‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ SplineBox
3333
<h1 style="margin-bottom: 0.2rem">SplineBox</h1>
3434
<h2 style="margin-top: 0.2rem">Take control of your splines</h2>
3535
<p style="margin-right: 3em">
36-
SplineBox is an open-source python package for anyone trying to fit splines.
36+
SplineBox is an open-source Python package for anyone trying to fit splines.
3737
It offers a wide variety of spline types including Hermite splines and makes
38-
it easy to specify custom loss function to control spline properties such as
38+
it easy to specify custom loss functions to control spline properties such as
3939
smoothness.
4040
</p>
4141

@@ -97,7 +97,7 @@ SplineBox
9797
</svg>
9898
<p>
9999
<strong> Custom loss functions </strong> <br/>
100-
Compatibility with python optimization frame works makes it easy to use custom loss functions for fitting.
100+
Compatibility with Python optimisation frameworks makes it easy to use custom loss functions for fitting.
101101
</p>
102102
</div>
103103

@@ -117,7 +117,7 @@ SplineBox
117117
</svg>
118118
<p>
119119
<strong> High performance </strong> <br/>
120-
Just-in-time compilation allows us to match and in some cases overcome the performance of SciPy's fortran based splines.
120+
Just-in-time compilation allows us to match and in some cases overcome the performance of SciPy's Fortran-based splines.
121121
</p>
122122
</div>
123123

@@ -185,7 +185,7 @@ SplineBox
185185
.. raw:: html
186186

187187
<p style="margin-left: 3em">
188-
Scipy requires you to pre-compute the parameter values for all knots and data points
188+
SciPy requires you to pre-compute the parameter values for all knots and data points
189189
accounting for padding and periodicity of the data.
190190
This can be confusing and difficult to do.
191191
</p>
@@ -207,14 +207,14 @@ SplineBox
207207
.. raw:: html
208208

209209
<p>
210-
We compare the performance to splinbox to SciPy's splines
210+
We compare the performance of splinebox to SciPy's splines
211211
on three main tasks:
212212
<ul>
213-
<li>Spline creation give a set of knots</li>
213+
<li>Spline creation given a set of knots</li>
214214
<li>Evaluation of a spline at a given parameter value</li>
215215
<li>Data approximation using least-squares fitting</li>
216216
</ul>
217-
Splinebox out performs SciPy by approximately two orders of magnitude on the first task, achieves comparable performance on the second task, and is out performed for least-squares fitting of splines.
217+
Splinebox outperforms SciPy by approximately two orders of magnitude on the first task, achieves comparable performance on the second task, and is outperformed for least-squares fitting of splines.
218218
<a href="./_auto_examples/plot_performance_comparison_with_scipy.html">See detailed comparison →</a>
219219
</p>
220220

‎docs/pyplots/plot_b1.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import numpy as np
33
import splinebox.basis_functions
44

5+
56
fig, axes = plt.subplots(2, 1, sharex=True)
67

78
b1 = splinebox.basis_functions.B1()
@@ -12,9 +13,9 @@
1213
b1_1st = b1(t, derivative=1)
1314

1415
fig.suptitle("B1 basis function and its derivatives")
15-
axes[0].plot(t, b1_0th, label=r"$\Phi(t)$")
16+
axes[0].plot(t, b1_0th, label=r"$\beta_1(t)$")
1617
axes[0].legend()
17-
axes[1].plot(t, b1_1st, label=r"$\frac{d\Phi}{dt}(t)$")
18+
axes[1].plot(t, b1_1st, label=r"$\frac{d\beta_1}{dt}(t)$")
1819
axes[1].legend()
1920
axes[1].set_xlabel(r"$t$")
2021
plt.tight_layout()

‎docs/pyplots/plot_b2.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515

1616
fig.suptitle("B2 basis function and its derivatives")
17-
axes[0].plot(t, b2_0th, label=r"$\Phi(t)$")
17+
axes[0].plot(t, b2_0th, label=r"$\beta_2(t)$")
1818
axes[0].legend()
19-
axes[1].plot(t, b2_1st, label=r"$\frac{d\Phi}{dt}(t)$")
19+
axes[1].plot(t, b2_1st, label=r"$\frac{d\beta_2}{dt}(t)$")
2020
axes[1].legend()
21-
axes[2].plot(t, b2_2nd, label=r"$\frac{d^2\Phi}{dt^2}(t)$")
21+
axes[2].plot(t, b2_2nd, label=r"$\frac{d^2\beta_2}{dt^2}(t)$")
2222
axes[2].legend()
2323
axes[2].set_xlabel(r"$t$")
2424
plt.tight_layout()

‎docs/pyplots/plot_b3.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
b3_2nd = b3(t, derivative=2)
1414

1515
fig.suptitle("B3 basis function and its derivatives")
16-
axes[0].plot(t, b3_0th, label=r"$\Phi(t)$")
16+
axes[0].plot(t, b3_0th, label=r"$\beta_3(t)$")
1717
axes[0].legend()
18-
axes[1].plot(t, b3_1st, label=r"$\frac{d\Phi}{dt}(t)$")
18+
axes[1].plot(t, b3_1st, label=r"$\frac{d\beta_3}{dt}(t)$")
1919
axes[1].legend()
20-
axes[2].plot(t, b3_2nd, label=r"$\frac{d^2\Phi}{dt^2}(t)$")
20+
axes[2].plot(t, b3_2nd, label=r"$\frac{d^2\beta_3}{dt^2}(t)$")
2121
axes[2].legend()
2222
axes[2].set_xlabel(r"$t$")
2323
plt.tight_layout()

‎docs/pyplots/plot_catmullrom.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
basis_2nd = basis(t, derivative=2)
1414

1515
fig.suptitle("Catmull Rom basis function and its derivatives")
16-
axes[0].plot(t, basis_0th, label=r"$\Phi(t)$")
16+
axes[0].plot(t, basis_0th, label=r"$\varphi(t)$")
1717
axes[0].legend()
18-
axes[1].plot(t, basis_1st, label=r"$\frac{d\Phi}{dt}(t)$")
18+
axes[1].plot(t, basis_1st, label=r"$\frac{d\varphi}{dt}(t)$")
1919
axes[1].legend()
20-
axes[2].plot(t, basis_2nd, label=r"$\frac{d^2\Phi}{dt^2}(t)$")
20+
axes[2].plot(t, basis_2nd, label=r"$\frac{d^2\varphi}{dt^2}(t)$")
2121
axes[2].legend()
2222
axes[2].set_xlabel(r"$t$")
2323
plt.tight_layout()

‎docs/pyplots/plot_cubichermite.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
basis_2nd = basis(t, derivative=2)
1414

1515
fig.suptitle("Cubic Hermite basis function and its derivatives")
16-
axes[0][0].plot(t, basis_0th[:, 0], label=r"$\Phi_1(t)$")
16+
axes[0][0].plot(t, basis_0th[:, 0], label=r"$\varphi_1(t)$")
1717
axes[0][0].legend()
18-
axes[1][0].plot(t, basis_1st[:, 0], label=r"$\frac{d\Phi_1}{dt}(t)$")
18+
axes[1][0].plot(t, basis_1st[:, 0], label=r"$\frac{d\varphi_1}{dt}(t)$")
1919
axes[1][0].legend()
20-
axes[2][0].plot(t, basis_2nd[:, 0], label=r"$\frac{d^2\Phi_1}{dt^2}(t)$")
20+
axes[2][0].plot(t, basis_2nd[:, 0], label=r"$\frac{d^2\varphi_1}{dt^2}(t)$")
2121
axes[2][0].legend()
2222
axes[2][0].set_xlabel(r"$t$")
23-
axes[0][1].plot(t, basis_0th[:, 1], label=r"$\Phi_2(t)$")
23+
axes[0][1].plot(t, basis_0th[:, 1], label=r"$\varphi_2(t)$")
2424
axes[0][1].legend()
25-
axes[1][1].plot(t, basis_1st[:, 1], label=r"$\frac{d\Phi_2}{dt}(t)$")
25+
axes[1][1].plot(t, basis_1st[:, 1], label=r"$\frac{d\varphi_2}{dt}(t)$")
2626
axes[1][1].legend()
27-
axes[2][1].plot(t, basis_2nd[:, 1], label=r"$\frac{d^2\Phi_2}{dt^2}(t)$")
27+
axes[2][1].plot(t, basis_2nd[:, 1], label=r"$\frac{d^2\varphi_2}{dt^2}(t)$")
2828
axes[2][1].legend()
2929
axes[2][1].set_xlabel(r"$t$")
3030
plt.tight_layout()

‎docs/pyplots/plot_exponential.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
basis_2nd = basis(t, derivative=2)
1515

1616
fig.suptitle(f"Exponential basis function and its derivatives for $M={M}$")
17-
axes[0].plot(t, basis_0th, label=r"$\Phi(t)$")
17+
axes[0].plot(t, basis_0th, label=r"$\varphi(t)$")
1818
axes[0].legend()
19-
axes[1].plot(t, basis_1st, label=r"$\frac{d\Phi}{dt}(t)$")
19+
axes[1].plot(t, basis_1st, label=r"$\frac{d\varphi}{dt}(t)$")
2020
axes[1].legend()
21-
axes[2].plot(t, basis_2nd, label=r"$\frac{d^2\Phi}{dt^2}(t)$")
21+
axes[2].plot(t, basis_2nd, label=r"$\frac{d^2\varphi}{dt^2}(t)$")
2222
axes[2].legend()
2323
axes[2].set_xlabel(r"$t$")
2424
plt.tight_layout()

0 commit comments

Comments
 (0)