Note
Click here to download the full example code
Create a simple cochlea model and test it on a sinusoidal input signal
# import matplotlib
# matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from simplecochlea import Cochlea
sns.set_context('paper')
Create the cochlea
fs, fmin, fmax, freq_scale, n_channels = 44100, 200, 8000, 'erbscale', 100
comp_factor, comp_gain = 0.3, 1.5
tau, v_thresh, v_spike = np.linspace(0.001, 0.0004, n_channels), np.linspace(0.3, 0.17, n_channels), 0.5
cochlea_simp = Cochlea(n_channels, fs, fmin, fmax, freq_scale, comp_factor=comp_factor, comp_gain=comp_gain,
lif_tau=tau, lif_v_thresh=v_thresh, lif_v_spike=v_spike)
Print the description
print(cochlea_simp)
Out:
Cochlea model - 100 channels [200 - 8000 Hz] - erbscale - 2 order Butterworth filters
Rectifier Bank - full rectification - No low-pass filtering
Compression Bank : y = 1.5 * x ^ 0.3
LIF bank - Tau = [1.00, 0.40] ms - V_thresh = [0.3, 0.17] - V_reset = 0.0
Refractory period : 0.001s
No inhibition
Process a sin input signal
spikelist_sin, _ = cochlea_simp.process_test_signal('sin', f_sin=400, t_offset=0, t_max=0.1)
Out:
Function : process_input - Time elapsed : 0.28186678886413574
Plot the output spikelist
spikelist_sin.plot()
Total running time of the script: ( 0 minutes 8.694 seconds)