Cochlea Creation with Adpative ThresholdΒΆ

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), 0, 0.5
# Adaptive threshold parameters
tau_j, alpha_j = np.array([0.010, 0.200]), np.array([0.010, 0.000002])
omega = np.linspace(0.15, 0.2, n_channels)

cochlea_adaptive_thresh = 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, tau_j=tau_j, alpha_j=alpha_j,
                                  omega=omega)

Print the description

print(cochlea_adaptive_thresh)

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 -
Adaptive Threshold model - tau_j = [0.01 0.2 ], alpha_j = [1.e-02 2.e-06], omega = [0.15, 0.20]
Refractory period : 0.001s
No inhibition

Process a sin input signal

spikelist_sin, _ = cochlea_adaptive_thresh.process_test_signal('sin', f_sin=400, t_offset=0, t_max=0.5, do_plot=0)

Out:

Function : process_input - Time elapsed : 1.0043890476226807

Plot the output spikelist

spikelist_sin.plot()
../../_images/sphx_glr_plot_cochlea_with_adaptive_threshold_creation_001.png

Total running time of the script: ( 0 minutes 1.512 seconds)

Gallery generated by Sphinx-Gallery