Skip to content

Basis functions

Jan Clemens edited this page Sep 24, 2019 · 2 revisions
import numpy as np
import matplotlib.pyplot as plt
from glm_utils.bases import bsplines, laplacian_pyramid, raised_cosine

Laplacian Pyramid

Overcomplete bases that tiles time at multiple time scales. Regularization will choose the right time scales and time points.

B = laplacian_pyramid(width=100, levels=4, step=1, FWHM=20)
plt.gcf().set_size_inches(10, 10)
plt.subplot(211)
plt.plot(B);
plt.xlabel('time')
plt.subplot(212)
plt.imshow(B);
plt.ylabel('time')
plt.xlabel('basis functions')
B.shape
(100, 367)

output_2_1

B-splines

Simple bumps tiling time.

B = bsplines(width=100, positions=np.arange(5,100,5), periodic=False)
plt.gcf().set_size_inches(10, 10)
plt.subplot(211)
plt.plot(B);
plt.subplot(212)
plt.imshow(B);
B.shape
(100, 19)

output_4_1

Raised cosines

Nonlinearly spaced bumps to encode prior assumptions about the resolution required to represent a temporal filter.

B = raised_cosine(neye=0, ncos=10, kpeaks=(5, 70), b=2, nkt=10)
plt.gcf().set_size_inches(10, 10)
plt.subplot(211)
plt.plot(B);
plt.subplot(212)
plt.imshow(B);
B.shape
(119, 10)

output_6_1

Clone this wiki locally