splinebox.basis_functions.

BasisFunction#

class splinebox.basis_functions.BasisFunction(multigenerator, support)#

Base class for all basis functions. This class should not be used directly, but instead classes for specific basis functions should inherit from this class.

An example of how to implement your own basis function using inheriting from this class is given below.

Parameters:
multigeneratorboolean

Indicates whether the basis function generates multiple outputs. This is used to distinguish basis functions designed for Hermite splines, which return two values instead of one.

supportfloat

The support of the function, i.e. the size of the area being mapped to non-zero values.

Methods

__call__(t[, derivative])

Evaluate the function at position(s) t.

filter_periodic(s)

Returns a filtered version of the input s, used to convert knots into control points for a closed spline.

filter_symmetric(s)

Returns a filtered version of the input s, used to convert knots into control points for an open spline.

refinement_mask()

This function is needed for local refinement (see [Badoual2016]).

Examples

This example shows how to implement a new basis function.

>>> class MyBasis(splinebox.BasisFunction):
...     def __init__(self):
...         super().__init__(multigenerator=False, support=2)
...
...     def __str__(self):
...         return "MyBasis"
...
...     def __repr__(self):
...         # Change this if your new basis function is not in splinebox.basis_functions
...         return "splinebox.basis_functions.MyBasis()"
...
...     def _func(self, t):
...         # Implement your function here
...         return val
...
...     def _derivative_1(self, t):
...         # Implement the first derivative of your function here
...         return val
...
...     def _derivative_2(self, t):
...         # Implement the second derivative of your function here
...         # or raise an error if not differentiable
...         raise RuntimeError("MyBasis isn't twice differentiable.")
...
...     def filter_symmetric(self, s):
...         # Implement the function that can turn knots into control points
...         # for an open spline
...         return s.astype(float)
...
...     def filter_periodic(self, s):
...         # Implement the function that can turn knots into control points
...         # for a closed spline
...         return s.astype(float)

Plot 3D curvature

Plot 3D curvature

Active Contours

Active Contours

Generate the splinebox documentation background

Generate the splinebox documentation background

Fit boundary conditions

Fit boundary conditions

Tracking the Undulating Motion of C. elegans

Tracking the Undulating Motion of C. elegans

Curvature combs

Curvature combs

Dendrite-Centric Coordinate System

Dendrite-Centric Coordinate System

Distance between splines

Distance between splines

Closed interpolating splines

Closed interpolating splines

Moving Frames

Moving Frames

Saving and loading splines

Saving and loading splines

Spline to mesh

Spline to mesh

Multivariate splines

Multivariate splines

Measure the curvature of a peptide

Measure the curvature of a peptide

Performance Comparison: splinebox vs scipy

Performance Comparison: splinebox vs scipy

Approximating a Noisy Signal

Approximating a Noisy Signal

Comparison splinebox and scipy: contour approximation

Comparison splinebox and scipy: contour approximation

Comparison of splinebox and scipy: Edge Fitting

Comparison of splinebox and scipy: Edge Fitting