Filters for Neural Encoding

This notebook discusses the construction of filters for neural encoding via Generalized Linear Models. The basis for the filters consists of raised cosine functions which were introduced in Pillow, et.al., Nature, 2008.

Import scientific modules:


In [5]:
import numpy as np
import scipy as sp
from scipy import linalg
import matplotlib.pyplot as plt

In [6]:
%matplotlib inline

Import the filters module which contains functions for generating the bases.


In [11]:
import imp
imp.load_source('filters.py', '../code/filters.py')


Out[11]:
<module 'filters.py' from '../code/filters.py'>

Create a stimulus filter:


In [ ]:
kpeaks = np.array([0,round(20/3.)])
pars_k = {'neye':5,'n':5,'kpeaks':kpeaks,'b':3}
K,K_orth,kt_domain = filters.createStimulusBasis(pars_k, nkt = 20)

In [ ]:
fig, axs = plt.subplots(1,2)
fig.set_figwidth(12)
fig1 = axs[0].plot(-kt_domain[::-1],K)
fig2 = axs[1].plot(-kt_domain[::-1],K_orth)

In [ ]:
coeff_k = np.array([0.1703926,0.0782157,0.3387306,0.5680452,0.3835860,0.2163205,-0.1528571,0.0069939,-0.0528309,-0.0404678])

In [ ]:
fig, axs = plt.subplots(1,2)
fig.set_figwidth(12)
fig1 = axs[0].plot(-kt_domain[::-1],np.dot(K,coeff_k))
fig2 = axs[1].plot(-kt_domain[::-1],np.exp(np.dot(K,coeff_k)))

Create a post-spike filter:


In [ ]:
hpeaks = np.array([0.1,2])
pars_h = {'n':5,'hpeaks':hpeaks,'b':.5}
pars_h['absref']=0.1
dt = 0.01
H,H_orth,ht_domain = filters.createPostSpikeBasis(pars_h,dt)

In [ ]:
fig, axs = plt.subplots(1,2)
fig.set_figwidth(12)
fig1 = axs[0].plot(ht_domain,H)
fig2 = axs[1].plot(ht_domain,H_orth)

In [ ]:
coeff_h = np.array([.6,.47,.25,0,0])

In [ ]:
fig, axs = plt.subplots(1,2)
fig.set_figwidth(12)
fig1 = axs[0].plot(ht_domain,np.dot(H,coeff_h))
fig2 = axs[1].plot(ht_domain,np.exp(np.dot(H,coeff_h)))